@loaders.gl/shapefile 4.2.0 → 4.3.0-alpha.1
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.
- package/dist/dbf-loader.js +1 -1
- package/dist/dbf-worker.js +1 -1
- package/dist/dist.min.js +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +2 -2
- package/dist/shapefile-loader.js +1 -1
- package/dist/shp-loader.js +1 -1
- package/dist/shp-worker.js +1 -1
- package/package.json +5 -5
package/dist/dbf-loader.js
CHANGED
|
@@ -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.2.0
|
|
7
|
+
const VERSION = typeof "4.2.0" !== 'undefined' ? "4.2.0" : 'latest';
|
|
8
8
|
/**
|
|
9
9
|
* DBFLoader - DBF files are used to contain non-geometry columns in Shapefiles
|
|
10
10
|
*/
|
package/dist/dbf-worker.js
CHANGED
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 Oi=Object.create;var Ht=Object.defineProperty;var Bi=Object.getOwnPropertyDescriptor;var Gi=Object.getOwnPropertyNames;var Fi=Object.getPrototypeOf,qi=Object.prototype.hasOwnProperty;var zi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ji=(t,e)=>{for(var a in e)Ht(t,a,{get:e[a],enumerable:!0})},kt=(t,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Gi(e))!qi.call(t,i)&&i!==a&&Ht(t,i,{get:()=>e[i],enumerable:!(s=Bi(e,i))||s.enumerable});return t},Ut=(t,e,a)=>(kt(t,e,"default"),a&&kt(a,e,"default")),ki=(t,e,a)=>(a=t!=null?Oi(Fi(t)):{},kt(e||!t||!t.__esModule?Ht(a,"default",{value:t,enumerable:!0}):a,t)),Hi=t=>kt(Ht({},"__esModule",{value:!0}),t);var He=zi((wh,ke)=>{ke.exports=globalThis.loaders});var zt={};ji(zt,{DBFLoader:()=>Ft,DBFWorkerLoader:()=>je,SHPLoader:()=>Nt,SHPWorkerLoader:()=>_e,ShapefileLoader:()=>Ti,_BinaryChunkReader:()=>ot,_BinaryReader:()=>pe,_zipBatchIterators:()=>me});Ut(zt,ki(He(),1));var ot=class{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 s of this.arrayBuffers)if(a+=s.byteLength,a>=e)return!0;return!1}findBufferOffsets(e){let a=-this.offset,s=[];for(let i=0;i<this.arrayBuffers.length;i++){let r=this.arrayBuffers[i];if(a+r.byteLength<=0){a+=r.byteLength;continue}let n=a<=0?Math.abs(a):0,h;if(n+e<=r.byteLength)return h=n+e,s.push([i,[n,h]]),s;h=r.byteLength,s.push([i,[n,h]]),e-=r.byteLength-n,a+=r.byteLength}return null}getDataView(e){let a=this.findBufferOffsets(e);if(!a&&this.ended)throw new Error("binary data exhausted");if(!a)return null;if(a.length===1){let[i,[r,n]]=a[0],h=this.arrayBuffers[i],o=new DataView(h,r,n-r);return this.offset+=e,this.disposeBuffers(),o}let s=new DataView(this._combineArrayBuffers(a));return this.offset+=e,this.disposeBuffers(),s}disposeBuffers(){for(;this.arrayBuffers.length>0&&this.offset-this.maxRewindBytes>=this.arrayBuffers[0].byteLength;)this.offset-=this.arrayBuffers[0].byteLength,this.arrayBuffers.shift()}_combineArrayBuffers(e){let a=0;for(let r of e){let[n,h]=r[1];a+=h-n}let s=new Uint8Array(a),i=0;for(let r of e){let[n,[h,o]]=r,l=new Uint8Array(this.arrayBuffers[n]);s.set(l.subarray(h,o),i),i+=o-h}return s.buffer}skip(e){this.offset+=e}rewind(e){this.offset-=e}};function Wt(t){let e={magic:t.getInt32(0,!1),length:t.getInt32(24,!1)*2,version:t.getInt32(28,!0),type:t.getInt32(32,!0),bbox:{minX:t.getFloat64(36,!0),minY:t.getFloat64(44,!0),minZ:t.getFloat64(68,!0),minM:t.getFloat64(84,!0),maxX:t.getFloat64(52,!0),maxY:t.getFloat64(60,!0),maxZ:t.getFloat64(76,!0),maxM:t.getFloat64(92,!0)}};return e.magic!==9994&&console.error(`SHP file: bad magic number ${e.magic}`),e.version!==1e3&&console.error(`SHP file: bad version ${e.version}`),e}function Ue(t,e){let{_maxDimensions:a=4}=e?.shp||{},s=0,i=t.getInt32(s,!0);switch(s+=Int32Array.BYTES_PER_ELEMENT,i){case 0:return Ui();case 1:return ve(t,s,Math.min(2,a));case 3:return xt(t,s,Math.min(2,a),"LineString");case 5:return xt(t,s,Math.min(2,a),"Polygon");case 8:return ye(t,s,Math.min(2,a));case 11:return ve(t,s,Math.min(4,a));case 13:return xt(t,s,Math.min(4,a),"LineString");case 15:return xt(t,s,Math.min(4,a),"Polygon");case 18:return ye(t,s,Math.min(4,a));case 21:return ve(t,s,Math.min(3,a));case 23:return xt(t,s,Math.min(3,a),"LineString");case 25:return xt(t,s,Math.min(3,a),"Polygon");case 28:return ye(t,s,Math.min(3,a));default:throw new Error(`unsupported shape type: ${i}`)}}function Ui(){return null}function ve(t,e,a){let s;return[s,e]=mt(t,e,1,a),{positions:{value:s,size:a},type:"Point"}}function ye(t,e,a){e+=4*Float64Array.BYTES_PER_ELEMENT;let s=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let i=null,r=null,n=null;return[i,e]=mt(t,e,s,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[n,e]=mt(t,e,s,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[r,e]=mt(t,e,s,1)),{positions:{value:We(i,r,n),size:a},type:"Point"}}function xt(t,e,a,s){e+=4*Float64Array.BYTES_PER_ELEMENT;let i=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let r=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let n=t.byteOffset+e,h=i*Int32Array.BYTES_PER_ELEMENT,o=new Int32Array(i+1);o.set(new Int32Array(t.buffer.slice(n,n+h))),o[i]=r,e+=i*Int32Array.BYTES_PER_ELEMENT;let l=null,u=null,f=null;[l,e]=mt(t,e,r,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[f,e]=mt(t,e,r,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[u,e]=mt(t,e,r,1));let c=We(l,u,f);if(s==="LineString")return{type:s,positions:{value:c,size:a},pathIndices:{value:o,size:1}};let M=[];for(let d=1;d<o.length;d++){let y=o[d-1],x=o[d],g=l.subarray(y*2,x*2);Wi(g)>0&&M.push(y)}return M.push(r),{type:s,positions:{value:c,size:a},primitivePolygonIndices:{value:o,size:1},polygonIndices:{value:new Uint32Array(M),size:1}}}function mt(t,e,a,s){let i=t.byteOffset+e,r=a*s*Float64Array.BYTES_PER_ELEMENT;return[new Float64Array(t.buffer.slice(i,i+r)),e+r]}function We(t,e,a){if(!(e||a))return t;let s=t.length,i=2;a&&a.length&&(s+=a.length,i++),e&&e.length&&(s+=e.length,i++);let r=new Float64Array(s);for(let n=0;n<t.length/2;n++)r[i*n]=t[n*2],r[i*n+1]=t[n*2+1];if(a&&a.length)for(let n=0;n<a.length;n++)r[i*n+2]=a[n];if(e&&e.length)for(let n=0;n<e.length;n++)r[i*n+(i-1)]=e[n];return r}function Wi(t){return Math.sign(Ji(t))}function Ji(t){let e=0,a=t.length/2-1;for(let s=0;s<a;s++)e+=(t[s*2]+t[(s+1)*2])*(t[s*2+1]-t[(s+1)*2+1]);return e/2}var Xi=!0,Je=!1,Qi=100,St=12,J={EXPECTING_HEADER:0,EXPECTING_RECORD:1,END:2,ERROR:3},Jt=class{options={};binaryReader=new ot({maxRewindBytes:St});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=Xe(this.state,this.result,this.binaryReader,this.options)}end(){this.binaryReader.end(),this.state=Xe(this.state,this.result,this.binaryReader,this.options),this.state!==J.END&&(this.state=J.ERROR,this.result.error="SHP incomplete file")}};function xe(t,e){let a=new Jt(e);return a.write(t),a.end(),a.result}async function*Qe(t,e){let a=new Jt(e),s=!1;for await(let i of t)a.write(i),!s&&a.result.header&&(s=!0,yield a.result.header),a.result.geometries.length>0&&(yield a.result.geometries,a.result.geometries=[]);a.end(),a.result.geometries.length>0&&(yield a.result.geometries)}function Xe(t,e,a,s){for(;;)try{switch(t){case J.ERROR:case J.END:return t;case J.EXPECTING_HEADER:let i=a.getDataView(Qi);if(!i)return t;e.header=Wt(i),e.progress={bytesUsed:0,bytesTotal:e.header.length,rows:0},e.currentIndex=1,t=J.EXPECTING_RECORD;break;case J.EXPECTING_RECORD:for(;a.hasAvailableBytes(St);){let r=a.getDataView(St),n={recordNumber:r.getInt32(0,Je),byteLength:r.getInt32(4,Je)*2,type:r.getInt32(8,Xi)};if(!a.hasAvailableBytes(n.byteLength-4))return a.rewind(St),t;if(n.byteLength<4||n.type!==e.header?.type||n.recordNumber!==e.currentIndex)a.rewind(St-4);else{a.rewind(4);let o=a.getDataView(n.byteLength),l=Ue(o,s);e.geometries.push(l),e.currentIndex++,e.progress.rows=e.currentIndex-1}}return a.ended&&(t=J.END),t;default:return t=J.ERROR,e.error=`illegal parser state ${t}`,t}}catch(i){return t=J.ERROR,e.error=`SHP parsing failed: ${i?.message}`,t}}var Vi="4.2.0-beta.2",ge=[0,0,39,10],_e={dataType:null,batchType:null,name:"SHP",id:"shp",module:"shapefile",version:Vi,worker:!0,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(ge).buffer],options:{shp:{_maxDimensions:4}}},Nt={..._e,parse:async(t,e)=>xe(t,e),parseSync:xe,parseInBatches:(t,e)=>Qe(t,e)};async function Xt(t,e,a,s){return s._parse(t,e,a,s)}async function Qt(t,e,a,s){if(!s._parseInBatches)throw new Error("parseInBatches");return s._parseInBatches(t,e,a,s)}function lt(t){return lt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},lt(t)}function be(t,e){if(lt(t)!=="object"||t===null)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var s=a.call(t,e||"default");if(lt(s)!=="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ee(t){var e=be(t,"string");return lt(e)==="symbol"?e:String(e)}function Ie(t,e,a){return e=Ee(e),e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function Pe(t,e,a){switch(t.type){case"Point":return Yi(t,e,a);case"LineString":return Ki(t,e,a);case"Polygon":return Ve(t,e,a);default:let s=t;throw new Error(`Unsupported geometry type: ${s?.type}`)}}function Ve(t,e=-1/0,a=1/0){let{positions:s}=t,i=t.polygonIndices.value.filter(o=>o>=e&&o<=a),r=t.primitivePolygonIndices.value.filter(o=>o>=e&&o<=a);if(!(i.length>2)){let o=[];for(let l=0;l<r.length-1;l++){let u=r[l],f=r[l+1],c=Vt(s,u,f);o.push(c)}return{type:"Polygon",coordinates:o}}let h=[];for(let o=0;o<i.length-1;o++){let l=i[o],u=i[o+1],f=Ve(t,l,u).coordinates;h.push(f)}return{type:"MultiPolygon",coordinates:h}}function Ki(t,e=-1/0,a=1/0){let{positions:s}=t,i=t.pathIndices.value.filter(h=>h>=e&&h<=a);if(!(i.length>2))return{type:"LineString",coordinates:Vt(s,i[0],i[1])};let n=[];for(let h=0;h<i.length-1;h++){let o=Vt(s,i[h],i[h+1]);n.push(o)}return{type:"MultiLineString",coordinates:n}}function Yi(t,e,a){let{positions:s}=t,i=Vt(s,e,a);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Vt(t,e,a){e=e||0,a=a||t.value.length/t.size;let s=[];for(let i=e;i<a;i++){let r=Array();for(let n=i*t.size;n<(i+1)*t.size;n++)r.push(Number(t.value[n]));s.push(r)}return s}function Ae(t,e){for(let a of t)a.geometry.coordinates=Ke(a.geometry.coordinates,e);return t}function Ke(t,e){return Zi(t)?e(t):t.map(a=>Ke(a,e))}function Zi(t){return Array.isArray(t)&&Number.isFinite(t[0])&&Number.isFinite(t[1])}function Ye(t){t("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"),t("EPSG:4269","+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"),t("EPSG:3857","+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"),t.WGS84=t["EPSG:4326"],t["EPSG:3785"]=t["EPSG:3857"],t.GOOGLE=t["EPSG:3857"],t["EPSG:900913"]=t["EPSG:3857"],t["EPSG:102113"]=t["EPSG:3857"]}var X=1,Q=2,Ze=4,wt=5,Mt=484813681109536e-20,m=Math.PI/2,$e=.16666666666666666,ta=.04722222222222222,ea=.022156084656084655,p=1e-10,L=.017453292519943295,V=57.29577951308232,I=Math.PI/4,Rt=Math.PI*2,w=3.14159265359;var G={};G.greenwich=0;G.lisbon=-9.131906111111;G.paris=2.337229166667;G.bogota=-74.080916666667;G.madrid=-3.687938888889;G.rome=12.452333333333;G.bern=7.439583333333;G.jakarta=106.807719444444;G.ferro=-17.666666666667;G.brussels=4.367975;G.stockholm=18.058277777778;G.athens=23.7163375;G.oslo=10.722916666667;var aa={ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937}};var ia=/[\s_\-\/\(\)]/g;function k(t,e){if(t[e])return t[e];for(var a=Object.keys(t),s=e.toLowerCase().replace(ia,""),i=-1,r,n;++i<a.length;)if(r=a[i],n=r.toLowerCase().replace(ia,""),n===s)return t[r]}function Ct(t){var e={},a=t.split("+").map(function(h){return h.trim()}).filter(function(h){return h}).reduce(function(h,o){var l=o.split("=");return l.push(!0),h[l[0].toLowerCase()]=l[1],h},{}),s,i,r,n={proj:"projName",datum:"datumCode",rf:function(h){e.rf=parseFloat(h)},lat_0:function(h){e.lat0=h*L},lat_1:function(h){e.lat1=h*L},lat_2:function(h){e.lat2=h*L},lat_ts:function(h){e.lat_ts=h*L},lon_0:function(h){e.long0=h*L},lon_1:function(h){e.long1=h*L},lon_2:function(h){e.long2=h*L},alpha:function(h){e.alpha=parseFloat(h)*L},lonc:function(h){e.longc=h*L},x_0:function(h){e.x0=parseFloat(h)},y_0:function(h){e.y0=parseFloat(h)},k_0:function(h){e.k0=parseFloat(h)},k:function(h){e.k0=parseFloat(h)},a:function(h){e.a=parseFloat(h)},b:function(h){e.b=parseFloat(h)},r_a:function(){e.R_A=!0},zone:function(h){e.zone=parseInt(h,10)},south:function(){e.utmSouth=!0},towgs84:function(h){e.datum_params=h.split(",").map(function(o){return parseFloat(o)})},to_meter:function(h){e.to_meter=parseFloat(h)},units:function(h){e.units=h;var o=k(aa,h);o&&(e.to_meter=o.to_meter)},from_greenwich:function(h){e.from_greenwich=h*L},pm:function(h){var o=k(G,h);e.from_greenwich=(o||parseFloat(h))*L},nadgrids:function(h){h==="@null"?e.datumCode="none":e.nadgrids=h},axis:function(h){var o="ewnsud";h.length===3&&o.indexOf(h.substr(0,1))!==-1&&o.indexOf(h.substr(1,1))!==-1&&o.indexOf(h.substr(2,1))!==-1&&(e.axis=h)}};for(s in a)i=a[s],s in n?(r=n[s],typeof r=="function"?r(i):e[r]=i):e[s]=i;return typeof e.datumCode=="string"&&e.datumCode!=="WGS84"&&(e.datumCode=e.datumCode.toLowerCase()),e}var sa=as,Lt=1,ra=2,na=3,Kt=4,ha=5,Se=-1,$i=/\s/,ts=/[A-Za-z]/,es=/[A-Za-z84_]/,Yt=/[,\]]/,oa=/[\d\.E\-\+]/;function tt(t){if(typeof t!="string")throw new Error("not a string");this.text=t.trim(),this.level=0,this.place=0,this.root=null,this.stack=[],this.currentObject=null,this.state=Lt}tt.prototype.readCharicter=function(){var t=this.text[this.place++];if(this.state!==Kt)for(;$i.test(t);){if(this.place>=this.text.length)return;t=this.text[this.place++]}switch(this.state){case Lt:return this.neutral(t);case ra:return this.keyword(t);case Kt:return this.quoted(t);case ha:return this.afterquote(t);case na:return this.number(t);case Se:return}};tt.prototype.afterquote=function(t){if(t==='"'){this.word+='"',this.state=Kt;return}if(Yt.test(t)){this.word=this.word.trim(),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in afterquote yet, index '+this.place)};tt.prototype.afterItem=function(t){if(t===","){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=Lt;return}if(t==="]"){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=Lt,this.currentObject=this.stack.pop(),this.currentObject||(this.state=Se);return}};tt.prototype.number=function(t){if(oa.test(t)){this.word+=t;return}if(Yt.test(t)){this.word=parseFloat(this.word),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in number yet, index '+this.place)};tt.prototype.quoted=function(t){if(t==='"'){this.state=ha;return}this.word+=t};tt.prototype.keyword=function(t){if(es.test(t)){this.word+=t;return}if(t==="["){var e=[];e.push(this.word),this.level++,this.root===null?this.root=e:this.currentObject.push(e),this.stack.push(this.currentObject),this.currentObject=e,this.state=Lt;return}if(Yt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in keyword yet, index '+this.place)};tt.prototype.neutral=function(t){if(ts.test(t)){this.word=t,this.state=ra;return}if(t==='"'){this.word="",this.state=Kt;return}if(oa.test(t)){this.word=t,this.state=na;return}if(Yt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in neutral yet, index '+this.place)};tt.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===Se)return this.root;throw new Error('unable to parse string "'+this.text+'". State is '+this.state)};function as(t){var e=new tt(t);return e.output()}function la(t,e,a){Array.isArray(e)&&(a.unshift(e),e=null);var s=e?{}:t,i=a.reduce(function(r,n){return dt(n,r),r},s);e&&(t[e]=i)}function dt(t,e){if(!Array.isArray(t)){e[t]=!0;return}var a=t.shift();if(a==="PARAMETER"&&(a=t.shift()),t.length===1){if(Array.isArray(t[0])){e[a]={},dt(t[0],e[a]);return}e[a]=t[0];return}if(!t.length){e[a]=!0;return}if(a==="TOWGS84"){e[a]=t;return}if(a==="AXIS"){a in e||(e[a]=[]),e[a].push(t);return}Array.isArray(a)||(e[a]={});var s;switch(a){case"UNIT":case"PRIMEM":case"VERT_DATUM":e[a]={name:t[0].toLowerCase(),convert:t[1]},t.length===3&&dt(t[2],e[a]);return;case"SPHEROID":case"ELLIPSOID":e[a]={name:t[0],a:t[1],rf:t[2]},t.length===4&&dt(t[3],e[a]);return;case"PROJECTEDCRS":case"PROJCRS":case"GEOGCS":case"GEOCCS":case"PROJCS":case"LOCAL_CS":case"GEODCRS":case"GEODETICCRS":case"GEODETICDATUM":case"EDATUM":case"ENGINEERINGDATUM":case"VERT_CS":case"VERTCRS":case"VERTICALCRS":case"COMPD_CS":case"COMPOUNDCRS":case"ENGINEERINGCRS":case"ENGCRS":case"FITTED_CS":case"LOCAL_DATUM":case"DATUM":t[0]=["name",t[0]],la(e,a,t);return;default:for(s=-1;++s<t.length;)if(!Array.isArray(t[s]))return dt(t,e[a]);return la(e,a,t)}}var is=.017453292519943295;function ss(t,e){var a=e[0],s=e[1];!(a in t)&&s in t&&(t[a]=t[s],e.length===3&&(t[a]=e[2](t[a])))}function et(t){return t*is}function rs(t){if(t.type==="GEOGCS"?t.projName="longlat":t.type==="LOCAL_CS"?(t.projName="identity",t.local=!0):typeof t.PROJECTION=="object"?t.projName=Object.keys(t.PROJECTION)[0]:t.projName=t.PROJECTION,t.AXIS){for(var e="",a=0,s=t.AXIS.length;a<s;++a){var i=[t.AXIS[a][0].toLowerCase(),t.AXIS[a][1].toLowerCase()];i[0].indexOf("north")!==-1||(i[0]==="y"||i[0]==="lat")&&i[1]==="north"?e+="n":i[0].indexOf("south")!==-1||(i[0]==="y"||i[0]==="lat")&&i[1]==="south"?e+="s":i[0].indexOf("east")!==-1||(i[0]==="x"||i[0]==="lon")&&i[1]==="east"?e+="e":(i[0].indexOf("west")!==-1||(i[0]==="x"||i[0]==="lon")&&i[1]==="west")&&(e+="w")}e.length===2&&(e+="u"),e.length===3&&(t.axis=e)}t.UNIT&&(t.units=t.UNIT.name.toLowerCase(),t.units==="metre"&&(t.units="meter"),t.UNIT.convert&&(t.type==="GEOGCS"?t.DATUM&&t.DATUM.SPHEROID&&(t.to_meter=t.UNIT.convert*t.DATUM.SPHEROID.a):t.to_meter=t.UNIT.convert));var r=t.GEOGCS;t.type==="GEOGCS"&&(r=t),r&&(r.DATUM?t.datumCode=r.DATUM.name.toLowerCase():t.datumCode=r.name.toLowerCase(),t.datumCode.slice(0,2)==="d_"&&(t.datumCode=t.datumCode.slice(2)),(t.datumCode==="new_zealand_geodetic_datum_1949"||t.datumCode==="new_zealand_1949")&&(t.datumCode="nzgd49"),(t.datumCode==="wgs_1984"||t.datumCode==="world_geodetic_system_1984")&&(t.PROJECTION==="Mercator_Auxiliary_Sphere"&&(t.sphere=!0),t.datumCode="wgs84"),t.datumCode.slice(-6)==="_ferro"&&(t.datumCode=t.datumCode.slice(0,-6)),t.datumCode.slice(-8)==="_jakarta"&&(t.datumCode=t.datumCode.slice(0,-8)),~t.datumCode.indexOf("belge")&&(t.datumCode="rnb72"),r.DATUM&&r.DATUM.SPHEROID&&(t.ellps=r.DATUM.SPHEROID.name.replace("_19","").replace(/[Cc]larke\_18/,"clrk"),t.ellps.toLowerCase().slice(0,13)==="international"&&(t.ellps="intl"),t.a=r.DATUM.SPHEROID.a,t.rf=parseFloat(r.DATUM.SPHEROID.rf,10)),r.DATUM&&r.DATUM.TOWGS84&&(t.datum_params=r.DATUM.TOWGS84),~t.datumCode.indexOf("osgb_1936")&&(t.datumCode="osgb36"),~t.datumCode.indexOf("osni_1952")&&(t.datumCode="osni52"),(~t.datumCode.indexOf("tm65")||~t.datumCode.indexOf("geodetic_datum_of_1965"))&&(t.datumCode="ire65"),t.datumCode==="ch1903+"&&(t.datumCode="ch1903"),~t.datumCode.indexOf("israel")&&(t.datumCode="isr93")),t.b&&!isFinite(t.b)&&(t.b=t.a);function n(l){var u=t.to_meter||1;return l*u}var h=function(l){return ss(t,l)},o=[["standard_parallel_1","Standard_Parallel_1"],["standard_parallel_1","Latitude of 1st standard parallel"],["standard_parallel_2","Standard_Parallel_2"],["standard_parallel_2","Latitude of 2nd standard parallel"],["false_easting","False_Easting"],["false_easting","False easting"],["false-easting","Easting at false origin"],["false_northing","False_Northing"],["false_northing","False northing"],["false_northing","Northing at false origin"],["central_meridian","Central_Meridian"],["central_meridian","Longitude of natural origin"],["central_meridian","Longitude of false origin"],["latitude_of_origin","Latitude_Of_Origin"],["latitude_of_origin","Central_Parallel"],["latitude_of_origin","Latitude of natural origin"],["latitude_of_origin","Latitude of false origin"],["scale_factor","Scale_Factor"],["k0","scale_factor"],["latitude_of_center","Latitude_Of_Center"],["latitude_of_center","Latitude_of_center"],["lat0","latitude_of_center",et],["longitude_of_center","Longitude_Of_Center"],["longitude_of_center","Longitude_of_center"],["longc","longitude_of_center",et],["x0","false_easting",n],["y0","false_northing",n],["long0","central_meridian",et],["lat0","latitude_of_origin",et],["lat0","standard_parallel_1",et],["lat1","standard_parallel_1",et],["lat2","standard_parallel_2",et],["azimuth","Azimuth"],["alpha","azimuth",et],["srsCode","name"]];o.forEach(h),!t.long0&&t.longc&&(t.projName==="Albers_Conic_Equal_Area"||t.projName==="Lambert_Azimuthal_Equal_Area")&&(t.long0=t.longc),!t.lat_ts&&t.lat1&&(t.projName==="Stereographic_South_Pole"||t.projName==="Polar Stereographic (variant B)")&&(t.lat0=et(t.lat1>0?90:-90),t.lat_ts=t.lat1)}function Zt(t){var e=sa(t),a=e.shift(),s=e.shift();e.unshift(["name",s]),e.unshift(["type",a]);var i={};return dt(e,i),rs(i),i}function U(t){var e=this;if(arguments.length===2){var a=arguments[1];typeof a=="string"?a.charAt(0)==="+"?U[t]=Ct(arguments[1]):U[t]=Zt(arguments[1]):U[t]=a}else if(arguments.length===1){if(Array.isArray(t))return t.map(function(s){Array.isArray(s)?U.apply(e,s):U(s)});if(typeof t=="string"){if(t in U)return U[t]}else"EPSG"in t?U["EPSG:"+t.EPSG]=t:"ESRI"in t?U["ESRI:"+t.ESRI]=t:"IAU2000"in t?U["IAU2000:"+t.IAU2000]=t:console.log(t);return}}Ye(U);var gt=U;function ns(t){return typeof t=="string"}function hs(t){return t in gt}var os=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];function ls(t){return os.some(function(e){return t.indexOf(e)>-1})}var fs=["3857","900913","3785","102113"];function us(t){var e=k(t,"authority");if(e){var a=k(e,"epsg");return a&&fs.indexOf(a)>-1}}function cs(t){var e=k(t,"extension");if(e)return k(e,"proj4")}function ms(t){return t[0]==="+"}function Ms(t){if(ns(t)){if(hs(t))return gt[t];if(ls(t)){var e=Zt(t);if(us(e))return gt["EPSG:3857"];var a=cs(e);return a?Ct(a):e}if(ms(t))return Ct(t)}else return t}var fa=Ms;function Ne(t,e){t=t||{};var a,s;if(!e)return t;for(s in e)a=e[s],a!==void 0&&(t[s]=a);return t}function B(t,e,a){var s=t*e;return a/Math.sqrt(1-s*s)}function $(t){return t<0?-1:1}function v(t){return Math.abs(t)<=w?t:t-$(t)*Rt}function F(t,e,a){var s=t*a,i=.5*t;return s=Math.pow((1-s)/(1+s),i),Math.tan(.5*(m-e))/s}function at(t,e){for(var a=.5*t,s,i,r=m-2*Math.atan(e),n=0;n<=15;n++)if(s=t*Math.sin(r),i=m-2*Math.atan(e*Math.pow((1-s)/(1+s),a))-r,r+=i,Math.abs(i)<=1e-10)return r;return-9999}function ds(){var t=this.b/this.a;this.es=1-t*t,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)}function ps(t){var e=t.x,a=t.y;if(a*V>90&&a*V<-90&&e*V>180&&e*V<-180)return null;var s,i;if(Math.abs(Math.abs(a)-m)<=p)return null;if(this.sphere)s=this.x0+this.a*this.k0*v(e-this.long0),i=this.y0+this.a*this.k0*Math.log(Math.tan(I+.5*a));else{var r=Math.sin(a),n=F(this.e,a,r);s=this.x0+this.a*this.k0*v(e-this.long0),i=this.y0-this.a*this.k0*Math.log(n)}return t.x=s,t.y=i,t}function vs(t){var e=t.x-this.x0,a=t.y-this.y0,s,i;if(this.sphere)i=m-2*Math.atan(Math.exp(-a/(this.a*this.k0)));else{var r=Math.exp(-a/(this.a*this.k0));if(i=at(this.e,r),i===-9999)return null}return s=v(this.long0+e/(this.a*this.k0)),t.x=s,t.y=i,t}var ys=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"],ua={init:ds,forward:ps,inverse:vs,names:ys};function xs(){}function ca(t){return t}var gs=["longlat","identity"],ma={init:xs,forward:ca,inverse:ca,names:gs};var _s=[ua,ma],$t={},te=[];function Ma(t,e){var a=te.length;return t.names?(te[a]=t,t.names.forEach(function(s){$t[s.toLowerCase()]=a}),this):(console.log(e),!0)}function bs(t){if(!t)return!1;var e=t.toLowerCase();if(typeof $t[e]<"u"&&te[$t[e]])return te[$t[e]]}function Es(){_s.forEach(Ma)}var da={start:Es,add:Ma,get:bs};var _={};_.MERIT={a:6378137,rf:298.257,ellipseName:"MERIT 1983"};_.SGS85={a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"};_.GRS80={a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"};_.IAU76={a:6378140,rf:298.257,ellipseName:"IAU 1976"};_.airy={a:6377563396e-3,b:635625691e-2,ellipseName:"Airy 1830"};_.APL4={a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"};_.NWL9D={a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"};_.mod_airy={a:6377340189e-3,b:6356034446e-3,ellipseName:"Modified Airy"};_.andrae={a:637710443e-2,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"};_.aust_SA={a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"};_.GRS67={a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"};_.bessel={a:6377397155e-3,rf:299.1528128,ellipseName:"Bessel 1841"};_.bess_nam={a:6377483865e-3,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"};_.clrk66={a:63782064e-1,b:63565838e-1,ellipseName:"Clarke 1866"};_.clrk80={a:6378249145e-3,rf:293.4663,ellipseName:"Clarke 1880 mod."};_.clrk58={a:6378293645208759e-9,rf:294.2606763692654,ellipseName:"Clarke 1858"};_.CPM={a:63757387e-1,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"};_.delmbr={a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"};_.engelis={a:637813605e-2,rf:298.2566,ellipseName:"Engelis 1985"};_.evrst30={a:6377276345e-3,rf:300.8017,ellipseName:"Everest 1830"};_.evrst48={a:6377304063e-3,rf:300.8017,ellipseName:"Everest 1948"};_.evrst56={a:6377301243e-3,rf:300.8017,ellipseName:"Everest 1956"};_.evrst69={a:6377295664e-3,rf:300.8017,ellipseName:"Everest 1969"};_.evrstSS={a:6377298556e-3,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"};_.fschr60={a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"};_.fschr60m={a:6378155,rf:298.3,ellipseName:"Fischer 1960"};_.fschr68={a:6378150,rf:298.3,ellipseName:"Fischer 1968"};_.helmert={a:6378200,rf:298.3,ellipseName:"Helmert 1906"};_.hough={a:6378270,rf:297,ellipseName:"Hough"};_.intl={a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"};_.kaula={a:6378163,rf:298.24,ellipseName:"Kaula 1961"};_.lerch={a:6378139,rf:298.257,ellipseName:"Lerch 1979"};_.mprts={a:6397300,rf:191,ellipseName:"Maupertius 1738"};_.new_intl={a:63781575e-1,b:63567722e-1,ellipseName:"New International 1967"};_.plessis={a:6376523,rf:6355863,ellipseName:"Plessis 1817 (France)"};_.krass={a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"};_.SEasia={a:6378155,b:63567733205e-4,ellipseName:"Southeast Asia"};_.walbeck={a:6376896,b:63558348467e-4,ellipseName:"Walbeck"};_.WGS60={a:6378165,rf:298.3,ellipseName:"WGS 60"};_.WGS66={a:6378145,rf:298.25,ellipseName:"WGS 66"};_.WGS7={a:6378135,rf:298.26,ellipseName:"WGS 72"};var pa=_.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};_.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};function va(t,e,a,s){var i=t*t,r=e*e,n=(i-r)/i,h=0;s?(t*=1-n*($e+n*(ta+n*ea)),i=t*t,n=0):h=Math.sqrt(n);var o=(i-r)/r;return{es:n,e:h,ep2:o}}function ya(t,e,a,s,i){if(!t){var r=k(_,s);r||(r=pa),t=r.a,e=r.b,a=r.rf}return a&&!e&&(e=(1-1/a)*t),(a===0||Math.abs(t-e)<p)&&(i=!0,e=t),{a:t,b:e,rf:a,sphere:i}}var T={};T.wgs84={towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"};T.ch1903={towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"};T.ggrs87={towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"};T.nad83={towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"};T.nad27={nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"};T.potsdam={towgs84:"606.0,23.0,413.0",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"};T.carthage={towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"};T.hermannskogel={towgs84:"653.0,-212.0,449.0",ellipse:"bessel",datumName:"Hermannskogel"};T.osni52={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"};T.ire65={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"};T.rassadiran={towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"};T.nzgd49={towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"};T.osgb36={towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"};T.s_jtsk={towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"};T.beduaram={towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"};T.gunung_segara={towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"};T.rnb72={towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"};function Is(t,e,a,s,i,r){var n={};return t===void 0||t==="none"?n.datum_type=wt:n.datum_type=Ze,e&&(n.datum_params=e.map(parseFloat),(n.datum_params[0]!==0||n.datum_params[1]!==0||n.datum_params[2]!==0)&&(n.datum_type=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=s,n.es=i,n.ep2=r,n}var xa=Is;function _t(t,e){if(!(this instanceof _t))return new _t(t);e=e||function(o){if(o)throw o};var a=fa(t);if(typeof a!="object"){e(t);return}var s=_t.projections.get(a.projName);if(!s){e(t);return}if(a.datumCode&&a.datumCode!=="none"){var i=k(T,a.datumCode);i&&(a.datum_params=i.towgs84?i.towgs84.split(","):null,a.ellps=i.ellipse,a.datumName=i.datumName?i.datumName:a.datumCode)}a.k0=a.k0||1,a.axis=a.axis||"enu",a.ellps=a.ellps||"wgs84";var r=ya(a.a,a.b,a.rf,a.ellps,a.sphere),n=va(r.a,r.b,r.rf,a.R_A),h=a.datum||xa(a.datumCode,a.datum_params,r.a,r.b,n.es,n.ep2);Ne(this,a),Ne(this,s),this.a=r.a,this.b=r.b,this.rf=r.rf,this.sphere=r.sphere,this.es=n.es,this.e=n.e,this.ep2=n.ep2,this.datum=h,this.init(),e(null,this)}_t.projections=da;_t.projections.start();var ft=_t;function ga(t,e){return t.datum_type!==e.datum_type||t.a!==e.a||Math.abs(t.es-e.es)>5e-11?!1:t.datum_type===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 ee(t,e,a){var s=t.x,i=t.y,r=t.z?t.z:0,n,h,o,l;if(i<-m&&i>-1.001*m)i=-m;else if(i>m&&i<1.001*m)i=m;else{if(i<-m)return{x:-1/0,y:-1/0,z:t.z};if(i>m)return{x:1/0,y:1/0,z:t.z}}return s>Math.PI&&(s-=2*Math.PI),h=Math.sin(i),l=Math.cos(i),o=h*h,n=a/Math.sqrt(1-e*o),{x:(n+r)*l*Math.cos(s),y:(n+r)*l*Math.sin(s),z:(n*(1-e)+r)*h}}function ae(t,e,a,s){var i=1e-12,r=i*i,n=30,h,o,l,u,f,c,M,d,y,x,g,b,E,N=t.x,P=t.y,A=t.z?t.z:0,O,C,Z;if(h=Math.sqrt(N*N+P*P),o=Math.sqrt(N*N+P*P+A*A),h/a<i){if(O=0,o/a<i)return C=m,Z=-s,{x:t.x,y:t.y,z:t.z}}else O=Math.atan2(P,N);l=A/o,u=h/o,f=1/Math.sqrt(1-e*(2-e)*u*u),d=u*(1-e)*f,y=l*f,E=0;do E++,M=a/Math.sqrt(1-e*y*y),Z=h*d+A*y-M*(1-e*y*y),c=e*M/(M+Z),f=1/Math.sqrt(1-c*(2-c)*u*u),x=u*(1-c)*f,g=l*f,b=g*d-x*y,d=x,y=g;while(b*b>r&&E<n);return C=Math.atan(g/Math.abs(x)),{x:O,y:C,z:Z}}function _a(t,e,a){if(e===X)return{x:t.x+a[0],y:t.y+a[1],z:t.z+a[2]};if(e===Q){var s=a[0],i=a[1],r=a[2],n=a[3],h=a[4],o=a[5],l=a[6];return{x:l*(t.x-o*t.y+h*t.z)+s,y:l*(o*t.x+t.y-n*t.z)+i,z:l*(-h*t.x+n*t.y+t.z)+r}}}function ba(t,e,a){if(e===X)return{x:t.x-a[0],y:t.y-a[1],z:t.z-a[2]};if(e===Q){var s=a[0],i=a[1],r=a[2],n=a[3],h=a[4],o=a[5],l=a[6],u=(t.x-s)/l,f=(t.y-i)/l,c=(t.z-r)/l;return{x:u+o*f-h*c,y:-o*u+f+n*c,z:h*u-n*f+c}}}function ie(t){return t===X||t===Q}function Ea(t,e,a){return ga(t,e)||t.datum_type===wt||e.datum_type===wt||t.es===e.es&&t.a===e.a&&!ie(t.datum_type)&&!ie(e.datum_type)?a:(a=ee(a,t.es,t.a),ie(t.datum_type)&&(a=_a(a,t.datum_type,t.datum_params)),ie(e.datum_type)&&(a=ba(a,e.datum_type,e.datum_params)),ae(a,e.es,e.a,e.b))}function we(t,e,a){var s=a.x,i=a.y,r=a.z||0,n,h,o,l={};for(o=0;o<3;o++)if(!(e&&o===2&&a.z===void 0))switch(o===0?(n=s,"ew".indexOf(t.axis[o])!==-1?h="x":h="y"):o===1?(n=i,"ns".indexOf(t.axis[o])!==-1?h="y":h="x"):(n=r,h="z"),t.axis[o]){case"e":case"w":case"n":case"s":l[h]=n;break;case"u":a[h]!==void 0&&(l.z=n);break;case"d":a[h]!==void 0&&(l.z=-n);break;default:return null}return l}function se(t){var e={x:t[0],y:t[1]};return t.length>2&&(e.z=t[2]),t.length>3&&(e.m=t[3]),e}function Pa(t){Ia(t.x),Ia(t.y)}function Ia(t){if(typeof Number.isFinite=="function"){if(Number.isFinite(t))return;throw new TypeError("coordinates must be finite numbers")}if(typeof t!="number"||t!==t||!isFinite(t))throw new TypeError("coordinates must be finite numbers")}function Ps(t,e){return(t.datum.datum_type===X||t.datum.datum_type===Q)&&e.datumCode!=="WGS84"||(e.datum.datum_type===X||e.datum.datum_type===Q)&&t.datumCode!=="WGS84"}function pt(t,e,a){var s;if(Array.isArray(a)&&(a=se(a)),Pa(a),t.datum&&e.datum&&Ps(t,e)&&(s=new ft("WGS84"),a=pt(t,s,a),t=s),t.axis!=="enu"&&(a=we(t,!1,a)),t.projName==="longlat")a={x:a.x*L,y:a.y*L,z:a.z||0};else if(t.to_meter&&(a={x:a.x*t.to_meter,y:a.y*t.to_meter,z:a.z||0}),a=t.inverse(a),!a)return;return t.from_greenwich&&(a.x+=t.from_greenwich),a=Ea(t.datum,e.datum,a),e.from_greenwich&&(a={x:a.x-e.from_greenwich,y:a.y,z:a.z||0}),e.projName==="longlat"?a={x:a.x*V,y:a.y*V,z:a.z||0}:(a=e.forward(a),e.to_meter&&(a={x:a.x/e.to_meter,y:a.y/e.to_meter,z:a.z||0})),e.axis!=="enu"?we(e,!0,a):a}var Aa=ft("WGS84");function Re(t,e,a){var s,i,r;return Array.isArray(a)?(s=pt(t,e,a)||{x:NaN,y:NaN},a.length>2?typeof t.name<"u"&&t.name==="geocent"||typeof e.name<"u"&&e.name==="geocent"?typeof s.z=="number"?[s.x,s.y,s.z].concat(a.splice(3)):[s.x,s.y,a[2]].concat(a.splice(3)):[s.x,s.y].concat(a.splice(2)):[s.x,s.y]):(i=pt(t,e,a),r=Object.keys(a),r.length===2||r.forEach(function(n){if(typeof t.name<"u"&&t.name==="geocent"||typeof e.name<"u"&&e.name==="geocent"){if(n==="x"||n==="y"||n==="z")return}else if(n==="x"||n==="y")return;i[n]=a[n]}),i)}function Sa(t){return t instanceof ft?t:t.oProj?t.oProj:ft(t)}function As(t,e,a){t=Sa(t);var s=!1,i;return typeof e>"u"?(e=t,t=Aa,s=!0):(typeof e.x<"u"||Array.isArray(e))&&(a=e,e=t,t=Aa,s=!0),e=Sa(e),a?Re(t,e,a):(i={forward:function(r){return Re(t,e,r)},inverse:function(r){return Re(e,t,r)}},s&&(i.oProj=e),i)}var H=As;var Na=6,Ra="AJSAJS",Ca="AFAFAF",bt=65,z=73,W=79,Tt=86,Dt=90,La={forward:Le,inverse:Ss,toPoint:Te};function Le(t,e){return e=e||5,Rs(Ns({lat:t[1],lon:t[0]}),e)}function Ss(t){var e=De(Da(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat,e.lon,e.lat]:[e.left,e.bottom,e.right,e.top]}function Te(t){var e=De(Da(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat]:[(e.left+e.right)/2,(e.top+e.bottom)/2]}function Ce(t){return t*(Math.PI/180)}function wa(t){return 180*(t/Math.PI)}function Ns(t){var e=t.lat,a=t.lon,s=6378137,i=.00669438,r=.9996,n,h,o,l,u,f,c,M=Ce(e),d=Ce(a),y,x;x=Math.floor((a+180)/6)+1,a===180&&(x=60),e>=56&&e<64&&a>=3&&a<12&&(x=32),e>=72&&e<84&&(a>=0&&a<9?x=31:a>=9&&a<21?x=33:a>=21&&a<33?x=35:a>=33&&a<42&&(x=37)),n=(x-1)*6-180+3,y=Ce(n),h=i/(1-i),o=s/Math.sqrt(1-i*Math.sin(M)*Math.sin(M)),l=Math.tan(M)*Math.tan(M),u=h*Math.cos(M)*Math.cos(M),f=Math.cos(M)*(d-y),c=s*((1-i/4-3*i*i/64-5*i*i*i/256)*M-(3*i/8+3*i*i/32+45*i*i*i/1024)*Math.sin(2*M)+(15*i*i/256+45*i*i*i/1024)*Math.sin(4*M)-35*i*i*i/3072*Math.sin(6*M));var g=r*o*(f+(1-l+u)*f*f*f/6+(5-18*l+l*l+72*u-58*h)*f*f*f*f*f/120)+5e5,b=r*(c+o*Math.tan(M)*(f*f/2+(5-l+9*u+4*u*u)*f*f*f*f/24+(61-58*l+l*l+600*u-330*h)*f*f*f*f*f*f/720));return e<0&&(b+=1e7),{northing:Math.round(b),easting:Math.round(g),zoneNumber:x,zoneLetter:ws(e)}}function De(t){var e=t.northing,a=t.easting,s=t.zoneLetter,i=t.zoneNumber;if(i<0||i>60)return null;var r=.9996,n=6378137,h=.00669438,o,l=(1-Math.sqrt(1-h))/(1+Math.sqrt(1-h)),u,f,c,M,d,y,x,g,b,E=a-5e5,N=e;s<"N"&&(N-=1e7),x=(i-1)*6-180+3,o=h/(1-h),y=N/r,g=y/(n*(1-h/4-3*h*h/64-5*h*h*h/256)),b=g+(3*l/2-27*l*l*l/32)*Math.sin(2*g)+(21*l*l/16-55*l*l*l*l/32)*Math.sin(4*g)+151*l*l*l/96*Math.sin(6*g),u=n/Math.sqrt(1-h*Math.sin(b)*Math.sin(b)),f=Math.tan(b)*Math.tan(b),c=o*Math.cos(b)*Math.cos(b),M=n*(1-h)/Math.pow(1-h*Math.sin(b)*Math.sin(b),1.5),d=E/(u*r);var P=b-u*Math.tan(b)/M*(d*d/2-(5+3*f+10*c-4*c*c-9*o)*d*d*d*d/24+(61+90*f+298*c+45*f*f-252*o-3*c*c)*d*d*d*d*d*d/720);P=wa(P);var A=(d-(1+2*f+c)*d*d*d/6+(5-2*c+28*f-3*c*c+8*o+24*f*f)*d*d*d*d*d/120)/Math.cos(b);A=x+wa(A);var O;if(t.accuracy){var C=De({northing:t.northing+t.accuracy,easting:t.easting+t.accuracy,zoneLetter:t.zoneLetter,zoneNumber:t.zoneNumber});O={top:C.lat,right:C.lon,bottom:P,left:A}}else O={lat:P,lon:A};return O}function ws(t){var e="Z";return 84>=t&&t>=72?e="X":72>t&&t>=64?e="W":64>t&&t>=56?e="V":56>t&&t>=48?e="U":48>t&&t>=40?e="T":40>t&&t>=32?e="S":32>t&&t>=24?e="R":24>t&&t>=16?e="Q":16>t&&t>=8?e="P":8>t&&t>=0?e="N":0>t&&t>=-8?e="M":-8>t&&t>=-16?e="L":-16>t&&t>=-24?e="K":-24>t&&t>=-32?e="J":-32>t&&t>=-40?e="H":-40>t&&t>=-48?e="G":-48>t&&t>=-56?e="F":-56>t&&t>=-64?e="E":-64>t&&t>=-72?e="D":-72>t&&t>=-80&&(e="C"),e}function Rs(t,e){var a="00000"+t.easting,s="00000"+t.northing;return t.zoneNumber+t.zoneLetter+Cs(t.easting,t.northing,t.zoneNumber)+a.substr(a.length-5,e)+s.substr(s.length-5,e)}function Cs(t,e,a){var s=Ta(a),i=Math.floor(t/1e5),r=Math.floor(e/1e5)%20;return Ls(i,r,s)}function Ta(t){var e=t%Na;return e===0&&(e=Na),e}function Ls(t,e,a){var s=a-1,i=Ra.charCodeAt(s),r=Ca.charCodeAt(s),n=i+t-1,h=r+e,o=!1;n>Dt&&(n=n-Dt+bt-1,o=!0),(n===z||i<z&&n>z||(n>z||i<z)&&o)&&n++,(n===W||i<W&&n>W||(n>W||i<W)&&o)&&(n++,n===z&&n++),n>Dt&&(n=n-Dt+bt-1),h>Tt?(h=h-Tt+bt-1,o=!0):o=!1,(h===z||r<z&&h>z||(h>z||r<z)&&o)&&h++,(h===W||r<W&&h>W||(h>W||r<W)&&o)&&(h++,h===z&&h++),h>Tt&&(h=h-Tt+bt-1);var l=String.fromCharCode(n)+String.fromCharCode(h);return l}function Da(t){if(t&&t.length===0)throw"MGRSPoint coverting from nothing";for(var e=t.length,a=null,s="",i,r=0;!/[A-Z]/.test(i=t.charAt(r));){if(r>=2)throw"MGRSPoint bad conversion from: "+t;s+=i,r++}var n=parseInt(s,10);if(r===0||r+3>e)throw"MGRSPoint bad conversion from: "+t;var h=t.charAt(r++);if(h<="A"||h==="B"||h==="Y"||h>="Z"||h==="I"||h==="O")throw"MGRSPoint zone letter "+h+" not handled: "+t;a=t.substring(r,r+=2);for(var o=Ta(n),l=Ts(a.charAt(0),o),u=Ds(a.charAt(1),o);u<Os(h);)u+=2e6;var f=e-r;if(f%2!==0)throw`MGRSPoint has to have an even number
|
|
7
|
+
"use strict";var __exports__=(()=>{var Oi=Object.create;var Ht=Object.defineProperty;var Bi=Object.getOwnPropertyDescriptor;var Gi=Object.getOwnPropertyNames;var Fi=Object.getPrototypeOf,qi=Object.prototype.hasOwnProperty;var zi=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),ji=(t,e)=>{for(var a in e)Ht(t,a,{get:e[a],enumerable:!0})},kt=(t,e,a,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of Gi(e))!qi.call(t,i)&&i!==a&&Ht(t,i,{get:()=>e[i],enumerable:!(s=Bi(e,i))||s.enumerable});return t},Ut=(t,e,a)=>(kt(t,e,"default"),a&&kt(a,e,"default")),ki=(t,e,a)=>(a=t!=null?Oi(Fi(t)):{},kt(e||!t||!t.__esModule?Ht(a,"default",{value:t,enumerable:!0}):a,t)),Hi=t=>kt(Ht({},"__esModule",{value:!0}),t);var He=zi((wh,ke)=>{ke.exports=globalThis.loaders});var zt={};ji(zt,{DBFLoader:()=>Ft,DBFWorkerLoader:()=>je,SHPLoader:()=>Nt,SHPWorkerLoader:()=>_e,ShapefileLoader:()=>Ti,_BinaryChunkReader:()=>ot,_BinaryReader:()=>pe,_zipBatchIterators:()=>me});Ut(zt,ki(He(),1));var ot=class{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 s of this.arrayBuffers)if(a+=s.byteLength,a>=e)return!0;return!1}findBufferOffsets(e){let a=-this.offset,s=[];for(let i=0;i<this.arrayBuffers.length;i++){let r=this.arrayBuffers[i];if(a+r.byteLength<=0){a+=r.byteLength;continue}let n=a<=0?Math.abs(a):0,h;if(n+e<=r.byteLength)return h=n+e,s.push([i,[n,h]]),s;h=r.byteLength,s.push([i,[n,h]]),e-=r.byteLength-n,a+=r.byteLength}return null}getDataView(e){let a=this.findBufferOffsets(e);if(!a&&this.ended)throw new Error("binary data exhausted");if(!a)return null;if(a.length===1){let[i,[r,n]]=a[0],h=this.arrayBuffers[i],o=new DataView(h,r,n-r);return this.offset+=e,this.disposeBuffers(),o}let s=new DataView(this._combineArrayBuffers(a));return this.offset+=e,this.disposeBuffers(),s}disposeBuffers(){for(;this.arrayBuffers.length>0&&this.offset-this.maxRewindBytes>=this.arrayBuffers[0].byteLength;)this.offset-=this.arrayBuffers[0].byteLength,this.arrayBuffers.shift()}_combineArrayBuffers(e){let a=0;for(let r of e){let[n,h]=r[1];a+=h-n}let s=new Uint8Array(a),i=0;for(let r of e){let[n,[h,o]]=r,l=new Uint8Array(this.arrayBuffers[n]);s.set(l.subarray(h,o),i),i+=o-h}return s.buffer}skip(e){this.offset+=e}rewind(e){this.offset-=e}};function Wt(t){let e={magic:t.getInt32(0,!1),length:t.getInt32(24,!1)*2,version:t.getInt32(28,!0),type:t.getInt32(32,!0),bbox:{minX:t.getFloat64(36,!0),minY:t.getFloat64(44,!0),minZ:t.getFloat64(68,!0),minM:t.getFloat64(84,!0),maxX:t.getFloat64(52,!0),maxY:t.getFloat64(60,!0),maxZ:t.getFloat64(76,!0),maxM:t.getFloat64(92,!0)}};return e.magic!==9994&&console.error(`SHP file: bad magic number ${e.magic}`),e.version!==1e3&&console.error(`SHP file: bad version ${e.version}`),e}function Ue(t,e){let{_maxDimensions:a=4}=e?.shp||{},s=0,i=t.getInt32(s,!0);switch(s+=Int32Array.BYTES_PER_ELEMENT,i){case 0:return Ui();case 1:return ve(t,s,Math.min(2,a));case 3:return xt(t,s,Math.min(2,a),"LineString");case 5:return xt(t,s,Math.min(2,a),"Polygon");case 8:return ye(t,s,Math.min(2,a));case 11:return ve(t,s,Math.min(4,a));case 13:return xt(t,s,Math.min(4,a),"LineString");case 15:return xt(t,s,Math.min(4,a),"Polygon");case 18:return ye(t,s,Math.min(4,a));case 21:return ve(t,s,Math.min(3,a));case 23:return xt(t,s,Math.min(3,a),"LineString");case 25:return xt(t,s,Math.min(3,a),"Polygon");case 28:return ye(t,s,Math.min(3,a));default:throw new Error(`unsupported shape type: ${i}`)}}function Ui(){return null}function ve(t,e,a){let s;return[s,e]=mt(t,e,1,a),{positions:{value:s,size:a},type:"Point"}}function ye(t,e,a){e+=4*Float64Array.BYTES_PER_ELEMENT;let s=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let i=null,r=null,n=null;return[i,e]=mt(t,e,s,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[n,e]=mt(t,e,s,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[r,e]=mt(t,e,s,1)),{positions:{value:We(i,r,n),size:a},type:"Point"}}function xt(t,e,a,s){e+=4*Float64Array.BYTES_PER_ELEMENT;let i=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let r=t.getInt32(e,!0);e+=Int32Array.BYTES_PER_ELEMENT;let n=t.byteOffset+e,h=i*Int32Array.BYTES_PER_ELEMENT,o=new Int32Array(i+1);o.set(new Int32Array(t.buffer.slice(n,n+h))),o[i]=r,e+=i*Int32Array.BYTES_PER_ELEMENT;let l=null,u=null,f=null;[l,e]=mt(t,e,r,2),a===4&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[f,e]=mt(t,e,r,1)),a>=3&&(e+=2*Float64Array.BYTES_PER_ELEMENT,[u,e]=mt(t,e,r,1));let c=We(l,u,f);if(s==="LineString")return{type:s,positions:{value:c,size:a},pathIndices:{value:o,size:1}};let M=[];for(let d=1;d<o.length;d++){let y=o[d-1],x=o[d],g=l.subarray(y*2,x*2);Wi(g)>0&&M.push(y)}return M.push(r),{type:s,positions:{value:c,size:a},primitivePolygonIndices:{value:o,size:1},polygonIndices:{value:new Uint32Array(M),size:1}}}function mt(t,e,a,s){let i=t.byteOffset+e,r=a*s*Float64Array.BYTES_PER_ELEMENT;return[new Float64Array(t.buffer.slice(i,i+r)),e+r]}function We(t,e,a){if(!(e||a))return t;let s=t.length,i=2;a&&a.length&&(s+=a.length,i++),e&&e.length&&(s+=e.length,i++);let r=new Float64Array(s);for(let n=0;n<t.length/2;n++)r[i*n]=t[n*2],r[i*n+1]=t[n*2+1];if(a&&a.length)for(let n=0;n<a.length;n++)r[i*n+2]=a[n];if(e&&e.length)for(let n=0;n<e.length;n++)r[i*n+(i-1)]=e[n];return r}function Wi(t){return Math.sign(Ji(t))}function Ji(t){let e=0,a=t.length/2-1;for(let s=0;s<a;s++)e+=(t[s*2]+t[(s+1)*2])*(t[s*2+1]-t[(s+1)*2+1]);return e/2}var Xi=!0,Je=!1,Qi=100,St=12,J={EXPECTING_HEADER:0,EXPECTING_RECORD:1,END:2,ERROR:3},Jt=class{options={};binaryReader=new ot({maxRewindBytes:St});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=Xe(this.state,this.result,this.binaryReader,this.options)}end(){this.binaryReader.end(),this.state=Xe(this.state,this.result,this.binaryReader,this.options),this.state!==J.END&&(this.state=J.ERROR,this.result.error="SHP incomplete file")}};function xe(t,e){let a=new Jt(e);return a.write(t),a.end(),a.result}async function*Qe(t,e){let a=new Jt(e),s=!1;for await(let i of t)a.write(i),!s&&a.result.header&&(s=!0,yield a.result.header),a.result.geometries.length>0&&(yield a.result.geometries,a.result.geometries=[]);a.end(),a.result.geometries.length>0&&(yield a.result.geometries)}function Xe(t,e,a,s){for(;;)try{switch(t){case J.ERROR:case J.END:return t;case J.EXPECTING_HEADER:let i=a.getDataView(Qi);if(!i)return t;e.header=Wt(i),e.progress={bytesUsed:0,bytesTotal:e.header.length,rows:0},e.currentIndex=1,t=J.EXPECTING_RECORD;break;case J.EXPECTING_RECORD:for(;a.hasAvailableBytes(St);){let r=a.getDataView(St),n={recordNumber:r.getInt32(0,Je),byteLength:r.getInt32(4,Je)*2,type:r.getInt32(8,Xi)};if(!a.hasAvailableBytes(n.byteLength-4))return a.rewind(St),t;if(n.byteLength<4||n.type!==e.header?.type||n.recordNumber!==e.currentIndex)a.rewind(St-4);else{a.rewind(4);let o=a.getDataView(n.byteLength),l=Ue(o,s);e.geometries.push(l),e.currentIndex++,e.progress.rows=e.currentIndex-1}}return a.ended&&(t=J.END),t;default:return t=J.ERROR,e.error=`illegal parser state ${t}`,t}}catch(i){return t=J.ERROR,e.error=`SHP parsing failed: ${i?.message}`,t}}var Vi="4.2.0",ge=[0,0,39,10],_e={dataType:null,batchType:null,name:"SHP",id:"shp",module:"shapefile",version:Vi,worker:!0,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(ge).buffer],options:{shp:{_maxDimensions:4}}},Nt={..._e,parse:async(t,e)=>xe(t,e),parseSync:xe,parseInBatches:(t,e)=>Qe(t,e)};async function Xt(t,e,a,s){return s._parse(t,e,a,s)}async function Qt(t,e,a,s){if(!s._parseInBatches)throw new Error("parseInBatches");return s._parseInBatches(t,e,a,s)}function lt(t){return lt=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},lt(t)}function be(t,e){if(lt(t)!=="object"||t===null)return t;var a=t[Symbol.toPrimitive];if(a!==void 0){var s=a.call(t,e||"default");if(lt(s)!=="object")return s;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function Ee(t){var e=be(t,"string");return lt(e)==="symbol"?e:String(e)}function Ie(t,e,a){return e=Ee(e),e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function Pe(t,e,a){switch(t.type){case"Point":return Yi(t,e,a);case"LineString":return Ki(t,e,a);case"Polygon":return Ve(t,e,a);default:let s=t;throw new Error(`Unsupported geometry type: ${s?.type}`)}}function Ve(t,e=-1/0,a=1/0){let{positions:s}=t,i=t.polygonIndices.value.filter(o=>o>=e&&o<=a),r=t.primitivePolygonIndices.value.filter(o=>o>=e&&o<=a);if(!(i.length>2)){let o=[];for(let l=0;l<r.length-1;l++){let u=r[l],f=r[l+1],c=Vt(s,u,f);o.push(c)}return{type:"Polygon",coordinates:o}}let h=[];for(let o=0;o<i.length-1;o++){let l=i[o],u=i[o+1],f=Ve(t,l,u).coordinates;h.push(f)}return{type:"MultiPolygon",coordinates:h}}function Ki(t,e=-1/0,a=1/0){let{positions:s}=t,i=t.pathIndices.value.filter(h=>h>=e&&h<=a);if(!(i.length>2))return{type:"LineString",coordinates:Vt(s,i[0],i[1])};let n=[];for(let h=0;h<i.length-1;h++){let o=Vt(s,i[h],i[h+1]);n.push(o)}return{type:"MultiLineString",coordinates:n}}function Yi(t,e,a){let{positions:s}=t,i=Vt(s,e,a);return i.length>1?{type:"MultiPoint",coordinates:i}:{type:"Point",coordinates:i[0]}}function Vt(t,e,a){e=e||0,a=a||t.value.length/t.size;let s=[];for(let i=e;i<a;i++){let r=Array();for(let n=i*t.size;n<(i+1)*t.size;n++)r.push(Number(t.value[n]));s.push(r)}return s}function Ae(t,e){for(let a of t)a.geometry.coordinates=Ke(a.geometry.coordinates,e);return t}function Ke(t,e){return Zi(t)?e(t):t.map(a=>Ke(a,e))}function Zi(t){return Array.isArray(t)&&Number.isFinite(t[0])&&Number.isFinite(t[1])}function Ye(t){t("EPSG:4326","+title=WGS 84 (long/lat) +proj=longlat +ellps=WGS84 +datum=WGS84 +units=degrees"),t("EPSG:4269","+title=NAD83 (long/lat) +proj=longlat +a=6378137.0 +b=6356752.31414036 +ellps=GRS80 +datum=NAD83 +units=degrees"),t("EPSG:3857","+title=WGS 84 / Pseudo-Mercator +proj=merc +a=6378137 +b=6378137 +lat_ts=0.0 +lon_0=0.0 +x_0=0.0 +y_0=0 +k=1.0 +units=m +nadgrids=@null +no_defs"),t.WGS84=t["EPSG:4326"],t["EPSG:3785"]=t["EPSG:3857"],t.GOOGLE=t["EPSG:3857"],t["EPSG:900913"]=t["EPSG:3857"],t["EPSG:102113"]=t["EPSG:3857"]}var X=1,Q=2,Ze=4,wt=5,Mt=484813681109536e-20,m=Math.PI/2,$e=.16666666666666666,ta=.04722222222222222,ea=.022156084656084655,p=1e-10,L=.017453292519943295,V=57.29577951308232,I=Math.PI/4,Rt=Math.PI*2,w=3.14159265359;var G={};G.greenwich=0;G.lisbon=-9.131906111111;G.paris=2.337229166667;G.bogota=-74.080916666667;G.madrid=-3.687938888889;G.rome=12.452333333333;G.bern=7.439583333333;G.jakarta=106.807719444444;G.ferro=-17.666666666667;G.brussels=4.367975;G.stockholm=18.058277777778;G.athens=23.7163375;G.oslo=10.722916666667;var aa={ft:{to_meter:.3048},"us-ft":{to_meter:1200/3937}};var ia=/[\s_\-\/\(\)]/g;function k(t,e){if(t[e])return t[e];for(var a=Object.keys(t),s=e.toLowerCase().replace(ia,""),i=-1,r,n;++i<a.length;)if(r=a[i],n=r.toLowerCase().replace(ia,""),n===s)return t[r]}function Ct(t){var e={},a=t.split("+").map(function(h){return h.trim()}).filter(function(h){return h}).reduce(function(h,o){var l=o.split("=");return l.push(!0),h[l[0].toLowerCase()]=l[1],h},{}),s,i,r,n={proj:"projName",datum:"datumCode",rf:function(h){e.rf=parseFloat(h)},lat_0:function(h){e.lat0=h*L},lat_1:function(h){e.lat1=h*L},lat_2:function(h){e.lat2=h*L},lat_ts:function(h){e.lat_ts=h*L},lon_0:function(h){e.long0=h*L},lon_1:function(h){e.long1=h*L},lon_2:function(h){e.long2=h*L},alpha:function(h){e.alpha=parseFloat(h)*L},lonc:function(h){e.longc=h*L},x_0:function(h){e.x0=parseFloat(h)},y_0:function(h){e.y0=parseFloat(h)},k_0:function(h){e.k0=parseFloat(h)},k:function(h){e.k0=parseFloat(h)},a:function(h){e.a=parseFloat(h)},b:function(h){e.b=parseFloat(h)},r_a:function(){e.R_A=!0},zone:function(h){e.zone=parseInt(h,10)},south:function(){e.utmSouth=!0},towgs84:function(h){e.datum_params=h.split(",").map(function(o){return parseFloat(o)})},to_meter:function(h){e.to_meter=parseFloat(h)},units:function(h){e.units=h;var o=k(aa,h);o&&(e.to_meter=o.to_meter)},from_greenwich:function(h){e.from_greenwich=h*L},pm:function(h){var o=k(G,h);e.from_greenwich=(o||parseFloat(h))*L},nadgrids:function(h){h==="@null"?e.datumCode="none":e.nadgrids=h},axis:function(h){var o="ewnsud";h.length===3&&o.indexOf(h.substr(0,1))!==-1&&o.indexOf(h.substr(1,1))!==-1&&o.indexOf(h.substr(2,1))!==-1&&(e.axis=h)}};for(s in a)i=a[s],s in n?(r=n[s],typeof r=="function"?r(i):e[r]=i):e[s]=i;return typeof e.datumCode=="string"&&e.datumCode!=="WGS84"&&(e.datumCode=e.datumCode.toLowerCase()),e}var sa=as,Lt=1,ra=2,na=3,Kt=4,ha=5,Se=-1,$i=/\s/,ts=/[A-Za-z]/,es=/[A-Za-z84_]/,Yt=/[,\]]/,oa=/[\d\.E\-\+]/;function tt(t){if(typeof t!="string")throw new Error("not a string");this.text=t.trim(),this.level=0,this.place=0,this.root=null,this.stack=[],this.currentObject=null,this.state=Lt}tt.prototype.readCharicter=function(){var t=this.text[this.place++];if(this.state!==Kt)for(;$i.test(t);){if(this.place>=this.text.length)return;t=this.text[this.place++]}switch(this.state){case Lt:return this.neutral(t);case ra:return this.keyword(t);case Kt:return this.quoted(t);case ha:return this.afterquote(t);case na:return this.number(t);case Se:return}};tt.prototype.afterquote=function(t){if(t==='"'){this.word+='"',this.state=Kt;return}if(Yt.test(t)){this.word=this.word.trim(),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in afterquote yet, index '+this.place)};tt.prototype.afterItem=function(t){if(t===","){this.word!==null&&this.currentObject.push(this.word),this.word=null,this.state=Lt;return}if(t==="]"){this.level--,this.word!==null&&(this.currentObject.push(this.word),this.word=null),this.state=Lt,this.currentObject=this.stack.pop(),this.currentObject||(this.state=Se);return}};tt.prototype.number=function(t){if(oa.test(t)){this.word+=t;return}if(Yt.test(t)){this.word=parseFloat(this.word),this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in number yet, index '+this.place)};tt.prototype.quoted=function(t){if(t==='"'){this.state=ha;return}this.word+=t};tt.prototype.keyword=function(t){if(es.test(t)){this.word+=t;return}if(t==="["){var e=[];e.push(this.word),this.level++,this.root===null?this.root=e:this.currentObject.push(e),this.stack.push(this.currentObject),this.currentObject=e,this.state=Lt;return}if(Yt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in keyword yet, index '+this.place)};tt.prototype.neutral=function(t){if(ts.test(t)){this.word=t,this.state=ra;return}if(t==='"'){this.word="",this.state=Kt;return}if(oa.test(t)){this.word=t,this.state=na;return}if(Yt.test(t)){this.afterItem(t);return}throw new Error(`havn't handled "`+t+'" in neutral yet, index '+this.place)};tt.prototype.output=function(){for(;this.place<this.text.length;)this.readCharicter();if(this.state===Se)return this.root;throw new Error('unable to parse string "'+this.text+'". State is '+this.state)};function as(t){var e=new tt(t);return e.output()}function la(t,e,a){Array.isArray(e)&&(a.unshift(e),e=null);var s=e?{}:t,i=a.reduce(function(r,n){return dt(n,r),r},s);e&&(t[e]=i)}function dt(t,e){if(!Array.isArray(t)){e[t]=!0;return}var a=t.shift();if(a==="PARAMETER"&&(a=t.shift()),t.length===1){if(Array.isArray(t[0])){e[a]={},dt(t[0],e[a]);return}e[a]=t[0];return}if(!t.length){e[a]=!0;return}if(a==="TOWGS84"){e[a]=t;return}if(a==="AXIS"){a in e||(e[a]=[]),e[a].push(t);return}Array.isArray(a)||(e[a]={});var s;switch(a){case"UNIT":case"PRIMEM":case"VERT_DATUM":e[a]={name:t[0].toLowerCase(),convert:t[1]},t.length===3&&dt(t[2],e[a]);return;case"SPHEROID":case"ELLIPSOID":e[a]={name:t[0],a:t[1],rf:t[2]},t.length===4&&dt(t[3],e[a]);return;case"PROJECTEDCRS":case"PROJCRS":case"GEOGCS":case"GEOCCS":case"PROJCS":case"LOCAL_CS":case"GEODCRS":case"GEODETICCRS":case"GEODETICDATUM":case"EDATUM":case"ENGINEERINGDATUM":case"VERT_CS":case"VERTCRS":case"VERTICALCRS":case"COMPD_CS":case"COMPOUNDCRS":case"ENGINEERINGCRS":case"ENGCRS":case"FITTED_CS":case"LOCAL_DATUM":case"DATUM":t[0]=["name",t[0]],la(e,a,t);return;default:for(s=-1;++s<t.length;)if(!Array.isArray(t[s]))return dt(t,e[a]);return la(e,a,t)}}var is=.017453292519943295;function ss(t,e){var a=e[0],s=e[1];!(a in t)&&s in t&&(t[a]=t[s],e.length===3&&(t[a]=e[2](t[a])))}function et(t){return t*is}function rs(t){if(t.type==="GEOGCS"?t.projName="longlat":t.type==="LOCAL_CS"?(t.projName="identity",t.local=!0):typeof t.PROJECTION=="object"?t.projName=Object.keys(t.PROJECTION)[0]:t.projName=t.PROJECTION,t.AXIS){for(var e="",a=0,s=t.AXIS.length;a<s;++a){var i=[t.AXIS[a][0].toLowerCase(),t.AXIS[a][1].toLowerCase()];i[0].indexOf("north")!==-1||(i[0]==="y"||i[0]==="lat")&&i[1]==="north"?e+="n":i[0].indexOf("south")!==-1||(i[0]==="y"||i[0]==="lat")&&i[1]==="south"?e+="s":i[0].indexOf("east")!==-1||(i[0]==="x"||i[0]==="lon")&&i[1]==="east"?e+="e":(i[0].indexOf("west")!==-1||(i[0]==="x"||i[0]==="lon")&&i[1]==="west")&&(e+="w")}e.length===2&&(e+="u"),e.length===3&&(t.axis=e)}t.UNIT&&(t.units=t.UNIT.name.toLowerCase(),t.units==="metre"&&(t.units="meter"),t.UNIT.convert&&(t.type==="GEOGCS"?t.DATUM&&t.DATUM.SPHEROID&&(t.to_meter=t.UNIT.convert*t.DATUM.SPHEROID.a):t.to_meter=t.UNIT.convert));var r=t.GEOGCS;t.type==="GEOGCS"&&(r=t),r&&(r.DATUM?t.datumCode=r.DATUM.name.toLowerCase():t.datumCode=r.name.toLowerCase(),t.datumCode.slice(0,2)==="d_"&&(t.datumCode=t.datumCode.slice(2)),(t.datumCode==="new_zealand_geodetic_datum_1949"||t.datumCode==="new_zealand_1949")&&(t.datumCode="nzgd49"),(t.datumCode==="wgs_1984"||t.datumCode==="world_geodetic_system_1984")&&(t.PROJECTION==="Mercator_Auxiliary_Sphere"&&(t.sphere=!0),t.datumCode="wgs84"),t.datumCode.slice(-6)==="_ferro"&&(t.datumCode=t.datumCode.slice(0,-6)),t.datumCode.slice(-8)==="_jakarta"&&(t.datumCode=t.datumCode.slice(0,-8)),~t.datumCode.indexOf("belge")&&(t.datumCode="rnb72"),r.DATUM&&r.DATUM.SPHEROID&&(t.ellps=r.DATUM.SPHEROID.name.replace("_19","").replace(/[Cc]larke\_18/,"clrk"),t.ellps.toLowerCase().slice(0,13)==="international"&&(t.ellps="intl"),t.a=r.DATUM.SPHEROID.a,t.rf=parseFloat(r.DATUM.SPHEROID.rf,10)),r.DATUM&&r.DATUM.TOWGS84&&(t.datum_params=r.DATUM.TOWGS84),~t.datumCode.indexOf("osgb_1936")&&(t.datumCode="osgb36"),~t.datumCode.indexOf("osni_1952")&&(t.datumCode="osni52"),(~t.datumCode.indexOf("tm65")||~t.datumCode.indexOf("geodetic_datum_of_1965"))&&(t.datumCode="ire65"),t.datumCode==="ch1903+"&&(t.datumCode="ch1903"),~t.datumCode.indexOf("israel")&&(t.datumCode="isr93")),t.b&&!isFinite(t.b)&&(t.b=t.a);function n(l){var u=t.to_meter||1;return l*u}var h=function(l){return ss(t,l)},o=[["standard_parallel_1","Standard_Parallel_1"],["standard_parallel_1","Latitude of 1st standard parallel"],["standard_parallel_2","Standard_Parallel_2"],["standard_parallel_2","Latitude of 2nd standard parallel"],["false_easting","False_Easting"],["false_easting","False easting"],["false-easting","Easting at false origin"],["false_northing","False_Northing"],["false_northing","False northing"],["false_northing","Northing at false origin"],["central_meridian","Central_Meridian"],["central_meridian","Longitude of natural origin"],["central_meridian","Longitude of false origin"],["latitude_of_origin","Latitude_Of_Origin"],["latitude_of_origin","Central_Parallel"],["latitude_of_origin","Latitude of natural origin"],["latitude_of_origin","Latitude of false origin"],["scale_factor","Scale_Factor"],["k0","scale_factor"],["latitude_of_center","Latitude_Of_Center"],["latitude_of_center","Latitude_of_center"],["lat0","latitude_of_center",et],["longitude_of_center","Longitude_Of_Center"],["longitude_of_center","Longitude_of_center"],["longc","longitude_of_center",et],["x0","false_easting",n],["y0","false_northing",n],["long0","central_meridian",et],["lat0","latitude_of_origin",et],["lat0","standard_parallel_1",et],["lat1","standard_parallel_1",et],["lat2","standard_parallel_2",et],["azimuth","Azimuth"],["alpha","azimuth",et],["srsCode","name"]];o.forEach(h),!t.long0&&t.longc&&(t.projName==="Albers_Conic_Equal_Area"||t.projName==="Lambert_Azimuthal_Equal_Area")&&(t.long0=t.longc),!t.lat_ts&&t.lat1&&(t.projName==="Stereographic_South_Pole"||t.projName==="Polar Stereographic (variant B)")&&(t.lat0=et(t.lat1>0?90:-90),t.lat_ts=t.lat1)}function Zt(t){var e=sa(t),a=e.shift(),s=e.shift();e.unshift(["name",s]),e.unshift(["type",a]);var i={};return dt(e,i),rs(i),i}function U(t){var e=this;if(arguments.length===2){var a=arguments[1];typeof a=="string"?a.charAt(0)==="+"?U[t]=Ct(arguments[1]):U[t]=Zt(arguments[1]):U[t]=a}else if(arguments.length===1){if(Array.isArray(t))return t.map(function(s){Array.isArray(s)?U.apply(e,s):U(s)});if(typeof t=="string"){if(t in U)return U[t]}else"EPSG"in t?U["EPSG:"+t.EPSG]=t:"ESRI"in t?U["ESRI:"+t.ESRI]=t:"IAU2000"in t?U["IAU2000:"+t.IAU2000]=t:console.log(t);return}}Ye(U);var gt=U;function ns(t){return typeof t=="string"}function hs(t){return t in gt}var os=["PROJECTEDCRS","PROJCRS","GEOGCS","GEOCCS","PROJCS","LOCAL_CS","GEODCRS","GEODETICCRS","GEODETICDATUM","ENGCRS","ENGINEERINGCRS"];function ls(t){return os.some(function(e){return t.indexOf(e)>-1})}var fs=["3857","900913","3785","102113"];function us(t){var e=k(t,"authority");if(e){var a=k(e,"epsg");return a&&fs.indexOf(a)>-1}}function cs(t){var e=k(t,"extension");if(e)return k(e,"proj4")}function ms(t){return t[0]==="+"}function Ms(t){if(ns(t)){if(hs(t))return gt[t];if(ls(t)){var e=Zt(t);if(us(e))return gt["EPSG:3857"];var a=cs(e);return a?Ct(a):e}if(ms(t))return Ct(t)}else return t}var fa=Ms;function Ne(t,e){t=t||{};var a,s;if(!e)return t;for(s in e)a=e[s],a!==void 0&&(t[s]=a);return t}function B(t,e,a){var s=t*e;return a/Math.sqrt(1-s*s)}function $(t){return t<0?-1:1}function v(t){return Math.abs(t)<=w?t:t-$(t)*Rt}function F(t,e,a){var s=t*a,i=.5*t;return s=Math.pow((1-s)/(1+s),i),Math.tan(.5*(m-e))/s}function at(t,e){for(var a=.5*t,s,i,r=m-2*Math.atan(e),n=0;n<=15;n++)if(s=t*Math.sin(r),i=m-2*Math.atan(e*Math.pow((1-s)/(1+s),a))-r,r+=i,Math.abs(i)<=1e-10)return r;return-9999}function ds(){var t=this.b/this.a;this.es=1-t*t,"x0"in this||(this.x0=0),"y0"in this||(this.y0=0),this.e=Math.sqrt(this.es),this.lat_ts?this.sphere?this.k0=Math.cos(this.lat_ts):this.k0=B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)):this.k0||(this.k?this.k0=this.k:this.k0=1)}function ps(t){var e=t.x,a=t.y;if(a*V>90&&a*V<-90&&e*V>180&&e*V<-180)return null;var s,i;if(Math.abs(Math.abs(a)-m)<=p)return null;if(this.sphere)s=this.x0+this.a*this.k0*v(e-this.long0),i=this.y0+this.a*this.k0*Math.log(Math.tan(I+.5*a));else{var r=Math.sin(a),n=F(this.e,a,r);s=this.x0+this.a*this.k0*v(e-this.long0),i=this.y0-this.a*this.k0*Math.log(n)}return t.x=s,t.y=i,t}function vs(t){var e=t.x-this.x0,a=t.y-this.y0,s,i;if(this.sphere)i=m-2*Math.atan(Math.exp(-a/(this.a*this.k0)));else{var r=Math.exp(-a/(this.a*this.k0));if(i=at(this.e,r),i===-9999)return null}return s=v(this.long0+e/(this.a*this.k0)),t.x=s,t.y=i,t}var ys=["Mercator","Popular Visualisation Pseudo Mercator","Mercator_1SP","Mercator_Auxiliary_Sphere","merc"],ua={init:ds,forward:ps,inverse:vs,names:ys};function xs(){}function ca(t){return t}var gs=["longlat","identity"],ma={init:xs,forward:ca,inverse:ca,names:gs};var _s=[ua,ma],$t={},te=[];function Ma(t,e){var a=te.length;return t.names?(te[a]=t,t.names.forEach(function(s){$t[s.toLowerCase()]=a}),this):(console.log(e),!0)}function bs(t){if(!t)return!1;var e=t.toLowerCase();if(typeof $t[e]<"u"&&te[$t[e]])return te[$t[e]]}function Es(){_s.forEach(Ma)}var da={start:Es,add:Ma,get:bs};var _={};_.MERIT={a:6378137,rf:298.257,ellipseName:"MERIT 1983"};_.SGS85={a:6378136,rf:298.257,ellipseName:"Soviet Geodetic System 85"};_.GRS80={a:6378137,rf:298.257222101,ellipseName:"GRS 1980(IUGG, 1980)"};_.IAU76={a:6378140,rf:298.257,ellipseName:"IAU 1976"};_.airy={a:6377563396e-3,b:635625691e-2,ellipseName:"Airy 1830"};_.APL4={a:6378137,rf:298.25,ellipseName:"Appl. Physics. 1965"};_.NWL9D={a:6378145,rf:298.25,ellipseName:"Naval Weapons Lab., 1965"};_.mod_airy={a:6377340189e-3,b:6356034446e-3,ellipseName:"Modified Airy"};_.andrae={a:637710443e-2,rf:300,ellipseName:"Andrae 1876 (Den., Iclnd.)"};_.aust_SA={a:6378160,rf:298.25,ellipseName:"Australian Natl & S. Amer. 1969"};_.GRS67={a:6378160,rf:298.247167427,ellipseName:"GRS 67(IUGG 1967)"};_.bessel={a:6377397155e-3,rf:299.1528128,ellipseName:"Bessel 1841"};_.bess_nam={a:6377483865e-3,rf:299.1528128,ellipseName:"Bessel 1841 (Namibia)"};_.clrk66={a:63782064e-1,b:63565838e-1,ellipseName:"Clarke 1866"};_.clrk80={a:6378249145e-3,rf:293.4663,ellipseName:"Clarke 1880 mod."};_.clrk58={a:6378293645208759e-9,rf:294.2606763692654,ellipseName:"Clarke 1858"};_.CPM={a:63757387e-1,rf:334.29,ellipseName:"Comm. des Poids et Mesures 1799"};_.delmbr={a:6376428,rf:311.5,ellipseName:"Delambre 1810 (Belgium)"};_.engelis={a:637813605e-2,rf:298.2566,ellipseName:"Engelis 1985"};_.evrst30={a:6377276345e-3,rf:300.8017,ellipseName:"Everest 1830"};_.evrst48={a:6377304063e-3,rf:300.8017,ellipseName:"Everest 1948"};_.evrst56={a:6377301243e-3,rf:300.8017,ellipseName:"Everest 1956"};_.evrst69={a:6377295664e-3,rf:300.8017,ellipseName:"Everest 1969"};_.evrstSS={a:6377298556e-3,rf:300.8017,ellipseName:"Everest (Sabah & Sarawak)"};_.fschr60={a:6378166,rf:298.3,ellipseName:"Fischer (Mercury Datum) 1960"};_.fschr60m={a:6378155,rf:298.3,ellipseName:"Fischer 1960"};_.fschr68={a:6378150,rf:298.3,ellipseName:"Fischer 1968"};_.helmert={a:6378200,rf:298.3,ellipseName:"Helmert 1906"};_.hough={a:6378270,rf:297,ellipseName:"Hough"};_.intl={a:6378388,rf:297,ellipseName:"International 1909 (Hayford)"};_.kaula={a:6378163,rf:298.24,ellipseName:"Kaula 1961"};_.lerch={a:6378139,rf:298.257,ellipseName:"Lerch 1979"};_.mprts={a:6397300,rf:191,ellipseName:"Maupertius 1738"};_.new_intl={a:63781575e-1,b:63567722e-1,ellipseName:"New International 1967"};_.plessis={a:6376523,rf:6355863,ellipseName:"Plessis 1817 (France)"};_.krass={a:6378245,rf:298.3,ellipseName:"Krassovsky, 1942"};_.SEasia={a:6378155,b:63567733205e-4,ellipseName:"Southeast Asia"};_.walbeck={a:6376896,b:63558348467e-4,ellipseName:"Walbeck"};_.WGS60={a:6378165,rf:298.3,ellipseName:"WGS 60"};_.WGS66={a:6378145,rf:298.25,ellipseName:"WGS 66"};_.WGS7={a:6378135,rf:298.26,ellipseName:"WGS 72"};var pa=_.WGS84={a:6378137,rf:298.257223563,ellipseName:"WGS 84"};_.sphere={a:6370997,b:6370997,ellipseName:"Normal Sphere (r=6370997)"};function va(t,e,a,s){var i=t*t,r=e*e,n=(i-r)/i,h=0;s?(t*=1-n*($e+n*(ta+n*ea)),i=t*t,n=0):h=Math.sqrt(n);var o=(i-r)/r;return{es:n,e:h,ep2:o}}function ya(t,e,a,s,i){if(!t){var r=k(_,s);r||(r=pa),t=r.a,e=r.b,a=r.rf}return a&&!e&&(e=(1-1/a)*t),(a===0||Math.abs(t-e)<p)&&(i=!0,e=t),{a:t,b:e,rf:a,sphere:i}}var T={};T.wgs84={towgs84:"0,0,0",ellipse:"WGS84",datumName:"WGS84"};T.ch1903={towgs84:"674.374,15.056,405.346",ellipse:"bessel",datumName:"swiss"};T.ggrs87={towgs84:"-199.87,74.79,246.62",ellipse:"GRS80",datumName:"Greek_Geodetic_Reference_System_1987"};T.nad83={towgs84:"0,0,0",ellipse:"GRS80",datumName:"North_American_Datum_1983"};T.nad27={nadgrids:"@conus,@alaska,@ntv2_0.gsb,@ntv1_can.dat",ellipse:"clrk66",datumName:"North_American_Datum_1927"};T.potsdam={towgs84:"606.0,23.0,413.0",ellipse:"bessel",datumName:"Potsdam Rauenberg 1950 DHDN"};T.carthage={towgs84:"-263.0,6.0,431.0",ellipse:"clark80",datumName:"Carthage 1934 Tunisia"};T.hermannskogel={towgs84:"653.0,-212.0,449.0",ellipse:"bessel",datumName:"Hermannskogel"};T.osni52={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"airy",datumName:"Irish National"};T.ire65={towgs84:"482.530,-130.596,564.557,-1.042,-0.214,-0.631,8.15",ellipse:"mod_airy",datumName:"Ireland 1965"};T.rassadiran={towgs84:"-133.63,-157.5,-158.62",ellipse:"intl",datumName:"Rassadiran"};T.nzgd49={towgs84:"59.47,-5.04,187.44,0.47,-0.1,1.024,-4.5993",ellipse:"intl",datumName:"New Zealand Geodetic Datum 1949"};T.osgb36={towgs84:"446.448,-125.157,542.060,0.1502,0.2470,0.8421,-20.4894",ellipse:"airy",datumName:"Airy 1830"};T.s_jtsk={towgs84:"589,76,480",ellipse:"bessel",datumName:"S-JTSK (Ferro)"};T.beduaram={towgs84:"-106,-87,188",ellipse:"clrk80",datumName:"Beduaram"};T.gunung_segara={towgs84:"-403,684,41",ellipse:"bessel",datumName:"Gunung Segara Jakarta"};T.rnb72={towgs84:"106.869,-52.2978,103.724,-0.33657,0.456955,-1.84218,1",ellipse:"intl",datumName:"Reseau National Belge 1972"};function Is(t,e,a,s,i,r){var n={};return t===void 0||t==="none"?n.datum_type=wt:n.datum_type=Ze,e&&(n.datum_params=e.map(parseFloat),(n.datum_params[0]!==0||n.datum_params[1]!==0||n.datum_params[2]!==0)&&(n.datum_type=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=s,n.es=i,n.ep2=r,n}var xa=Is;function _t(t,e){if(!(this instanceof _t))return new _t(t);e=e||function(o){if(o)throw o};var a=fa(t);if(typeof a!="object"){e(t);return}var s=_t.projections.get(a.projName);if(!s){e(t);return}if(a.datumCode&&a.datumCode!=="none"){var i=k(T,a.datumCode);i&&(a.datum_params=i.towgs84?i.towgs84.split(","):null,a.ellps=i.ellipse,a.datumName=i.datumName?i.datumName:a.datumCode)}a.k0=a.k0||1,a.axis=a.axis||"enu",a.ellps=a.ellps||"wgs84";var r=ya(a.a,a.b,a.rf,a.ellps,a.sphere),n=va(r.a,r.b,r.rf,a.R_A),h=a.datum||xa(a.datumCode,a.datum_params,r.a,r.b,n.es,n.ep2);Ne(this,a),Ne(this,s),this.a=r.a,this.b=r.b,this.rf=r.rf,this.sphere=r.sphere,this.es=n.es,this.e=n.e,this.ep2=n.ep2,this.datum=h,this.init(),e(null,this)}_t.projections=da;_t.projections.start();var ft=_t;function ga(t,e){return t.datum_type!==e.datum_type||t.a!==e.a||Math.abs(t.es-e.es)>5e-11?!1:t.datum_type===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 ee(t,e,a){var s=t.x,i=t.y,r=t.z?t.z:0,n,h,o,l;if(i<-m&&i>-1.001*m)i=-m;else if(i>m&&i<1.001*m)i=m;else{if(i<-m)return{x:-1/0,y:-1/0,z:t.z};if(i>m)return{x:1/0,y:1/0,z:t.z}}return s>Math.PI&&(s-=2*Math.PI),h=Math.sin(i),l=Math.cos(i),o=h*h,n=a/Math.sqrt(1-e*o),{x:(n+r)*l*Math.cos(s),y:(n+r)*l*Math.sin(s),z:(n*(1-e)+r)*h}}function ae(t,e,a,s){var i=1e-12,r=i*i,n=30,h,o,l,u,f,c,M,d,y,x,g,b,E,N=t.x,P=t.y,A=t.z?t.z:0,O,C,Z;if(h=Math.sqrt(N*N+P*P),o=Math.sqrt(N*N+P*P+A*A),h/a<i){if(O=0,o/a<i)return C=m,Z=-s,{x:t.x,y:t.y,z:t.z}}else O=Math.atan2(P,N);l=A/o,u=h/o,f=1/Math.sqrt(1-e*(2-e)*u*u),d=u*(1-e)*f,y=l*f,E=0;do E++,M=a/Math.sqrt(1-e*y*y),Z=h*d+A*y-M*(1-e*y*y),c=e*M/(M+Z),f=1/Math.sqrt(1-c*(2-c)*u*u),x=u*(1-c)*f,g=l*f,b=g*d-x*y,d=x,y=g;while(b*b>r&&E<n);return C=Math.atan(g/Math.abs(x)),{x:O,y:C,z:Z}}function _a(t,e,a){if(e===X)return{x:t.x+a[0],y:t.y+a[1],z:t.z+a[2]};if(e===Q){var s=a[0],i=a[1],r=a[2],n=a[3],h=a[4],o=a[5],l=a[6];return{x:l*(t.x-o*t.y+h*t.z)+s,y:l*(o*t.x+t.y-n*t.z)+i,z:l*(-h*t.x+n*t.y+t.z)+r}}}function ba(t,e,a){if(e===X)return{x:t.x-a[0],y:t.y-a[1],z:t.z-a[2]};if(e===Q){var s=a[0],i=a[1],r=a[2],n=a[3],h=a[4],o=a[5],l=a[6],u=(t.x-s)/l,f=(t.y-i)/l,c=(t.z-r)/l;return{x:u+o*f-h*c,y:-o*u+f+n*c,z:h*u-n*f+c}}}function ie(t){return t===X||t===Q}function Ea(t,e,a){return ga(t,e)||t.datum_type===wt||e.datum_type===wt||t.es===e.es&&t.a===e.a&&!ie(t.datum_type)&&!ie(e.datum_type)?a:(a=ee(a,t.es,t.a),ie(t.datum_type)&&(a=_a(a,t.datum_type,t.datum_params)),ie(e.datum_type)&&(a=ba(a,e.datum_type,e.datum_params)),ae(a,e.es,e.a,e.b))}function we(t,e,a){var s=a.x,i=a.y,r=a.z||0,n,h,o,l={};for(o=0;o<3;o++)if(!(e&&o===2&&a.z===void 0))switch(o===0?(n=s,"ew".indexOf(t.axis[o])!==-1?h="x":h="y"):o===1?(n=i,"ns".indexOf(t.axis[o])!==-1?h="y":h="x"):(n=r,h="z"),t.axis[o]){case"e":case"w":case"n":case"s":l[h]=n;break;case"u":a[h]!==void 0&&(l.z=n);break;case"d":a[h]!==void 0&&(l.z=-n);break;default:return null}return l}function se(t){var e={x:t[0],y:t[1]};return t.length>2&&(e.z=t[2]),t.length>3&&(e.m=t[3]),e}function Pa(t){Ia(t.x),Ia(t.y)}function Ia(t){if(typeof Number.isFinite=="function"){if(Number.isFinite(t))return;throw new TypeError("coordinates must be finite numbers")}if(typeof t!="number"||t!==t||!isFinite(t))throw new TypeError("coordinates must be finite numbers")}function Ps(t,e){return(t.datum.datum_type===X||t.datum.datum_type===Q)&&e.datumCode!=="WGS84"||(e.datum.datum_type===X||e.datum.datum_type===Q)&&t.datumCode!=="WGS84"}function pt(t,e,a){var s;if(Array.isArray(a)&&(a=se(a)),Pa(a),t.datum&&e.datum&&Ps(t,e)&&(s=new ft("WGS84"),a=pt(t,s,a),t=s),t.axis!=="enu"&&(a=we(t,!1,a)),t.projName==="longlat")a={x:a.x*L,y:a.y*L,z:a.z||0};else if(t.to_meter&&(a={x:a.x*t.to_meter,y:a.y*t.to_meter,z:a.z||0}),a=t.inverse(a),!a)return;return t.from_greenwich&&(a.x+=t.from_greenwich),a=Ea(t.datum,e.datum,a),e.from_greenwich&&(a={x:a.x-e.from_greenwich,y:a.y,z:a.z||0}),e.projName==="longlat"?a={x:a.x*V,y:a.y*V,z:a.z||0}:(a=e.forward(a),e.to_meter&&(a={x:a.x/e.to_meter,y:a.y/e.to_meter,z:a.z||0})),e.axis!=="enu"?we(e,!0,a):a}var Aa=ft("WGS84");function Re(t,e,a){var s,i,r;return Array.isArray(a)?(s=pt(t,e,a)||{x:NaN,y:NaN},a.length>2?typeof t.name<"u"&&t.name==="geocent"||typeof e.name<"u"&&e.name==="geocent"?typeof s.z=="number"?[s.x,s.y,s.z].concat(a.splice(3)):[s.x,s.y,a[2]].concat(a.splice(3)):[s.x,s.y].concat(a.splice(2)):[s.x,s.y]):(i=pt(t,e,a),r=Object.keys(a),r.length===2||r.forEach(function(n){if(typeof t.name<"u"&&t.name==="geocent"||typeof e.name<"u"&&e.name==="geocent"){if(n==="x"||n==="y"||n==="z")return}else if(n==="x"||n==="y")return;i[n]=a[n]}),i)}function Sa(t){return t instanceof ft?t:t.oProj?t.oProj:ft(t)}function As(t,e,a){t=Sa(t);var s=!1,i;return typeof e>"u"?(e=t,t=Aa,s=!0):(typeof e.x<"u"||Array.isArray(e))&&(a=e,e=t,t=Aa,s=!0),e=Sa(e),a?Re(t,e,a):(i={forward:function(r){return Re(t,e,r)},inverse:function(r){return Re(e,t,r)}},s&&(i.oProj=e),i)}var H=As;var Na=6,Ra="AJSAJS",Ca="AFAFAF",bt=65,z=73,W=79,Tt=86,Dt=90,La={forward:Le,inverse:Ss,toPoint:Te};function Le(t,e){return e=e||5,Rs(Ns({lat:t[1],lon:t[0]}),e)}function Ss(t){var e=De(Da(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat,e.lon,e.lat]:[e.left,e.bottom,e.right,e.top]}function Te(t){var e=De(Da(t.toUpperCase()));return e.lat&&e.lon?[e.lon,e.lat]:[(e.left+e.right)/2,(e.top+e.bottom)/2]}function Ce(t){return t*(Math.PI/180)}function wa(t){return 180*(t/Math.PI)}function Ns(t){var e=t.lat,a=t.lon,s=6378137,i=.00669438,r=.9996,n,h,o,l,u,f,c,M=Ce(e),d=Ce(a),y,x;x=Math.floor((a+180)/6)+1,a===180&&(x=60),e>=56&&e<64&&a>=3&&a<12&&(x=32),e>=72&&e<84&&(a>=0&&a<9?x=31:a>=9&&a<21?x=33:a>=21&&a<33?x=35:a>=33&&a<42&&(x=37)),n=(x-1)*6-180+3,y=Ce(n),h=i/(1-i),o=s/Math.sqrt(1-i*Math.sin(M)*Math.sin(M)),l=Math.tan(M)*Math.tan(M),u=h*Math.cos(M)*Math.cos(M),f=Math.cos(M)*(d-y),c=s*((1-i/4-3*i*i/64-5*i*i*i/256)*M-(3*i/8+3*i*i/32+45*i*i*i/1024)*Math.sin(2*M)+(15*i*i/256+45*i*i*i/1024)*Math.sin(4*M)-35*i*i*i/3072*Math.sin(6*M));var g=r*o*(f+(1-l+u)*f*f*f/6+(5-18*l+l*l+72*u-58*h)*f*f*f*f*f/120)+5e5,b=r*(c+o*Math.tan(M)*(f*f/2+(5-l+9*u+4*u*u)*f*f*f*f/24+(61-58*l+l*l+600*u-330*h)*f*f*f*f*f*f/720));return e<0&&(b+=1e7),{northing:Math.round(b),easting:Math.round(g),zoneNumber:x,zoneLetter:ws(e)}}function De(t){var e=t.northing,a=t.easting,s=t.zoneLetter,i=t.zoneNumber;if(i<0||i>60)return null;var r=.9996,n=6378137,h=.00669438,o,l=(1-Math.sqrt(1-h))/(1+Math.sqrt(1-h)),u,f,c,M,d,y,x,g,b,E=a-5e5,N=e;s<"N"&&(N-=1e7),x=(i-1)*6-180+3,o=h/(1-h),y=N/r,g=y/(n*(1-h/4-3*h*h/64-5*h*h*h/256)),b=g+(3*l/2-27*l*l*l/32)*Math.sin(2*g)+(21*l*l/16-55*l*l*l*l/32)*Math.sin(4*g)+151*l*l*l/96*Math.sin(6*g),u=n/Math.sqrt(1-h*Math.sin(b)*Math.sin(b)),f=Math.tan(b)*Math.tan(b),c=o*Math.cos(b)*Math.cos(b),M=n*(1-h)/Math.pow(1-h*Math.sin(b)*Math.sin(b),1.5),d=E/(u*r);var P=b-u*Math.tan(b)/M*(d*d/2-(5+3*f+10*c-4*c*c-9*o)*d*d*d*d/24+(61+90*f+298*c+45*f*f-252*o-3*c*c)*d*d*d*d*d*d/720);P=wa(P);var A=(d-(1+2*f+c)*d*d*d/6+(5-2*c+28*f-3*c*c+8*o+24*f*f)*d*d*d*d*d/120)/Math.cos(b);A=x+wa(A);var O;if(t.accuracy){var C=De({northing:t.northing+t.accuracy,easting:t.easting+t.accuracy,zoneLetter:t.zoneLetter,zoneNumber:t.zoneNumber});O={top:C.lat,right:C.lon,bottom:P,left:A}}else O={lat:P,lon:A};return O}function ws(t){var e="Z";return 84>=t&&t>=72?e="X":72>t&&t>=64?e="W":64>t&&t>=56?e="V":56>t&&t>=48?e="U":48>t&&t>=40?e="T":40>t&&t>=32?e="S":32>t&&t>=24?e="R":24>t&&t>=16?e="Q":16>t&&t>=8?e="P":8>t&&t>=0?e="N":0>t&&t>=-8?e="M":-8>t&&t>=-16?e="L":-16>t&&t>=-24?e="K":-24>t&&t>=-32?e="J":-32>t&&t>=-40?e="H":-40>t&&t>=-48?e="G":-48>t&&t>=-56?e="F":-56>t&&t>=-64?e="E":-64>t&&t>=-72?e="D":-72>t&&t>=-80&&(e="C"),e}function Rs(t,e){var a="00000"+t.easting,s="00000"+t.northing;return t.zoneNumber+t.zoneLetter+Cs(t.easting,t.northing,t.zoneNumber)+a.substr(a.length-5,e)+s.substr(s.length-5,e)}function Cs(t,e,a){var s=Ta(a),i=Math.floor(t/1e5),r=Math.floor(e/1e5)%20;return Ls(i,r,s)}function Ta(t){var e=t%Na;return e===0&&(e=Na),e}function Ls(t,e,a){var s=a-1,i=Ra.charCodeAt(s),r=Ca.charCodeAt(s),n=i+t-1,h=r+e,o=!1;n>Dt&&(n=n-Dt+bt-1,o=!0),(n===z||i<z&&n>z||(n>z||i<z)&&o)&&n++,(n===W||i<W&&n>W||(n>W||i<W)&&o)&&(n++,n===z&&n++),n>Dt&&(n=n-Dt+bt-1),h>Tt?(h=h-Tt+bt-1,o=!0):o=!1,(h===z||r<z&&h>z||(h>z||r<z)&&o)&&h++,(h===W||r<W&&h>W||(h>W||r<W)&&o)&&(h++,h===z&&h++),h>Tt&&(h=h-Tt+bt-1);var l=String.fromCharCode(n)+String.fromCharCode(h);return l}function Da(t){if(t&&t.length===0)throw"MGRSPoint coverting from nothing";for(var e=t.length,a=null,s="",i,r=0;!/[A-Z]/.test(i=t.charAt(r));){if(r>=2)throw"MGRSPoint bad conversion from: "+t;s+=i,r++}var n=parseInt(s,10);if(r===0||r+3>e)throw"MGRSPoint bad conversion from: "+t;var h=t.charAt(r++);if(h<="A"||h==="B"||h==="Y"||h>="Z"||h==="I"||h==="O")throw"MGRSPoint zone letter "+h+" not handled: "+t;a=t.substring(r,r+=2);for(var o=Ta(n),l=Ts(a.charAt(0),o),u=Ds(a.charAt(1),o);u<Os(h);)u+=2e6;var f=e-r;if(f%2!==0)throw`MGRSPoint has to have an even number
|
|
8
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 Ts(t,e){for(var a=Ra.charCodeAt(e-1),s=1e5,i=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Dt){if(i)throw"Bad character: "+t;a=bt,i=!0}s+=1e5}return s}function Ds(t,e){if(t>"V")throw"MGRSPoint given invalid Northing "+t;for(var a=Ca.charCodeAt(e-1),s=0,i=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Tt){if(i)throw"Bad character: "+t;a=bt,i=!0}s+=1e5}return s}function Os(t){var e;switch(t){case"C":e=11e5;break;case"D":e=2e6;break;case"E":e=28e5;break;case"F":e=37e5;break;case"G":e=46e5;break;case"H":e=55e5;break;case"J":e=64e5;break;case"K":e=73e5;break;case"L":e=82e5;break;case"M":e=91e5;break;case"N":e=0;break;case"P":e=8e5;break;case"Q":e=17e5;break;case"R":e=26e5;break;case"S":e=35e5;break;case"T":e=44e5;break;case"U":e=53e5;break;case"V":e=62e5;break;case"W":e=7e6;break;case"X":e=79e5;break;default:e=-1}if(e>=0)return e;throw"Invalid zone letter: "+t}function Et(t,e,a){if(!(this instanceof Et))return new Et(t,e,a);if(Array.isArray(t))this.x=t[0],this.y=t[1],this.z=t[2]||0;else if(typeof t=="object")this.x=t.x,this.y=t.y,this.z=t.z||0;else if(typeof t=="string"&&typeof e>"u"){var s=t.split(",");this.x=parseFloat(s[0],10),this.y=parseFloat(s[1],10),this.z=parseFloat(s[2],10)||0}else this.x=t,this.y=e,this.z=a||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}Et.fromMGRS=function(t){return new Et(Te(t))};Et.prototype.toMGRS=function(t){return Le([this.x,this.y],t)};var Oa=Et;var Bs=1,Gs=.25,Ba=.046875,Ga=.01953125,Fa=.01068115234375,Fs=.75,qs=.46875,zs=.013020833333333334,js=.007120768229166667,ks=.3645833333333333,Hs=.005696614583333333,Us=.3076171875;function re(t){var e=[];e[0]=Bs-t*(Gs+t*(Ba+t*(Ga+t*Fa))),e[1]=t*(Fs-t*(Ba+t*(Ga+t*Fa)));var a=t*t;return e[2]=a*(qs-t*(zs+t*js)),a*=t,e[3]=a*(ks-t*Hs),e[4]=a*t*Us,e}function vt(t,e,a,s){return a*=e,e*=e,s[0]*t-a*(s[1]+e*(s[2]+e*(s[3]+e*s[4])))}var Ws=20;function ne(t,e,a){for(var s=1/(1-e),i=t,r=Ws;r;--r){var n=Math.sin(i),h=1-e*n*n;if(h=(vt(i,n,Math.cos(i),a)-t)*(h*Math.sqrt(h))*s,i-=h,Math.abs(h)<p)return i}return i}function Js(){this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0,this.lat0=this.lat0!==void 0?this.lat0:0,this.es&&(this.en=re(this.es),this.ml0=vt(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function Xs(t){var e=t.x,a=t.y,s=v(e-this.long0),i,r,n,h=Math.sin(a),o=Math.cos(a);if(this.es){var u=o*s,f=Math.pow(u,2),c=this.ep2*Math.pow(o,2),M=Math.pow(c,2),d=Math.abs(o)>p?Math.tan(a):0,y=Math.pow(d,2),x=Math.pow(y,2);i=1-this.es*Math.pow(h,2),u=u/Math.sqrt(i);var g=vt(a,h,o,this.en);r=this.a*(this.k0*u*(1+f/6*(1-y+c+f/20*(5-18*y+x+14*c-58*y*c+f/42*(61+179*x-x*y-479*y)))))+this.x0,n=this.a*(this.k0*(g-this.ml0+h*s*u/2*(1+f/12*(5-y+9*c+4*M+f/30*(61+x-58*y+270*c-330*y*c+f/56*(1385+543*x-x*y-3111*y))))))+this.y0}else{var l=o*Math.sin(s);if(Math.abs(Math.abs(l)-1)<p)return 93;if(r=.5*this.a*this.k0*Math.log((1+l)/(1-l))+this.x0,n=o*Math.cos(s)/Math.sqrt(1-Math.pow(l,2)),l=Math.abs(n),l>=1){if(l-1>p)return 93;n=0}else n=Math.acos(n);a<0&&(n=-n),n=this.a*this.k0*(n-this.lat0)+this.y0}return t.x=r,t.y=n,t}function Qs(t){var e,a,s,i,r=(t.x-this.x0)*(1/this.a),n=(t.y-this.y0)*(1/this.a);if(this.es)if(e=this.ml0+n/this.k0,a=ne(e,this.es,this.en),Math.abs(a)<m){var f=Math.sin(a),c=Math.cos(a),M=Math.abs(c)>p?Math.tan(a):0,d=this.ep2*Math.pow(c,2),y=Math.pow(d,2),x=Math.pow(M,2),g=Math.pow(x,2);e=1-this.es*Math.pow(f,2);var b=r*Math.sqrt(e)/this.k0,E=Math.pow(b,2);e=e*M,s=a-e*E/(1-this.es)*.5*(1-E/12*(5+3*x-9*d*x+d-4*y-E/30*(61+90*x-252*d*x+45*g+46*d-E/56*(1385+3633*x+4095*g+1574*g*x)))),i=v(this.long0+b*(1-E/6*(1+2*x+d-E/20*(5+28*x+24*g+8*d*x+6*d-E/42*(61+662*x+1320*g+720*g*x))))/c)}else s=m*$(n),i=0;else{var h=Math.exp(r/this.k0),o=.5*(h-1/h),l=this.lat0+n/this.k0,u=Math.cos(l);e=Math.sqrt((1-Math.pow(u,2))/(1+Math.pow(o,2))),s=Math.asin(e),n<0&&(s=-s),o===0&&u===0?i=0:i=v(Math.atan2(o,u)+this.long0)}return t.x=i,t.y=s,t}var Vs=["Transverse_Mercator","Transverse Mercator","tmerc"],qa={init:Js,forward:Xs,inverse:Qs,names:Vs};function he(t){var e=Math.exp(t);return e=(e-1/e)/2,e}function Ot(t,e){t=Math.abs(t),e=Math.abs(e);var a=Math.max(t,e),s=Math.min(t,e)/(a||1);return a*Math.sqrt(1+Math.pow(s,2))}function za(t){var e=1+t,a=e-1;return a===0?t:t*Math.log(e)/a}function ja(t){var e=Math.abs(t);return e=za(e*(1+e/(Ot(1,e)+1))),t<0?-e:e}function oe(t,e){for(var a=2*Math.cos(2*e),s=t.length-1,i=t[s],r=0,n;--s>=0;)n=-r+a*i+t[s],r=i,i=n;return e+n*Math.sin(2*e)}function ka(t,e){for(var a=2*Math.cos(e),s=t.length-1,i=t[s],r=0,n;--s>=0;)n=-r+a*i+t[s],r=i,i=n;return Math.sin(e)*n}function Ha(t){var e=Math.exp(t);return e=(e+1/e)/2,e}function Oe(t,e,a){for(var s=Math.sin(e),i=Math.cos(e),r=he(a),n=Ha(a),h=2*i*n,o=-2*s*r,l=t.length-1,u=t[l],f=0,c=0,M=0,d,y;--l>=0;)d=c,y=f,c=u,f=M,u=-d+h*c-o*f+t[l],M=-y+o*c+h*f;return h=s*n,o=i*r,[h*u-o*M,h*M+o*u]}function Ks(){if(this.es===void 0||this.es<=0)throw new Error("incorrect elliptical usage");this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0,this.lat0=this.lat0!==void 0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var t=this.es/(1+Math.sqrt(1-this.es)),e=t/(2-t),a=e;this.cgb[0]=e*(2+e*(-2/3+e*(-2+e*(116/45+e*(26/45+e*(-2854/675)))))),this.cbg[0]=e*(-2+e*(2/3+e*(4/3+e*(-82/45+e*(32/45+e*(4642/4725)))))),a=a*e,this.cgb[1]=a*(7/3+e*(-8/5+e*(-227/45+e*(2704/315+e*(2323/945))))),this.cbg[1]=a*(5/3+e*(-16/15+e*(-13/9+e*(904/315+e*(-1522/945))))),a=a*e,this.cgb[2]=a*(56/15+e*(-136/35+e*(-1262/105+e*(73814/2835)))),this.cbg[2]=a*(-26/15+e*(34/21+e*(8/5+e*(-12686/2835)))),a=a*e,this.cgb[3]=a*(4279/630+e*(-332/35+e*(-399572/14175))),this.cbg[3]=a*(1237/630+e*(-12/5+e*(-24832/14175))),a=a*e,this.cgb[4]=a*(4174/315+e*(-144838/6237)),this.cbg[4]=a*(-734/315+e*(109598/31185)),a=a*e,this.cgb[5]=a*(601676/22275),this.cbg[5]=a*(444337/155925),a=Math.pow(e,2),this.Qn=this.k0/(1+e)*(1+a*(1/4+a*(1/64+a/256))),this.utg[0]=e*(-.5+e*(2/3+e*(-37/96+e*(1/360+e*(81/512+e*(-96199/604800)))))),this.gtu[0]=e*(.5+e*(-2/3+e*(5/16+e*(41/180+e*(-127/288+e*(7891/37800)))))),this.utg[1]=a*(-1/48+e*(-1/15+e*(437/1440+e*(-46/105+e*(1118711/3870720))))),this.gtu[1]=a*(13/48+e*(-3/5+e*(557/1440+e*(281/630+e*(-1983433/1935360))))),a=a*e,this.utg[2]=a*(-17/480+e*(37/840+e*(209/4480+e*(-5569/90720)))),this.gtu[2]=a*(61/240+e*(-103/140+e*(15061/26880+e*(167603/181440)))),a=a*e,this.utg[3]=a*(-4397/161280+e*(11/504+e*(830251/7257600))),this.gtu[3]=a*(49561/161280+e*(-179/168+e*(6601661/7257600))),a=a*e,this.utg[4]=a*(-4583/161280+e*(108847/3991680)),this.gtu[4]=a*(34729/80640+e*(-3418889/1995840)),a=a*e,this.utg[5]=a*(-20648693/638668800),this.gtu[5]=a*(212378941/319334400);var s=oe(this.cbg,this.lat0);this.Zb=-this.Qn*(s+ka(this.gtu,2*s))}function Ys(t){var e=v(t.x-this.long0),a=t.y;a=oe(this.cbg,a);var s=Math.sin(a),i=Math.cos(a),r=Math.sin(e),n=Math.cos(e);a=Math.atan2(s,n*i),e=Math.atan2(r*i,Ot(s,i*n)),e=ja(Math.tan(e));var h=Oe(this.gtu,2*a,2*e);a=a+h[0],e=e+h[1];var o,l;return Math.abs(e)<=2.623395162778?(o=this.a*(this.Qn*e)+this.x0,l=this.a*(this.Qn*a+this.Zb)+this.y0):(o=1/0,l=1/0),t.x=o,t.y=l,t}function Zs(t){var e=(t.x-this.x0)*(1/this.a),a=(t.y-this.y0)*(1/this.a);a=(a-this.Zb)/this.Qn,e=e/this.Qn;var s,i;if(Math.abs(e)<=2.623395162778){var r=Oe(this.utg,2*a,2*e);a=a+r[0],e=e+r[1],e=Math.atan(he(e));var n=Math.sin(a),h=Math.cos(a),o=Math.sin(e),l=Math.cos(e);a=Math.atan2(n*l,Ot(o,l*h)),e=Math.atan2(o,l*h),s=v(e+this.long0),i=oe(this.cgb,a)}else s=1/0,i=1/0;return t.x=s,t.y=i,t}var $s=["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc"],It={init:Ks,forward:Ys,inverse:Zs,names:$s};function Ua(t,e){if(t===void 0){if(t=Math.floor((v(e)+Math.PI)*30/Math.PI)+1,t<0)return 0;if(t>60)return 60}return t}var tr="etmerc";function er(){var t=Ua(this.zone,this.long0);if(t===void 0)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(t)-183)*L,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,It.init.apply(this),this.forward=It.forward,this.inverse=It.inverse}var ar=["Universal Transverse Mercator System","utm"],Wa={init:er,names:ar,dependsOn:tr};function le(t,e){return Math.pow((1-t)/(1+t),e)}var ir=20;function sr(){var t=Math.sin(this.lat0),e=Math.cos(this.lat0);e*=e,this.rc=Math.sqrt(1-this.es)/(1-this.es*t*t),this.C=Math.sqrt(1+this.es*e*e/(1-this.es)),this.phic0=Math.asin(t/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+I)/(Math.pow(Math.tan(.5*this.lat0+I),this.C)*le(this.e*t,this.ratexp))}function rr(t){var e=t.x,a=t.y;return t.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*a+I),this.C)*le(this.e*Math.sin(a),this.ratexp))-m,t.x=this.C*e,t}function nr(t){for(var e=1e-14,a=t.x/this.C,s=t.y,i=Math.pow(Math.tan(.5*s+I)/this.K,1/this.C),r=ir;r>0&&(s=2*Math.atan(i*le(this.e*Math.sin(t.y),-.5*this.e))-m,!(Math.abs(s-t.y)<e));--r)t.y=s;return r?(t.x=a,t.y=s,t):null}var hr=["gauss"],fe={init:sr,forward:rr,inverse:nr,names:hr};function or(){fe.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))}function lr(t){var e,a,s,i;return t.x=v(t.x-this.long0),fe.forward.apply(this,[t]),e=Math.sin(t.y),a=Math.cos(t.y),s=Math.cos(t.x),i=this.k0*this.R2/(1+this.sinc0*e+this.cosc0*a*s),t.x=i*a*Math.sin(t.x),t.y=i*(this.cosc0*e-this.sinc0*a*s),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t}function fr(t){var e,a,s,i,r;if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,r=Math.sqrt(t.x*t.x+t.y*t.y)){var n=2*Math.atan2(r,this.R2);e=Math.sin(n),a=Math.cos(n),i=Math.asin(a*this.sinc0+t.y*e*this.cosc0/r),s=Math.atan2(t.x*e,r*this.cosc0*a-t.y*this.sinc0*e)}else i=this.phic0,s=0;return t.x=s,t.y=i,fe.inverse.apply(this,[t]),t.x=v(t.x+this.long0),t}var ur=["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"],Ja={init:or,forward:lr,inverse:fr,names:ur};function cr(t,e,a){return e*=a,Math.tan(.5*(m+t))*Math.pow((1-e)/(1+e),.5*a)}function mr(){this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=p&&(this.k0=.5*(1+$(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=p&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=p&&(this.k0=.5*this.cons*B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/F(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=B(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(this.ssfn_(this.lat0,this.sinlat0,this.e))-m,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))}function Mr(t){var e=t.x,a=t.y,s=Math.sin(a),i=Math.cos(a),r,n,h,o,l,u,f=v(e-this.long0);return Math.abs(Math.abs(e-this.long0)-Math.PI)<=p&&Math.abs(a+this.lat0)<=p?(t.x=NaN,t.y=NaN,t):this.sphere?(r=2*this.k0/(1+this.sinlat0*s+this.coslat0*i*Math.cos(f)),t.x=this.a*r*i*Math.sin(f)+this.x0,t.y=this.a*r*(this.coslat0*s-this.sinlat0*i*Math.cos(f))+this.y0,t):(n=2*Math.atan(this.ssfn_(a,s,this.e))-m,o=Math.cos(n),h=Math.sin(n),Math.abs(this.coslat0)<=p?(l=F(this.e,a*this.con,this.con*s),u=2*this.a*this.k0*l/this.cons,t.x=this.x0+u*Math.sin(e-this.long0),t.y=this.y0-this.con*u*Math.cos(e-this.long0),t):(Math.abs(this.sinlat0)<p?(r=2*this.a*this.k0/(1+o*Math.cos(f)),t.y=r*h):(r=2*this.a*this.k0*this.ms1/(this.cosX0*(1+this.sinX0*h+this.cosX0*o*Math.cos(f))),t.y=r*(this.cosX0*h-this.sinX0*o*Math.cos(f))+this.y0),t.x=r*o*Math.sin(f)+this.x0,t))}function dr(t){t.x-=this.x0,t.y-=this.y0;var e,a,s,i,r,n=Math.sqrt(t.x*t.x+t.y*t.y);if(this.sphere){var h=2*Math.atan(n/(2*this.a*this.k0));return e=this.long0,a=this.lat0,n<=p?(t.x=e,t.y=a,t):(a=Math.asin(Math.cos(h)*this.sinlat0+t.y*Math.sin(h)*this.coslat0/n),Math.abs(this.coslat0)<p?this.lat0>0?e=v(this.long0+Math.atan2(t.x,-1*t.y)):e=v(this.long0+Math.atan2(t.x,t.y)):e=v(this.long0+Math.atan2(t.x*Math.sin(h),n*this.coslat0*Math.cos(h)-t.y*this.sinlat0*Math.sin(h))),t.x=e,t.y=a,t)}else if(Math.abs(this.coslat0)<=p){if(n<=p)return a=this.lat0,e=this.long0,t.x=e,t.y=a,t;t.x*=this.con,t.y*=this.con,s=n*this.cons/(2*this.a*this.k0),a=this.con*at(this.e,s),e=this.con*v(this.con*this.long0+Math.atan2(t.x,-1*t.y))}else i=2*Math.atan(n*this.cosX0/(2*this.a*this.k0*this.ms1)),e=this.long0,n<=p?r=this.X0:(r=Math.asin(Math.cos(i)*this.sinX0+t.y*Math.sin(i)*this.cosX0/n),e=v(this.long0+Math.atan2(t.x*Math.sin(i),n*this.cosX0*Math.cos(i)-t.y*this.sinX0*Math.sin(i)))),a=-1*at(this.e,Math.tan(.5*(m+r)));return t.x=e,t.y=a,t}var pr=["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"],Xa={init:mr,forward:Mr,inverse:dr,names:pr,ssfn_:cr};function vr(){var t=this.lat0;this.lambda0=this.long0;var e=Math.sin(t),a=this.a,s=this.rf,i=1/s,r=2*i-Math.pow(i,2),n=this.e=Math.sqrt(r);this.R=this.k0*a*Math.sqrt(1-r)/(1-r*Math.pow(e,2)),this.alpha=Math.sqrt(1+r/(1-r)*Math.pow(Math.cos(t),4)),this.b0=Math.asin(e/this.alpha);var h=Math.log(Math.tan(Math.PI/4+this.b0/2)),o=Math.log(Math.tan(Math.PI/4+t/2)),l=Math.log((1+n*e)/(1-n*e));this.K=h-this.alpha*o+this.alpha*n/2*l}function yr(t){var e=Math.log(Math.tan(Math.PI/4-t.y/2)),a=this.e/2*Math.log((1+this.e*Math.sin(t.y))/(1-this.e*Math.sin(t.y))),s=-this.alpha*(e+a)+this.K,i=2*(Math.atan(Math.exp(s))-Math.PI/4),r=this.alpha*(t.x-this.lambda0),n=Math.atan(Math.sin(r)/(Math.sin(this.b0)*Math.tan(i)+Math.cos(this.b0)*Math.cos(r))),h=Math.asin(Math.cos(this.b0)*Math.sin(i)-Math.sin(this.b0)*Math.cos(i)*Math.cos(r));return t.y=this.R/2*Math.log((1+Math.sin(h))/(1-Math.sin(h)))+this.y0,t.x=this.R*n+this.x0,t}function xr(t){for(var e=t.x-this.x0,a=t.y-this.y0,s=e/this.R,i=2*(Math.atan(Math.exp(a/this.R))-Math.PI/4),r=Math.asin(Math.cos(this.b0)*Math.sin(i)+Math.sin(this.b0)*Math.cos(i)*Math.cos(s)),n=Math.atan(Math.sin(s)/(Math.cos(this.b0)*Math.cos(s)-Math.sin(this.b0)*Math.tan(i))),h=this.lambda0+n/this.alpha,o=0,l=r,u=-1e3,f=0;Math.abs(l-u)>1e-7;){if(++f>20)return;o=1/this.alpha*(Math.log(Math.tan(Math.PI/4+r/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(l))/2)),u=l,l=2*Math.atan(Math.exp(o))-Math.PI/2}return t.x=h,t.y=l,t}var gr=["somerc"],Qa={init:vr,forward:yr,inverse:xr,names:gr};function _r(){this.no_off=this.no_off||!1,this.no_rot=this.no_rot||!1,isNaN(this.k0)&&(this.k0=1);var t=Math.sin(this.lat0),e=Math.cos(this.lat0),a=this.e*t;this.bl=Math.sqrt(1+this.es/(1-this.es)*Math.pow(e,4)),this.al=this.a*this.bl*this.k0*Math.sqrt(1-this.es)/(1-a*a);var s=F(this.e,this.lat0,t),i=this.bl/e*Math.sqrt((1-this.es)/(1-a*a));i*i<1&&(i=1);var r,n;if(!isNaN(this.longc))this.lat0>=0?r=i+Math.sqrt(i*i-1):r=i-Math.sqrt(i*i-1),this.el=r*Math.pow(s,this.bl),n=.5*(r-1/r),this.gamma0=Math.asin(Math.sin(this.alpha)/i),this.long0=this.longc-Math.asin(n*Math.tan(this.gamma0))/this.bl;else{var h=F(this.e,this.lat1,Math.sin(this.lat1)),o=F(this.e,this.lat2,Math.sin(this.lat2));this.lat0>=0?this.el=(i+Math.sqrt(i*i-1))*Math.pow(s,this.bl):this.el=(i-Math.sqrt(i*i-1))*Math.pow(s,this.bl);var l=Math.pow(h,this.bl),u=Math.pow(o,this.bl);r=this.el/l,n=.5*(r-1/r);var f=(this.el*this.el-u*l)/(this.el*this.el+u*l),c=(u-l)/(u+l),M=v(this.long1-this.long2);this.long0=.5*(this.long1+this.long2)-Math.atan(f*Math.tan(.5*this.bl*M)/c)/this.bl,this.long0=v(this.long0);var d=v(this.long1-this.long0);this.gamma0=Math.atan(Math.sin(this.bl*d)/n),this.alpha=Math.asin(i*Math.sin(this.gamma0))}this.no_off?this.uc=0:this.lat0>=0?this.uc=this.al/this.bl*Math.atan2(Math.sqrt(i*i-1),Math.cos(this.alpha)):this.uc=-1*this.al/this.bl*Math.atan2(Math.sqrt(i*i-1),Math.cos(this.alpha))}function br(t){var e=t.x,a=t.y,s=v(e-this.long0),i,r,n;if(Math.abs(Math.abs(a)-m)<=p)a>0?n=-1:n=1,r=this.al/this.bl*Math.log(Math.tan(I+n*this.gamma0*.5)),i=-1*n*m*this.al/this.bl;else{var h=F(this.e,a,Math.sin(a)),o=this.el/Math.pow(h,this.bl),l=.5*(o-1/o),u=.5*(o+1/o),f=Math.sin(this.bl*s),c=(l*Math.sin(this.gamma0)-f*Math.cos(this.gamma0))/u;Math.abs(Math.abs(c)-1)<=p?r=Number.POSITIVE_INFINITY:r=.5*this.al*Math.log((1-c)/(1+c))/this.bl,Math.abs(Math.cos(this.bl*s))<=p?i=this.al*this.bl*s:i=this.al*Math.atan2(l*Math.cos(this.gamma0)+f*Math.sin(this.gamma0),Math.cos(this.bl*s))/this.bl}return this.no_rot?(t.x=this.x0+i,t.y=this.y0+r):(i-=this.uc,t.x=this.x0+r*Math.cos(this.alpha)+i*Math.sin(this.alpha),t.y=this.y0+i*Math.cos(this.alpha)-r*Math.sin(this.alpha)),t}function Er(t){var e,a;this.no_rot?(a=t.y-this.y0,e=t.x-this.x0):(a=(t.x-this.x0)*Math.cos(this.alpha)-(t.y-this.y0)*Math.sin(this.alpha),e=(t.y-this.y0)*Math.cos(this.alpha)+(t.x-this.x0)*Math.sin(this.alpha),e+=this.uc);var s=Math.exp(-1*this.bl*a/this.al),i=.5*(s-1/s),r=.5*(s+1/s),n=Math.sin(this.bl*e/this.al),h=(n*Math.cos(this.gamma0)+i*Math.sin(this.gamma0))/r,o=Math.pow(this.el/Math.sqrt((1+h)/(1-h)),1/this.bl);return Math.abs(h-1)<p?(t.x=this.long0,t.y=m):Math.abs(h+1)<p?(t.x=this.long0,t.y=-1*m):(t.y=at(this.e,o),t.x=v(this.long0-Math.atan2(i*Math.cos(this.gamma0)-n*Math.sin(this.gamma0),Math.cos(this.bl*e/this.al))/this.bl)),t}var Ir=["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","omerc"],Va={init:_r,forward:br,inverse:Er,names:Ir};function Pr(){if(this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,!(Math.abs(this.lat1+this.lat2)<p)){var t=this.b/this.a;this.e=Math.sqrt(1-t*t);var e=Math.sin(this.lat1),a=Math.cos(this.lat1),s=B(this.e,e,a),i=F(this.e,this.lat1,e),r=Math.sin(this.lat2),n=Math.cos(this.lat2),h=B(this.e,r,n),o=F(this.e,this.lat2,r),l=F(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>p?this.ns=Math.log(s/h)/Math.log(i/o):this.ns=e,isNaN(this.ns)&&(this.ns=e),this.f0=s/(this.ns*Math.pow(i,this.ns)),this.rh=this.a*this.f0*Math.pow(l,this.ns),this.title||(this.title="Lambert Conformal Conic")}}function Ar(t){var e=t.x,a=t.y;Math.abs(2*Math.abs(a)-Math.PI)<=p&&(a=$(a)*(m-2*p));var s=Math.abs(Math.abs(a)-m),i,r;if(s>p)i=F(this.e,a,Math.sin(a)),r=this.a*this.f0*Math.pow(i,this.ns);else{if(s=a*this.ns,s<=0)return null;r=0}var n=this.ns*v(e-this.long0);return t.x=this.k0*(r*Math.sin(n))+this.x0,t.y=this.k0*(this.rh-r*Math.cos(n))+this.y0,t}function Sr(t){var e,a,s,i,r,n=(t.x-this.x0)/this.k0,h=this.rh-(t.y-this.y0)/this.k0;this.ns>0?(e=Math.sqrt(n*n+h*h),a=1):(e=-Math.sqrt(n*n+h*h),a=-1);var o=0;if(e!==0&&(o=Math.atan2(a*n,a*h)),e!==0||this.ns>0){if(a=1/this.ns,s=Math.pow(e/(this.a*this.f0),a),i=at(this.e,s),i===-9999)return null}else i=-m;return r=v(o/this.ns+this.long0),t.x=r,t.y=i,t}var Nr=["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_2SP","lcc"],Ka={init:Pr,forward:Ar,inverse:Sr,names:Nr};function wr(){this.a=6377397155e-3,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.7417649320975901-.308341501185665),this.k0||(this.k0=.9999),this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)),this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.pow(Math.tan(this.fi0/2+this.s45),this.alfa)*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.pow(Math.sin(this.fi0),2)),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq}function Rr(t){var e,a,s,i,r,n,h,o=t.x,l=t.y,u=v(o-this.long0);return e=Math.pow((1+this.e*Math.sin(l))/(1-this.e*Math.sin(l)),this.alfa*this.e/2),a=2*(Math.atan(this.k*Math.pow(Math.tan(l/2+this.s45),this.alfa)/e)-this.s45),s=-u*this.alfa,i=Math.asin(Math.cos(this.ad)*Math.sin(a)+Math.sin(this.ad)*Math.cos(a)*Math.cos(s)),r=Math.asin(Math.cos(a)*Math.sin(s)/Math.cos(i)),n=this.n*r,h=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(i/2+this.s45),this.n),t.y=h*Math.cos(n)/1,t.x=h*Math.sin(n)/1,this.czech||(t.y*=-1,t.x*=-1),t}function Cr(t){var e,a,s,i,r,n,h,o,l=t.x;t.x=t.y,t.y=l,this.czech||(t.y*=-1,t.x*=-1),n=Math.sqrt(t.x*t.x+t.y*t.y),r=Math.atan2(t.y,t.x),i=r/Math.sin(this.s0),s=2*(Math.atan(Math.pow(this.ro0/n,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),e=Math.asin(Math.cos(this.ad)*Math.sin(s)-Math.sin(this.ad)*Math.cos(s)*Math.cos(i)),a=Math.asin(Math.cos(s)*Math.sin(i)/Math.cos(e)),t.x=this.long0-a/this.alfa,h=e,o=0;var u=0;do t.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(e/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(h))/(1-this.e*Math.sin(h)),this.e/2))-this.s45),Math.abs(h-t.y)<1e-10&&(o=1),h=t.y,u+=1;while(o===0&&u<15);return u>=15?null:t}var Lr=["Krovak","krovak"],Ya={init:wr,forward:Rr,inverse:Cr,names:Lr};function D(t,e,a,s,i){return t*i-e*Math.sin(2*i)+a*Math.sin(4*i)-s*Math.sin(6*i)}function it(t){return 1-.25*t*(1+t/16*(3+1.25*t))}function st(t){return .375*t*(1+.25*t*(1+.46875*t))}function rt(t){return .05859375*t*t*(1+.75*t)}function nt(t){return t*t*t*(35/3072)}function ht(t,e,a){var s=e*a;return t/Math.sqrt(1-s*s)}function K(t){return Math.abs(t)<m?t:t-$(t)*Math.PI}function yt(t,e,a,s,i){var r,n;r=t/e;for(var h=0;h<15;h++)if(n=(t-(e*r-a*Math.sin(2*r)+s*Math.sin(4*r)-i*Math.sin(6*r)))/(e-2*a*Math.cos(2*r)+4*s*Math.cos(4*r)-6*i*Math.cos(6*r)),r+=n,Math.abs(n)<=1e-10)return r;return NaN}function Tr(){this.sphere||(this.e0=it(this.es),this.e1=st(this.es),this.e2=rt(this.es),this.e3=nt(this.es),this.ml0=this.a*D(this.e0,this.e1,this.e2,this.e3,this.lat0))}function Dr(t){var e,a,s=t.x,i=t.y;if(s=v(s-this.long0),this.sphere)e=this.a*Math.asin(Math.cos(i)*Math.sin(s)),a=this.a*(Math.atan2(Math.tan(i),Math.cos(s))-this.lat0);else{var r=Math.sin(i),n=Math.cos(i),h=ht(this.a,this.e,r),o=Math.tan(i)*Math.tan(i),l=s*Math.cos(i),u=l*l,f=this.es*n*n/(1-this.es),c=this.a*D(this.e0,this.e1,this.e2,this.e3,i);e=h*l*(1-u*o*(1/6-(8-o+8*f)*u/120)),a=c-this.ml0+h*r/n*u*(.5+(5-o+6*f)*u/24)}return t.x=e+this.x0,t.y=a+this.y0,t}function Or(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,s,i;if(this.sphere){var r=a+this.lat0;s=Math.asin(Math.sin(r)*Math.cos(e)),i=Math.atan2(Math.tan(e),Math.cos(r))}else{var n=this.ml0/this.a+a,h=yt(n,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(h)-m)<=p)return t.x=this.long0,t.y=m,a<0&&(t.y*=-1),t;var o=ht(this.a,this.e,Math.sin(h)),l=o*o*o/this.a/this.a*(1-this.es),u=Math.pow(Math.tan(h),2),f=e*this.a/o,c=f*f;s=h-o*Math.tan(h)/l*f*f*(.5-(1+3*u)*f*f/24),i=f*(1-c*(u/3+(1+3*u)*u*c/15))/Math.cos(h)}return t.x=v(i+this.long0),t.y=K(s),t}var Br=["Cassini","Cassini_Soldner","cass"],Za={init:Tr,forward:Dr,inverse:Or,names:Br};function Y(t,e){var a;return t>1e-7?(a=t*e,(1-t*t)*(e/(1-a*a)-.5/t*Math.log((1-a)/(1+a)))):2*e}var Gr=1,Fr=2,qr=3,zr=4;function jr(){var t=Math.abs(this.lat0);if(Math.abs(t-m)<p?this.mode=this.lat0<0?this.S_POLE:this.N_POLE:Math.abs(t)<p?this.mode=this.EQUIT:this.mode=this.OBLIQ,this.es>0){var e;switch(this.qp=Y(this.e,1),this.mmf=.5/(1-this.es),this.apa=Kr(this.es),this.mode){case this.N_POLE:this.dd=1;break;case this.S_POLE:this.dd=1;break;case this.EQUIT:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case this.OBLIQ:this.rq=Math.sqrt(.5*this.qp),e=Math.sin(this.lat0),this.sinb1=Y(this.e,e)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*e*e)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd;break}}else this.mode===this.OBLIQ&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))}function kr(t){var e,a,s,i,r,n,h,o,l,u,f=t.x,c=t.y;if(f=v(f-this.long0),this.sphere){if(r=Math.sin(c),u=Math.cos(c),s=Math.cos(f),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(a=this.mode===this.EQUIT?1+u*s:1+this.sinph0*r+this.cosph0*u*s,a<=p)return null;a=Math.sqrt(2/a),e=a*u*Math.sin(f),a*=this.mode===this.EQUIT?r:this.cosph0*r-this.sinph0*u*s}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(s=-s),Math.abs(c+this.lat0)<p)return null;a=I-c*.5,a=2*(this.mode===this.S_POLE?Math.cos(a):Math.sin(a)),e=a*Math.sin(f),a*=s}}else{switch(h=0,o=0,l=0,s=Math.cos(f),i=Math.sin(f),r=Math.sin(c),n=Y(this.e,r),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(h=n/this.qp,o=Math.sqrt(1-h*h)),this.mode){case this.OBLIQ:l=1+this.sinb1*h+this.cosb1*o*s;break;case this.EQUIT:l=1+o*s;break;case this.N_POLE:l=m+c,n=this.qp-n;break;case this.S_POLE:l=c-m,n=this.qp+n;break}if(Math.abs(l)<p)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:l=Math.sqrt(2/l),this.mode===this.OBLIQ?a=this.ymf*l*(this.cosb1*h-this.sinb1*o*s):a=(l=Math.sqrt(2/(1+o*s)))*h*this.ymf,e=this.xmf*l*o*i;break;case this.N_POLE:case this.S_POLE:n>=0?(e=(l=Math.sqrt(n))*i,a=s*(this.mode===this.S_POLE?l:-l)):e=a=0;break}}return t.x=this.a*e+this.x0,t.y=this.a*a+this.y0,t}function Hr(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,s,i,r,n,h,o,l;if(this.sphere){var u=0,f,c=0;if(f=Math.sqrt(e*e+a*a),i=f*.5,i>1)return null;switch(i=2*Math.asin(i),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(c=Math.sin(i),u=Math.cos(i)),this.mode){case this.EQUIT:i=Math.abs(f)<=p?0:Math.asin(a*c/f),e*=c,a=u*f;break;case this.OBLIQ:i=Math.abs(f)<=p?this.lat0:Math.asin(u*this.sinph0+a*c*this.cosph0/f),e*=c*this.cosph0,a=(u-Math.sin(i)*this.sinph0)*f;break;case this.N_POLE:a=-a,i=m-i;break;case this.S_POLE:i-=m;break}s=a===0&&(this.mode===this.EQUIT||this.mode===this.OBLIQ)?0:Math.atan2(e,a)}else{if(l=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(e/=this.dd,a*=this.dd,o=Math.sqrt(e*e+a*a),o<p)return t.x=this.long0,t.y=this.lat0,t;n=2*Math.asin(.5*o/this.rq),r=Math.cos(n),e*=n=Math.sin(n),this.mode===this.OBLIQ?(l=r*this.sinb1+a*n*this.cosb1/o,h=this.qp*l,a=o*this.cosb1*r-a*this.sinb1*n):(l=a*n/o,h=this.qp*l,a=o*r)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(a=-a),h=e*e+a*a,!h)return t.x=this.long0,t.y=this.lat0,t;l=1-h/this.qp,this.mode===this.S_POLE&&(l=-l)}s=Math.atan2(e,a),i=Yr(Math.asin(l),this.apa)}return t.x=v(this.long0+s),t.y=i,t}var Ur=.3333333333333333,Wr=.17222222222222222,Jr=.10257936507936508,Xr=.06388888888888888,Qr=.0664021164021164,Vr=.016415012942191543;function Kr(t){var e,a=[];return a[0]=t*Ur,e=t*t,a[0]+=e*Wr,a[1]=e*Xr,e*=t,a[0]+=e*Jr,a[1]+=e*Qr,a[2]=e*Vr,a}function Yr(t,e){var a=t+t;return t+e[0]*Math.sin(a)+e[1]*Math.sin(a+a)+e[2]*Math.sin(a+a+a)}var Zr=["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],$a={init:jr,forward:kr,inverse:Hr,names:Zr,S_POLE:Gr,N_POLE:Fr,EQUIT:qr,OBLIQ:zr};function j(t){return Math.abs(t)>1&&(t=t>1?1:-1),Math.asin(t)}function $r(){Math.abs(this.lat1+this.lat2)<p||(this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e3=Math.sqrt(this.es),this.sin_po=Math.sin(this.lat1),this.cos_po=Math.cos(this.lat1),this.t1=this.sin_po,this.con=this.sin_po,this.ms1=B(this.e3,this.sin_po,this.cos_po),this.qs1=Y(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat2),this.cos_po=Math.cos(this.lat2),this.t2=this.sin_po,this.ms2=B(this.e3,this.sin_po,this.cos_po),this.qs2=Y(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat0),this.cos_po=Math.cos(this.lat0),this.t3=this.sin_po,this.qs0=Y(this.e3,this.sin_po,this.cos_po),Math.abs(this.lat1-this.lat2)>p?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)}function tn(t){var e=t.x,a=t.y;this.sin_phi=Math.sin(a),this.cos_phi=Math.cos(a);var s=Y(this.e3,this.sin_phi,this.cos_phi),i=this.a*Math.sqrt(this.c-this.ns0*s)/this.ns0,r=this.ns0*v(e-this.long0),n=i*Math.sin(r)+this.x0,h=this.rh-i*Math.cos(r)+this.y0;return t.x=n,t.y=h,t}function en(t){var e,a,s,i,r,n;return t.x-=this.x0,t.y=this.rh-t.y+this.y0,this.ns0>=0?(e=Math.sqrt(t.x*t.x+t.y*t.y),s=1):(e=-Math.sqrt(t.x*t.x+t.y*t.y),s=-1),i=0,e!==0&&(i=Math.atan2(s*t.x,s*t.y)),s=e*this.ns0/this.a,this.sphere?n=Math.asin((this.c-s*s)/(2*this.ns0)):(a=(this.c-s*s)/this.ns0,n=this.phi1z(this.e3,a)),r=v(i/this.ns0+this.long0),t.x=r,t.y=n,t}function an(t,e){var a,s,i,r,n,h=j(.5*e);if(t<p)return h;for(var o=t*t,l=1;l<=25;l++)if(a=Math.sin(h),s=Math.cos(h),i=t*a,r=1-i*i,n=.5*r*r/s*(e/(1-o)-a/r+.5/t*Math.log((1-i)/(1+i))),h=h+n,Math.abs(n)<=1e-7)return h;return null}var sn=["Albers_Conic_Equal_Area","Albers","aea"],ti={init:$r,forward:tn,inverse:en,names:sn,phi1z:an};function rn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function nn(t){var e,a,s,i,r,n,h,o,l=t.x,u=t.y;return s=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),i=Math.cos(s),n=this.sin_p14*e+this.cos_p14*a*i,r=1,n>0||Math.abs(n)<=p?(h=this.x0+this.a*r*a*Math.sin(s)/n,o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*i)/n):(h=this.x0+this.infinity_dist*a*Math.sin(s),o=this.y0+this.infinity_dist*(this.cos_p14*e-this.sin_p14*a*i)),t.x=h,t.y=o,t}function hn(t){var e,a,s,i,r,n;return t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,(e=Math.sqrt(t.x*t.x+t.y*t.y))?(i=Math.atan2(e,this.rc),a=Math.sin(i),s=Math.cos(i),n=j(s*this.sin_p14+t.y*a*this.cos_p14/e),r=Math.atan2(t.x*a,e*this.cos_p14*s-t.y*this.sin_p14*a),r=v(this.long0+r)):(n=this.phic0,r=0),t.x=r,t.y=n,t}var on=["gnom"],ei={init:rn,forward:nn,inverse:hn,names:on};function ai(t,e){var a=1-(1-t*t)/(2*t)*Math.log((1-t)/(1+t));if(Math.abs(Math.abs(e)-a)<1e-6)return e<0?-1*m:m;for(var s=Math.asin(.5*e),i,r,n,h,o=0;o<30;o++)if(r=Math.sin(s),n=Math.cos(s),h=t*r,i=Math.pow(1-h*h,2)/(2*n)*(e/(1-t*t)-r/(1-h*h)+.5/t*Math.log((1-h)/(1+h))),s+=i,Math.abs(i)<=1e-10)return s;return NaN}function ln(){this.sphere||(this.k0=B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function fn(t){var e=t.x,a=t.y,s,i,r=v(e-this.long0);if(this.sphere)s=this.x0+this.a*r*Math.cos(this.lat_ts),i=this.y0+this.a*Math.sin(a)/Math.cos(this.lat_ts);else{var n=Y(this.e,Math.sin(a));s=this.x0+this.a*this.k0*r,i=this.y0+this.a*n*.5/this.k0}return t.x=s,t.y=i,t}function un(t){t.x-=this.x0,t.y-=this.y0;var e,a;return this.sphere?(e=v(this.long0+t.x/this.a/Math.cos(this.lat_ts)),a=Math.asin(t.y/this.a*Math.cos(this.lat_ts))):(a=ai(this.e,2*t.y*this.k0/this.a),e=v(this.long0+t.x/(this.a*this.k0))),t.x=e,t.y=a,t}var cn=["cea"],ii={init:ln,forward:fn,inverse:un,names:cn};function mn(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Equidistant Cylindrical (Plate Carre)",this.rc=Math.cos(this.lat_ts)}function Mn(t){var e=t.x,a=t.y,s=v(e-this.long0),i=K(a-this.lat0);return t.x=this.x0+this.a*s*this.rc,t.y=this.y0+this.a*i,t}function dn(t){var e=t.x,a=t.y;return t.x=v(this.long0+(e-this.x0)/(this.a*this.rc)),t.y=K(this.lat0+(a-this.y0)/this.a),t}var pn=["Equirectangular","Equidistant_Cylindrical","eqc"],si={init:mn,forward:Mn,inverse:dn,names:pn};var ri=20;function vn(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=it(this.es),this.e1=st(this.es),this.e2=rt(this.es),this.e3=nt(this.es),this.ml0=this.a*D(this.e0,this.e1,this.e2,this.e3,this.lat0)}function yn(t){var e=t.x,a=t.y,s,i,r,n=v(e-this.long0);if(r=n*Math.sin(a),this.sphere)Math.abs(a)<=p?(s=this.a*n,i=-1*this.a*this.lat0):(s=this.a*Math.sin(r)/Math.tan(a),i=this.a*(K(a-this.lat0)+(1-Math.cos(r))/Math.tan(a)));else if(Math.abs(a)<=p)s=this.a*n,i=-1*this.ml0;else{var h=ht(this.a,this.e,Math.sin(a))/Math.tan(a);s=h*Math.sin(r),i=this.a*D(this.e0,this.e1,this.e2,this.e3,a)-this.ml0+h*(1-Math.cos(r))}return t.x=s+this.x0,t.y=i+this.y0,t}function xn(t){var e,a,s,i,r,n,h,o,l;if(s=t.x-this.x0,i=t.y-this.y0,this.sphere)if(Math.abs(i+this.a*this.lat0)<=p)e=v(s/this.a+this.long0),a=0;else{n=this.lat0+i/this.a,h=s*s/this.a/this.a+n*n,o=n;var u;for(r=ri;r;--r)if(u=Math.tan(o),l=-1*(n*(o*u+1)-o-.5*(o*o+h)*u)/((o-n)/u-1),o+=l,Math.abs(l)<=p){a=o;break}e=v(this.long0+Math.asin(s*Math.tan(o)/this.a)/Math.sin(a))}else if(Math.abs(i+this.ml0)<=p)a=0,e=v(this.long0+s/this.a);else{n=(this.ml0+i)/this.a,h=s*s/this.a/this.a+n*n,o=n;var f,c,M,d,y;for(r=ri;r;--r)if(y=this.e*Math.sin(o),f=Math.sqrt(1-y*y)*Math.tan(o),c=this.a*D(this.e0,this.e1,this.e2,this.e3,o),M=this.e0-2*this.e1*Math.cos(2*o)+4*this.e2*Math.cos(4*o)-6*this.e3*Math.cos(6*o),d=c/this.a,l=(n*(f*d+1)-d-.5*f*(d*d+h))/(this.es*Math.sin(2*o)*(d*d+h-2*n*d)/(4*f)+(n-d)*(f*M-2/Math.sin(2*o))-M),o-=l,Math.abs(l)<=p){a=o;break}f=Math.sqrt(1-this.es*Math.pow(Math.sin(a),2))*Math.tan(a),e=v(this.long0+Math.asin(s*f/this.a)/Math.sin(a))}return t.x=e,t.y=a,t}var gn=["Polyconic","poly"],ni={init:vn,forward:yn,inverse:xn,names:gn};function _n(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013}function bn(t){var e,a=t.x,s=t.y,i=s-this.lat0,r=a-this.long0,n=i/Mt*1e-5,h=r,o=1,l=0;for(e=1;e<=10;e++)o=o*n,l=l+this.A[e]*o;var u=l,f=h,c=1,M=0,d,y,x=0,g=0;for(e=1;e<=6;e++)d=c*u-M*f,y=M*u+c*f,c=d,M=y,x=x+this.B_re[e]*c-this.B_im[e]*M,g=g+this.B_im[e]*c+this.B_re[e]*M;return t.x=g*this.a+this.x0,t.y=x*this.a+this.y0,t}function En(t){var e,a=t.x,s=t.y,i=a-this.x0,r=s-this.y0,n=r/this.a,h=i/this.a,o=1,l=0,u,f,c=0,M=0;for(e=1;e<=6;e++)u=o*n-l*h,f=l*n+o*h,o=u,l=f,c=c+this.C_re[e]*o-this.C_im[e]*l,M=M+this.C_im[e]*o+this.C_re[e]*l;for(var d=0;d<this.iterations;d++){var y=c,x=M,g,b,E=n,N=h;for(e=2;e<=6;e++)g=y*c-x*M,b=x*c+y*M,y=g,x=b,E=E+(e-1)*(this.B_re[e]*y-this.B_im[e]*x),N=N+(e-1)*(this.B_im[e]*y+this.B_re[e]*x);y=1,x=0;var P=this.B_re[1],A=this.B_im[1];for(e=2;e<=6;e++)g=y*c-x*M,b=x*c+y*M,y=g,x=b,P=P+e*(this.B_re[e]*y-this.B_im[e]*x),A=A+e*(this.B_im[e]*y+this.B_re[e]*x);var O=P*P+A*A;c=(E*P+N*A)/O,M=(N*P-E*A)/O}var C=c,Z=M,ut=1,ct=0;for(e=1;e<=9;e++)ut=ut*C,ct=ct+this.D[e]*ut;var jt=this.lat0+ct*Mt*1e5,Di=this.long0+Z;return t.x=Di,t.y=jt,t}var In=["New_Zealand_Map_Grid","nzmg"],hi={init:_n,forward:bn,inverse:En,names:In};function Pn(){}function An(t){var e=t.x,a=t.y,s=v(e-this.long0),i=this.x0+this.a*s,r=this.y0+this.a*Math.log(Math.tan(Math.PI/4+a/2.5))*1.25;return t.x=i,t.y=r,t}function Sn(t){t.x-=this.x0,t.y-=this.y0;var e=v(this.long0+t.x/this.a),a=2.5*(Math.atan(Math.exp(.8*t.y/this.a))-Math.PI/4);return t.x=e,t.y=a,t}var Nn=["Miller_Cylindrical","mill"],oi={init:Pn,forward:An,inverse:Sn,names:Nn};var wn=20;function Rn(){this.sphere?(this.n=1,this.m=0,this.es=0,this.C_y=Math.sqrt((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)):this.en=re(this.es)}function Cn(t){var e,a,s=t.x,i=t.y;if(s=v(s-this.long0),this.sphere){if(!this.m)i=this.n!==1?Math.asin(this.n*Math.sin(i)):i;else for(var r=this.n*Math.sin(i),n=wn;n;--n){var h=(this.m*i+Math.sin(i)-r)/(this.m+Math.cos(i));if(i-=h,Math.abs(h)<p)break}e=this.a*this.C_x*s*(this.m+Math.cos(i)),a=this.a*this.C_y*i}else{var o=Math.sin(i),l=Math.cos(i);a=this.a*vt(i,o,l,this.en),e=this.a*s*l/Math.sqrt(1-this.es*o*o)}return t.x=e,t.y=a,t}function Ln(t){var e,a,s,i;return t.x-=this.x0,s=t.x/this.a,t.y-=this.y0,e=t.y/this.a,this.sphere?(e/=this.C_y,s=s/(this.C_x*(this.m+Math.cos(e))),this.m?e=j((this.m*e+Math.sin(e))/this.n):this.n!==1&&(e=j(Math.sin(e)/this.n)),s=v(s+this.long0),e=K(e)):(e=ne(t.y/this.a,this.es,this.en),i=Math.abs(e),i<m?(i=Math.sin(e),a=this.long0+t.x*Math.sqrt(1-this.es*i*i)/(this.a*Math.cos(e)),s=v(a)):i-p<m&&(s=this.long0)),t.x=s,t.y=e,t}var Tn=["Sinusoidal","sinu"],li={init:Rn,forward:Cn,inverse:Ln,names:Tn};function Dn(){}function On(t){for(var e=t.x,a=t.y,s=v(e-this.long0),i=a,r=Math.PI*Math.sin(a);;){var n=-(i+Math.sin(i)-r)/(1+Math.cos(i));if(i+=n,Math.abs(n)<p)break}i/=2,Math.PI/2-Math.abs(a)<p&&(s=0);var h=.900316316158*this.a*s*Math.cos(i)+this.x0,o=1.4142135623731*this.a*Math.sin(i)+this.y0;return t.x=h,t.y=o,t}function Bn(t){var e,a;t.x-=this.x0,t.y-=this.y0,a=t.y/(1.4142135623731*this.a),Math.abs(a)>.999999999999&&(a=.999999999999),e=Math.asin(a);var s=v(this.long0+t.x/(.900316316158*this.a*Math.cos(e)));s<-Math.PI&&(s=-Math.PI),s>Math.PI&&(s=Math.PI),a=(2*e+Math.sin(2*e))/Math.PI,Math.abs(a)>1&&(a=1);var i=Math.asin(a);return t.x=s,t.y=i,t}var Gn=["Mollweide","moll"],fi={init:Dn,forward:On,inverse:Bn,names:Gn};function Fn(){Math.abs(this.lat1+this.lat2)<p||(this.lat2=this.lat2||this.lat1,this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=it(this.es),this.e1=st(this.es),this.e2=rt(this.es),this.e3=nt(this.es),this.sinphi=Math.sin(this.lat1),this.cosphi=Math.cos(this.lat1),this.ms1=B(this.e,this.sinphi,this.cosphi),this.ml1=D(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<p?this.ns=this.sinphi:(this.sinphi=Math.sin(this.lat2),this.cosphi=Math.cos(this.lat2),this.ms2=B(this.e,this.sinphi,this.cosphi),this.ml2=D(this.e0,this.e1,this.e2,this.e3,this.lat2),this.ns=(this.ms1-this.ms2)/(this.ml2-this.ml1)),this.g=this.ml1+this.ms1/this.ns,this.ml0=D(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))}function qn(t){var e=t.x,a=t.y,s;if(this.sphere)s=this.a*(this.g-a);else{var i=D(this.e0,this.e1,this.e2,this.e3,a);s=this.a*(this.g-i)}var r=this.ns*v(e-this.long0),n=this.x0+s*Math.sin(r),h=this.y0+this.rh-s*Math.cos(r);return t.x=n,t.y=h,t}function zn(t){t.x-=this.x0,t.y=this.rh-t.y+this.y0;var e,a,s,i;this.ns>=0?(a=Math.sqrt(t.x*t.x+t.y*t.y),e=1):(a=-Math.sqrt(t.x*t.x+t.y*t.y),e=-1);var r=0;if(a!==0&&(r=Math.atan2(e*t.x,e*t.y)),this.sphere)return i=v(this.long0+r/this.ns),s=K(this.g-a/this.a),t.x=i,t.y=s,t;var n=this.g-a/this.a;return s=yt(n,this.e0,this.e1,this.e2,this.e3),i=v(this.long0+r/this.ns),t.x=i,t.y=s,t}var jn=["Equidistant_Conic","eqdc"],ui={init:Fn,forward:qn,inverse:zn,names:jn};function kn(){this.R=this.a}function Hn(t){var e=t.x,a=t.y,s=v(e-this.long0),i,r;Math.abs(a)<=p&&(i=this.x0+this.R*s,r=this.y0);var n=j(2*Math.abs(a/Math.PI));(Math.abs(s)<=p||Math.abs(Math.abs(a)-m)<=p)&&(i=this.x0,a>=0?r=this.y0+Math.PI*this.R*Math.tan(.5*n):r=this.y0+Math.PI*this.R*-Math.tan(.5*n));var h=.5*Math.abs(Math.PI/s-s/Math.PI),o=h*h,l=Math.sin(n),u=Math.cos(n),f=u/(l+u-1),c=f*f,M=f*(2/l-1),d=M*M,y=Math.PI*this.R*(h*(f-d)+Math.sqrt(o*(f-d)*(f-d)-(d+o)*(c-d)))/(d+o);s<0&&(y=-y),i=this.x0+y;var x=o+f;return y=Math.PI*this.R*(M*x-h*Math.sqrt((d+o)*(o+1)-x*x))/(d+o),a>=0?r=this.y0+y:r=this.y0-y,t.x=i,t.y=r,t}function Un(t){var e,a,s,i,r,n,h,o,l,u,f,c,M;return t.x-=this.x0,t.y-=this.y0,f=Math.PI*this.R,s=t.x/f,i=t.y/f,r=s*s+i*i,n=-Math.abs(i)*(1+r),h=n-2*i*i+s*s,o=-2*n+1+2*i*i+r*r,M=i*i/o+(2*h*h*h/o/o/o-9*n*h/o/o)/27,l=(n-h*h/3/o)/o,u=2*Math.sqrt(-l/3),f=3*M/l/u,Math.abs(f)>1&&(f>=0?f=1:f=-1),c=Math.acos(f)/3,t.y>=0?a=(-u*Math.cos(c+Math.PI/3)-h/3/o)*Math.PI:a=-(-u*Math.cos(c+Math.PI/3)-h/3/o)*Math.PI,Math.abs(s)<p?e=this.long0:e=v(this.long0+Math.PI*(r-1+Math.sqrt(1+2*(s*s-i*i)+r*r))/2/s),t.x=e,t.y=a,t}var Wn=["Van_der_Grinten_I","VanDerGrinten","vandg"],ci={init:kn,forward:Hn,inverse:Un,names:Wn};function Jn(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0)}function Xn(t){var e=t.x,a=t.y,s=Math.sin(t.y),i=Math.cos(t.y),r=v(e-this.long0),n,h,o,l,u,f,c,M,d,y,x,g,b,E,N,P,A,O,C,Z,ut,ct,jt;return this.sphere?Math.abs(this.sin_p12-1)<=p?(t.x=this.x0+this.a*(m-a)*Math.sin(r),t.y=this.y0-this.a*(m-a)*Math.cos(r),t):Math.abs(this.sin_p12+1)<=p?(t.x=this.x0+this.a*(m+a)*Math.sin(r),t.y=this.y0+this.a*(m+a)*Math.cos(r),t):(O=this.sin_p12*s+this.cos_p12*i*Math.cos(r),P=Math.acos(O),A=P?P/Math.sin(P):1,t.x=this.x0+this.a*A*i*Math.sin(r),t.y=this.y0+this.a*A*(this.cos_p12*s-this.sin_p12*i*Math.cos(r)),t):(n=it(this.es),h=st(this.es),o=rt(this.es),l=nt(this.es),Math.abs(this.sin_p12-1)<=p?(u=this.a*D(n,h,o,l,m),f=this.a*D(n,h,o,l,a),t.x=this.x0+(u-f)*Math.sin(r),t.y=this.y0-(u-f)*Math.cos(r),t):Math.abs(this.sin_p12+1)<=p?(u=this.a*D(n,h,o,l,m),f=this.a*D(n,h,o,l,a),t.x=this.x0+(u+f)*Math.sin(r),t.y=this.y0+(u+f)*Math.cos(r),t):(c=s/i,M=ht(this.a,this.e,this.sin_p12),d=ht(this.a,this.e,s),y=Math.atan((1-this.es)*c+this.es*M*this.sin_p12/(d*i)),x=Math.atan2(Math.sin(r),this.cos_p12*Math.tan(y)-this.sin_p12*Math.cos(r)),x===0?C=Math.asin(this.cos_p12*Math.sin(y)-this.sin_p12*Math.cos(y)):Math.abs(Math.abs(x)-Math.PI)<=p?C=-Math.asin(this.cos_p12*Math.sin(y)-this.sin_p12*Math.cos(y)):C=Math.asin(Math.sin(r)*Math.cos(y)/Math.sin(x)),g=this.e*this.sin_p12/Math.sqrt(1-this.es),b=this.e*this.cos_p12*Math.cos(x)/Math.sqrt(1-this.es),E=g*b,N=b*b,Z=C*C,ut=Z*C,ct=ut*C,jt=ct*C,P=M*C*(1-Z*N*(1-N)/6+ut/8*E*(1-2*N)+ct/120*(N*(4-7*N)-3*g*g*(1-7*N))-jt/48*E),t.x=this.x0+P*Math.sin(x),t.y=this.y0+P*Math.cos(x),t))}function Qn(t){t.x-=this.x0,t.y-=this.y0;var e,a,s,i,r,n,h,o,l,u,f,c,M,d,y,x,g,b,E,N,P,A,O,C;return this.sphere?(e=Math.sqrt(t.x*t.x+t.y*t.y),e>2*m*this.a?void 0:(a=e/this.a,s=Math.sin(a),i=Math.cos(a),r=this.long0,Math.abs(e)<=p?n=this.lat0:(n=j(i*this.sin_p12+t.y*s*this.cos_p12/e),h=Math.abs(this.lat0)-m,Math.abs(h)<=p?this.lat0>=0?r=v(this.long0+Math.atan2(t.x,-t.y)):r=v(this.long0-Math.atan2(-t.x,t.y)):r=v(this.long0+Math.atan2(t.x*s,e*this.cos_p12*i-t.y*this.sin_p12*s))),t.x=r,t.y=n,t)):(o=it(this.es),l=st(this.es),u=rt(this.es),f=nt(this.es),Math.abs(this.sin_p12-1)<=p?(c=this.a*D(o,l,u,f,m),e=Math.sqrt(t.x*t.x+t.y*t.y),M=c-e,n=yt(M/this.a,o,l,u,f),r=v(this.long0+Math.atan2(t.x,-1*t.y)),t.x=r,t.y=n,t):Math.abs(this.sin_p12+1)<=p?(c=this.a*D(o,l,u,f,m),e=Math.sqrt(t.x*t.x+t.y*t.y),M=e-c,n=yt(M/this.a,o,l,u,f),r=v(this.long0+Math.atan2(t.x,t.y)),t.x=r,t.y=n,t):(e=Math.sqrt(t.x*t.x+t.y*t.y),x=Math.atan2(t.x,t.y),d=ht(this.a,this.e,this.sin_p12),g=Math.cos(x),b=this.e*this.cos_p12*g,E=-b*b/(1-this.es),N=3*this.es*(1-E)*this.sin_p12*this.cos_p12*g/(1-this.es),P=e/d,A=P-E*(1+E)*Math.pow(P,3)/6-N*(1+3*E)*Math.pow(P,4)/24,O=1-E*A*A/2-P*A*A*A/6,y=Math.asin(this.sin_p12*Math.cos(A)+this.cos_p12*Math.sin(A)*g),r=v(this.long0+Math.asin(Math.sin(x)*Math.sin(A)/Math.cos(y))),C=Math.sin(y),n=Math.atan2((C-this.es*O*this.sin_p12)*Math.tan(y),C*(1-this.es)),t.x=r,t.y=n,t))}var Vn=["Azimuthal_Equidistant","aeqd"],mi={init:Jn,forward:Xn,inverse:Qn,names:Vn};function Kn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)}function Yn(t){var e,a,s,i,r,n,h,o,l=t.x,u=t.y;return s=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),i=Math.cos(s),n=this.sin_p14*e+this.cos_p14*a*i,r=1,(n>0||Math.abs(n)<=p)&&(h=this.a*r*a*Math.sin(s),o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*i)),t.x=h,t.y=o,t}function Zn(t){var e,a,s,i,r,n,h;return t.x-=this.x0,t.y-=this.y0,e=Math.sqrt(t.x*t.x+t.y*t.y),a=j(e/this.a),s=Math.sin(a),i=Math.cos(a),n=this.long0,Math.abs(e)<=p?(h=this.lat0,t.x=n,t.y=h,t):(h=j(i*this.sin_p14+t.y*s*this.cos_p14/e),r=Math.abs(this.lat0)-m,Math.abs(r)<=p?(this.lat0>=0?n=v(this.long0+Math.atan2(t.x,-t.y)):n=v(this.long0-Math.atan2(-t.x,t.y)),t.x=n,t.y=h,t):(n=v(this.long0+Math.atan2(t.x*s,e*this.cos_p14*i-t.y*this.sin_p14*s)),t.x=n,t.y=h,t))}var $n=["ortho"],Mi={init:Kn,forward:Yn,inverse:Zn,names:$n};var R={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},S={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function th(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Quadrilateralized Spherical Cube",this.lat0>=m-I/2?this.face=R.TOP:this.lat0<=-(m-I/2)?this.face=R.BOTTOM:Math.abs(this.long0)<=I?this.face=R.FRONT:Math.abs(this.long0)<=m+I?this.face=this.long0>0?R.RIGHT:R.LEFT:this.face=R.BACK,this.es!==0&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)}function eh(t){var e={x:0,y:0},a,s,i,r,n,h,o={value:0};if(t.x-=this.long0,this.es!==0?a=Math.atan(this.one_minus_f_squared*Math.tan(t.y)):a=t.y,s=t.x,this.face===R.TOP)r=m-a,s>=I&&s<=m+I?(o.value=S.AREA_0,i=s-m):s>m+I||s<=-(m+I)?(o.value=S.AREA_1,i=s>0?s-w:s+w):s>-(m+I)&&s<=-I?(o.value=S.AREA_2,i=s+m):(o.value=S.AREA_3,i=s);else if(this.face===R.BOTTOM)r=m+a,s>=I&&s<=m+I?(o.value=S.AREA_0,i=-s+m):s<I&&s>=-I?(o.value=S.AREA_1,i=-s):s<-I&&s>=-(m+I)?(o.value=S.AREA_2,i=-s-m):(o.value=S.AREA_3,i=s>0?-s+w:-s-w);else{var l,u,f,c,M,d,y;this.face===R.RIGHT?s=Pt(s,+m):this.face===R.BACK?s=Pt(s,+w):this.face===R.LEFT&&(s=Pt(s,-m)),c=Math.sin(a),M=Math.cos(a),d=Math.sin(s),y=Math.cos(s),l=M*y,u=M*d,f=c,this.face===R.FRONT?(r=Math.acos(l),i=ue(r,f,u,o)):this.face===R.RIGHT?(r=Math.acos(u),i=ue(r,f,-l,o)):this.face===R.BACK?(r=Math.acos(-l),i=ue(r,f,-u,o)):this.face===R.LEFT?(r=Math.acos(-u),i=ue(r,f,l,o)):(r=i=0,o.value=S.AREA_0)}return h=Math.atan(12/w*(i+Math.acos(Math.sin(i)*Math.cos(I))-m)),n=Math.sqrt((1-Math.cos(r))/(Math.cos(h)*Math.cos(h))/(1-Math.cos(Math.atan(1/Math.cos(i))))),o.value===S.AREA_1?h+=m:o.value===S.AREA_2?h+=w:o.value===S.AREA_3&&(h+=1.5*w),e.x=n*Math.cos(h),e.y=n*Math.sin(h),e.x=e.x*this.a+this.x0,e.y=e.y*this.a+this.y0,t.x=e.x,t.y=e.y,t}function ah(t){var e={lam:0,phi:0},a,s,i,r,n,h,o,l,u,f={value:0};if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,s=Math.atan(Math.sqrt(t.x*t.x+t.y*t.y)),a=Math.atan2(t.y,t.x),t.x>=0&&t.x>=Math.abs(t.y)?f.value=S.AREA_0:t.y>=0&&t.y>=Math.abs(t.x)?(f.value=S.AREA_1,a-=m):t.x<0&&-t.x>=Math.abs(t.y)?(f.value=S.AREA_2,a=a<0?a+w:a-w):(f.value=S.AREA_3,a+=m),u=w/12*Math.tan(a),n=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),h=Math.atan(n),i=Math.cos(a),r=Math.tan(s),o=1-i*i*r*r*(1-Math.cos(Math.atan(1/Math.cos(h)))),o<-1?o=-1:o>1&&(o=1),this.face===R.TOP)l=Math.acos(o),e.phi=m-l,f.value===S.AREA_0?e.lam=h+m:f.value===S.AREA_1?e.lam=h<0?h+w:h-w:f.value===S.AREA_2?e.lam=h-m:e.lam=h;else if(this.face===R.BOTTOM)l=Math.acos(o),e.phi=l-m,f.value===S.AREA_0?e.lam=-h+m:f.value===S.AREA_1?e.lam=-h:f.value===S.AREA_2?e.lam=-h-m:e.lam=h<0?-h-w:-h+w;else{var c,M,d;c=o,u=c*c,u>=1?d=0:d=Math.sqrt(1-u)*Math.sin(h),u+=d*d,u>=1?M=0:M=Math.sqrt(1-u),f.value===S.AREA_1?(u=M,M=-d,d=u):f.value===S.AREA_2?(M=-M,d=-d):f.value===S.AREA_3&&(u=M,M=d,d=-u),this.face===R.RIGHT?(u=c,c=-M,M=u):this.face===R.BACK?(c=-c,M=-M):this.face===R.LEFT&&(u=c,c=M,M=-u),e.phi=Math.acos(-d)-m,e.lam=Math.atan2(M,c),this.face===R.RIGHT?e.lam=Pt(e.lam,-m):this.face===R.BACK?e.lam=Pt(e.lam,-w):this.face===R.LEFT&&(e.lam=Pt(e.lam,+m))}if(this.es!==0){var y,x,g;y=e.phi<0?1:0,x=Math.tan(e.phi),g=this.b/Math.sqrt(x*x+this.one_minus_f_squared),e.phi=Math.atan(Math.sqrt(this.a*this.a-g*g)/(this.one_minus_f*g)),y&&(e.phi=-e.phi)}return e.lam+=this.long0,t.x=e.lam,t.y=e.phi,t}function ue(t,e,a,s){var i;return t<p?(s.value=S.AREA_0,i=0):(i=Math.atan2(e,a),Math.abs(i)<=I?s.value=S.AREA_0:i>I&&i<=m+I?(s.value=S.AREA_1,i-=m):i>m+I||i<=-(m+I)?(s.value=S.AREA_2,i=i>=0?i-w:i+w):(s.value=S.AREA_3,i+=m)),i}function Pt(t,e){var a=t+e;return a<-w?a+=Rt:a>+w&&(a-=Rt),a}var ih=["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"],di={init:th,forward:eh,inverse:ah,names:ih};var Be=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-986701e-12],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,18736e-12],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,934959e-12],[.7986,-.00755338,-500009e-10,935324e-12],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],Bt=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-126793e-14,422642e-15],[.124,.0124,507171e-14,-160604e-14],[.186,.0123999,-190189e-13,600152e-14],[.248,.0124002,710039e-13,-224e-10],[.31,.0123992,-264997e-12,835986e-13],[.372,.0124029,988983e-12,-311994e-12],[.434,.0123893,-369093e-11,-435621e-12],[.4958,.0123198,-102252e-10,-345523e-12],[.5571,.0121916,-154081e-10,-582288e-12],[.6176,.0119938,-241424e-10,-525327e-12],[.6769,.011713,-320223e-10,-516405e-12],[.7346,.0113541,-397684e-10,-609052e-12],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-140374e-14],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],pi=.8487,vi=1.3523,yi=V/5,sh=1/yi,At=18,ce=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))},rh=function(t,e){return t[1]+e*(2*t[2]+e*3*t[3])};function nh(t,e,a,s){for(var i=e;s;--s){var r=t(i);if(i-=r,Math.abs(r)<a)break}return i}function hh(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"}function oh(t){var e=v(t.x-this.long0),a=Math.abs(t.y),s=Math.floor(a*yi);s<0?s=0:s>=At&&(s=At-1),a=V*(a-sh*s);var i={x:ce(Be[s],a)*e,y:ce(Bt[s],a)};return t.y<0&&(i.y=-i.y),i.x=i.x*this.a*pi+this.x0,i.y=i.y*this.a*vi+this.y0,i}function lh(t){var e={x:(t.x-this.x0)/(this.a*pi),y:Math.abs(t.y-this.y0)/(this.a*vi)};if(e.y>=1)e.x/=Be[At][0],e.y=t.y<0?-m:m;else{var a=Math.floor(e.y*At);for(a<0?a=0:a>=At&&(a=At-1);;)if(Bt[a][0]>e.y)--a;else if(Bt[a+1][0]<=e.y)++a;else break;var s=Bt[a],i=5*(e.y-s[0])/(Bt[a+1][0]-s[0]);i=nh(function(r){return(ce(s,r)-e.y)/rh(s,r)},i,p,100),e.x/=ce(Be[a],i),e.y=(5*a+i)*L,t.y<0&&(e.y=-e.y)}return e.x=v(e.x+this.long0),e}var fh=["Robinson","robin"],xi={init:hh,forward:oh,inverse:lh,names:fh};function uh(){this.name="geocent"}function ch(t){var e=ee(t,this.es,this.a);return e}function mh(t){var e=ae(t,this.es,this.a,this.b);return e}var Mh=["Geocentric","geocentric","geocent","Geocent"],gi={init:uh,forward:ch,inverse:mh,names:Mh};function _i(t){t.Proj.projections.add(qa),t.Proj.projections.add(It),t.Proj.projections.add(Wa),t.Proj.projections.add(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(Za),t.Proj.projections.add($a),t.Proj.projections.add(ti),t.Proj.projections.add(ei),t.Proj.projections.add(ii),t.Proj.projections.add(si),t.Proj.projections.add(ni),t.Proj.projections.add(hi),t.Proj.projections.add(oi),t.Proj.projections.add(li),t.Proj.projections.add(fi),t.Proj.projections.add(ui),t.Proj.projections.add(ci),t.Proj.projections.add(mi),t.Proj.projections.add(Mi),t.Proj.projections.add(di),t.Proj.projections.add(xi),t.Proj.projections.add(gi)}H.defaultDatum="WGS84";H.Proj=ft;H.WGS84=new H.Proj("WGS84");H.Point=Oa;H.toPoint=se;H.defs=gt;H.transform=pt;H.mgrs=La;H.version="__VERSION__";_i(H);var Ge=H;var Gt=class{static defineProjectionAliases(e){let a=[];for(let s in e)a.push([s,e[s]]);Ge.defs(a)}constructor({from:e="WGS84",to:a="WGS84"}){if(Ie(this,"_projection",void 0),this._projection=Ge(e,a),!this._projection)throw new Error("Invalid projection");this.project=this.project.bind(this),this.unproject=this.unproject.bind(this)}project(e){return this._projection.forward(e)}unproject(e){return this._projection.inverse(e)}};var Fe=100,bi=!1;function Ei(t){let e=new DataView(t,0,Fe),s=Wt(e).length-Fe,i=new DataView(t,Fe,s),r=new Int32Array(s),n=new Int32Array(s);for(let h=0;h<s/8;h++)r[h]=i.getInt32(h*8,bi),n[h]=i.getInt32(h*8+4,bi);return{offsets:r,lengths:n}}async function*me(t,e,a){let s=[],i=[],r=!1,n=!1;for(;!r&&!n;){if(s.length===0&&!r){let{value:o,done:l}=await t.next();l?r=!0:s.push(...o)}if(i.length===0&&!n){let{value:o,done:l}=await e.next();l?n=!0:i.push(...o)}let h=dh(s,i);h&&(yield{batchType:"data",shape:a,length:h.length,data:h})}}function dh(t,e){let a=Math.min(t.length,e.length);if(a===0)return null;let s=[t.slice(0,a),e.slice(0,a)];return t.splice(0,a),e.splice(0,a),s}var qe=!0,Ii=32,q;(function(t){t[t.START=0]="START",t[t.FIELD_DESCRIPTORS=1]="FIELD_DESCRIPTORS",t[t.FIELD_PROPERTIES=2]="FIELD_PROPERTIES",t[t.END=3]="END",t[t.ERROR=4]="ERROR"})(q||(q={}));var de=class{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=Pi(this.state,this.result,this.binaryReader,this.textDecoder)}end(){this.binaryReader.end(),this.state=Pi(this.state,this.result,this.binaryReader,this.textDecoder),this.state!==q.END&&(this.state=q.ERROR,this.result.error="DBF incomplete file")}};function ze(t,e={}){let{encoding:a="latin1"}=e.dbf||{},s=new de({encoding:a});s.write(t),s.end();let{data:i,schema:r}=s.result;switch(e?.dbf?.shape){case"object-row-table":return{shape:"object-row-table",schema:r,data:i};case"table":return{schema:r,rows:i};case"rows":default:return i}}async function*Ai(t,e={}){let{encoding:a="latin1"}=e.dbf||{},s=new de({encoding:a}),i=!1;for await(let r of t)s.write(r),!i&&s.result.dbfHeader&&(i=!0,yield s.result.dbfHeader),s.result.data.length>0&&(yield s.result.data,s.result.data=[]);s.end(),s.result.data.length>0&&(yield s.result.data)}function Pi(t,e,a,s){for(;;)try{switch(t){case q.ERROR:case q.END:return t;case q.START:let i=a.getDataView(Ii);if(!i)return t;e.dbfHeader=ph(i),e.progress={bytesUsed:0,rowsTotal:e.dbfHeader.nRecords,rows:0},t=q.FIELD_DESCRIPTORS;break;case q.FIELD_DESCRIPTORS:let r=a.getDataView(e.dbfHeader.headerLength-Ii);if(!r)return t;e.dbfFields=vh(r,s),e.schema={fields:e.dbfFields.map(o=>Eh(o)),metadata:{}},t=q.FIELD_PROPERTIES,a.skip(1);break;case q.FIELD_PROPERTIES:let{recordLength:n=0,nRecords:h=0}=e?.dbfHeader||{};for(;e.data.length<h;){let o=a.getDataView(n-1);if(!o)return t;a.skip(1);let l=yh(o,e.dbfFields,s);e.data.push(l),e.progress.rows=e.data.length}t=q.END;break;default:return t=q.ERROR,e.error=`illegal parser state ${t}`,t}}catch(i){return t=q.ERROR,e.error=`DBF parsing failed: ${i.message}`,t}}function ph(t){return{year:t.getUint8(1)+1900,month:t.getUint8(2),day:t.getUint8(3),nRecords:t.getUint32(4,qe),headerLength:t.getUint16(8,qe),recordLength:t.getUint16(10,qe),languageDriver:t.getUint8(29)}}function vh(t,e){let a=(t.byteLength-1)/32,s=[],i=0;for(let r=0;r<a;r++){let n=e.decode(new Uint8Array(t.buffer,t.byteOffset+i,11)).replace(/\u0000/g,"");s.push({name:n,dataType:String.fromCharCode(t.getUint8(i+11)),fieldLength:t.getUint8(i+16),decimal:t.getUint8(i+17)}),i+=32}return s}function yh(t,e,a){let s={},i=0;for(let r of e){let n=a.decode(new Uint8Array(t.buffer,t.byteOffset+i,r.fieldLength));s[r.name]=xh(n,r.dataType),i+=r.fieldLength}return s}function xh(t,e){switch(e){case"B":return Me(t);case"C":return bh(t);case"F":return Me(t);case"N":return Me(t);case"O":return Me(t);case"D":return gh(t);case"L":return _h(t);default:throw new Error("Unsupported data type")}}function gh(t){return Date.UTC(t.slice(0,4),parseInt(t.slice(4,6),10)-1,t.slice(6,8))}function _h(t){return/^[nf]$/i.test(t)?!1:/^[yt]$/i.test(t)?!0:null}function Me(t){let e=parseFloat(t);return isNaN(e)?null:e}function bh(t){return t.trim()||null}function Eh({name:t,dataType:e,fieldLength:a,decimal:s}){switch(e){case"B":return{name:t,type:"float64",nullable:!0,metadata:{}};case"C":return{name:t,type:"utf8",nullable:!0,metadata:{}};case"F":return{name:t,type:"float64",nullable:!0,metadata:{}};case"N":return{name:t,type:"float64",nullable:!0,metadata:{}};case"O":return{name:t,type:"float64",nullable:!0,metadata:{}};case"D":return{name:t,type:"timestamp-millisecond",nullable:!0,metadata:{}};case"L":return{name:t,type:"bool",nullable:!0,metadata:{}};default:throw new Error("Unsupported data type")}}var Ih="4.2.0-beta.2",je={name:"DBF",dataType:null,batchType:null,id:"dbf",module:"shapefile",version:Ih,worker:!0,category:"table",extensions:["dbf"],mimeTypes:["application/x-dbf"],options:{dbf:{encoding:"latin1"}}},Ft={...je,parse:async(t,e)=>ze(t,e),parseSync:ze,parseInBatches(t,e){return Ai(t,e)}};async function*Si(t,e,a){let{reproject:s=!1,_targetCrs:i="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Li(e,a),o=await Qt(t,Nt,e,a),l=o[Symbol.asyncIterator]?.()||o[Symbol.iterator]?.(),u=null,f=await a?.fetch(qt(a?.url||"","dbf"));if(f?.ok){let x=await Qt(f,Ft,{...e,dbf:{encoding:n||"latin1"}},a);u=x[Symbol.asyncIterator]?.()||x[Symbol.iterator]()}let c=(await l.next()).value;c&&c.batchType==="metadata"&&(c=(await l.next()).value);let M={};u&&(M=(await u.next()).value,M&&M.batchType==="metadata"&&(M=(await u.next()).value));let d=u?me(l,u,"object-row-table"):l,y={[Symbol.asyncIterator](){return d}};for await(let x of y){let g,b;u?[g,b]=x.data:g=x;let E=wi(g),N=Ri(E,b);s&&(N=Ci(N,h,i)),yield{encoding:n,prj:h,shx:r,header:c,data:N}}}async function Ni(t,e,a){let{reproject:s=!1,_targetCrs:i="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Li(e,a),{header:o,geometries:l}=await Xt(t,Nt,e,a),u=wi(l),f,c=await a?.fetch(qt(a?.url,"dbf"));c?.ok&&(f=await Xt(c,Ft,{dbf:{shape:"object-row-table",encoding:n||"latin1"}},a));let M=Ri(u,f?.data||[]);switch(s&&(M=Ci(M,h,i)),e?.shapefile?.shape){case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",encoding:n,schema:f?.schema||{metadata:{},fields:[]},prj:h,shx:r,header:o,features:M};default:return{encoding:n,prj:h,shx:r,header:o,data:M}}}function wi(t){let e=[];for(let a of t)e.push(Pe(a));return e}function Ri(t,e){let a=[];for(let s=0;s<t.length;s++){let r={type:"Feature",geometry:t[s],properties:e&&e[s]||{}};a.push(r)}return a}function Ci(t,e,a){if(!e&&!a)return t;let s=new Gt({from:e||"WGS84",to:a||"WGS84"});return Ae(t,i=>s.project(i))}async function Li(t,e){let{url:a,fetch:s}=e,i=s(qt(a,"shx")),r=s(qt(a,"cpg")),n=s(qt(a,"prj"));await Promise.all([i,r,n]);let h,o,l,u=await i;if(u.ok){let M=await u.arrayBuffer();h=Ei(M)}let f=await r;f.ok&&(o=await f.text());let c=await n;return c.ok&&(l=await c.text()),{shx:h,cpg:o,prj:l}}function qt(t,e){let a=Ph(t),s=Ah(t);return s===s.toUpperCase()&&(e=e.toUpperCase()),`${a}.${e}`}function Ph(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(0,e):"":e}function Ah(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(e+1):"":e}var Sh="4.2.0-beta.2",Ti={name:"Shapefile",id:"shapefile",module:"shapefile",version:Sh,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(ge).buffer],options:{shapefile:{shape:"v3"},shp:{_maxDimensions:4}},parse:Ni,parseInBatches:Si};var pe=class{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 Hi(zt);})();
|
|
10
|
+
northing meters`+t;var c=f/2,M=0,d=0,y,x,g,b,E;return c>0&&(y=1e5/Math.pow(10,c),x=t.substring(r,r+c),M=parseFloat(x)*y,g=t.substring(r+c),d=parseFloat(g)*y),b=M+l,E=d+u,{easting:b,northing:E,zoneLetter:h,zoneNumber:n,accuracy:y}}function Ts(t,e){for(var a=Ra.charCodeAt(e-1),s=1e5,i=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Dt){if(i)throw"Bad character: "+t;a=bt,i=!0}s+=1e5}return s}function Ds(t,e){if(t>"V")throw"MGRSPoint given invalid Northing "+t;for(var a=Ca.charCodeAt(e-1),s=0,i=!1;a!==t.charCodeAt(0);){if(a++,a===z&&a++,a===W&&a++,a>Tt){if(i)throw"Bad character: "+t;a=bt,i=!0}s+=1e5}return s}function Os(t){var e;switch(t){case"C":e=11e5;break;case"D":e=2e6;break;case"E":e=28e5;break;case"F":e=37e5;break;case"G":e=46e5;break;case"H":e=55e5;break;case"J":e=64e5;break;case"K":e=73e5;break;case"L":e=82e5;break;case"M":e=91e5;break;case"N":e=0;break;case"P":e=8e5;break;case"Q":e=17e5;break;case"R":e=26e5;break;case"S":e=35e5;break;case"T":e=44e5;break;case"U":e=53e5;break;case"V":e=62e5;break;case"W":e=7e6;break;case"X":e=79e5;break;default:e=-1}if(e>=0)return e;throw"Invalid zone letter: "+t}function Et(t,e,a){if(!(this instanceof Et))return new Et(t,e,a);if(Array.isArray(t))this.x=t[0],this.y=t[1],this.z=t[2]||0;else if(typeof t=="object")this.x=t.x,this.y=t.y,this.z=t.z||0;else if(typeof t=="string"&&typeof e>"u"){var s=t.split(",");this.x=parseFloat(s[0],10),this.y=parseFloat(s[1],10),this.z=parseFloat(s[2],10)||0}else this.x=t,this.y=e,this.z=a||0;console.warn("proj4.Point will be removed in version 3, use proj4.toPoint")}Et.fromMGRS=function(t){return new Et(Te(t))};Et.prototype.toMGRS=function(t){return Le([this.x,this.y],t)};var Oa=Et;var Bs=1,Gs=.25,Ba=.046875,Ga=.01953125,Fa=.01068115234375,Fs=.75,qs=.46875,zs=.013020833333333334,js=.007120768229166667,ks=.3645833333333333,Hs=.005696614583333333,Us=.3076171875;function re(t){var e=[];e[0]=Bs-t*(Gs+t*(Ba+t*(Ga+t*Fa))),e[1]=t*(Fs-t*(Ba+t*(Ga+t*Fa)));var a=t*t;return e[2]=a*(qs-t*(zs+t*js)),a*=t,e[3]=a*(ks-t*Hs),e[4]=a*t*Us,e}function vt(t,e,a,s){return a*=e,e*=e,s[0]*t-a*(s[1]+e*(s[2]+e*(s[3]+e*s[4])))}var Ws=20;function ne(t,e,a){for(var s=1/(1-e),i=t,r=Ws;r;--r){var n=Math.sin(i),h=1-e*n*n;if(h=(vt(i,n,Math.cos(i),a)-t)*(h*Math.sqrt(h))*s,i-=h,Math.abs(h)<p)return i}return i}function Js(){this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0,this.lat0=this.lat0!==void 0?this.lat0:0,this.es&&(this.en=re(this.es),this.ml0=vt(this.lat0,Math.sin(this.lat0),Math.cos(this.lat0),this.en))}function Xs(t){var e=t.x,a=t.y,s=v(e-this.long0),i,r,n,h=Math.sin(a),o=Math.cos(a);if(this.es){var u=o*s,f=Math.pow(u,2),c=this.ep2*Math.pow(o,2),M=Math.pow(c,2),d=Math.abs(o)>p?Math.tan(a):0,y=Math.pow(d,2),x=Math.pow(y,2);i=1-this.es*Math.pow(h,2),u=u/Math.sqrt(i);var g=vt(a,h,o,this.en);r=this.a*(this.k0*u*(1+f/6*(1-y+c+f/20*(5-18*y+x+14*c-58*y*c+f/42*(61+179*x-x*y-479*y)))))+this.x0,n=this.a*(this.k0*(g-this.ml0+h*s*u/2*(1+f/12*(5-y+9*c+4*M+f/30*(61+x-58*y+270*c-330*y*c+f/56*(1385+543*x-x*y-3111*y))))))+this.y0}else{var l=o*Math.sin(s);if(Math.abs(Math.abs(l)-1)<p)return 93;if(r=.5*this.a*this.k0*Math.log((1+l)/(1-l))+this.x0,n=o*Math.cos(s)/Math.sqrt(1-Math.pow(l,2)),l=Math.abs(n),l>=1){if(l-1>p)return 93;n=0}else n=Math.acos(n);a<0&&(n=-n),n=this.a*this.k0*(n-this.lat0)+this.y0}return t.x=r,t.y=n,t}function Qs(t){var e,a,s,i,r=(t.x-this.x0)*(1/this.a),n=(t.y-this.y0)*(1/this.a);if(this.es)if(e=this.ml0+n/this.k0,a=ne(e,this.es,this.en),Math.abs(a)<m){var f=Math.sin(a),c=Math.cos(a),M=Math.abs(c)>p?Math.tan(a):0,d=this.ep2*Math.pow(c,2),y=Math.pow(d,2),x=Math.pow(M,2),g=Math.pow(x,2);e=1-this.es*Math.pow(f,2);var b=r*Math.sqrt(e)/this.k0,E=Math.pow(b,2);e=e*M,s=a-e*E/(1-this.es)*.5*(1-E/12*(5+3*x-9*d*x+d-4*y-E/30*(61+90*x-252*d*x+45*g+46*d-E/56*(1385+3633*x+4095*g+1574*g*x)))),i=v(this.long0+b*(1-E/6*(1+2*x+d-E/20*(5+28*x+24*g+8*d*x+6*d-E/42*(61+662*x+1320*g+720*g*x))))/c)}else s=m*$(n),i=0;else{var h=Math.exp(r/this.k0),o=.5*(h-1/h),l=this.lat0+n/this.k0,u=Math.cos(l);e=Math.sqrt((1-Math.pow(u,2))/(1+Math.pow(o,2))),s=Math.asin(e),n<0&&(s=-s),o===0&&u===0?i=0:i=v(Math.atan2(o,u)+this.long0)}return t.x=i,t.y=s,t}var Vs=["Transverse_Mercator","Transverse Mercator","tmerc"],qa={init:Js,forward:Xs,inverse:Qs,names:Vs};function he(t){var e=Math.exp(t);return e=(e-1/e)/2,e}function Ot(t,e){t=Math.abs(t),e=Math.abs(e);var a=Math.max(t,e),s=Math.min(t,e)/(a||1);return a*Math.sqrt(1+Math.pow(s,2))}function za(t){var e=1+t,a=e-1;return a===0?t:t*Math.log(e)/a}function ja(t){var e=Math.abs(t);return e=za(e*(1+e/(Ot(1,e)+1))),t<0?-e:e}function oe(t,e){for(var a=2*Math.cos(2*e),s=t.length-1,i=t[s],r=0,n;--s>=0;)n=-r+a*i+t[s],r=i,i=n;return e+n*Math.sin(2*e)}function ka(t,e){for(var a=2*Math.cos(e),s=t.length-1,i=t[s],r=0,n;--s>=0;)n=-r+a*i+t[s],r=i,i=n;return Math.sin(e)*n}function Ha(t){var e=Math.exp(t);return e=(e+1/e)/2,e}function Oe(t,e,a){for(var s=Math.sin(e),i=Math.cos(e),r=he(a),n=Ha(a),h=2*i*n,o=-2*s*r,l=t.length-1,u=t[l],f=0,c=0,M=0,d,y;--l>=0;)d=c,y=f,c=u,f=M,u=-d+h*c-o*f+t[l],M=-y+o*c+h*f;return h=s*n,o=i*r,[h*u-o*M,h*M+o*u]}function Ks(){if(this.es===void 0||this.es<=0)throw new Error("incorrect elliptical usage");this.x0=this.x0!==void 0?this.x0:0,this.y0=this.y0!==void 0?this.y0:0,this.long0=this.long0!==void 0?this.long0:0,this.lat0=this.lat0!==void 0?this.lat0:0,this.cgb=[],this.cbg=[],this.utg=[],this.gtu=[];var t=this.es/(1+Math.sqrt(1-this.es)),e=t/(2-t),a=e;this.cgb[0]=e*(2+e*(-2/3+e*(-2+e*(116/45+e*(26/45+e*(-2854/675)))))),this.cbg[0]=e*(-2+e*(2/3+e*(4/3+e*(-82/45+e*(32/45+e*(4642/4725)))))),a=a*e,this.cgb[1]=a*(7/3+e*(-8/5+e*(-227/45+e*(2704/315+e*(2323/945))))),this.cbg[1]=a*(5/3+e*(-16/15+e*(-13/9+e*(904/315+e*(-1522/945))))),a=a*e,this.cgb[2]=a*(56/15+e*(-136/35+e*(-1262/105+e*(73814/2835)))),this.cbg[2]=a*(-26/15+e*(34/21+e*(8/5+e*(-12686/2835)))),a=a*e,this.cgb[3]=a*(4279/630+e*(-332/35+e*(-399572/14175))),this.cbg[3]=a*(1237/630+e*(-12/5+e*(-24832/14175))),a=a*e,this.cgb[4]=a*(4174/315+e*(-144838/6237)),this.cbg[4]=a*(-734/315+e*(109598/31185)),a=a*e,this.cgb[5]=a*(601676/22275),this.cbg[5]=a*(444337/155925),a=Math.pow(e,2),this.Qn=this.k0/(1+e)*(1+a*(1/4+a*(1/64+a/256))),this.utg[0]=e*(-.5+e*(2/3+e*(-37/96+e*(1/360+e*(81/512+e*(-96199/604800)))))),this.gtu[0]=e*(.5+e*(-2/3+e*(5/16+e*(41/180+e*(-127/288+e*(7891/37800)))))),this.utg[1]=a*(-1/48+e*(-1/15+e*(437/1440+e*(-46/105+e*(1118711/3870720))))),this.gtu[1]=a*(13/48+e*(-3/5+e*(557/1440+e*(281/630+e*(-1983433/1935360))))),a=a*e,this.utg[2]=a*(-17/480+e*(37/840+e*(209/4480+e*(-5569/90720)))),this.gtu[2]=a*(61/240+e*(-103/140+e*(15061/26880+e*(167603/181440)))),a=a*e,this.utg[3]=a*(-4397/161280+e*(11/504+e*(830251/7257600))),this.gtu[3]=a*(49561/161280+e*(-179/168+e*(6601661/7257600))),a=a*e,this.utg[4]=a*(-4583/161280+e*(108847/3991680)),this.gtu[4]=a*(34729/80640+e*(-3418889/1995840)),a=a*e,this.utg[5]=a*(-20648693/638668800),this.gtu[5]=a*(212378941/319334400);var s=oe(this.cbg,this.lat0);this.Zb=-this.Qn*(s+ka(this.gtu,2*s))}function Ys(t){var e=v(t.x-this.long0),a=t.y;a=oe(this.cbg,a);var s=Math.sin(a),i=Math.cos(a),r=Math.sin(e),n=Math.cos(e);a=Math.atan2(s,n*i),e=Math.atan2(r*i,Ot(s,i*n)),e=ja(Math.tan(e));var h=Oe(this.gtu,2*a,2*e);a=a+h[0],e=e+h[1];var o,l;return Math.abs(e)<=2.623395162778?(o=this.a*(this.Qn*e)+this.x0,l=this.a*(this.Qn*a+this.Zb)+this.y0):(o=1/0,l=1/0),t.x=o,t.y=l,t}function Zs(t){var e=(t.x-this.x0)*(1/this.a),a=(t.y-this.y0)*(1/this.a);a=(a-this.Zb)/this.Qn,e=e/this.Qn;var s,i;if(Math.abs(e)<=2.623395162778){var r=Oe(this.utg,2*a,2*e);a=a+r[0],e=e+r[1],e=Math.atan(he(e));var n=Math.sin(a),h=Math.cos(a),o=Math.sin(e),l=Math.cos(e);a=Math.atan2(n*l,Ot(o,l*h)),e=Math.atan2(o,l*h),s=v(e+this.long0),i=oe(this.cgb,a)}else s=1/0,i=1/0;return t.x=s,t.y=i,t}var $s=["Extended_Transverse_Mercator","Extended Transverse Mercator","etmerc"],It={init:Ks,forward:Ys,inverse:Zs,names:$s};function Ua(t,e){if(t===void 0){if(t=Math.floor((v(e)+Math.PI)*30/Math.PI)+1,t<0)return 0;if(t>60)return 60}return t}var tr="etmerc";function er(){var t=Ua(this.zone,this.long0);if(t===void 0)throw new Error("unknown utm zone");this.lat0=0,this.long0=(6*Math.abs(t)-183)*L,this.x0=5e5,this.y0=this.utmSouth?1e7:0,this.k0=.9996,It.init.apply(this),this.forward=It.forward,this.inverse=It.inverse}var ar=["Universal Transverse Mercator System","utm"],Wa={init:er,names:ar,dependsOn:tr};function le(t,e){return Math.pow((1-t)/(1+t),e)}var ir=20;function sr(){var t=Math.sin(this.lat0),e=Math.cos(this.lat0);e*=e,this.rc=Math.sqrt(1-this.es)/(1-this.es*t*t),this.C=Math.sqrt(1+this.es*e*e/(1-this.es)),this.phic0=Math.asin(t/this.C),this.ratexp=.5*this.C*this.e,this.K=Math.tan(.5*this.phic0+I)/(Math.pow(Math.tan(.5*this.lat0+I),this.C)*le(this.e*t,this.ratexp))}function rr(t){var e=t.x,a=t.y;return t.y=2*Math.atan(this.K*Math.pow(Math.tan(.5*a+I),this.C)*le(this.e*Math.sin(a),this.ratexp))-m,t.x=this.C*e,t}function nr(t){for(var e=1e-14,a=t.x/this.C,s=t.y,i=Math.pow(Math.tan(.5*s+I)/this.K,1/this.C),r=ir;r>0&&(s=2*Math.atan(i*le(this.e*Math.sin(t.y),-.5*this.e))-m,!(Math.abs(s-t.y)<e));--r)t.y=s;return r?(t.x=a,t.y=s,t):null}var hr=["gauss"],fe={init:sr,forward:rr,inverse:nr,names:hr};function or(){fe.init.apply(this),this.rc&&(this.sinc0=Math.sin(this.phic0),this.cosc0=Math.cos(this.phic0),this.R2=2*this.rc,this.title||(this.title="Oblique Stereographic Alternative"))}function lr(t){var e,a,s,i;return t.x=v(t.x-this.long0),fe.forward.apply(this,[t]),e=Math.sin(t.y),a=Math.cos(t.y),s=Math.cos(t.x),i=this.k0*this.R2/(1+this.sinc0*e+this.cosc0*a*s),t.x=i*a*Math.sin(t.x),t.y=i*(this.cosc0*e-this.sinc0*a*s),t.x=this.a*t.x+this.x0,t.y=this.a*t.y+this.y0,t}function fr(t){var e,a,s,i,r;if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,r=Math.sqrt(t.x*t.x+t.y*t.y)){var n=2*Math.atan2(r,this.R2);e=Math.sin(n),a=Math.cos(n),i=Math.asin(a*this.sinc0+t.y*e*this.cosc0/r),s=Math.atan2(t.x*e,r*this.cosc0*a-t.y*this.sinc0*e)}else i=this.phic0,s=0;return t.x=s,t.y=i,fe.inverse.apply(this,[t]),t.x=v(t.x+this.long0),t}var ur=["Stereographic_North_Pole","Oblique_Stereographic","Polar_Stereographic","sterea","Oblique Stereographic Alternative","Double_Stereographic"],Ja={init:or,forward:lr,inverse:fr,names:ur};function cr(t,e,a){return e*=a,Math.tan(.5*(m+t))*Math.pow((1-e)/(1+e),.5*a)}function mr(){this.coslat0=Math.cos(this.lat0),this.sinlat0=Math.sin(this.lat0),this.sphere?this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=p&&(this.k0=.5*(1+$(this.lat0)*Math.sin(this.lat_ts))):(Math.abs(this.coslat0)<=p&&(this.lat0>0?this.con=1:this.con=-1),this.cons=Math.sqrt(Math.pow(1+this.e,1+this.e)*Math.pow(1-this.e,1-this.e)),this.k0===1&&!isNaN(this.lat_ts)&&Math.abs(this.coslat0)<=p&&(this.k0=.5*this.cons*B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts))/F(this.e,this.con*this.lat_ts,this.con*Math.sin(this.lat_ts))),this.ms1=B(this.e,this.sinlat0,this.coslat0),this.X0=2*Math.atan(this.ssfn_(this.lat0,this.sinlat0,this.e))-m,this.cosX0=Math.cos(this.X0),this.sinX0=Math.sin(this.X0))}function Mr(t){var e=t.x,a=t.y,s=Math.sin(a),i=Math.cos(a),r,n,h,o,l,u,f=v(e-this.long0);return Math.abs(Math.abs(e-this.long0)-Math.PI)<=p&&Math.abs(a+this.lat0)<=p?(t.x=NaN,t.y=NaN,t):this.sphere?(r=2*this.k0/(1+this.sinlat0*s+this.coslat0*i*Math.cos(f)),t.x=this.a*r*i*Math.sin(f)+this.x0,t.y=this.a*r*(this.coslat0*s-this.sinlat0*i*Math.cos(f))+this.y0,t):(n=2*Math.atan(this.ssfn_(a,s,this.e))-m,o=Math.cos(n),h=Math.sin(n),Math.abs(this.coslat0)<=p?(l=F(this.e,a*this.con,this.con*s),u=2*this.a*this.k0*l/this.cons,t.x=this.x0+u*Math.sin(e-this.long0),t.y=this.y0-this.con*u*Math.cos(e-this.long0),t):(Math.abs(this.sinlat0)<p?(r=2*this.a*this.k0/(1+o*Math.cos(f)),t.y=r*h):(r=2*this.a*this.k0*this.ms1/(this.cosX0*(1+this.sinX0*h+this.cosX0*o*Math.cos(f))),t.y=r*(this.cosX0*h-this.sinX0*o*Math.cos(f))+this.y0),t.x=r*o*Math.sin(f)+this.x0,t))}function dr(t){t.x-=this.x0,t.y-=this.y0;var e,a,s,i,r,n=Math.sqrt(t.x*t.x+t.y*t.y);if(this.sphere){var h=2*Math.atan(n/(2*this.a*this.k0));return e=this.long0,a=this.lat0,n<=p?(t.x=e,t.y=a,t):(a=Math.asin(Math.cos(h)*this.sinlat0+t.y*Math.sin(h)*this.coslat0/n),Math.abs(this.coslat0)<p?this.lat0>0?e=v(this.long0+Math.atan2(t.x,-1*t.y)):e=v(this.long0+Math.atan2(t.x,t.y)):e=v(this.long0+Math.atan2(t.x*Math.sin(h),n*this.coslat0*Math.cos(h)-t.y*this.sinlat0*Math.sin(h))),t.x=e,t.y=a,t)}else if(Math.abs(this.coslat0)<=p){if(n<=p)return a=this.lat0,e=this.long0,t.x=e,t.y=a,t;t.x*=this.con,t.y*=this.con,s=n*this.cons/(2*this.a*this.k0),a=this.con*at(this.e,s),e=this.con*v(this.con*this.long0+Math.atan2(t.x,-1*t.y))}else i=2*Math.atan(n*this.cosX0/(2*this.a*this.k0*this.ms1)),e=this.long0,n<=p?r=this.X0:(r=Math.asin(Math.cos(i)*this.sinX0+t.y*Math.sin(i)*this.cosX0/n),e=v(this.long0+Math.atan2(t.x*Math.sin(i),n*this.cosX0*Math.cos(i)-t.y*this.sinX0*Math.sin(i)))),a=-1*at(this.e,Math.tan(.5*(m+r)));return t.x=e,t.y=a,t}var pr=["stere","Stereographic_South_Pole","Polar Stereographic (variant B)"],Xa={init:mr,forward:Mr,inverse:dr,names:pr,ssfn_:cr};function vr(){var t=this.lat0;this.lambda0=this.long0;var e=Math.sin(t),a=this.a,s=this.rf,i=1/s,r=2*i-Math.pow(i,2),n=this.e=Math.sqrt(r);this.R=this.k0*a*Math.sqrt(1-r)/(1-r*Math.pow(e,2)),this.alpha=Math.sqrt(1+r/(1-r)*Math.pow(Math.cos(t),4)),this.b0=Math.asin(e/this.alpha);var h=Math.log(Math.tan(Math.PI/4+this.b0/2)),o=Math.log(Math.tan(Math.PI/4+t/2)),l=Math.log((1+n*e)/(1-n*e));this.K=h-this.alpha*o+this.alpha*n/2*l}function yr(t){var e=Math.log(Math.tan(Math.PI/4-t.y/2)),a=this.e/2*Math.log((1+this.e*Math.sin(t.y))/(1-this.e*Math.sin(t.y))),s=-this.alpha*(e+a)+this.K,i=2*(Math.atan(Math.exp(s))-Math.PI/4),r=this.alpha*(t.x-this.lambda0),n=Math.atan(Math.sin(r)/(Math.sin(this.b0)*Math.tan(i)+Math.cos(this.b0)*Math.cos(r))),h=Math.asin(Math.cos(this.b0)*Math.sin(i)-Math.sin(this.b0)*Math.cos(i)*Math.cos(r));return t.y=this.R/2*Math.log((1+Math.sin(h))/(1-Math.sin(h)))+this.y0,t.x=this.R*n+this.x0,t}function xr(t){for(var e=t.x-this.x0,a=t.y-this.y0,s=e/this.R,i=2*(Math.atan(Math.exp(a/this.R))-Math.PI/4),r=Math.asin(Math.cos(this.b0)*Math.sin(i)+Math.sin(this.b0)*Math.cos(i)*Math.cos(s)),n=Math.atan(Math.sin(s)/(Math.cos(this.b0)*Math.cos(s)-Math.sin(this.b0)*Math.tan(i))),h=this.lambda0+n/this.alpha,o=0,l=r,u=-1e3,f=0;Math.abs(l-u)>1e-7;){if(++f>20)return;o=1/this.alpha*(Math.log(Math.tan(Math.PI/4+r/2))-this.K)+this.e*Math.log(Math.tan(Math.PI/4+Math.asin(this.e*Math.sin(l))/2)),u=l,l=2*Math.atan(Math.exp(o))-Math.PI/2}return t.x=h,t.y=l,t}var gr=["somerc"],Qa={init:vr,forward:yr,inverse:xr,names:gr};function _r(){this.no_off=this.no_off||!1,this.no_rot=this.no_rot||!1,isNaN(this.k0)&&(this.k0=1);var t=Math.sin(this.lat0),e=Math.cos(this.lat0),a=this.e*t;this.bl=Math.sqrt(1+this.es/(1-this.es)*Math.pow(e,4)),this.al=this.a*this.bl*this.k0*Math.sqrt(1-this.es)/(1-a*a);var s=F(this.e,this.lat0,t),i=this.bl/e*Math.sqrt((1-this.es)/(1-a*a));i*i<1&&(i=1);var r,n;if(!isNaN(this.longc))this.lat0>=0?r=i+Math.sqrt(i*i-1):r=i-Math.sqrt(i*i-1),this.el=r*Math.pow(s,this.bl),n=.5*(r-1/r),this.gamma0=Math.asin(Math.sin(this.alpha)/i),this.long0=this.longc-Math.asin(n*Math.tan(this.gamma0))/this.bl;else{var h=F(this.e,this.lat1,Math.sin(this.lat1)),o=F(this.e,this.lat2,Math.sin(this.lat2));this.lat0>=0?this.el=(i+Math.sqrt(i*i-1))*Math.pow(s,this.bl):this.el=(i-Math.sqrt(i*i-1))*Math.pow(s,this.bl);var l=Math.pow(h,this.bl),u=Math.pow(o,this.bl);r=this.el/l,n=.5*(r-1/r);var f=(this.el*this.el-u*l)/(this.el*this.el+u*l),c=(u-l)/(u+l),M=v(this.long1-this.long2);this.long0=.5*(this.long1+this.long2)-Math.atan(f*Math.tan(.5*this.bl*M)/c)/this.bl,this.long0=v(this.long0);var d=v(this.long1-this.long0);this.gamma0=Math.atan(Math.sin(this.bl*d)/n),this.alpha=Math.asin(i*Math.sin(this.gamma0))}this.no_off?this.uc=0:this.lat0>=0?this.uc=this.al/this.bl*Math.atan2(Math.sqrt(i*i-1),Math.cos(this.alpha)):this.uc=-1*this.al/this.bl*Math.atan2(Math.sqrt(i*i-1),Math.cos(this.alpha))}function br(t){var e=t.x,a=t.y,s=v(e-this.long0),i,r,n;if(Math.abs(Math.abs(a)-m)<=p)a>0?n=-1:n=1,r=this.al/this.bl*Math.log(Math.tan(I+n*this.gamma0*.5)),i=-1*n*m*this.al/this.bl;else{var h=F(this.e,a,Math.sin(a)),o=this.el/Math.pow(h,this.bl),l=.5*(o-1/o),u=.5*(o+1/o),f=Math.sin(this.bl*s),c=(l*Math.sin(this.gamma0)-f*Math.cos(this.gamma0))/u;Math.abs(Math.abs(c)-1)<=p?r=Number.POSITIVE_INFINITY:r=.5*this.al*Math.log((1-c)/(1+c))/this.bl,Math.abs(Math.cos(this.bl*s))<=p?i=this.al*this.bl*s:i=this.al*Math.atan2(l*Math.cos(this.gamma0)+f*Math.sin(this.gamma0),Math.cos(this.bl*s))/this.bl}return this.no_rot?(t.x=this.x0+i,t.y=this.y0+r):(i-=this.uc,t.x=this.x0+r*Math.cos(this.alpha)+i*Math.sin(this.alpha),t.y=this.y0+i*Math.cos(this.alpha)-r*Math.sin(this.alpha)),t}function Er(t){var e,a;this.no_rot?(a=t.y-this.y0,e=t.x-this.x0):(a=(t.x-this.x0)*Math.cos(this.alpha)-(t.y-this.y0)*Math.sin(this.alpha),e=(t.y-this.y0)*Math.cos(this.alpha)+(t.x-this.x0)*Math.sin(this.alpha),e+=this.uc);var s=Math.exp(-1*this.bl*a/this.al),i=.5*(s-1/s),r=.5*(s+1/s),n=Math.sin(this.bl*e/this.al),h=(n*Math.cos(this.gamma0)+i*Math.sin(this.gamma0))/r,o=Math.pow(this.el/Math.sqrt((1+h)/(1-h)),1/this.bl);return Math.abs(h-1)<p?(t.x=this.long0,t.y=m):Math.abs(h+1)<p?(t.x=this.long0,t.y=-1*m):(t.y=at(this.e,o),t.x=v(this.long0-Math.atan2(i*Math.cos(this.gamma0)-n*Math.sin(this.gamma0),Math.cos(this.bl*e/this.al))/this.bl)),t}var Ir=["Hotine_Oblique_Mercator","Hotine Oblique Mercator","Hotine_Oblique_Mercator_Azimuth_Natural_Origin","Hotine_Oblique_Mercator_Azimuth_Center","omerc"],Va={init:_r,forward:br,inverse:Er,names:Ir};function Pr(){if(this.lat2||(this.lat2=this.lat1),this.k0||(this.k0=1),this.x0=this.x0||0,this.y0=this.y0||0,!(Math.abs(this.lat1+this.lat2)<p)){var t=this.b/this.a;this.e=Math.sqrt(1-t*t);var e=Math.sin(this.lat1),a=Math.cos(this.lat1),s=B(this.e,e,a),i=F(this.e,this.lat1,e),r=Math.sin(this.lat2),n=Math.cos(this.lat2),h=B(this.e,r,n),o=F(this.e,this.lat2,r),l=F(this.e,this.lat0,Math.sin(this.lat0));Math.abs(this.lat1-this.lat2)>p?this.ns=Math.log(s/h)/Math.log(i/o):this.ns=e,isNaN(this.ns)&&(this.ns=e),this.f0=s/(this.ns*Math.pow(i,this.ns)),this.rh=this.a*this.f0*Math.pow(l,this.ns),this.title||(this.title="Lambert Conformal Conic")}}function Ar(t){var e=t.x,a=t.y;Math.abs(2*Math.abs(a)-Math.PI)<=p&&(a=$(a)*(m-2*p));var s=Math.abs(Math.abs(a)-m),i,r;if(s>p)i=F(this.e,a,Math.sin(a)),r=this.a*this.f0*Math.pow(i,this.ns);else{if(s=a*this.ns,s<=0)return null;r=0}var n=this.ns*v(e-this.long0);return t.x=this.k0*(r*Math.sin(n))+this.x0,t.y=this.k0*(this.rh-r*Math.cos(n))+this.y0,t}function Sr(t){var e,a,s,i,r,n=(t.x-this.x0)/this.k0,h=this.rh-(t.y-this.y0)/this.k0;this.ns>0?(e=Math.sqrt(n*n+h*h),a=1):(e=-Math.sqrt(n*n+h*h),a=-1);var o=0;if(e!==0&&(o=Math.atan2(a*n,a*h)),e!==0||this.ns>0){if(a=1/this.ns,s=Math.pow(e/(this.a*this.f0),a),i=at(this.e,s),i===-9999)return null}else i=-m;return r=v(o/this.ns+this.long0),t.x=r,t.y=i,t}var Nr=["Lambert Tangential Conformal Conic Projection","Lambert_Conformal_Conic","Lambert_Conformal_Conic_2SP","lcc"],Ka={init:Pr,forward:Ar,inverse:Sr,names:Nr};function wr(){this.a=6377397155e-3,this.es=.006674372230614,this.e=Math.sqrt(this.es),this.lat0||(this.lat0=.863937979737193),this.long0||(this.long0=.7417649320975901-.308341501185665),this.k0||(this.k0=.9999),this.s45=.785398163397448,this.s90=2*this.s45,this.fi0=this.lat0,this.e2=this.es,this.e=Math.sqrt(this.e2),this.alfa=Math.sqrt(1+this.e2*Math.pow(Math.cos(this.fi0),4)/(1-this.e2)),this.uq=1.04216856380474,this.u0=Math.asin(Math.sin(this.fi0)/this.alfa),this.g=Math.pow((1+this.e*Math.sin(this.fi0))/(1-this.e*Math.sin(this.fi0)),this.alfa*this.e/2),this.k=Math.tan(this.u0/2+this.s45)/Math.pow(Math.tan(this.fi0/2+this.s45),this.alfa)*this.g,this.k1=this.k0,this.n0=this.a*Math.sqrt(1-this.e2)/(1-this.e2*Math.pow(Math.sin(this.fi0),2)),this.s0=1.37008346281555,this.n=Math.sin(this.s0),this.ro0=this.k1*this.n0/Math.tan(this.s0),this.ad=this.s90-this.uq}function Rr(t){var e,a,s,i,r,n,h,o=t.x,l=t.y,u=v(o-this.long0);return e=Math.pow((1+this.e*Math.sin(l))/(1-this.e*Math.sin(l)),this.alfa*this.e/2),a=2*(Math.atan(this.k*Math.pow(Math.tan(l/2+this.s45),this.alfa)/e)-this.s45),s=-u*this.alfa,i=Math.asin(Math.cos(this.ad)*Math.sin(a)+Math.sin(this.ad)*Math.cos(a)*Math.cos(s)),r=Math.asin(Math.cos(a)*Math.sin(s)/Math.cos(i)),n=this.n*r,h=this.ro0*Math.pow(Math.tan(this.s0/2+this.s45),this.n)/Math.pow(Math.tan(i/2+this.s45),this.n),t.y=h*Math.cos(n)/1,t.x=h*Math.sin(n)/1,this.czech||(t.y*=-1,t.x*=-1),t}function Cr(t){var e,a,s,i,r,n,h,o,l=t.x;t.x=t.y,t.y=l,this.czech||(t.y*=-1,t.x*=-1),n=Math.sqrt(t.x*t.x+t.y*t.y),r=Math.atan2(t.y,t.x),i=r/Math.sin(this.s0),s=2*(Math.atan(Math.pow(this.ro0/n,1/this.n)*Math.tan(this.s0/2+this.s45))-this.s45),e=Math.asin(Math.cos(this.ad)*Math.sin(s)-Math.sin(this.ad)*Math.cos(s)*Math.cos(i)),a=Math.asin(Math.cos(s)*Math.sin(i)/Math.cos(e)),t.x=this.long0-a/this.alfa,h=e,o=0;var u=0;do t.y=2*(Math.atan(Math.pow(this.k,-1/this.alfa)*Math.pow(Math.tan(e/2+this.s45),1/this.alfa)*Math.pow((1+this.e*Math.sin(h))/(1-this.e*Math.sin(h)),this.e/2))-this.s45),Math.abs(h-t.y)<1e-10&&(o=1),h=t.y,u+=1;while(o===0&&u<15);return u>=15?null:t}var Lr=["Krovak","krovak"],Ya={init:wr,forward:Rr,inverse:Cr,names:Lr};function D(t,e,a,s,i){return t*i-e*Math.sin(2*i)+a*Math.sin(4*i)-s*Math.sin(6*i)}function it(t){return 1-.25*t*(1+t/16*(3+1.25*t))}function st(t){return .375*t*(1+.25*t*(1+.46875*t))}function rt(t){return .05859375*t*t*(1+.75*t)}function nt(t){return t*t*t*(35/3072)}function ht(t,e,a){var s=e*a;return t/Math.sqrt(1-s*s)}function K(t){return Math.abs(t)<m?t:t-$(t)*Math.PI}function yt(t,e,a,s,i){var r,n;r=t/e;for(var h=0;h<15;h++)if(n=(t-(e*r-a*Math.sin(2*r)+s*Math.sin(4*r)-i*Math.sin(6*r)))/(e-2*a*Math.cos(2*r)+4*s*Math.cos(4*r)-6*i*Math.cos(6*r)),r+=n,Math.abs(n)<=1e-10)return r;return NaN}function Tr(){this.sphere||(this.e0=it(this.es),this.e1=st(this.es),this.e2=rt(this.es),this.e3=nt(this.es),this.ml0=this.a*D(this.e0,this.e1,this.e2,this.e3,this.lat0))}function Dr(t){var e,a,s=t.x,i=t.y;if(s=v(s-this.long0),this.sphere)e=this.a*Math.asin(Math.cos(i)*Math.sin(s)),a=this.a*(Math.atan2(Math.tan(i),Math.cos(s))-this.lat0);else{var r=Math.sin(i),n=Math.cos(i),h=ht(this.a,this.e,r),o=Math.tan(i)*Math.tan(i),l=s*Math.cos(i),u=l*l,f=this.es*n*n/(1-this.es),c=this.a*D(this.e0,this.e1,this.e2,this.e3,i);e=h*l*(1-u*o*(1/6-(8-o+8*f)*u/120)),a=c-this.ml0+h*r/n*u*(.5+(5-o+6*f)*u/24)}return t.x=e+this.x0,t.y=a+this.y0,t}function Or(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,s,i;if(this.sphere){var r=a+this.lat0;s=Math.asin(Math.sin(r)*Math.cos(e)),i=Math.atan2(Math.tan(e),Math.cos(r))}else{var n=this.ml0/this.a+a,h=yt(n,this.e0,this.e1,this.e2,this.e3);if(Math.abs(Math.abs(h)-m)<=p)return t.x=this.long0,t.y=m,a<0&&(t.y*=-1),t;var o=ht(this.a,this.e,Math.sin(h)),l=o*o*o/this.a/this.a*(1-this.es),u=Math.pow(Math.tan(h),2),f=e*this.a/o,c=f*f;s=h-o*Math.tan(h)/l*f*f*(.5-(1+3*u)*f*f/24),i=f*(1-c*(u/3+(1+3*u)*u*c/15))/Math.cos(h)}return t.x=v(i+this.long0),t.y=K(s),t}var Br=["Cassini","Cassini_Soldner","cass"],Za={init:Tr,forward:Dr,inverse:Or,names:Br};function Y(t,e){var a;return t>1e-7?(a=t*e,(1-t*t)*(e/(1-a*a)-.5/t*Math.log((1-a)/(1+a)))):2*e}var Gr=1,Fr=2,qr=3,zr=4;function jr(){var t=Math.abs(this.lat0);if(Math.abs(t-m)<p?this.mode=this.lat0<0?this.S_POLE:this.N_POLE:Math.abs(t)<p?this.mode=this.EQUIT:this.mode=this.OBLIQ,this.es>0){var e;switch(this.qp=Y(this.e,1),this.mmf=.5/(1-this.es),this.apa=Kr(this.es),this.mode){case this.N_POLE:this.dd=1;break;case this.S_POLE:this.dd=1;break;case this.EQUIT:this.rq=Math.sqrt(.5*this.qp),this.dd=1/this.rq,this.xmf=1,this.ymf=.5*this.qp;break;case this.OBLIQ:this.rq=Math.sqrt(.5*this.qp),e=Math.sin(this.lat0),this.sinb1=Y(this.e,e)/this.qp,this.cosb1=Math.sqrt(1-this.sinb1*this.sinb1),this.dd=Math.cos(this.lat0)/(Math.sqrt(1-this.es*e*e)*this.rq*this.cosb1),this.ymf=(this.xmf=this.rq)/this.dd,this.xmf*=this.dd;break}}else this.mode===this.OBLIQ&&(this.sinph0=Math.sin(this.lat0),this.cosph0=Math.cos(this.lat0))}function kr(t){var e,a,s,i,r,n,h,o,l,u,f=t.x,c=t.y;if(f=v(f-this.long0),this.sphere){if(r=Math.sin(c),u=Math.cos(c),s=Math.cos(f),this.mode===this.OBLIQ||this.mode===this.EQUIT){if(a=this.mode===this.EQUIT?1+u*s:1+this.sinph0*r+this.cosph0*u*s,a<=p)return null;a=Math.sqrt(2/a),e=a*u*Math.sin(f),a*=this.mode===this.EQUIT?r:this.cosph0*r-this.sinph0*u*s}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(s=-s),Math.abs(c+this.lat0)<p)return null;a=I-c*.5,a=2*(this.mode===this.S_POLE?Math.cos(a):Math.sin(a)),e=a*Math.sin(f),a*=s}}else{switch(h=0,o=0,l=0,s=Math.cos(f),i=Math.sin(f),r=Math.sin(c),n=Y(this.e,r),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(h=n/this.qp,o=Math.sqrt(1-h*h)),this.mode){case this.OBLIQ:l=1+this.sinb1*h+this.cosb1*o*s;break;case this.EQUIT:l=1+o*s;break;case this.N_POLE:l=m+c,n=this.qp-n;break;case this.S_POLE:l=c-m,n=this.qp+n;break}if(Math.abs(l)<p)return null;switch(this.mode){case this.OBLIQ:case this.EQUIT:l=Math.sqrt(2/l),this.mode===this.OBLIQ?a=this.ymf*l*(this.cosb1*h-this.sinb1*o*s):a=(l=Math.sqrt(2/(1+o*s)))*h*this.ymf,e=this.xmf*l*o*i;break;case this.N_POLE:case this.S_POLE:n>=0?(e=(l=Math.sqrt(n))*i,a=s*(this.mode===this.S_POLE?l:-l)):e=a=0;break}}return t.x=this.a*e+this.x0,t.y=this.a*a+this.y0,t}function Hr(t){t.x-=this.x0,t.y-=this.y0;var e=t.x/this.a,a=t.y/this.a,s,i,r,n,h,o,l;if(this.sphere){var u=0,f,c=0;if(f=Math.sqrt(e*e+a*a),i=f*.5,i>1)return null;switch(i=2*Math.asin(i),(this.mode===this.OBLIQ||this.mode===this.EQUIT)&&(c=Math.sin(i),u=Math.cos(i)),this.mode){case this.EQUIT:i=Math.abs(f)<=p?0:Math.asin(a*c/f),e*=c,a=u*f;break;case this.OBLIQ:i=Math.abs(f)<=p?this.lat0:Math.asin(u*this.sinph0+a*c*this.cosph0/f),e*=c*this.cosph0,a=(u-Math.sin(i)*this.sinph0)*f;break;case this.N_POLE:a=-a,i=m-i;break;case this.S_POLE:i-=m;break}s=a===0&&(this.mode===this.EQUIT||this.mode===this.OBLIQ)?0:Math.atan2(e,a)}else{if(l=0,this.mode===this.OBLIQ||this.mode===this.EQUIT){if(e/=this.dd,a*=this.dd,o=Math.sqrt(e*e+a*a),o<p)return t.x=this.long0,t.y=this.lat0,t;n=2*Math.asin(.5*o/this.rq),r=Math.cos(n),e*=n=Math.sin(n),this.mode===this.OBLIQ?(l=r*this.sinb1+a*n*this.cosb1/o,h=this.qp*l,a=o*this.cosb1*r-a*this.sinb1*n):(l=a*n/o,h=this.qp*l,a=o*r)}else if(this.mode===this.N_POLE||this.mode===this.S_POLE){if(this.mode===this.N_POLE&&(a=-a),h=e*e+a*a,!h)return t.x=this.long0,t.y=this.lat0,t;l=1-h/this.qp,this.mode===this.S_POLE&&(l=-l)}s=Math.atan2(e,a),i=Yr(Math.asin(l),this.apa)}return t.x=v(this.long0+s),t.y=i,t}var Ur=.3333333333333333,Wr=.17222222222222222,Jr=.10257936507936508,Xr=.06388888888888888,Qr=.0664021164021164,Vr=.016415012942191543;function Kr(t){var e,a=[];return a[0]=t*Ur,e=t*t,a[0]+=e*Wr,a[1]=e*Xr,e*=t,a[0]+=e*Jr,a[1]+=e*Qr,a[2]=e*Vr,a}function Yr(t,e){var a=t+t;return t+e[0]*Math.sin(a)+e[1]*Math.sin(a+a)+e[2]*Math.sin(a+a+a)}var Zr=["Lambert Azimuthal Equal Area","Lambert_Azimuthal_Equal_Area","laea"],$a={init:jr,forward:kr,inverse:Hr,names:Zr,S_POLE:Gr,N_POLE:Fr,EQUIT:qr,OBLIQ:zr};function j(t){return Math.abs(t)>1&&(t=t>1?1:-1),Math.asin(t)}function $r(){Math.abs(this.lat1+this.lat2)<p||(this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e3=Math.sqrt(this.es),this.sin_po=Math.sin(this.lat1),this.cos_po=Math.cos(this.lat1),this.t1=this.sin_po,this.con=this.sin_po,this.ms1=B(this.e3,this.sin_po,this.cos_po),this.qs1=Y(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat2),this.cos_po=Math.cos(this.lat2),this.t2=this.sin_po,this.ms2=B(this.e3,this.sin_po,this.cos_po),this.qs2=Y(this.e3,this.sin_po,this.cos_po),this.sin_po=Math.sin(this.lat0),this.cos_po=Math.cos(this.lat0),this.t3=this.sin_po,this.qs0=Y(this.e3,this.sin_po,this.cos_po),Math.abs(this.lat1-this.lat2)>p?this.ns0=(this.ms1*this.ms1-this.ms2*this.ms2)/(this.qs2-this.qs1):this.ns0=this.con,this.c=this.ms1*this.ms1+this.ns0*this.qs1,this.rh=this.a*Math.sqrt(this.c-this.ns0*this.qs0)/this.ns0)}function tn(t){var e=t.x,a=t.y;this.sin_phi=Math.sin(a),this.cos_phi=Math.cos(a);var s=Y(this.e3,this.sin_phi,this.cos_phi),i=this.a*Math.sqrt(this.c-this.ns0*s)/this.ns0,r=this.ns0*v(e-this.long0),n=i*Math.sin(r)+this.x0,h=this.rh-i*Math.cos(r)+this.y0;return t.x=n,t.y=h,t}function en(t){var e,a,s,i,r,n;return t.x-=this.x0,t.y=this.rh-t.y+this.y0,this.ns0>=0?(e=Math.sqrt(t.x*t.x+t.y*t.y),s=1):(e=-Math.sqrt(t.x*t.x+t.y*t.y),s=-1),i=0,e!==0&&(i=Math.atan2(s*t.x,s*t.y)),s=e*this.ns0/this.a,this.sphere?n=Math.asin((this.c-s*s)/(2*this.ns0)):(a=(this.c-s*s)/this.ns0,n=this.phi1z(this.e3,a)),r=v(i/this.ns0+this.long0),t.x=r,t.y=n,t}function an(t,e){var a,s,i,r,n,h=j(.5*e);if(t<p)return h;for(var o=t*t,l=1;l<=25;l++)if(a=Math.sin(h),s=Math.cos(h),i=t*a,r=1-i*i,n=.5*r*r/s*(e/(1-o)-a/r+.5/t*Math.log((1-i)/(1+i))),h=h+n,Math.abs(n)<=1e-7)return h;return null}var sn=["Albers_Conic_Equal_Area","Albers","aea"],ti={init:$r,forward:tn,inverse:en,names:sn,phi1z:an};function rn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0),this.infinity_dist=1e3*this.a,this.rc=1}function nn(t){var e,a,s,i,r,n,h,o,l=t.x,u=t.y;return s=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),i=Math.cos(s),n=this.sin_p14*e+this.cos_p14*a*i,r=1,n>0||Math.abs(n)<=p?(h=this.x0+this.a*r*a*Math.sin(s)/n,o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*i)/n):(h=this.x0+this.infinity_dist*a*Math.sin(s),o=this.y0+this.infinity_dist*(this.cos_p14*e-this.sin_p14*a*i)),t.x=h,t.y=o,t}function hn(t){var e,a,s,i,r,n;return t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,t.x/=this.k0,t.y/=this.k0,(e=Math.sqrt(t.x*t.x+t.y*t.y))?(i=Math.atan2(e,this.rc),a=Math.sin(i),s=Math.cos(i),n=j(s*this.sin_p14+t.y*a*this.cos_p14/e),r=Math.atan2(t.x*a,e*this.cos_p14*s-t.y*this.sin_p14*a),r=v(this.long0+r)):(n=this.phic0,r=0),t.x=r,t.y=n,t}var on=["gnom"],ei={init:rn,forward:nn,inverse:hn,names:on};function ai(t,e){var a=1-(1-t*t)/(2*t)*Math.log((1-t)/(1+t));if(Math.abs(Math.abs(e)-a)<1e-6)return e<0?-1*m:m;for(var s=Math.asin(.5*e),i,r,n,h,o=0;o<30;o++)if(r=Math.sin(s),n=Math.cos(s),h=t*r,i=Math.pow(1-h*h,2)/(2*n)*(e/(1-t*t)-r/(1-h*h)+.5/t*Math.log((1-h)/(1+h))),s+=i,Math.abs(i)<=1e-10)return s;return NaN}function ln(){this.sphere||(this.k0=B(this.e,Math.sin(this.lat_ts),Math.cos(this.lat_ts)))}function fn(t){var e=t.x,a=t.y,s,i,r=v(e-this.long0);if(this.sphere)s=this.x0+this.a*r*Math.cos(this.lat_ts),i=this.y0+this.a*Math.sin(a)/Math.cos(this.lat_ts);else{var n=Y(this.e,Math.sin(a));s=this.x0+this.a*this.k0*r,i=this.y0+this.a*n*.5/this.k0}return t.x=s,t.y=i,t}function un(t){t.x-=this.x0,t.y-=this.y0;var e,a;return this.sphere?(e=v(this.long0+t.x/this.a/Math.cos(this.lat_ts)),a=Math.asin(t.y/this.a*Math.cos(this.lat_ts))):(a=ai(this.e,2*t.y*this.k0/this.a),e=v(this.long0+t.x/(this.a*this.k0))),t.x=e,t.y=a,t}var cn=["cea"],ii={init:ln,forward:fn,inverse:un,names:cn};function mn(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Equidistant Cylindrical (Plate Carre)",this.rc=Math.cos(this.lat_ts)}function Mn(t){var e=t.x,a=t.y,s=v(e-this.long0),i=K(a-this.lat0);return t.x=this.x0+this.a*s*this.rc,t.y=this.y0+this.a*i,t}function dn(t){var e=t.x,a=t.y;return t.x=v(this.long0+(e-this.x0)/(this.a*this.rc)),t.y=K(this.lat0+(a-this.y0)/this.a),t}var pn=["Equirectangular","Equidistant_Cylindrical","eqc"],si={init:mn,forward:Mn,inverse:dn,names:pn};var ri=20;function vn(){this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=it(this.es),this.e1=st(this.es),this.e2=rt(this.es),this.e3=nt(this.es),this.ml0=this.a*D(this.e0,this.e1,this.e2,this.e3,this.lat0)}function yn(t){var e=t.x,a=t.y,s,i,r,n=v(e-this.long0);if(r=n*Math.sin(a),this.sphere)Math.abs(a)<=p?(s=this.a*n,i=-1*this.a*this.lat0):(s=this.a*Math.sin(r)/Math.tan(a),i=this.a*(K(a-this.lat0)+(1-Math.cos(r))/Math.tan(a)));else if(Math.abs(a)<=p)s=this.a*n,i=-1*this.ml0;else{var h=ht(this.a,this.e,Math.sin(a))/Math.tan(a);s=h*Math.sin(r),i=this.a*D(this.e0,this.e1,this.e2,this.e3,a)-this.ml0+h*(1-Math.cos(r))}return t.x=s+this.x0,t.y=i+this.y0,t}function xn(t){var e,a,s,i,r,n,h,o,l;if(s=t.x-this.x0,i=t.y-this.y0,this.sphere)if(Math.abs(i+this.a*this.lat0)<=p)e=v(s/this.a+this.long0),a=0;else{n=this.lat0+i/this.a,h=s*s/this.a/this.a+n*n,o=n;var u;for(r=ri;r;--r)if(u=Math.tan(o),l=-1*(n*(o*u+1)-o-.5*(o*o+h)*u)/((o-n)/u-1),o+=l,Math.abs(l)<=p){a=o;break}e=v(this.long0+Math.asin(s*Math.tan(o)/this.a)/Math.sin(a))}else if(Math.abs(i+this.ml0)<=p)a=0,e=v(this.long0+s/this.a);else{n=(this.ml0+i)/this.a,h=s*s/this.a/this.a+n*n,o=n;var f,c,M,d,y;for(r=ri;r;--r)if(y=this.e*Math.sin(o),f=Math.sqrt(1-y*y)*Math.tan(o),c=this.a*D(this.e0,this.e1,this.e2,this.e3,o),M=this.e0-2*this.e1*Math.cos(2*o)+4*this.e2*Math.cos(4*o)-6*this.e3*Math.cos(6*o),d=c/this.a,l=(n*(f*d+1)-d-.5*f*(d*d+h))/(this.es*Math.sin(2*o)*(d*d+h-2*n*d)/(4*f)+(n-d)*(f*M-2/Math.sin(2*o))-M),o-=l,Math.abs(l)<=p){a=o;break}f=Math.sqrt(1-this.es*Math.pow(Math.sin(a),2))*Math.tan(a),e=v(this.long0+Math.asin(s*f/this.a)/Math.sin(a))}return t.x=e,t.y=a,t}var gn=["Polyconic","poly"],ni={init:vn,forward:yn,inverse:xn,names:gn};function _n(){this.A=[],this.A[1]=.6399175073,this.A[2]=-.1358797613,this.A[3]=.063294409,this.A[4]=-.02526853,this.A[5]=.0117879,this.A[6]=-.0055161,this.A[7]=.0026906,this.A[8]=-.001333,this.A[9]=67e-5,this.A[10]=-34e-5,this.B_re=[],this.B_im=[],this.B_re[1]=.7557853228,this.B_im[1]=0,this.B_re[2]=.249204646,this.B_im[2]=.003371507,this.B_re[3]=-.001541739,this.B_im[3]=.04105856,this.B_re[4]=-.10162907,this.B_im[4]=.01727609,this.B_re[5]=-.26623489,this.B_im[5]=-.36249218,this.B_re[6]=-.6870983,this.B_im[6]=-1.1651967,this.C_re=[],this.C_im=[],this.C_re[1]=1.3231270439,this.C_im[1]=0,this.C_re[2]=-.577245789,this.C_im[2]=-.007809598,this.C_re[3]=.508307513,this.C_im[3]=-.112208952,this.C_re[4]=-.15094762,this.C_im[4]=.18200602,this.C_re[5]=1.01418179,this.C_im[5]=1.64497696,this.C_re[6]=1.9660549,this.C_im[6]=2.5127645,this.D=[],this.D[1]=1.5627014243,this.D[2]=.5185406398,this.D[3]=-.03333098,this.D[4]=-.1052906,this.D[5]=-.0368594,this.D[6]=.007317,this.D[7]=.0122,this.D[8]=.00394,this.D[9]=-.0013}function bn(t){var e,a=t.x,s=t.y,i=s-this.lat0,r=a-this.long0,n=i/Mt*1e-5,h=r,o=1,l=0;for(e=1;e<=10;e++)o=o*n,l=l+this.A[e]*o;var u=l,f=h,c=1,M=0,d,y,x=0,g=0;for(e=1;e<=6;e++)d=c*u-M*f,y=M*u+c*f,c=d,M=y,x=x+this.B_re[e]*c-this.B_im[e]*M,g=g+this.B_im[e]*c+this.B_re[e]*M;return t.x=g*this.a+this.x0,t.y=x*this.a+this.y0,t}function En(t){var e,a=t.x,s=t.y,i=a-this.x0,r=s-this.y0,n=r/this.a,h=i/this.a,o=1,l=0,u,f,c=0,M=0;for(e=1;e<=6;e++)u=o*n-l*h,f=l*n+o*h,o=u,l=f,c=c+this.C_re[e]*o-this.C_im[e]*l,M=M+this.C_im[e]*o+this.C_re[e]*l;for(var d=0;d<this.iterations;d++){var y=c,x=M,g,b,E=n,N=h;for(e=2;e<=6;e++)g=y*c-x*M,b=x*c+y*M,y=g,x=b,E=E+(e-1)*(this.B_re[e]*y-this.B_im[e]*x),N=N+(e-1)*(this.B_im[e]*y+this.B_re[e]*x);y=1,x=0;var P=this.B_re[1],A=this.B_im[1];for(e=2;e<=6;e++)g=y*c-x*M,b=x*c+y*M,y=g,x=b,P=P+e*(this.B_re[e]*y-this.B_im[e]*x),A=A+e*(this.B_im[e]*y+this.B_re[e]*x);var O=P*P+A*A;c=(E*P+N*A)/O,M=(N*P-E*A)/O}var C=c,Z=M,ut=1,ct=0;for(e=1;e<=9;e++)ut=ut*C,ct=ct+this.D[e]*ut;var jt=this.lat0+ct*Mt*1e5,Di=this.long0+Z;return t.x=Di,t.y=jt,t}var In=["New_Zealand_Map_Grid","nzmg"],hi={init:_n,forward:bn,inverse:En,names:In};function Pn(){}function An(t){var e=t.x,a=t.y,s=v(e-this.long0),i=this.x0+this.a*s,r=this.y0+this.a*Math.log(Math.tan(Math.PI/4+a/2.5))*1.25;return t.x=i,t.y=r,t}function Sn(t){t.x-=this.x0,t.y-=this.y0;var e=v(this.long0+t.x/this.a),a=2.5*(Math.atan(Math.exp(.8*t.y/this.a))-Math.PI/4);return t.x=e,t.y=a,t}var Nn=["Miller_Cylindrical","mill"],oi={init:Pn,forward:An,inverse:Sn,names:Nn};var wn=20;function Rn(){this.sphere?(this.n=1,this.m=0,this.es=0,this.C_y=Math.sqrt((this.m+1)/this.n),this.C_x=this.C_y/(this.m+1)):this.en=re(this.es)}function Cn(t){var e,a,s=t.x,i=t.y;if(s=v(s-this.long0),this.sphere){if(!this.m)i=this.n!==1?Math.asin(this.n*Math.sin(i)):i;else for(var r=this.n*Math.sin(i),n=wn;n;--n){var h=(this.m*i+Math.sin(i)-r)/(this.m+Math.cos(i));if(i-=h,Math.abs(h)<p)break}e=this.a*this.C_x*s*(this.m+Math.cos(i)),a=this.a*this.C_y*i}else{var o=Math.sin(i),l=Math.cos(i);a=this.a*vt(i,o,l,this.en),e=this.a*s*l/Math.sqrt(1-this.es*o*o)}return t.x=e,t.y=a,t}function Ln(t){var e,a,s,i;return t.x-=this.x0,s=t.x/this.a,t.y-=this.y0,e=t.y/this.a,this.sphere?(e/=this.C_y,s=s/(this.C_x*(this.m+Math.cos(e))),this.m?e=j((this.m*e+Math.sin(e))/this.n):this.n!==1&&(e=j(Math.sin(e)/this.n)),s=v(s+this.long0),e=K(e)):(e=ne(t.y/this.a,this.es,this.en),i=Math.abs(e),i<m?(i=Math.sin(e),a=this.long0+t.x*Math.sqrt(1-this.es*i*i)/(this.a*Math.cos(e)),s=v(a)):i-p<m&&(s=this.long0)),t.x=s,t.y=e,t}var Tn=["Sinusoidal","sinu"],li={init:Rn,forward:Cn,inverse:Ln,names:Tn};function Dn(){}function On(t){for(var e=t.x,a=t.y,s=v(e-this.long0),i=a,r=Math.PI*Math.sin(a);;){var n=-(i+Math.sin(i)-r)/(1+Math.cos(i));if(i+=n,Math.abs(n)<p)break}i/=2,Math.PI/2-Math.abs(a)<p&&(s=0);var h=.900316316158*this.a*s*Math.cos(i)+this.x0,o=1.4142135623731*this.a*Math.sin(i)+this.y0;return t.x=h,t.y=o,t}function Bn(t){var e,a;t.x-=this.x0,t.y-=this.y0,a=t.y/(1.4142135623731*this.a),Math.abs(a)>.999999999999&&(a=.999999999999),e=Math.asin(a);var s=v(this.long0+t.x/(.900316316158*this.a*Math.cos(e)));s<-Math.PI&&(s=-Math.PI),s>Math.PI&&(s=Math.PI),a=(2*e+Math.sin(2*e))/Math.PI,Math.abs(a)>1&&(a=1);var i=Math.asin(a);return t.x=s,t.y=i,t}var Gn=["Mollweide","moll"],fi={init:Dn,forward:On,inverse:Bn,names:Gn};function Fn(){Math.abs(this.lat1+this.lat2)<p||(this.lat2=this.lat2||this.lat1,this.temp=this.b/this.a,this.es=1-Math.pow(this.temp,2),this.e=Math.sqrt(this.es),this.e0=it(this.es),this.e1=st(this.es),this.e2=rt(this.es),this.e3=nt(this.es),this.sinphi=Math.sin(this.lat1),this.cosphi=Math.cos(this.lat1),this.ms1=B(this.e,this.sinphi,this.cosphi),this.ml1=D(this.e0,this.e1,this.e2,this.e3,this.lat1),Math.abs(this.lat1-this.lat2)<p?this.ns=this.sinphi:(this.sinphi=Math.sin(this.lat2),this.cosphi=Math.cos(this.lat2),this.ms2=B(this.e,this.sinphi,this.cosphi),this.ml2=D(this.e0,this.e1,this.e2,this.e3,this.lat2),this.ns=(this.ms1-this.ms2)/(this.ml2-this.ml1)),this.g=this.ml1+this.ms1/this.ns,this.ml0=D(this.e0,this.e1,this.e2,this.e3,this.lat0),this.rh=this.a*(this.g-this.ml0))}function qn(t){var e=t.x,a=t.y,s;if(this.sphere)s=this.a*(this.g-a);else{var i=D(this.e0,this.e1,this.e2,this.e3,a);s=this.a*(this.g-i)}var r=this.ns*v(e-this.long0),n=this.x0+s*Math.sin(r),h=this.y0+this.rh-s*Math.cos(r);return t.x=n,t.y=h,t}function zn(t){t.x-=this.x0,t.y=this.rh-t.y+this.y0;var e,a,s,i;this.ns>=0?(a=Math.sqrt(t.x*t.x+t.y*t.y),e=1):(a=-Math.sqrt(t.x*t.x+t.y*t.y),e=-1);var r=0;if(a!==0&&(r=Math.atan2(e*t.x,e*t.y)),this.sphere)return i=v(this.long0+r/this.ns),s=K(this.g-a/this.a),t.x=i,t.y=s,t;var n=this.g-a/this.a;return s=yt(n,this.e0,this.e1,this.e2,this.e3),i=v(this.long0+r/this.ns),t.x=i,t.y=s,t}var jn=["Equidistant_Conic","eqdc"],ui={init:Fn,forward:qn,inverse:zn,names:jn};function kn(){this.R=this.a}function Hn(t){var e=t.x,a=t.y,s=v(e-this.long0),i,r;Math.abs(a)<=p&&(i=this.x0+this.R*s,r=this.y0);var n=j(2*Math.abs(a/Math.PI));(Math.abs(s)<=p||Math.abs(Math.abs(a)-m)<=p)&&(i=this.x0,a>=0?r=this.y0+Math.PI*this.R*Math.tan(.5*n):r=this.y0+Math.PI*this.R*-Math.tan(.5*n));var h=.5*Math.abs(Math.PI/s-s/Math.PI),o=h*h,l=Math.sin(n),u=Math.cos(n),f=u/(l+u-1),c=f*f,M=f*(2/l-1),d=M*M,y=Math.PI*this.R*(h*(f-d)+Math.sqrt(o*(f-d)*(f-d)-(d+o)*(c-d)))/(d+o);s<0&&(y=-y),i=this.x0+y;var x=o+f;return y=Math.PI*this.R*(M*x-h*Math.sqrt((d+o)*(o+1)-x*x))/(d+o),a>=0?r=this.y0+y:r=this.y0-y,t.x=i,t.y=r,t}function Un(t){var e,a,s,i,r,n,h,o,l,u,f,c,M;return t.x-=this.x0,t.y-=this.y0,f=Math.PI*this.R,s=t.x/f,i=t.y/f,r=s*s+i*i,n=-Math.abs(i)*(1+r),h=n-2*i*i+s*s,o=-2*n+1+2*i*i+r*r,M=i*i/o+(2*h*h*h/o/o/o-9*n*h/o/o)/27,l=(n-h*h/3/o)/o,u=2*Math.sqrt(-l/3),f=3*M/l/u,Math.abs(f)>1&&(f>=0?f=1:f=-1),c=Math.acos(f)/3,t.y>=0?a=(-u*Math.cos(c+Math.PI/3)-h/3/o)*Math.PI:a=-(-u*Math.cos(c+Math.PI/3)-h/3/o)*Math.PI,Math.abs(s)<p?e=this.long0:e=v(this.long0+Math.PI*(r-1+Math.sqrt(1+2*(s*s-i*i)+r*r))/2/s),t.x=e,t.y=a,t}var Wn=["Van_der_Grinten_I","VanDerGrinten","vandg"],ci={init:kn,forward:Hn,inverse:Un,names:Wn};function Jn(){this.sin_p12=Math.sin(this.lat0),this.cos_p12=Math.cos(this.lat0)}function Xn(t){var e=t.x,a=t.y,s=Math.sin(t.y),i=Math.cos(t.y),r=v(e-this.long0),n,h,o,l,u,f,c,M,d,y,x,g,b,E,N,P,A,O,C,Z,ut,ct,jt;return this.sphere?Math.abs(this.sin_p12-1)<=p?(t.x=this.x0+this.a*(m-a)*Math.sin(r),t.y=this.y0-this.a*(m-a)*Math.cos(r),t):Math.abs(this.sin_p12+1)<=p?(t.x=this.x0+this.a*(m+a)*Math.sin(r),t.y=this.y0+this.a*(m+a)*Math.cos(r),t):(O=this.sin_p12*s+this.cos_p12*i*Math.cos(r),P=Math.acos(O),A=P?P/Math.sin(P):1,t.x=this.x0+this.a*A*i*Math.sin(r),t.y=this.y0+this.a*A*(this.cos_p12*s-this.sin_p12*i*Math.cos(r)),t):(n=it(this.es),h=st(this.es),o=rt(this.es),l=nt(this.es),Math.abs(this.sin_p12-1)<=p?(u=this.a*D(n,h,o,l,m),f=this.a*D(n,h,o,l,a),t.x=this.x0+(u-f)*Math.sin(r),t.y=this.y0-(u-f)*Math.cos(r),t):Math.abs(this.sin_p12+1)<=p?(u=this.a*D(n,h,o,l,m),f=this.a*D(n,h,o,l,a),t.x=this.x0+(u+f)*Math.sin(r),t.y=this.y0+(u+f)*Math.cos(r),t):(c=s/i,M=ht(this.a,this.e,this.sin_p12),d=ht(this.a,this.e,s),y=Math.atan((1-this.es)*c+this.es*M*this.sin_p12/(d*i)),x=Math.atan2(Math.sin(r),this.cos_p12*Math.tan(y)-this.sin_p12*Math.cos(r)),x===0?C=Math.asin(this.cos_p12*Math.sin(y)-this.sin_p12*Math.cos(y)):Math.abs(Math.abs(x)-Math.PI)<=p?C=-Math.asin(this.cos_p12*Math.sin(y)-this.sin_p12*Math.cos(y)):C=Math.asin(Math.sin(r)*Math.cos(y)/Math.sin(x)),g=this.e*this.sin_p12/Math.sqrt(1-this.es),b=this.e*this.cos_p12*Math.cos(x)/Math.sqrt(1-this.es),E=g*b,N=b*b,Z=C*C,ut=Z*C,ct=ut*C,jt=ct*C,P=M*C*(1-Z*N*(1-N)/6+ut/8*E*(1-2*N)+ct/120*(N*(4-7*N)-3*g*g*(1-7*N))-jt/48*E),t.x=this.x0+P*Math.sin(x),t.y=this.y0+P*Math.cos(x),t))}function Qn(t){t.x-=this.x0,t.y-=this.y0;var e,a,s,i,r,n,h,o,l,u,f,c,M,d,y,x,g,b,E,N,P,A,O,C;return this.sphere?(e=Math.sqrt(t.x*t.x+t.y*t.y),e>2*m*this.a?void 0:(a=e/this.a,s=Math.sin(a),i=Math.cos(a),r=this.long0,Math.abs(e)<=p?n=this.lat0:(n=j(i*this.sin_p12+t.y*s*this.cos_p12/e),h=Math.abs(this.lat0)-m,Math.abs(h)<=p?this.lat0>=0?r=v(this.long0+Math.atan2(t.x,-t.y)):r=v(this.long0-Math.atan2(-t.x,t.y)):r=v(this.long0+Math.atan2(t.x*s,e*this.cos_p12*i-t.y*this.sin_p12*s))),t.x=r,t.y=n,t)):(o=it(this.es),l=st(this.es),u=rt(this.es),f=nt(this.es),Math.abs(this.sin_p12-1)<=p?(c=this.a*D(o,l,u,f,m),e=Math.sqrt(t.x*t.x+t.y*t.y),M=c-e,n=yt(M/this.a,o,l,u,f),r=v(this.long0+Math.atan2(t.x,-1*t.y)),t.x=r,t.y=n,t):Math.abs(this.sin_p12+1)<=p?(c=this.a*D(o,l,u,f,m),e=Math.sqrt(t.x*t.x+t.y*t.y),M=e-c,n=yt(M/this.a,o,l,u,f),r=v(this.long0+Math.atan2(t.x,t.y)),t.x=r,t.y=n,t):(e=Math.sqrt(t.x*t.x+t.y*t.y),x=Math.atan2(t.x,t.y),d=ht(this.a,this.e,this.sin_p12),g=Math.cos(x),b=this.e*this.cos_p12*g,E=-b*b/(1-this.es),N=3*this.es*(1-E)*this.sin_p12*this.cos_p12*g/(1-this.es),P=e/d,A=P-E*(1+E)*Math.pow(P,3)/6-N*(1+3*E)*Math.pow(P,4)/24,O=1-E*A*A/2-P*A*A*A/6,y=Math.asin(this.sin_p12*Math.cos(A)+this.cos_p12*Math.sin(A)*g),r=v(this.long0+Math.asin(Math.sin(x)*Math.sin(A)/Math.cos(y))),C=Math.sin(y),n=Math.atan2((C-this.es*O*this.sin_p12)*Math.tan(y),C*(1-this.es)),t.x=r,t.y=n,t))}var Vn=["Azimuthal_Equidistant","aeqd"],mi={init:Jn,forward:Xn,inverse:Qn,names:Vn};function Kn(){this.sin_p14=Math.sin(this.lat0),this.cos_p14=Math.cos(this.lat0)}function Yn(t){var e,a,s,i,r,n,h,o,l=t.x,u=t.y;return s=v(l-this.long0),e=Math.sin(u),a=Math.cos(u),i=Math.cos(s),n=this.sin_p14*e+this.cos_p14*a*i,r=1,(n>0||Math.abs(n)<=p)&&(h=this.a*r*a*Math.sin(s),o=this.y0+this.a*r*(this.cos_p14*e-this.sin_p14*a*i)),t.x=h,t.y=o,t}function Zn(t){var e,a,s,i,r,n,h;return t.x-=this.x0,t.y-=this.y0,e=Math.sqrt(t.x*t.x+t.y*t.y),a=j(e/this.a),s=Math.sin(a),i=Math.cos(a),n=this.long0,Math.abs(e)<=p?(h=this.lat0,t.x=n,t.y=h,t):(h=j(i*this.sin_p14+t.y*s*this.cos_p14/e),r=Math.abs(this.lat0)-m,Math.abs(r)<=p?(this.lat0>=0?n=v(this.long0+Math.atan2(t.x,-t.y)):n=v(this.long0-Math.atan2(-t.x,t.y)),t.x=n,t.y=h,t):(n=v(this.long0+Math.atan2(t.x*s,e*this.cos_p14*i-t.y*this.sin_p14*s)),t.x=n,t.y=h,t))}var $n=["ortho"],Mi={init:Kn,forward:Yn,inverse:Zn,names:$n};var R={FRONT:1,RIGHT:2,BACK:3,LEFT:4,TOP:5,BOTTOM:6},S={AREA_0:1,AREA_1:2,AREA_2:3,AREA_3:4};function th(){this.x0=this.x0||0,this.y0=this.y0||0,this.lat0=this.lat0||0,this.long0=this.long0||0,this.lat_ts=this.lat_ts||0,this.title=this.title||"Quadrilateralized Spherical Cube",this.lat0>=m-I/2?this.face=R.TOP:this.lat0<=-(m-I/2)?this.face=R.BOTTOM:Math.abs(this.long0)<=I?this.face=R.FRONT:Math.abs(this.long0)<=m+I?this.face=this.long0>0?R.RIGHT:R.LEFT:this.face=R.BACK,this.es!==0&&(this.one_minus_f=1-(this.a-this.b)/this.a,this.one_minus_f_squared=this.one_minus_f*this.one_minus_f)}function eh(t){var e={x:0,y:0},a,s,i,r,n,h,o={value:0};if(t.x-=this.long0,this.es!==0?a=Math.atan(this.one_minus_f_squared*Math.tan(t.y)):a=t.y,s=t.x,this.face===R.TOP)r=m-a,s>=I&&s<=m+I?(o.value=S.AREA_0,i=s-m):s>m+I||s<=-(m+I)?(o.value=S.AREA_1,i=s>0?s-w:s+w):s>-(m+I)&&s<=-I?(o.value=S.AREA_2,i=s+m):(o.value=S.AREA_3,i=s);else if(this.face===R.BOTTOM)r=m+a,s>=I&&s<=m+I?(o.value=S.AREA_0,i=-s+m):s<I&&s>=-I?(o.value=S.AREA_1,i=-s):s<-I&&s>=-(m+I)?(o.value=S.AREA_2,i=-s-m):(o.value=S.AREA_3,i=s>0?-s+w:-s-w);else{var l,u,f,c,M,d,y;this.face===R.RIGHT?s=Pt(s,+m):this.face===R.BACK?s=Pt(s,+w):this.face===R.LEFT&&(s=Pt(s,-m)),c=Math.sin(a),M=Math.cos(a),d=Math.sin(s),y=Math.cos(s),l=M*y,u=M*d,f=c,this.face===R.FRONT?(r=Math.acos(l),i=ue(r,f,u,o)):this.face===R.RIGHT?(r=Math.acos(u),i=ue(r,f,-l,o)):this.face===R.BACK?(r=Math.acos(-l),i=ue(r,f,-u,o)):this.face===R.LEFT?(r=Math.acos(-u),i=ue(r,f,l,o)):(r=i=0,o.value=S.AREA_0)}return h=Math.atan(12/w*(i+Math.acos(Math.sin(i)*Math.cos(I))-m)),n=Math.sqrt((1-Math.cos(r))/(Math.cos(h)*Math.cos(h))/(1-Math.cos(Math.atan(1/Math.cos(i))))),o.value===S.AREA_1?h+=m:o.value===S.AREA_2?h+=w:o.value===S.AREA_3&&(h+=1.5*w),e.x=n*Math.cos(h),e.y=n*Math.sin(h),e.x=e.x*this.a+this.x0,e.y=e.y*this.a+this.y0,t.x=e.x,t.y=e.y,t}function ah(t){var e={lam:0,phi:0},a,s,i,r,n,h,o,l,u,f={value:0};if(t.x=(t.x-this.x0)/this.a,t.y=(t.y-this.y0)/this.a,s=Math.atan(Math.sqrt(t.x*t.x+t.y*t.y)),a=Math.atan2(t.y,t.x),t.x>=0&&t.x>=Math.abs(t.y)?f.value=S.AREA_0:t.y>=0&&t.y>=Math.abs(t.x)?(f.value=S.AREA_1,a-=m):t.x<0&&-t.x>=Math.abs(t.y)?(f.value=S.AREA_2,a=a<0?a+w:a-w):(f.value=S.AREA_3,a+=m),u=w/12*Math.tan(a),n=Math.sin(u)/(Math.cos(u)-1/Math.sqrt(2)),h=Math.atan(n),i=Math.cos(a),r=Math.tan(s),o=1-i*i*r*r*(1-Math.cos(Math.atan(1/Math.cos(h)))),o<-1?o=-1:o>1&&(o=1),this.face===R.TOP)l=Math.acos(o),e.phi=m-l,f.value===S.AREA_0?e.lam=h+m:f.value===S.AREA_1?e.lam=h<0?h+w:h-w:f.value===S.AREA_2?e.lam=h-m:e.lam=h;else if(this.face===R.BOTTOM)l=Math.acos(o),e.phi=l-m,f.value===S.AREA_0?e.lam=-h+m:f.value===S.AREA_1?e.lam=-h:f.value===S.AREA_2?e.lam=-h-m:e.lam=h<0?-h-w:-h+w;else{var c,M,d;c=o,u=c*c,u>=1?d=0:d=Math.sqrt(1-u)*Math.sin(h),u+=d*d,u>=1?M=0:M=Math.sqrt(1-u),f.value===S.AREA_1?(u=M,M=-d,d=u):f.value===S.AREA_2?(M=-M,d=-d):f.value===S.AREA_3&&(u=M,M=d,d=-u),this.face===R.RIGHT?(u=c,c=-M,M=u):this.face===R.BACK?(c=-c,M=-M):this.face===R.LEFT&&(u=c,c=M,M=-u),e.phi=Math.acos(-d)-m,e.lam=Math.atan2(M,c),this.face===R.RIGHT?e.lam=Pt(e.lam,-m):this.face===R.BACK?e.lam=Pt(e.lam,-w):this.face===R.LEFT&&(e.lam=Pt(e.lam,+m))}if(this.es!==0){var y,x,g;y=e.phi<0?1:0,x=Math.tan(e.phi),g=this.b/Math.sqrt(x*x+this.one_minus_f_squared),e.phi=Math.atan(Math.sqrt(this.a*this.a-g*g)/(this.one_minus_f*g)),y&&(e.phi=-e.phi)}return e.lam+=this.long0,t.x=e.lam,t.y=e.phi,t}function ue(t,e,a,s){var i;return t<p?(s.value=S.AREA_0,i=0):(i=Math.atan2(e,a),Math.abs(i)<=I?s.value=S.AREA_0:i>I&&i<=m+I?(s.value=S.AREA_1,i-=m):i>m+I||i<=-(m+I)?(s.value=S.AREA_2,i=i>=0?i-w:i+w):(s.value=S.AREA_3,i+=m)),i}function Pt(t,e){var a=t+e;return a<-w?a+=Rt:a>+w&&(a-=Rt),a}var ih=["Quadrilateralized Spherical Cube","Quadrilateralized_Spherical_Cube","qsc"],di={init:th,forward:eh,inverse:ah,names:ih};var Be=[[1,22199e-21,-715515e-10,31103e-10],[.9986,-482243e-9,-24897e-9,-13309e-10],[.9954,-83103e-8,-448605e-10,-986701e-12],[.99,-.00135364,-59661e-9,36777e-10],[.9822,-.00167442,-449547e-11,-572411e-11],[.973,-.00214868,-903571e-10,18736e-12],[.96,-.00305085,-900761e-10,164917e-11],[.9427,-.00382792,-653386e-10,-26154e-10],[.9216,-.00467746,-10457e-8,481243e-11],[.8962,-.00536223,-323831e-10,-543432e-11],[.8679,-.00609363,-113898e-9,332484e-11],[.835,-.00698325,-640253e-10,934959e-12],[.7986,-.00755338,-500009e-10,935324e-12],[.7597,-.00798324,-35971e-9,-227626e-11],[.7186,-.00851367,-701149e-10,-86303e-10],[.6732,-.00986209,-199569e-9,191974e-10],[.6213,-.010418,883923e-10,624051e-11],[.5722,-.00906601,182e-6,624051e-11],[.5322,-.00677797,275608e-9,624051e-11]],Bt=[[-520417e-23,.0124,121431e-23,-845284e-16],[.062,.0124,-126793e-14,422642e-15],[.124,.0124,507171e-14,-160604e-14],[.186,.0123999,-190189e-13,600152e-14],[.248,.0124002,710039e-13,-224e-10],[.31,.0123992,-264997e-12,835986e-13],[.372,.0124029,988983e-12,-311994e-12],[.434,.0123893,-369093e-11,-435621e-12],[.4958,.0123198,-102252e-10,-345523e-12],[.5571,.0121916,-154081e-10,-582288e-12],[.6176,.0119938,-241424e-10,-525327e-12],[.6769,.011713,-320223e-10,-516405e-12],[.7346,.0113541,-397684e-10,-609052e-12],[.7903,.0109107,-489042e-10,-104739e-11],[.8435,.0103431,-64615e-9,-140374e-14],[.8936,.00969686,-64636e-9,-8547e-9],[.9394,.00840947,-192841e-9,-42106e-10],[.9761,.00616527,-256e-6,-42106e-10],[1,.00328947,-319159e-9,-42106e-10]],pi=.8487,vi=1.3523,yi=V/5,sh=1/yi,At=18,ce=function(t,e){return t[0]+e*(t[1]+e*(t[2]+e*t[3]))},rh=function(t,e){return t[1]+e*(2*t[2]+e*3*t[3])};function nh(t,e,a,s){for(var i=e;s;--s){var r=t(i);if(i-=r,Math.abs(r)<a)break}return i}function hh(){this.x0=this.x0||0,this.y0=this.y0||0,this.long0=this.long0||0,this.es=0,this.title=this.title||"Robinson"}function oh(t){var e=v(t.x-this.long0),a=Math.abs(t.y),s=Math.floor(a*yi);s<0?s=0:s>=At&&(s=At-1),a=V*(a-sh*s);var i={x:ce(Be[s],a)*e,y:ce(Bt[s],a)};return t.y<0&&(i.y=-i.y),i.x=i.x*this.a*pi+this.x0,i.y=i.y*this.a*vi+this.y0,i}function lh(t){var e={x:(t.x-this.x0)/(this.a*pi),y:Math.abs(t.y-this.y0)/(this.a*vi)};if(e.y>=1)e.x/=Be[At][0],e.y=t.y<0?-m:m;else{var a=Math.floor(e.y*At);for(a<0?a=0:a>=At&&(a=At-1);;)if(Bt[a][0]>e.y)--a;else if(Bt[a+1][0]<=e.y)++a;else break;var s=Bt[a],i=5*(e.y-s[0])/(Bt[a+1][0]-s[0]);i=nh(function(r){return(ce(s,r)-e.y)/rh(s,r)},i,p,100),e.x/=ce(Be[a],i),e.y=(5*a+i)*L,t.y<0&&(e.y=-e.y)}return e.x=v(e.x+this.long0),e}var fh=["Robinson","robin"],xi={init:hh,forward:oh,inverse:lh,names:fh};function uh(){this.name="geocent"}function ch(t){var e=ee(t,this.es,this.a);return e}function mh(t){var e=ae(t,this.es,this.a,this.b);return e}var Mh=["Geocentric","geocentric","geocent","Geocent"],gi={init:uh,forward:ch,inverse:mh,names:Mh};function _i(t){t.Proj.projections.add(qa),t.Proj.projections.add(It),t.Proj.projections.add(Wa),t.Proj.projections.add(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(Za),t.Proj.projections.add($a),t.Proj.projections.add(ti),t.Proj.projections.add(ei),t.Proj.projections.add(ii),t.Proj.projections.add(si),t.Proj.projections.add(ni),t.Proj.projections.add(hi),t.Proj.projections.add(oi),t.Proj.projections.add(li),t.Proj.projections.add(fi),t.Proj.projections.add(ui),t.Proj.projections.add(ci),t.Proj.projections.add(mi),t.Proj.projections.add(Mi),t.Proj.projections.add(di),t.Proj.projections.add(xi),t.Proj.projections.add(gi)}H.defaultDatum="WGS84";H.Proj=ft;H.WGS84=new H.Proj("WGS84");H.Point=Oa;H.toPoint=se;H.defs=gt;H.transform=pt;H.mgrs=La;H.version="__VERSION__";_i(H);var Ge=H;var Gt=class{static defineProjectionAliases(e){let a=[];for(let s in e)a.push([s,e[s]]);Ge.defs(a)}constructor({from:e="WGS84",to:a="WGS84"}){if(Ie(this,"_projection",void 0),this._projection=Ge(e,a),!this._projection)throw new Error("Invalid projection");this.project=this.project.bind(this),this.unproject=this.unproject.bind(this)}project(e){return this._projection.forward(e)}unproject(e){return this._projection.inverse(e)}};var Fe=100,bi=!1;function Ei(t){let e=new DataView(t,0,Fe),s=Wt(e).length-Fe,i=new DataView(t,Fe,s),r=new Int32Array(s),n=new Int32Array(s);for(let h=0;h<s/8;h++)r[h]=i.getInt32(h*8,bi),n[h]=i.getInt32(h*8+4,bi);return{offsets:r,lengths:n}}async function*me(t,e,a){let s=[],i=[],r=!1,n=!1;for(;!r&&!n;){if(s.length===0&&!r){let{value:o,done:l}=await t.next();l?r=!0:s.push(...o)}if(i.length===0&&!n){let{value:o,done:l}=await e.next();l?n=!0:i.push(...o)}let h=dh(s,i);h&&(yield{batchType:"data",shape:a,length:h.length,data:h})}}function dh(t,e){let a=Math.min(t.length,e.length);if(a===0)return null;let s=[t.slice(0,a),e.slice(0,a)];return t.splice(0,a),e.splice(0,a),s}var qe=!0,Ii=32,q;(function(t){t[t.START=0]="START",t[t.FIELD_DESCRIPTORS=1]="FIELD_DESCRIPTORS",t[t.FIELD_PROPERTIES=2]="FIELD_PROPERTIES",t[t.END=3]="END",t[t.ERROR=4]="ERROR"})(q||(q={}));var de=class{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=Pi(this.state,this.result,this.binaryReader,this.textDecoder)}end(){this.binaryReader.end(),this.state=Pi(this.state,this.result,this.binaryReader,this.textDecoder),this.state!==q.END&&(this.state=q.ERROR,this.result.error="DBF incomplete file")}};function ze(t,e={}){let{encoding:a="latin1"}=e.dbf||{},s=new de({encoding:a});s.write(t),s.end();let{data:i,schema:r}=s.result;switch(e?.dbf?.shape){case"object-row-table":return{shape:"object-row-table",schema:r,data:i};case"table":return{schema:r,rows:i};case"rows":default:return i}}async function*Ai(t,e={}){let{encoding:a="latin1"}=e.dbf||{},s=new de({encoding:a}),i=!1;for await(let r of t)s.write(r),!i&&s.result.dbfHeader&&(i=!0,yield s.result.dbfHeader),s.result.data.length>0&&(yield s.result.data,s.result.data=[]);s.end(),s.result.data.length>0&&(yield s.result.data)}function Pi(t,e,a,s){for(;;)try{switch(t){case q.ERROR:case q.END:return t;case q.START:let i=a.getDataView(Ii);if(!i)return t;e.dbfHeader=ph(i),e.progress={bytesUsed:0,rowsTotal:e.dbfHeader.nRecords,rows:0},t=q.FIELD_DESCRIPTORS;break;case q.FIELD_DESCRIPTORS:let r=a.getDataView(e.dbfHeader.headerLength-Ii);if(!r)return t;e.dbfFields=vh(r,s),e.schema={fields:e.dbfFields.map(o=>Eh(o)),metadata:{}},t=q.FIELD_PROPERTIES,a.skip(1);break;case q.FIELD_PROPERTIES:let{recordLength:n=0,nRecords:h=0}=e?.dbfHeader||{};for(;e.data.length<h;){let o=a.getDataView(n-1);if(!o)return t;a.skip(1);let l=yh(o,e.dbfFields,s);e.data.push(l),e.progress.rows=e.data.length}t=q.END;break;default:return t=q.ERROR,e.error=`illegal parser state ${t}`,t}}catch(i){return t=q.ERROR,e.error=`DBF parsing failed: ${i.message}`,t}}function ph(t){return{year:t.getUint8(1)+1900,month:t.getUint8(2),day:t.getUint8(3),nRecords:t.getUint32(4,qe),headerLength:t.getUint16(8,qe),recordLength:t.getUint16(10,qe),languageDriver:t.getUint8(29)}}function vh(t,e){let a=(t.byteLength-1)/32,s=[],i=0;for(let r=0;r<a;r++){let n=e.decode(new Uint8Array(t.buffer,t.byteOffset+i,11)).replace(/\u0000/g,"");s.push({name:n,dataType:String.fromCharCode(t.getUint8(i+11)),fieldLength:t.getUint8(i+16),decimal:t.getUint8(i+17)}),i+=32}return s}function yh(t,e,a){let s={},i=0;for(let r of e){let n=a.decode(new Uint8Array(t.buffer,t.byteOffset+i,r.fieldLength));s[r.name]=xh(n,r.dataType),i+=r.fieldLength}return s}function xh(t,e){switch(e){case"B":return Me(t);case"C":return bh(t);case"F":return Me(t);case"N":return Me(t);case"O":return Me(t);case"D":return gh(t);case"L":return _h(t);default:throw new Error("Unsupported data type")}}function gh(t){return Date.UTC(t.slice(0,4),parseInt(t.slice(4,6),10)-1,t.slice(6,8))}function _h(t){return/^[nf]$/i.test(t)?!1:/^[yt]$/i.test(t)?!0:null}function Me(t){let e=parseFloat(t);return isNaN(e)?null:e}function bh(t){return t.trim()||null}function Eh({name:t,dataType:e,fieldLength:a,decimal:s}){switch(e){case"B":return{name:t,type:"float64",nullable:!0,metadata:{}};case"C":return{name:t,type:"utf8",nullable:!0,metadata:{}};case"F":return{name:t,type:"float64",nullable:!0,metadata:{}};case"N":return{name:t,type:"float64",nullable:!0,metadata:{}};case"O":return{name:t,type:"float64",nullable:!0,metadata:{}};case"D":return{name:t,type:"timestamp-millisecond",nullable:!0,metadata:{}};case"L":return{name:t,type:"bool",nullable:!0,metadata:{}};default:throw new Error("Unsupported data type")}}var Ih="4.2.0",je={name:"DBF",dataType:null,batchType:null,id:"dbf",module:"shapefile",version:Ih,worker:!0,category:"table",extensions:["dbf"],mimeTypes:["application/x-dbf"],options:{dbf:{encoding:"latin1"}}},Ft={...je,parse:async(t,e)=>ze(t,e),parseSync:ze,parseInBatches(t,e){return Ai(t,e)}};async function*Si(t,e,a){let{reproject:s=!1,_targetCrs:i="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Li(e,a),o=await Qt(t,Nt,e,a),l=o[Symbol.asyncIterator]?.()||o[Symbol.iterator]?.(),u=null,f=await a?.fetch(qt(a?.url||"","dbf"));if(f?.ok){let x=await Qt(f,Ft,{...e,dbf:{encoding:n||"latin1"}},a);u=x[Symbol.asyncIterator]?.()||x[Symbol.iterator]()}let c=(await l.next()).value;c&&c.batchType==="metadata"&&(c=(await l.next()).value);let M={};u&&(M=(await u.next()).value,M&&M.batchType==="metadata"&&(M=(await u.next()).value));let d=u?me(l,u,"object-row-table"):l,y={[Symbol.asyncIterator](){return d}};for await(let x of y){let g,b;u?[g,b]=x.data:g=x;let E=wi(g),N=Ri(E,b);s&&(N=Ci(N,h,i)),yield{encoding:n,prj:h,shx:r,header:c,data:N}}}async function Ni(t,e,a){let{reproject:s=!1,_targetCrs:i="WGS84"}=e?.gis||{},{shx:r,cpg:n,prj:h}=await Li(e,a),{header:o,geometries:l}=await Xt(t,Nt,e,a),u=wi(l),f,c=await a?.fetch(qt(a?.url,"dbf"));c?.ok&&(f=await Xt(c,Ft,{dbf:{shape:"object-row-table",encoding:n||"latin1"}},a));let M=Ri(u,f?.data||[]);switch(s&&(M=Ci(M,h,i)),e?.shapefile?.shape){case"geojson-table":return{shape:"geojson-table",type:"FeatureCollection",encoding:n,schema:f?.schema||{metadata:{},fields:[]},prj:h,shx:r,header:o,features:M};default:return{encoding:n,prj:h,shx:r,header:o,data:M}}}function wi(t){let e=[];for(let a of t)e.push(Pe(a));return e}function Ri(t,e){let a=[];for(let s=0;s<t.length;s++){let r={type:"Feature",geometry:t[s],properties:e&&e[s]||{}};a.push(r)}return a}function Ci(t,e,a){if(!e&&!a)return t;let s=new Gt({from:e||"WGS84",to:a||"WGS84"});return Ae(t,i=>s.project(i))}async function Li(t,e){let{url:a,fetch:s}=e,i=s(qt(a,"shx")),r=s(qt(a,"cpg")),n=s(qt(a,"prj"));await Promise.all([i,r,n]);let h,o,l,u=await i;if(u.ok){let M=await u.arrayBuffer();h=Ei(M)}let f=await r;f.ok&&(o=await f.text());let c=await n;return c.ok&&(l=await c.text()),{shx:h,cpg:o,prj:l}}function qt(t,e){let a=Ph(t),s=Ah(t);return s===s.toUpperCase()&&(e=e.toUpperCase()),`${a}.${e}`}function Ph(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(0,e):"":e}function Ah(t){let e=t&&t.lastIndexOf(".");return typeof e=="number"?e>=0?t.substr(e+1):"":e}var Sh="4.2.0",Ti={name:"Shapefile",id:"shapefile",module:"shapefile",version:Sh,category:"geometry",extensions:["shp"],mimeTypes:["application/octet-stream"],tests:[new Uint8Array(ge).buffer],options:{shapefile:{shape:"v3"},shp:{_maxDimensions:4}},parse:Ni,parseInBatches:Si};var pe=class{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 Hi(zt);})();
|
|
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.2.0
|
|
519
|
+
var VERSION = true ? "4.2.0" : "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.2.0
|
|
857
|
+
var VERSION2 = true ? "4.2.0" : "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.2.0
|
|
1058
|
+
var VERSION3 = true ? "4.2.0" : "latest";
|
|
1059
1059
|
var ShapefileLoader = {
|
|
1060
1060
|
name: "Shapefile",
|
|
1061
1061
|
id: "shapefile",
|
package/dist/index.cjs.map
CHANGED
|
@@ -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.2.0-beta.2\" !== 'undefined' ? \"4.2.0-beta.2\" : '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.2.0-beta.2\" !== 'undefined' ? \"4.2.0-beta.2\" : '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.2.0-beta.2\" !== 'undefined' ? \"4.2.0-beta.2\" : '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
|
-
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,oBAAN,MAAwB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,SAAS;AACjB,UAAM,EAAE,iBAAiB,EAAE,IAAI,WAAW,CAAC;AAE3C,SAAK,SAAS;AAEd,SAAK,eAAe,CAAC;AACrB,SAAK,QAAQ;AAEb,SAAK,iBAAiB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAIA,MAAM,aAAa;AACf,SAAK,aAAa,KAAK,WAAW;AAAA,EACtC;AAAA,EACA,MAAM;AACF,SAAK,eAAe,CAAC;AACrB,SAAK,QAAQ;AAAA,EAC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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;",
|
|
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.2.0\" !== 'undefined' ? \"4.2.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.2.0\" !== 'undefined' ? \"4.2.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.2.0\" !== 'undefined' ? \"4.2.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"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGO,IAAM,oBAAN,MAAwB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,YAAY,SAAS;AACjB,UAAM,EAAE,iBAAiB,EAAE,IAAI,WAAW,CAAC;AAE3C,SAAK,SAAS;AAEd,SAAK,eAAe,CAAC;AACrB,SAAK,QAAQ;AAEb,SAAK,iBAAiB;AAAA,EAC1B;AAAA;AAAA;AAAA;AAAA,EAIA,MAAM,aAAa;AACf,SAAK,aAAa,KAAK,WAAW;AAAA,EACtC;AAAA,EACA,MAAM;AACF,SAAK,eAAe,CAAC;AACrB,SAAK,QAAQ;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,kBAAkB,OAAO;AACrB,QAAI,iBAAiB,CAAC,KAAK;AAC3B,eAAW,eAAe,KAAK,cAAc;AACzC,wBAAkB,YAAY;AAC9B,UAAI,kBAAkB,OAAO;AACz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E_ENDIAN", "LITTLE_ENDIAN", "BIG_ENDIAN", "SHP_MAGIC_NUMBER", "BIG_ENDIAN", "LITTLE_ENDIAN", "STATE", "parseState", "VERSION", "VERSION", "SHP_MAGIC_NUMBER"]
|
|
7
7
|
}
|
package/dist/shapefile-loader.js
CHANGED
|
@@ -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.2.0
|
|
8
|
+
const VERSION = typeof "4.2.0" !== 'undefined' ? "4.2.0" : 'latest';
|
|
9
9
|
/**
|
|
10
10
|
* Shapefile loader
|
|
11
11
|
* @note Shapefile is multifile format and requires providing additional files
|
package/dist/shp-loader.js
CHANGED
|
@@ -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.2.0
|
|
7
|
+
const VERSION = typeof "4.2.0" !== 'undefined' ? "4.2.0" : 'latest';
|
|
8
8
|
export const SHP_MAGIC_NUMBER = [0x00, 0x00, 0x27, 0x0a];
|
|
9
9
|
/**
|
|
10
10
|
* SHP file loader
|
package/dist/shp-worker.js
CHANGED
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.
|
|
4
|
+
"version": "4.3.0-alpha.1",
|
|
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.
|
|
49
|
-
"@loaders.gl/loader-utils": "4.
|
|
50
|
-
"@loaders.gl/schema": "4.
|
|
48
|
+
"@loaders.gl/gis": "4.3.0-alpha.1",
|
|
49
|
+
"@loaders.gl/loader-utils": "4.3.0-alpha.1",
|
|
50
|
+
"@loaders.gl/schema": "4.3.0-alpha.1",
|
|
51
51
|
"@math.gl/proj4": "^4.0.0"
|
|
52
52
|
},
|
|
53
53
|
"peerDependencies": {
|
|
54
54
|
"@loaders.gl/core": "^4.0.0"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "568446ea69eb590f0c42d965459b636216cda74e"
|
|
57
57
|
}
|