(()=>{var lg={};(function(N,tr){tr(N.turf={})})(lg,function(N){"use strict";var tr=63710088e-1,Qs={centimeters:637100880,centimetres:637100880,degrees:57.22891354143274,feet:20902260511392e-6,inches:39.37*tr,kilometers:6371.0088,kilometres:6371.0088,meters:tr,metres:tr,miles:3958.761333810546,millimeters:6371008800,millimetres:6371008800,nauticalmiles:tr/1852,radians:1,yards:6967335223679999e-9},Jl={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/tr,yards:1.0936133},$s={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046};function Te(t,e,n){n===void 0&&(n={});var r={type:"Feature"};return(n.id===0||n.id)&&(r.id=n.id),n.bbox&&(r.bbox=n.bbox),r.properties=e||{},r.geometry=t,r}function Zl(t,e,n){switch(t){case"Point":return ft(e).geometry;case"LineString":return Wt(e).geometry;case"Polygon":return ct(e).geometry;case"MultiPoint":return ta(e).geometry;case"MultiLineString":return yi(e).geometry;case"MultiPolygon":return xr(e).geometry;default:throw new Error(t+" is invalid")}}function ft(t,e,n){if(n===void 0&&(n={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!Ge(t[0])||!Ge(t[1]))throw new Error("coordinates must contain numbers");return Te({type:"Point",coordinates:t},e,n)}function Kl(t,e,n){return n===void 0&&(n={}),nt(t.map(function(r){return ft(r,e)}),n)}function ct(t,e,n){n===void 0&&(n={});for(var r=0,i=t;r=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n}function co(t,e){e===void 0&&(e="kilometers");var n=Qs[e];if(!n)throw new Error(e+" units is invalid");return t*n}function ki(t,e){e===void 0&&(e="kilometers");var n=Qs[e];if(!n)throw new Error(e+" units is invalid");return t/n}function ea(t,e){return mi(ki(t,e))}function Gi(t){var e=t%360;return e<0&&(e+=360),e}function mi(t){return 180*(t%(2*Math.PI))/Math.PI}function ke(t){return t%360*Math.PI/180}function qi(t,e,n){if(e===void 0&&(e="kilometers"),n===void 0&&(n="kilometers"),!(t>=0))throw new Error("length must be a positive number");return co(ki(t,e),n)}function ec(t,e,n){if(e===void 0&&(e="meters"),n===void 0&&(n="kilometers"),!(t>=0))throw new Error("area must be a positive number");var r=$s[e];if(!r)throw new Error("invalid original units");var i=$s[n];if(!i)throw new Error("invalid final units");return t/r*i}function Ge(t){return!isNaN(t)&&t!==null&&!Array.isArray(t)}function Qt(t){return!!t&&t.constructor===Object}function nc(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(t.length!==4&&t.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach(function(e){if(!Ge(e))throw new Error("bbox must only contain numbers")})}function rc(t){if(!t)throw new Error("id is required");if(["string","number"].indexOf(typeof t)===-1)throw new Error("id must be a number or a string")}var cg=Object.freeze({__proto__:null,earthRadius:tr,factors:Qs,unitsFactors:Jl,areaFactors:$s,feature:Te,geometry:Zl,point:ft,points:Kl,polygon:ct,polygons:Ql,lineString:Wt,lineStrings:$l,featureCollection:nt,multiLineString:yi,multiPoint:ta,multiPolygon:xr,geometryCollection:au,round:tc,radiansToLength:co,lengthToRadians:ki,lengthToDegrees:ea,bearingToAzimuth:Gi,radiansToDegrees:mi,degreesToRadians:ke,convertLength:qi,convertArea:ec,isNumber:Ge,isObject:Qt,validateBBox:nc,validateId:rc});function re(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if(t.type==="Feature"&&t.geometry!==null&&t.geometry.type==="Point")return t.geometry.coordinates;if(t.type==="Point")return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")}function it(t){if(Array.isArray(t))return t;if(t.type==="Feature"){if(t.geometry!==null)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function uu(t){if(t.length>1&&Ge(t[0])&&Ge(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return uu(t[0]);throw new Error("coordinates must only contain numbers")}function ic(t,e,n){if(!e||!n)throw new Error("type and name required");if(!t||t.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.type)}function ts(t,e,n){if(!t)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!t||t.type!=="Feature"||!t.geometry)throw new Error("Invalid input to "+n+", Feature with geometry required");if(!t.geometry||t.geometry.type!==e)throw new Error("Invalid input to "+n+": must be a "+e+", given "+t.geometry.type)}function ti(t,e,n){if(!t)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!t||t.type!=="FeatureCollection")throw new Error("Invalid input to "+n+", FeatureCollection required");for(var r=0,i=t.features;ru||g>l||m>h)return a=c,u=r,l=g,h=m,void(o=0);var f=Wt([a,c],n.properties);if(e(f,r,i,m,o)===!1)return!1;o++,a=c})!==!1&&void 0}}})}function fu(t,e,n){var r=n,i=!1;return ei(t,function(o,s,a,u,l){r=i===!1&&n===void 0?o:e(r,o,s,a,u,l),i=!0}),r}function gu(t,e){if(!t)throw new Error("geojson is required");Ee(t,function(n,r,i){if(n.geometry!==null){var o=n.geometry.type,s=n.geometry.coordinates;switch(o){case"LineString":if(e(n,r,i,0,0)===!1)return!1;break;case"Polygon":for(var a=0;an[0]&&(e[0]=n[0]),e[1]>n[1]&&(e[1]=n[1]),e[2] * v. 1.2.0 * https://github.com/RaumZeit/MarchingSquares.js * * MarchingSquaresJS is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * MarchingSquaresJS is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * As additional permission under GNU Affero General Public License version 3 * section 7, third-party projects (personal or commercial) may distribute, * include, or link against UNMODIFIED VERSIONS of MarchingSquaresJS without the * requirement that said third-party project for that reason alone becomes * subject to any requirement of the GNU Affero General Public License version 3. * Any modifications to MarchingSquaresJS, however, must be shared with the public * and made available. * * In summary this: * - allows you to use MarchingSquaresJS at no cost * - allows you to use MarchingSquaresJS for both personal and commercial purposes * - allows you to distribute UNMODIFIED VERSIONS of MarchingSquaresJS under any * license as long as this license notice is included * - enables you to keep the source code of your program that uses MarchingSquaresJS * undisclosed * - forces you to share any modifications you have made to MarchingSquaresJS, * e.g. bug-fixes * * You should have received a copy of the GNU Affero General Public License * along with MarchingSquaresJS. If not, see . */function yg(t,e,n){n=n||{};for(var r=Object.keys(cc),i=0;i=0&&at>=0&&at=0;v--)if(Math.abs(l[v][0][0]-I)<=c&&Math.abs(l[v][0][1]-y)<=c){for(var x=f.path.length-2;x>=0;--x)l[v].unshift(f.path[x]);_=!0;break}}_||(l[h++]=f.path)}var b})}),l}(function(u,l){for(var h=u.length-1,c=u[0].length-1,p={rows:h,cols:c,cells:[]},d=0;d=l?8:0,m|=_>=l?4:0,m|=I>=l?2:0;var v,x,b,E,T=!1;if((m|=y>=l?1:0)===5||m===10){var C=(f+_+I+y)/4;m===5&&Cn;){if(r-n>600){var o=r-n+1,s=e-n+1,a=Math.log(o),u=.5*Math.exp(2*a/3),l=.5*Math.sqrt(a*u*(o-u)/o)*(s-o/2<0?-1:1);dc(t,e,Math.max(n,Math.floor(e-s*u/o+l)),Math.min(r,Math.floor(e+(o-s)*u/o+l)),i)}var h=t[e],c=n,p=r;for(es(t,n,e),i(t[r],h)>0&&es(t,n,r);c0;)p--}i(t[n],h)===0?es(t,n,p):es(t,++p,r),p<=e&&(n=p+1),e<=p&&(r=p-1)}}function es(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function _g(t,e){return te?1:0}fc.default=vg;var un=ns,xg=ns;function ns(t,e){if(!(this instanceof ns))return new ns(t,e);this._maxEntries=Math.max(4,t||9),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),e&&this._initFormat(e),this.clear()}function Eg(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r=t.minX&&e.maxY>=t.minY}function po(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function vc(t,e,n,r,i){for(var o,s=[e,n];s.length;)(n=s.pop())-(e=s.pop())<=r||(o=e+Math.ceil((n-e)/r/2)*r,fc(t,o,e,n,i),s.push(e,o,o,n))}function Dr(t){var e={exports:{}};return t(e,e.exports),e.exports}ns.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,n=[],r=this.toBBox;if(!ia(t,e))return n;for(var i,o,s,a,u=[];e;){for(i=0,o=e.children.length;i=0&&o[e].children.length>this._maxEntries;)this._split(o,e),e--;this._adjustParentBBoxes(i,o,e)},_split:function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),s=po(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,ho(n,this.toBBox),ho(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},_splitRoot:function(t,e){this.data=po([t,e]),this.data.height=t.height+1,this.data.leaf=!1,ho(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,n){var r,i,o,s,a,u,l,h,c,p,d,g,m,f;for(u=l=1/0,r=e;r<=n-e;r++)i=rs(t,0,r,this.toBBox),o=rs(t,r,n,this.toBBox),c=i,p=o,d=void 0,g=void 0,m=void 0,f=void 0,d=Math.max(c.minX,p.minX),g=Math.max(c.minY,p.minY),m=Math.min(c.maxX,p.maxX),f=Math.min(c.maxY,p.maxY),s=Math.max(0,m-d)*Math.max(0,f-g),a=vu(i)+vu(o),s=e;i--)o=t.children[i],is(u,t.leaf?s(o):o),l+=ra(u);return l},_adjustParentBBoxes:function(t,e,n){for(var r=n;r>=0;r--)is(e[r],t)},_condense:function(t){for(var e,n=t.length-1;n>=0;n--)t[n].children.length===0?n>0?(e=t[n-1].children).splice(e.indexOf(t[n]),1):this.clear():ho(t[n],this.toBBox)},_initFormat:function(t){var e=["return a"," - b",";"];this.compareMinX=new Function("a","b",e.join(t[0])),this.compareMinY=new Function("a","b",e.join(t[1])),this.toBBox=new Function("a","return {minX: a"+t[0]+", minY: a"+t[1]+", maxX: a"+t[2]+", maxY: a"+t[3]+"};")}},un.default=xg;var oa=function(t,e,n){var r=t*e,i=_c*t,o=i-(i-t),s=t-o,a=_c*e,u=a-(a-e),l=e-u,h=s*l-(r-o*u-s*u-o*l);return n?(n[0]=h,n[1]=r,n):[h,r]},_c=+(Math.pow(2,27)+1),bg=function(t,e){var n=0|t.length,r=0|e.length;if(n===1&&r===1)return function(b,E){var T=b+E,C=T-b,D=b-(T-C)+(E-C);return D?[D,T]:[T]}(t[0],e[0]);var i,o,s=new Array(n+r),a=0,u=0,l=0,h=Math.abs,c=t[u],p=h(c),d=e[l],g=h(d);p=r?(i=c,(u+=1)=r?(i=c,(u+=1)>1;return["sum(",n(l.slice(0,h)),",",n(l.slice(h)),")"].join("")}function r(l){if(l.length===2)return[["sum(prod(",l[0][0],",",l[1][1],"),prod(-",l[0][1],",",l[1][0],"))"].join("")];for(var h=[],c=0;c0){if(g<=0)return m;p=d+g}else{if(!(d<0)||g>=0)return m;p=-(d+g)}var f=33306690738754716e-32*p;return m>=f||m<=-f?m:o(l,h,c)},function(l,h,c,p){var d=l[0]-p[0],g=h[0]-p[0],m=c[0]-p[0],f=l[1]-p[1],_=h[1]-p[1],I=c[1]-p[1],y=l[2]-p[2],v=h[2]-p[2],x=c[2]-p[2],b=g*I,E=m*_,T=m*f,C=d*I,D=d*_,M=g*f,B=y*(b-E)+v*(T-C)+x*(D-M),O=7771561172376103e-31*((Math.abs(b)+Math.abs(E))*Math.abs(y)+(Math.abs(T)+Math.abs(C))*Math.abs(v)+(Math.abs(D)+Math.abs(M))*Math.abs(x));return B>O||-B>O?B:s(l,h,c,p)}];function u(l){var h=a[l.length];return h||(h=a[l.length]=i(l.length)),h.apply(void 0,l)}(function(){for(;a.length<=5;)a.push(i(a.length));for(var l=[],h=["slow"],c=0;c<=5;++c)l.push("a"+c),h.push("o"+c);var p=["function getOrientation(",l.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(c=2;c<=5;++c)p.push("case ",c,":return o",c,"(",l.slice(0,c).join(),");");p.push("}var s=new Array(arguments.length);for(var i=0;i1&&Ec(t[o[l-2]],t[o[l-1]],u)<=0;)l-=1,o.pop();for(o.push(a),l=s.length;l>1&&Ec(t[s[l-2]],t[s[l-1]],u)>=0;)l-=1,s.pop();s.push(a)}n=new Array(s.length+o.length-2);for(var h=0,c=(r=0,o.length);r0;--p)n[h++]=s[p];return n},Ec=xc[3],bc=os,Ng=os;function os(t,e){if(!(this instanceof os))return new os(t,e);if(this.data=t||[],this.length=this.data.length,this.compare=e||Pg,this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)}function Pg(t,e){return te?1:0}os.prototype={push:function(t){this.data.push(t),this.length++,this._up(this.length-1)},pop:function(){if(this.length!==0){var t=this.data[0];return this.length--,this.length>0&&(this.data[0]=this.data[this.length],this._down(0)),this.data.pop(),t}},peek:function(){return this.data[0]},_up:function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r},_down:function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=a,t=o}e[t]=i}},bc.default=Ng;var Mg=function(t,e){for(var n=t[0],r=t[1],i=!1,o=0,s=e.length-1;or!=h>r&&n<(l-a)*(r-u)/(h-u)+a&&(i=!i)}return i},sa=xc[3],wc=Ic,Lg=Ic;function Ic(t,e,n){e=Math.max(0,e===void 0?2:e),n=n||0;for(var r,i=function(I){for(var y=I[0],v=I[0],x=I[0],b=I[0],E=0;Ex[0]&&(x=T),T[1]b[1]&&(b=T)}var C=[y,v,x,b],D=C.slice();for(E=0;Eo||a.push({node:h,dist:c})}for(;a.length&&!a.peek().node.children;){var p=a.pop(),d=p.node,g=bu(d,e,n),m=bu(d,r,i);if(p.dist=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function Cc(t,e,n){for(var r,i,o,s,a=Math.min(t[0],e[0]),u=Math.min(t[1],e[1]),l=Math.max(t[0],e[0]),h=Math.max(t[1],e[1]),c=n.search({minX:a,minY:u,maxX:l,maxY:h}),p=0;p0!=sa(r,i,s)>0&&sa(o,s,r)>0!=sa(o,s,i)>0)return!1;return!0}function xu(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function Nc(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function Eu(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function bu(t,e,n){var r=e[0],i=e[1],o=n[0]-r,s=n[1]-i;if(o!==0||s!==0){var a=((t[0]-r)*o+(t[1]-i)*s)/(o*o+s*s);a>1?(r=n[0],i=n[1]):a>0&&(r+=o*a,i+=s*a)}return(o=t[0]-r)*o+(s=t[1]-i)*s}function aa(t,e,n,r,i,o,s,a){var u,l,h,c,p=n-t,d=r-e,g=s-i,m=a-o,f=t-i,_=e-o,I=p*p+d*d,y=p*g+d*m,v=g*g+m*m,x=p*f+d*_,b=g*f+m*_,E=I*v-y*y,T=E,C=E;E===0?(l=0,T=1,c=b,C=v):(c=I*b-y*x,(l=y*b-v*x)<0?(l=0,c=b,C=v):l>T&&(l=T,c=b+y,C=v)),c<0?(c=0,-x<0?l=0:-x>I?l=T:(l=-x,T=I)):c>C&&(c=C,-x+y<0?l=0:-x+y>I?l=T:(l=-x+y,T=I));var D=(1-(h=c===0?0:c/C))*i+h*s-((1-(u=l===0?0:l/T))*t+u*n),M=(1-h)*o+h*a-((1-u)*e+u*r);return D*D+M*M}function Pc(t,e){e===void 0&&(e={}),e.concavity=e.concavity||1/0;var n=[];if(Ce(t,function(i){n.push([i[0],i[1]])}),!n.length)return null;var r=wc(n,e.concavity);return r.length>3?ct([r]):null}function le(t,e,n){if(n===void 0&&(n={}),!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var r=re(t),i=ae(e),o=i.type,s=e.bbox,a=i.coordinates;if(s&&function(p,d){return d[0]<=p[0]&&d[1]<=p[1]&&d[2]>=p[0]&&d[3]>=p[1]}(r,s)===!1)return!1;o==="Polygon"&&(a=[a]);for(var u=!1,l=0;lt[1]!=l>t[1]&&t[0]<(u-s)*(t[1]-a)/(l-a)+s&&(r=!r)}return r}function wu(t,e){var n=[];return Zt(t,function(r){var i=!1;zn(e,function(o){le(r,o)&&(i=!0)}),i&&n.push(r)}),nt(n)}function $t(t,e,n){n===void 0&&(n={});var r=re(t),i=re(e),o=ke(i[1]-r[1]),s=ke(i[0]-r[0]),a=ke(r[1]),u=ke(i[1]),l=Math.pow(Math.sin(o/2),2)+Math.pow(Math.sin(s/2),2)*Math.cos(a)*Math.cos(u);return co(2*Math.atan2(Math.sqrt(l),Math.sqrt(1-l)),n.units)}function Lc(t,e){var n=!1;return nt(function(r){if(r.length<3)return[];r.sort(Ag);for(var i,o,s,a,u,l,h=r.length-1,c=r[h].x,p=r[0].x,d=r[h].y,g=d,m=1e-12;h--;)r[h].yg&&(g=r[h].y);var f,_=p-c,I=g-d,y=_>I?_:I,v=.5*(p+c),x=.5*(g+d),b=[new Oc({__sentinel:!0,x:v-20*y,y:x-y},{__sentinel:!0,x:v,y:x+20*y},{__sentinel:!0,x:v+20*y,y:x-y})],E=[],T=[];for(h=r.length;h--;){for(T.length=0,f=b.length;f--;)(_=r[h].x-b[f].x)>0&&_*_>b[f].r?(E.push(b[f]),b.splice(f,1)):_*_+(I=r[h].y-b[f].y)*I>b[f].r||(T.push(b[f].a,b[f].b,b[f].b,b[f].c,b[f].c,b[f].a),b.splice(f,1));for(Dg(T),f=T.length;f;)o=T[--f],i=T[--f],s=r[h],a=o.x-i.x,u=o.y-i.y,l=2*(a*(s.y-o.y)-u*(s.x-o.x)),Math.abs(l)>m&&b.push(new Oc(i,o,s))}for(Array.prototype.push.apply(E,b),h=E.length;h--;)(E[h].a.__sentinel||E[h].b.__sentinel||E[h].c.__sentinel)&&E.splice(h,1);return E}(t.features.map(function(r){var i={x:r.geometry.coordinates[0],y:r.geometry.coordinates[1]};return e?i.z=r.properties[e]:r.geometry.coordinates.length===3&&(n=!0,i.z=r.geometry.coordinates[2]),i})).map(function(r){var i=[r.a.x,r.a.y],o=[r.b.x,r.b.y],s=[r.c.x,r.c.y],a={};return n?(i.push(r.a.z),o.push(r.b.z),s.push(r.c.z)):a={a:r.a.z,b:r.b.z,c:r.c.z},ct([[i,o,s,i]],a)}))}wc.default=Lg;var Oc=function(t,e,n){this.a=t,this.b=e,this.c=n;var r,i,o=e.x-t.x,s=e.y-t.y,a=n.x-t.x,u=n.y-t.y,l=o*(t.x+e.x)+s*(t.y+e.y),h=a*(t.x+n.x)+u*(t.y+n.y),c=2*(o*(n.y-e.y)-s*(n.x-e.x));this.x=(u*l-s*h)/c,this.y=(o*h-a*l)/c,r=this.x-t.x,i=this.y-t.y,this.r=r*r+i*i};function Ag(t,e){return e.x-t.x}function Dg(t){var e,n,r,i,o,s=t.length;t:for(;s;)for(n=t[--s],e=t[--s],r=s;r;)if(o=t[--r],e===(i=t[--r])&&n===o||e===o&&n===i){t.splice(s,2),t.splice(r,2),s-=2;continue t}}function Ye(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return Rc(t);case"FeatureCollection":return function(e){var n={type:"FeatureCollection"};return Object.keys(e).forEach(function(r){switch(r){case"type":case"features":return;default:n[r]=e[r]}}),n.features=e.features.map(function(r){return Rc(r)}),n}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return Iu(t);default:throw new Error("unknown GeoJSON type")}}function Rc(t){var e={type:"Feature"};return Object.keys(t).forEach(function(n){switch(n){case"type":case"properties":case"geometry":return;default:e[n]=t[n]}}),e.properties=Tc(t.properties),e.geometry=Iu(t.geometry),e}function Tc(t){var e={};return t&&Object.keys(t).forEach(function(n){var r=t[n];typeof r=="object"?r===null?e[n]=null:Array.isArray(r)?e[n]=r.map(function(i){return i}):e[n]=Tc(r):e[n]=r}),e}function Iu(t){var e={type:t.type};return t.bbox&&(e.bbox=t.bbox),t.type==="GeometryCollection"?(e.geometries=t.geometries.map(function(n){return Iu(n)}),e):(e.coordinates=Ac(t.coordinates),e)}function Ac(t){var e=t;return typeof e[0]!="object"?e.slice():e.map(function(n){return Ac(n)})}function Fg(t,e){if(e===void 0&&(e={}),!Qt(e=e||{}))throw new Error("options is invalid");var n=e.mutate;if(wn(t)!=="FeatureCollection")throw new Error("geojson must be a FeatureCollection");if(!t.features.length)throw new Error("geojson is empty");n!==!1&&n!==void 0||(t=Ye(t));var r=[],i=du(t,function(o,s){var a=function(u,l){var h,c=u.geometry.coordinates,p=l.geometry.coordinates,d=ua(c[0]),g=ua(c[c.length-1]),m=ua(p[0]),f=ua(p[p.length-1]);if(d===f)h=p.concat(c.slice(1));else if(m===g)h=c.concat(p.slice(1));else if(d===m)h=c.slice(1).reverse().concat(p);else{if(g!==f)return null;h=c.concat(p.reverse().slice(1))}return Wt(h)}(o,s);return a||(r.push(o),s)});return i&&r.push(i),r.length?r.length===1?r[0]:yi(r.map(function(o){return o.coordinates})):null}function ua(t){return t[0].toString()+","+t[1].toString()}function kg(t){return t}function Dc(t,e){var n=function(l){if(l==null)return kg;var h,c,p=l.scale[0],d=l.scale[1],g=l.translate[0],m=l.translate[1];return function(f,_){_||(h=c=0);var I=2,y=f.length,v=new Array(y);for(v[0]=(h+=f[0])*p+g,v[1]=(c+=f[1])*d+m;I1)for(var h,c,p=1,d=s(l[0]);pd&&(c=l[0],l[0]=l[p],l[p]=c,d=h);return l}).filter(function(a){return a.length>0})}}var la=Object.prototype.hasOwnProperty;function Su(t,e,n,r,i,o){arguments.length===3&&(r=o=Array,i=null);for(var s=new r(t=1<=t)throw new Error("full hashmap");_=s[f=f+1&u]}return s[f]=g,a[f]=m,m}function c(g,m){for(var f=e(g)&u,_=s[f],I=0;_!=i;){if(n(_,g))return a[f];if(++I>=t)throw new Error("full hashmap");_=s[f=f+1&u]}return s[f]=g,a[f]=m,m}function p(g,m){for(var f=e(g)&u,_=s[f],I=0;_!=i;){if(n(_,g))return a[f];if(++I>=t)break;_=s[f=f+1&u]}return m}function d(){for(var g=[],m=0,f=s.length;m>7^ca[2]^ca[3])}function Bg(t){var e,n,r,i,o=t.coordinates,s=t.lines,a=t.rings,u=function(){for(var C=Su(1.4*o.length,x,b,Int32Array,-1,Int32Array),D=new Int32Array(o.length),M=0,B=o.length;M=0){var R=c[M];O===D&&R===B||O===B&&R===D||(++d,p[M]=1)}else h[M]=D,c[M]=B}}function x(C){return Cu(o[C])}function b(C,D){return Bi(o[C],o[D])}l=h=c=null;var E,T=function(C,D,M,B,O){arguments.length===3&&(B=Array,O=null);for(var R=new B(C=1<=C)throw new Error("full hashset");tt=R[j=j+1&P]}return R[j]=V,!0}function q(V){for(var j=D(V)&P,tt=R[j],at=0;tt!=O;){if(M(tt,V))return!0;if(++at>=C)break;tt=R[j=j+1&P]}return!1}function S(){for(var V=[],j=0,tt=R.length;j>1);em&&(m=T),Cf&&(f=C)}function v(E){E.forEach(y)}function x(E){E.forEach(v)}for(var b in p)_(p[b]);return m>=d&&f>=g?[d,g,m,f]:void 0}(t=jg(t)),r=e>0&&n&&function(p,d,g){var m=d[0],f=d[1],_=d[2],I=d[3],y=_-m?(g-1)/(_-m):1,v=I-f?(g-1)/(I-f):1;function x(O){return[Math.round((O[0]-m)*y),Math.round((O[1]-f)*v)]}function b(O,R){for(var P,F,k,q,S,V=-1,j=0,tt=O.length,at=new Array(tt);++V2&&Bc(n[i-3],n[i-1],n[i-2])&&n.splice(n.length-2,1))}if(n.push(e[e.length-1]),i=n.length,qc(e[0],e[e.length-1])&&i<4)throw new Error("invalid polygon");return Bc(n[i-3],n[i-1],n[i-2])&&n.splice(n.length-2,1),n}function qc(t,e){return t[0]===e[0]&&t[1]===e[1]}function Bc(t,e,n){var r=n[0],i=n[1],o=t[0],s=t[1],a=e[0],u=e[1],l=a-o,h=u-s;return(r-o)*h-(i-s)*l===0&&(Math.abs(l)>=Math.abs(h)?l>0?o<=r&&r<=a:a<=r&&r<=o:h>0?s<=i&&i<=u:u<=i&&i<=s)}function Jg(t,e,n){var r=e.x,i=e.y,o=n.x-r,s=n.y-i;if(o!==0||s!==0){var a=((t.x-r)*o+(t.y-i)*s)/(o*o+s*s);a>1?(r=n.x,i=n.y):a>0&&(r+=o*a,i+=s*a)}return(o=t.x-r)*o+(s=t.y-i)*s}function Lu(t,e,n,r,i){for(var o,s=r,a=e+1;as&&(o=a,s=u)}s>r&&(o-e>1&&Lu(t,e,o,r,i),i.push(t[o]),n-o>1&&Lu(t,o,n,r,i))}function Zg(t,e){var n=t.length-1,r=[t[0]];return Lu(t,0,n,e,r),r.push(t[n]),r}function Ou(t,e,n){if(t.length<=2)return t;var r=e!==void 0?e*e:1;return t=Zg(t=n?t:function(i,o){for(var s,a,u,l,h,c=i[0],p=[c],d=1,g=i.length;do&&(p.push(s),c=s);return c!==s&&p.push(s),p}(t,r),r)}function zc(t,e,n){return Ou(t.map(function(r){return{x:r[0],y:r[1],z:r[2]}}),e,n).map(function(r){return r.z?[r.x,r.y,r.z]:[r.x,r.y]})}function jc(t,e,n){return t.map(function(r){var i=r.map(function(s){return{x:s[0],y:s[1]}});if(i.length<4)throw new Error("invalid polygon");for(var o=Ou(i,e,n).map(function(s){return[s.x,s.y]});!Kg(o);)o=Ou(i,e-=.01*e,n).map(function(s){return[s.x,s.y]});return o[o.length-1][0]===o[0][0]&&o[o.length-1][1]===o[0][1]||o.push(o[0]),o})}function Kg(t){return!(t.length<3)&&!(t.length===3&&t[2][0]===t[0][0]&&t[2][1]===t[0][1])}var Qg=function(){function t(e){this.points=e.points||[],this.duration=e.duration||1e4,this.sharpness=e.sharpness||.85,this.centers=[],this.controls=[],this.stepLength=e.stepLength||60,this.length=this.points.length,this.delay=0;for(var n=0;ne&&(n.push(i),r=o)}return n},t.prototype.vector=function(e){var n=this.pos(e+10),r=this.pos(e-10);return{angle:180*Math.atan2(n.y-r.y,n.x-r.x)/3.14,speed:Math.sqrt((r.x-n.x)*(r.x-n.x)+(r.y-n.y)*(r.y-n.y)+(r.z-n.z)*(r.z-n.z))}},t.prototype.pos=function(e){var n=e-this.delay;n<0&&(n=0),n>this.duration&&(n=this.duration-1);var r=n/this.duration;if(r>=1)return this.points[this.length-1];var i=Math.floor((this.points.length-1)*r);return function(o,s,a,u,l){var h=function(c){var p=c*c;return[p*c,3*p*(1-c),3*c*(1-c)*(1-c),(1-c)*(1-c)*(1-c)]}(o);return{x:l.x*h[0]+u.x*h[1]+a.x*h[2]+s.x*h[3],y:l.y*h[0]+u.y*h[1]+a.y*h[2]+s.y*h[3],z:l.z*h[0]+u.z*h[1]+a.z*h[2]+s.z*h[3]}}((this.length-1)*r-i,this.points[i],this.controls[i][1],this.controls[i+1][0],this.points[i+1])},t}();function Uc(t,e){e===void 0&&(e={});for(var n=e.resolution||1e4,r=e.sharpness||.85,i=[],o=ae(t).coordinates.map(function(l){return{x:l[0],y:l[1]}}),s=new Qg({duration:n,points:o,sharpness:r}),a=function(l){var h=s.pos(l);Math.floor(l/100)%2==0&&i.push([h.x,h.y])},u=0;u=$t(t.slice(0,2),[e,i])){var o=(n+i)/2;return[e,o-(r-e)/2,r,o+(r-e)/2]}var s=(e+r)/2;return[s-(i-n)/2,n,s+(i-n)/2,i]}function Fr(t,e,n,r){r===void 0&&(r={});var i=re(t),o=ke(i[0]),s=ke(i[1]),a=ke(n),u=ki(e,r.units),l=Math.asin(Math.sin(s)*Math.cos(u)+Math.cos(s)*Math.sin(u)*Math.cos(a));return ft([mi(o+Math.atan2(Math.sin(a)*Math.sin(u)*Math.cos(s),Math.cos(u)-Math.sin(s)*Math.sin(l))),mi(l)],r.properties)}function Tu(t,e,n){n===void 0&&(n={});for(var r=n.steps||64,i=n.properties?n.properties:!Array.isArray(t)&&t.type==="Feature"&&t.properties?t.properties:{},o=[],s=0;s80*n){r=o=t[0],i=s=t[1];for(var g=n;go&&(o=a),u>s&&(s=u);l=(l=Math.max(o-r,s-i))!==0?1/l:0}return as(p,d,n,r,i,l),d}function Hc(t,e,n,r,i){var o,s;if(i===Fu(t,e,n,r)>0)for(o=e;o=e;o-=r)s=Zc(o,t[o],t[o+1],s);return s&&ji(s,s.next)&&(ls(s),s=s.next),s}function ss(t,e){if(!t)return t;e||(e=t);var n,r=t;do if(n=!1,r.steiner||!ji(r,r.next)&&ln(r.prev,r,r.next)!==0)r=r.next;else{if(ls(r),(r=e=r.prev)===r.next)break;n=!0}while(n||r!==e);return e}function as(t,e,n,r,i,o,s){if(t){!s&&o&&function(h,c,p,d){var g=h;do g.z===null&&(g.z=Au(g.x,g.y,c,p,d)),g.prevZ=g.prev,g.nextZ=g.next,g=g.next;while(g!==h);g.prevZ.nextZ=null,g.prevZ=null,function(m){var f,_,I,y,v,x,b,E,T=1;do{for(_=m,m=null,v=null,x=0;_;){for(x++,I=_,b=0,f=0;f0||E>0&&I;)b!==0&&(E===0||!I||_.z<=I.z)?(y=_,_=_.nextZ,b--):(y=I,I=I.nextZ,E--),v?v.nextZ=y:m=y,y.prevZ=v,v=y;_=I}v.nextZ=null,T*=2}while(x>1)}(g)}(t,r,i,o);for(var a,u,l=t;t.prev!==t.next;)if(a=t.prev,u=t.next,o?ed(t,r,i,o):td(t))e.push(a.i/n),e.push(t.i/n),e.push(u.i/n),ls(t),t=u.next,l=u.next;else if((t=u)===l){s?s===1?as(t=nd(t,e,n),e,n,r,i,o,2):s===2&&rd(t,e,n,r,i,o):as(ss(t),e,n,r,i,o,1);break}}}function td(t){var e=t.prev,n=t,r=t.next;if(ln(e,n,r)>=0)return!1;for(var i=t.next.next;i!==t.prev;){if(fo(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&ln(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}function ed(t,e,n,r){var i=t.prev,o=t,s=t.next;if(ln(i,o,s)>=0)return!1;for(var a=i.xo.x?i.x>s.x?i.x:s.x:o.x>s.x?o.x:s.x,h=i.y>o.y?i.y>s.y?i.y:s.y:o.y>s.y?o.y:s.y,c=Au(a,u,e,n,r),p=Au(l,h,e,n,r),d=t.prevZ,g=t.nextZ;d&&d.z>=c&&g&&g.z<=p;){if(d!==t.prev&&d!==t.next&&fo(i.x,i.y,o.x,o.y,s.x,s.y,d.x,d.y)&&ln(d.prev,d,d.next)>=0||(d=d.prevZ,g!==t.prev&&g!==t.next&&fo(i.x,i.y,o.x,o.y,s.x,s.y,g.x,g.y)&&ln(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;d&&d.z>=c;){if(d!==t.prev&&d!==t.next&&fo(i.x,i.y,o.x,o.y,s.x,s.y,d.x,d.y)&&ln(d.prev,d,d.next)>=0)return!1;d=d.prevZ}for(;g&&g.z<=p;){if(g!==t.prev&&g!==t.next&&fo(i.x,i.y,o.x,o.y,s.x,s.y,g.x,g.y)&&ln(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function nd(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!ji(i,o)&&Wc(i,r,r.next,o)&&us(i,o)&&us(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),ls(r),ls(r.next),r=t=o),r=r.next}while(r!==t);return r}function rd(t,e,n,r,i,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&ad(s,a)){var u=Jc(s,a);return s=ss(s,s.next),u=ss(u,u.next),as(s,e,n,r,i,o),void as(u,e,n,r,i,o)}a=a.next}s=s.next}while(s!==t)}function id(t,e){return t.x-e.x}function od(t,e){if(e=function(r,i){var o,s=i,a=r.x,u=r.y,l=-1/0;do{if(u<=s.y&&u>=s.next.y&&s.next.y!==s.y){var h=s.x+(u-s.y)*(s.next.x-s.x)/(s.next.y-s.y);if(h<=a&&h>l){if(l=h,h===a){if(u===s.y)return s;if(u===s.next.y)return s.next}o=s.x=s.x&&s.x>=d&&a!==s.x&&fo(uo.x)&&us(s,r)&&(o=s,m=c),s=s.next;return o}(t,e)){var n=Jc(e,t);ss(n,n.next)}}function Au(t,e,n,r,i){return(t=1431655765&((t=858993459&((t=252645135&((t=16711935&((t=32767*(t-n)*i)|t<<8))|t<<4))|t<<2))|t<<1))|(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-r)*i)|e<<8))|e<<4))|e<<2))|e<<1))<<1}function sd(t){var e=t,n=t;do e.x=0&&(t-s)*(r-a)-(n-s)*(e-a)>=0&&(n-s)*(o-a)-(i-s)*(r-a)>=0}function ad(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(n,r){var i=n;do{if(i.i!==n.i&&i.next.i!==n.i&&i.i!==r.i&&i.next.i!==r.i&&Wc(i,i.next,n,r))return!0;i=i.next}while(i!==n);return!1}(t,e)&&us(t,e)&&us(e,t)&&function(n,r){var i=n,o=!1,s=(n.x+r.x)/2,a=(n.y+r.y)/2;do i.y>a!=i.next.y>a&&i.next.y!==i.y&&s<(i.next.x-i.x)*(a-i.y)/(i.next.y-i.y)+i.x&&(o=!o),i=i.next;while(i!==n);return o}(t,e)}function ln(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function ji(t,e){return t.x===e.x&&t.y===e.y}function Wc(t,e,n,r){return!!(ji(t,e)&&ji(n,r)||ji(t,r)&&ji(n,e))||ln(t,e,n)>0!=ln(t,e,r)>0&&ln(n,r,t)>0!=ln(n,r,e)>0}function us(t,e){return ln(t.prev,t,t.next)<0?ln(t,e,t.next)>=0&&ln(t,t.prev,e)>=0:ln(t,e,t.prev)<0||ln(t,t.next,e)<0}function Jc(t,e){var n=new Du(t.i,t.x,t.y),r=new Du(e.i,e.x,e.y),i=t.next,o=e.prev;return t.next=e,e.prev=t,n.next=i,i.prev=n,r.next=n,n.prev=r,o.next=r,r.prev=o,r}function Zc(t,e,n,r){var i=new Du(t,e,n);return r?(i.next=r.next,i.prev=r,r.next.prev=i,r.next=i):(i.prev=i,i.next=i),i}function ls(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}function Du(t,e,n){this.i=t,this.x=e,this.y=n,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}function Fu(t,e,n,r){for(var i=0,o=e,s=n-r;o0&&(h+=a[c-1].length,l.holes.push(h))}return l}(t),n=Yc(e.vertices,e.holes,2),r=[],i=[];n.forEach(function(a,u){var l=n[u];i.push([e.vertices[2*l],e.vertices[2*l+1]])});for(var o=0;oI?f:I,_>y?_:y]}(c,p),h.push(d),p}),h})(a,r.properties).forEach(function(u){u.id=i.length,i.push(u)})})}})(n,e)}),nt(e)}fa.deviation=function(t,e,n,r){var i=e&&e.length,o=i?e[0]*n:t.length,s=Math.abs(Fu(t,0,o,n));if(i)for(var a=0,u=e.length;a0&&(r+=t[i-1].length,n.holes.push(r))}return n},Yc.default=$g;var Ke=Dr(function(t,e){function n(g,m,f){f===void 0&&(f={});var _={type:"Feature"};return(f.id===0||f.id)&&(_.id=f.id),f.bbox&&(_.bbox=f.bbox),_.properties=m||{},_.geometry=g,_}function r(g,m,f){if(f===void 0&&(f={}),!g)throw new Error("coordinates is required");if(!Array.isArray(g))throw new Error("coordinates must be an Array");if(g.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!d(g[0])||!d(g[1]))throw new Error("coordinates must contain numbers");return n({type:"Point",coordinates:g},m,f)}function i(g,m,f){f===void 0&&(f={});for(var _=0,I=g;_=0))throw new Error("precision must be a positive number");var f=Math.pow(10,m||0);return Math.round(g*f)/f},e.radiansToLength=h,e.lengthToRadians=c,e.lengthToDegrees=function(g,m){return p(c(g,m))},e.bearingToAzimuth=function(g){var m=g%360;return m<0&&(m+=360),m},e.radiansToDegrees=p,e.degreesToRadians=function(g){return g%360*Math.PI/180},e.convertLength=function(g,m,f){if(m===void 0&&(m="kilometers"),f===void 0&&(f="kilometers"),!(g>=0))throw new Error("length must be a positive number");return h(c(g,m),f)},e.convertArea=function(g,m,f){if(m===void 0&&(m="meters"),f===void 0&&(f="kilometers"),!(g>=0))throw new Error("area must be a positive number");var _=e.areaFactors[m];if(!_)throw new Error("invalid original units");var I=e.areaFactors[f];if(!I)throw new Error("invalid final units");return g/_*I},e.isNumber=d,e.isObject=function(g){return!!g&&g.constructor===Object},e.validateBBox=function(g){if(!g)throw new Error("bbox is required");if(!Array.isArray(g))throw new Error("bbox must be an Array");if(g.length!==4&&g.length!==6)throw new Error("bbox must be an Array of 4 or 6 numbers");g.forEach(function(m){if(!d(m))throw new Error("bbox must only contain numbers")})},e.validateId=function(g){if(!g)throw new Error("id is required");if(["string","number"].indexOf(typeof g)===-1)throw new Error("id must be a number or a string")}});function cs(t,e,n){if(t!==null)for(var r,i,o,s,a,u,l,h,c=0,p=0,d=t.type,g=d==="FeatureCollection",m=d==="Feature",f=g?t.features.length:1,_=0;_u||g>l||m>h)return a=c,u=r,l=g,h=m,void(o=0);var f=Ke.lineString([a,c],n.properties);if(e(f,r,i,m,o)===!1)return!1;o++,a=c})!==!1&&void 0}}})}function eh(t,e){if(!t)throw new Error("geojson is required");da(t,function(n,r,i){if(n.geometry!==null){var o=n.geometry.type,s=n.geometry.coordinates;switch(o){case"LineString":if(e(n,r,i,0,0)===!1)return!1;break;case"Polygon":for(var a=0;an[0]&&(e[0]=n[0]),e[1]>n[1]&&(e[1]=n[1]),e[2] line1 must only contain 2 coordinates");if(r.length!==2)throw new Error(" line2 must only contain 2 coordinates");var i=n[0][0],o=n[0][1],s=n[1][0],a=n[1][1],u=r[0][0],l=r[0][1],h=r[1][0],c=r[1][1],p=(c-l)*(s-i)-(h-u)*(a-o),d=(h-u)*(o-l)-(c-l)*(i-u),g=(s-i)*(o-l)-(a-o)*(i-u);if(p===0)return null;var m=d/p,f=g/p;return m>=0&&m<=1&&f>=0&&f<=1?ft([i+m*(s-i),o+m*(a-o)]):null}function ri(t,e,n){n===void 0&&(n={});var r=ft([1/0,1/0],{dist:1/0}),i=0;return Ee(t,function(o){for(var s=it(o),a=0;a0&&((f=m.features[0]).properties.dist=$t(e,f,n),f.properties.location=i+$t(u,f,n)),u.properties.dist180?-360:r[0]-i[0]>180?360:0,qi(function(o,s,a){var u=a=a===void 0?tr:Number(a),l=o[1]*Math.PI/180,h=s[1]*Math.PI/180,c=h-l,p=Math.abs(s[0]-o[0])*Math.PI/180;p>Math.PI&&(p-=2*Math.PI);var d=Math.log(Math.tan(h/2+Math.PI/4)/Math.tan(l/2+Math.PI/4)),g=Math.abs(d)>1e-11?c/d:Math.cos(l);return Math.sqrt(c*c+g*g*p*p)*u}(r,i),"meters",n.units)}function oh(t,e,n){if(n===void 0&&(n={}),n.method||(n.method="geodesic"),n.units||(n.units="kilometers"),!t)throw new Error("pt is required");if(Array.isArray(t)?t=ft(t):t.type==="Point"?t=Te(t):ts(t,"Point","point"),!e)throw new Error("line is required");Array.isArray(e)?e=Wt(e):e.type==="LineString"?e=Te(e):ts(e,"LineString","line");var r=1/0,i=t.geometry.coordinates;return ei(e,function(o){var s=o.geometry.coordinates[0],a=o.geometry.coordinates[1],u=function(l,h,c,p){var d=[c[0]-h[0],c[1]-h[1]],g=sh([l[0]-h[0],l[1]-h[1]],d);if(g<=0)return Bu(l,h,{method:p.method,units:"degrees"});var m=sh(d,d);if(m<=g)return Bu(l,c,{method:p.method,units:"degrees"});var f=g/m,_=[h[0]+f*d[0],h[1]+f*d[1]];return Bu(l,_,{method:p.method,units:"degrees"})}(i,s,a,n);u=0&&l<=1&&(p.onLine1=!0),h>=0&&h<=1&&(p.onLine2=!0),!(!p.onLine1||!p.onLine2)&&[p.x,p.y])}function ah(t){for(var e=function(p){return p.type!=="FeatureCollection"?p.type!=="Feature"?nt([Te(p)]):nt([p]):p}(t),n=ha(e),r=!1,i=0;!r&&i0){e+=Math.abs(hh(t[0]));for(var n=1;n2){for(s=0;s=h&&c===i.length-1);c++){if(h>e&&o.length===0){if(!(s=e-h))return o.push(i[c]),Wt(o);a=ni(i[c],i[c-1])-180,u=Fr(i[c],s,a,r),o.push(u.geometry.coordinates)}if(h>=n)return(s=n-h)?(a=ni(i[c],i[c-1])-180,u=Fr(i[c],s,a,r),o.push(u.geometry.coordinates),Wt(o)):(o.push(i[c]),Wt(o));if(h>=e&&o.push(i[c]),c===i.length-1)return Wt(o);h+=$t(i[c],i[c+1],r)}if(hi)return!1}else if(d!==0)return!1;return r?r==="start"?Math.abs(c)>=Math.abs(p)?c>0?a0?u=Math.abs(p)?c>0?a<=o&&o0?u<=s&&s=Math.abs(p)?c>0?a0?u=Math.abs(p)?c>0?a<=o&&o<=l:l<=o&&o<=a:p>0?u<=s&&s<=h:h<=s&&s<=u}function fh(t,e){var n=ae(t),r=ae(e),i=n.type,o=r.type;switch(i){case"Point":switch(o){case"MultiPoint":return function(s,a){var u,l=!1;for(u=0;ue[0])&&!(t[2]e[1])&&!(t[3] is required");if(typeof n!="number")throw new Error(" must be a number");if(typeof r!="number")throw new Error(" must be a number");i!==!1&&i!==void 0||(t=JSON.parse(JSON.stringify(t)));var o=Math.pow(10,n);return Ce(t,function(s){(function(a,u,l){a.length>l&&a.splice(l,a.length);for(var h=0;h=1||v<=0||x>=1||x<=0))){var M=D,B=!o[M];B&&(o[M]=!0),e?i.push(e(D,f,_,b,E,v,I,y,T,C,x,B)):i.push(D)}}function m(f,_){var I,y,v,x,b=r[f][_],E=r[f][_+1];return b[0]=0==e}function Rd(t){for(var e=0,n=0;n1&&n.push(Wt(l)),nt(n)}function Ih(t,e){if(!e.features.length)throw new Error("lines must contain features");if(e.features.length===1)return e.features[0];var n,r=1/0;return Zt(e,function(i){var o=ri(i,t).properties.dist;oh&&p.push(Fr(t,e,h,i).geometry.coordinates),Wt(p,u)}function Ch(t){var e=t%360;return e<0&&(e+=360),e}function gs(t,e){e===void 0&&(e={});var n=ae(t);switch(e.properties||t.type!=="Feature"||(e.properties=t.properties),n.type){case"Polygon":return Nh(n,e);case"MultiPolygon":return function(r,i){i===void 0&&(i={});var o=ae(r).coordinates,s=i.properties?i.properties:r.type==="Feature"?r.properties:{},a=[];return o.forEach(function(u){a.push(Ph(u,s))}),nt(a)}(n,e);default:throw new Error("invalid poly")}}function Nh(t,e){return e===void 0&&(e={}),Ph(ae(t).coordinates,e.properties?e.properties:t.type==="Feature"?t.properties:{})}function Ph(t,e){return t.length>1?yi(t,e):Wt(t[0],e)}function Mh(t,e){var n,r,i;e===void 0&&(e={});var o=e.properties,s=(n=e.autoComplete)===null||n===void 0||n,a=(r=e.orderCoords)===null||r===void 0||r;switch((i=e.mutate)!==null&&i!==void 0&&i||(t=Ye(t)),t.type){case"FeatureCollection":var u=[];return t.features.forEach(function(l){u.push(it(Lh(l,{},s,a)))}),xr(u,o);default:return Lh(t,o,s,a)}}function Lh(t,e,n,r){e=e||(t.type==="Feature"?t.properties:{});var i=ae(t),o=i.coordinates,s=i.type;if(!o.length)throw new Error("line must contain coordinates");switch(s){case"LineString":return n&&(o=Oh(o)),ct([o],e);case"MultiLineString":var a=[],u=0;return o.forEach(function(l){if(n&&(l=Oh(l)),r){var h=function(c){var p=c[0],d=c[1],g=c[2],m=c[3];return Math.abs(p-g)*Math.abs(d-m)}(ye(Wt(l)));h>u?(a.unshift(l),u=h):a.push(l)}else a.push(l)}),ct(a,e);default:throw new Error("geometry type "+s+" is not supported")}}function Oh(t){var e=t[0],n=e[0],r=e[1],i=t[t.length-1],o=i[0],s=i[1];return n===o&&r===s||t.push(e),t}function Td(t,e){var n,r,i,o,s,a,u;for(r=1;r<=8;r*=2){for(n=[],o=!(vo(i=t[t.length-1],e)&r),s=0;se[2]&&(n|=2),t[1]e[3]&&(n|=8),n}function Rh(t,e){for(var n=[],r=0,i=t;r0&&(o[0][0]===o[o.length-1][0]&&o[0][1]===o[o.length-1][1]||o.push(o[0]),o.length>=4&&n.push(o))}return n}Xu.prototype.interpolate=function(t){var e=Math.sin((1-t)*this.g)/Math.sin(this.g),n=Math.sin(t*this.g)/Math.sin(this.g),r=e*Math.cos(this.start.y)*Math.cos(this.start.x)+n*Math.cos(this.end.y)*Math.cos(this.end.x),i=e*Math.cos(this.start.y)*Math.sin(this.start.x)+n*Math.cos(this.end.y)*Math.sin(this.end.x),o=e*Math.sin(this.start.y)+n*Math.sin(this.end.y),s=Eh*Math.atan2(o,Math.sqrt(Math.pow(r,2)+Math.pow(i,2)));return[Eh*Math.atan2(i,r),s]},Xu.prototype.Arc=function(t,e){var n=[];if(!t||t<=2)n.push([this.start.lon,this.start.lat]),n.push([this.end.lon,this.end.lat]);else for(var r=1/(t-1),i=0;ip&&(m>h&&gh&&mu&&(u=f)}var _=[];if(a&&u0&&Math.abs(v-n[y-1][0])>p){var x=parseFloat(n[y-1][0]),b=parseFloat(n[y-1][1]),E=parseFloat(n[y][0]),T=parseFloat(n[y][1]);if(x>-180&&x-180&&n[y-1][0]h&&x<180&&E===-180&&y+1h&&n[y-1][0]<180){I.push([180,n[y][1]]),y++,I.push([n[y][0],n[y][1]]);continue}if(xh){var C=x;x=E,E=C;var D=b;b=T,T=D}if(x>h&&E=180&&xh?180:-180,B]),(I=[]).push([n[y-1][0]>h?-180:180,B]),_.push(I)}else I=[],_.push(I);I.push([v,n[y][1]])}else I.push([n[y][0],n[y][1]])}}else{var O=[];_.push(O);for(var R=0;R=0;c--)if(d[c]!=g[c])return!1;for(c=d.length-1;c>=0;c--)if(p=d[c],!n(u[p],l[p],h))return!1;return typeof u==typeof l}(o,s,a))};function r(o){return o==null}function i(o){return!(!o||typeof o!="object"||typeof o.length!="number")&&typeof o.copy=="function"&&typeof o.slice=="function"&&!(o.length>0&&typeof o[0]!="number")}});function Dh(t,e,n){if(n===void 0&&(n={}),!Qt(n=n||{}))throw new Error("options is invalid");var r,i=n.tolerance||0,o=[],s=yo(),a=Ui(t);return s.load(a),ei(e,function(u){var l=!1;u&&(Zt(s.search(u),function(h){if(l===!1){var c=it(u).sort(),p=it(h).sort();_o(c,p)||(i===0?Rn(c[0],h)&&Rn(c[1],h):ri(h,c[0]).properties.dist<=i&&ri(h,c[1]).properties.dist<=i)?(l=!0,r=r?Fh(r,u):u):(i===0?Rn(p[0],u)&&Rn(p[1],u):ri(u,p[0]).properties.dist<=i&&ri(u,p[1]).properties.dist<=i)&&(r=r?Fh(r,h):h)}}),l===!1&&r&&(o.push(r),r=void 0))}),r&&o.push(r),nt(o)}function Fh(t,e){var n=it(e),r=it(t),i=r[0],o=r[r.length-1],s=t.geometry.coordinates;return _o(n[0],i)?s.unshift(n[1]):_o(n[0],o)?s.push(n[1]):_o(n[1],i)?s.unshift(n[0]):_o(n[1],o)&&s.push(n[0]),t}function kh(t){var e=t%360;return e<0&&(e+=360),e}function Vi(t,e,n){var r;return n===void 0&&(n={}),(r=n.final?Gh(re(e),re(t)):Gh(re(t),re(e)))>180?-(360-r):r}function Gh(t,e){var n=ke(t[1]),r=ke(e[1]),i=ke(e[0]-t[0]);i>Math.PI&&(i-=2*Math.PI),i<-Math.PI&&(i+=2*Math.PI);var o=Math.log(Math.tan(r/2+Math.PI/4)/Math.tan(n/2+Math.PI/4));return(mi(Math.atan2(i,o))+360)%360}function xo(t,e,n,r){r===void 0&&(r={});var i=e<0,o=qi(Math.abs(e),r.units,"meters");i&&(o=-Math.abs(o));var s=re(t),a=function(u,l,h,c){c=c===void 0?tr:Number(c);var p=l/c,d=u[0]*Math.PI/180,g=ke(u[1]),m=ke(h),f=p*Math.cos(m),_=g+f;Math.abs(_)>Math.PI/2&&(_=_>0?Math.PI-_:-Math.PI-_);var I=Math.log(Math.tan(_/2+Math.PI/4)/Math.tan(g/2+Math.PI/4)),y=Math.abs(I)>1e-11?f/I:Math.cos(g),v=p*Math.sin(m)/y;return[(180*(d+v)/Math.PI+540)%360-180,180*_/Math.PI]}(s,o,n);return a[0]+=a[0]-s[0]>180?-360:s[0]-a[0]>180?360:0,ft(a,r.properties)}function qh(t,e,n,r,i,o){for(var s=0;s0?ds(e,a,i)<0||(i=a):n>0&&r<=0&&(Ad(e,a,o)||(o=a)),n=r}return[i,o]}function Ad(t,e,n){return ds(t,e,n)>0}function ds(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(n[0]-t[0])*(e[1]-t[1])}function va(t){for(var e,n,r=it(t),i=0,o=1;o0}function _a(t,e){switch(t.type==="Feature"?t.geometry.type:t.type){case"GeometryCollection":return zn(t,function(n){_a(n,e)}),t;case"LineString":return Bh(it(t),e),t;case"Polygon":return zh(it(t),e),t;case"MultiLineString":return it(t).forEach(function(n){Bh(n,e)}),t;case"MultiPolygon":return it(t).forEach(function(n){zh(n,e)}),t;case"Point":case"MultiPoint":return t}}function Bh(t,e){va(t)===e&&t.reverse()}function zh(t,e){va(t[0])!==e&&t[0].reverse();for(var n=1;nf?128:64,y|=xf?32:16,y|=bf?8:4;var T=+(y|=Ef?2:1),C=0;if(y===17||y===18||y===33||y===34||y===38||y===68||y===72||y===98||y===102||y===132||y===136||y===137||y===152||y===153){var D=(v+x+b+E)/4;C=D>f?2:D0?(y=156,C=4):y=152:y===33?C>0?(y=139,C=4):y=137:y===72?C>0?(y=99,C=4):y=98:y===132&&(C>0?(y=39,C=4):y=38)}if(y!=0&&y!=170){var M,B,O,R,P,F,k,q;M=B=O=R=P=F=k=q=.5;var S=[];y===1?(O=1-w(c,b,E),q=1-w(c,v,E),S.push(K[y])):y===169?(O=w(f,E,b),q=w(f,E,v),S.push(K[y])):y===4?(F=1-w(c,x,b),R=w(c,E,b),S.push(H[y])):y===166?(F=w(f,b,x),R=1-w(f,b,E),S.push(H[y])):y===16?(P=w(c,b,x),B=w(c,v,x),S.push(W[y])):y===154?(P=1-w(f,x,b),B=1-w(f,x,v),S.push(W[y])):y===64?(k=w(c,E,v),M=1-w(c,x,v),S.push(rt[y])):y===106?(k=1-w(f,v,E),M=w(f,v,x),S.push(rt[y])):y===168?(R=w(f,E,b),O=w(c,E,b),q=w(c,E,v),k=w(f,E,v),S.push(Q[y]),S.push(K[y])):y===2?(R=1-w(c,b,E),O=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),S.push(Q[y]),S.push(K[y])):y===162?(P=w(f,b,x),F=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),S.push(Q[y]),S.push(K[y])):y===8?(P=1-w(c,x,b),F=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),S.push(W[y]),S.push(H[y])):y===138?(P=1-w(c,x,b),F=1-w(f,x,b),M=1-w(f,x,v),B=1-w(c,x,v),S.push(W[y]),S.push(H[y])):y===32?(P=w(f,b,x),F=w(c,b,x),M=w(c,v,x),B=w(f,v,x),S.push(W[y]),S.push(H[y])):y===42?(q=1-w(f,v,E),k=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x),S.push(ot[y]),S.push(rt[y])):y===128&&(q=w(c,E,v),k=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v),S.push(ot[y]),S.push(rt[y])),y===5?(F=1-w(c,x,b),q=1-w(c,v,E),S.push(H[y])):y===165?(F=w(f,b,x),q=w(f,E,v),S.push(H[y])):y===20?(R=w(c,E,b),B=w(c,v,x),S.push(Q[y])):y===150?(R=1-w(f,b,E),B=1-w(f,x,v),S.push(Q[y])):y===80?(P=w(c,b,x),k=w(c,E,v),S.push(W[y])):y===90?(P=1-w(f,x,b),k=1-w(f,v,E),S.push(W[y])):y===65?(O=1-w(c,b,E),M=1-w(c,x,v),S.push(K[y])):y===105?(O=w(f,E,b),M=w(f,v,x),S.push(K[y])):y===160?(P=w(f,b,x),F=w(c,b,x),q=w(c,E,v),k=w(f,E,v),S.push(W[y]),S.push(H[y])):y===10?(P=1-w(c,x,b),F=1-w(f,x,b),q=1-w(f,v,E),k=1-w(c,v,E),S.push(W[y]),S.push(H[y])):y===130?(R=1-w(c,b,E),O=1-w(f,b,E),M=1-w(f,x,v),B=1-w(c,x,v),S.push(Q[y]),S.push(K[y])):y===40?(R=w(f,E,b),O=w(c,E,b),M=w(c,v,x),B=w(f,v,x),S.push(Q[y]),S.push(K[y])):y===101?(F=w(f,b,x),M=w(f,v,x),S.push(H[y])):y===69?(F=1-w(c,x,b),M=1-w(c,x,v),S.push(H[y])):y===149?(q=w(f,E,v),B=1-w(f,x,v),S.push(ot[y])):y===21?(q=1-w(c,v,E),B=w(c,v,x),S.push(ot[y])):y===86?(R=1-w(f,b,E),k=1-w(f,v,E),S.push(Q[y])):y===84?(R=w(c,E,b),k=w(c,E,v),S.push(Q[y])):y===89?(P=1-w(f,x,b),O=w(f,E,b),S.push(K[y])):y===81?(P=w(c,b,x),O=1-w(c,b,E),S.push(K[y])):y===96?(P=w(f,b,x),F=w(c,b,x),k=w(c,E,v),M=w(f,v,x),S.push(W[y]),S.push(H[y])):y===74?(P=1-w(c,x,b),F=1-w(f,x,b),k=1-w(f,v,E),M=1-w(c,x,v),S.push(W[y]),S.push(H[y])):y===24?(P=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),B=w(c,v,x),S.push(W[y]),S.push(K[y])):y===146?(P=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),B=1-w(f,x,v),S.push(W[y]),S.push(K[y])):y===6?(F=1-w(c,x,b),R=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),S.push(H[y]),S.push(Q[y])):y===164?(F=w(f,b,x),R=w(c,E,b),q=w(c,E,v),k=w(f,E,v),S.push(H[y]),S.push(Q[y])):y===129?(O=1-w(c,b,E),q=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v),S.push(K[y]),S.push(ot[y])):y===41?(O=w(f,E,b),q=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x),S.push(K[y]),S.push(ot[y])):y===66?(R=1-w(c,b,E),O=1-w(f,b,E),k=1-w(f,v,E),M=1-w(c,x,v),S.push(Q[y]),S.push(K[y])):y===104?(R=w(f,E,b),O=w(c,E,b),k=w(c,E,v),M=w(f,v,x),S.push(K[y]),S.push(jt[y])):y===144?(P=w(c,b,x),q=w(c,E,v),k=w(f,E,v),B=1-w(f,x,v),S.push(W[y]),S.push(rt[y])):y===26?(P=1-w(f,x,b),q=1-w(f,v,E),k=1-w(c,v,E),B=w(c,v,x),S.push(W[y]),S.push(rt[y])):y===36?(F=w(f,b,x),R=w(c,E,b),M=w(c,v,x),B=w(f,v,x),S.push(H[y]),S.push(Q[y])):y===134?(F=1-w(c,x,b),R=1-w(f,b,E),M=1-w(f,x,v),B=1-w(c,x,v),S.push(H[y]),S.push(Q[y])):y===9?(P=1-w(c,x,b),F=1-w(f,x,b),O=w(f,E,b),q=1-w(c,v,E),S.push(W[y]),S.push(H[y])):y===161?(P=w(f,b,x),F=w(c,b,x),O=1-w(c,b,E),q=w(f,E,v),S.push(W[y]),S.push(H[y])):y===37?(F=w(f,b,x),q=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x),S.push(H[y]),S.push(ot[y])):y===133?(F=1-w(c,x,b),q=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v),S.push(H[y]),S.push(ot[y])):y===148?(R=w(c,E,b),q=w(c,E,v),k=w(f,E,v),B=1-w(f,x,v),S.push(Q[y]),S.push(rt[y])):y===22?(R=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),B=w(c,v,x),S.push(Q[y]),S.push(rt[y])):y===82?(P=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),k=1-w(f,v,E),S.push(W[y]),S.push(K[y])):y===88?(P=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),k=w(c,E,v),S.push(W[y]),S.push(K[y])):y===73?(P=1-w(c,x,b),F=1-w(f,x,b),O=w(f,E,b),M=1-w(c,x,v),S.push(W[y]),S.push(H[y])):y===97?(P=w(f,b,x),F=w(c,b,x),O=1-w(c,b,E),M=w(f,v,x),S.push(W[y]),S.push(H[y])):y===145?(P=w(c,b,x),O=1-w(c,b,E),q=w(f,E,v),B=1-w(f,x,v),S.push(W[y]),S.push(ot[y])):y===25?(P=1-w(f,x,b),O=w(f,E,b),q=1-w(c,v,E),B=w(c,v,x),S.push(W[y]),S.push(ot[y])):y===70?(F=1-w(c,x,b),R=1-w(f,b,E),k=1-w(f,v,E),M=1-w(c,x,v),S.push(H[y]),S.push(Q[y])):y===100?(F=w(f,b,x),R=w(c,E,b),k=w(c,E,v),M=w(f,v,x),S.push(H[y]),S.push(Q[y])):y===34?(C===0?(P=1-w(c,x,b),F=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),q=w(c,E,v),k=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v)):(P=w(f,b,x),F=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x)),S.push(W[y]),S.push(H[y]),S.push(ot[y]),S.push(rt[y])):y===35?(C===4?(P=1-w(c,x,b),F=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),q=w(c,E,v),k=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v)):(P=w(f,b,x),F=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x)),S.push(W[y]),S.push(H[y]),S.push(K[y]),S.push(rt[y])):y===136?(C===0?(P=w(f,b,x),F=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x)):(P=1-w(c,x,b),F=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),q=w(c,E,v),k=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v)),S.push(W[y]),S.push(H[y]),S.push(ot[y]),S.push(rt[y])):y===153?(C===0?(P=w(c,b,x),O=1-w(c,b,E),q=1-w(c,v,E),B=w(c,v,x)):(P=1-w(f,x,b),O=w(f,E,b),q=w(f,E,v),B=1-w(f,x,v)),S.push(W[y]),S.push(K[y])):y===102?(C===0?(F=1-w(c,x,b),R=w(c,E,b),k=w(c,E,v),M=1-w(c,x,v)):(F=w(f,b,x),R=1-w(f,b,E),k=1-w(f,v,E),M=w(f,v,x)),S.push(H[y]),S.push(rt[y])):y===155?(C===4?(P=w(c,b,x),O=1-w(c,b,E),q=1-w(c,v,E),B=w(c,v,x)):(P=1-w(f,x,b),O=w(f,E,b),q=w(f,E,v),B=1-w(f,x,v)),S.push(W[y]),S.push(ot[y])):y===103?(C===4?(F=1-w(c,x,b),R=w(c,E,b),k=w(c,E,v),M=1-w(c,x,v)):(F=w(f,b,x),R=1-w(f,b,E),k=1-w(f,v,E),M=w(f,v,x)),S.push(H[y]),S.push(Q[y])):y===152?(C===0?(P=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),B=w(c,v,x)):(P=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),q=w(c,E,v),k=w(f,E,v),B=1-w(f,x,v)),S.push(W[y]),S.push(Q[y]),S.push(K[y])):y===156?(C===4?(P=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),B=w(c,v,x)):(P=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),q=w(c,E,v),k=w(f,E,v),B=1-w(f,x,v)),S.push(W[y]),S.push(K[y]),S.push(rt[y])):y===137?(C===0?(P=w(f,b,x),F=w(c,b,x),O=1-w(c,b,E),q=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x)):(P=1-w(c,x,b),F=1-w(f,x,b),O=w(f,E,b),q=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v)),S.push(W[y]),S.push(H[y]),S.push(K[y])):y===139?(C===4?(P=w(f,b,x),F=w(c,b,x),O=1-w(c,b,E),q=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x)):(P=1-w(c,x,b),F=1-w(f,x,b),O=w(f,E,b),q=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v)),S.push(W[y]),S.push(H[y]),S.push(ot[y])):y===98?(C===0?(P=1-w(c,x,b),F=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),k=w(c,E,v),M=1-w(c,x,v)):(P=w(f,b,x),F=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),k=1-w(f,v,E),M=w(f,v,x)),S.push(W[y]),S.push(H[y]),S.push(rt[y])):y===99?(C===4?(P=1-w(c,x,b),F=1-w(f,x,b),R=w(f,E,b),O=w(c,E,b),k=w(c,E,v),M=1-w(c,x,v)):(P=w(f,b,x),F=w(c,b,x),R=1-w(c,b,E),O=1-w(f,b,E),k=1-w(f,v,E),M=w(f,v,x)),S.push(W[y]),S.push(H[y]),S.push(K[y])):y===38?(C===0?(F=1-w(c,x,b),R=w(c,E,b),q=w(c,E,v),k=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v)):(F=w(f,b,x),R=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x)),S.push(H[y]),S.push(ot[y]),S.push(rt[y])):y===39?(C===4?(F=1-w(c,x,b),R=w(c,E,b),q=w(c,E,v),k=w(f,E,v),M=1-w(f,x,v),B=1-w(c,x,v)):(F=w(f,b,x),R=1-w(f,b,E),q=1-w(f,v,E),k=1-w(c,v,E),M=w(c,v,x),B=w(f,v,x)),S.push(H[y]),S.push(Q[y]),S.push(rt[y])):y===85&&(P=1,F=0,R=1,O=0,q=0,k=1,M=0,B=1),(M<0||M>1||B<0||B>1||P<0||P>1||R<0||R>1||q<0||q>1||k<0||k>1)&&console.log("MarchingSquaresJS-isoBands: "+y+" "+T+" "+v+","+x+","+b+","+E+" "+C+" "+M+" "+B+" "+P+" "+F+" "+R+" "+O+" "+q+" "+k),m.cells[_][I]={cval:y,cval_real:T,flipped:C,topleft:M,topright:B,righttop:P,rightbottom:F,bottomright:R,bottomleft:O,leftbottom:q,lefttop:k,edges:S}}}}}return m}(t,e,n);return Xi.polygons?(Xi.verbose&&console.log("MarchingSquaresJS-isoBands: returning single polygons for each grid cell"),u=function(h){var c=[],p=0;return h.cells.forEach(function(d,g){d.forEach(function(m,f){if(m!==void 0){var _=Y[m.cval](m);typeof _=="object"&&rl(_)?typeof _[0]=="object"&&rl(_[0])?typeof _[0][0]=="object"&&rl(_[0][0])?_.forEach(function(I){I.forEach(function(y){y[0]+=f,y[1]+=g}),c[p++]=I}):(_.forEach(function(I){I[0]+=f,I[1]+=g}),c[p++]=_):console.log("MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates"):console.log("MarchingSquaresJS-isoBands: bandcell polygon with null coordinates")}})}),c}(l)):(Xi.verbose&&console.log("MarchingSquaresJS-isoBands: returning polygon paths for entire data grid"),u=function(h){for(var c=[],p=h.rows,d=h.cols,g=[],m=0;m0){var _=Gd(h.cells[m][f]),I=null,y=f,v=m;_!==null&&g.push([_.p[0]+y,_.p[1]+v]);do{if((I=qd(h.cells[v][y],_.x,_.y,_.o))===null)break;if(g.push([I.p[0]+y,I.p[1]+v]),y+=I.x,_=I,(v+=I.y)<0||v>=p||y<0||y>=d||h.cells[v][y]===void 0){var x=kd(h,y-=I.x,v-=I.y,I.x,I.y,I.o);if(x===null)break;x.path.forEach(function(b){g.push(b)}),y=x.i,v=x.j,_=x}}while(h.cells[v][y]!==void 0&&h.cells[v][y].edges.length>0);c.push(g),g=[],h.cells[m][f].edges.length>0&&f--}return c}(l)),typeof Xi.successCallback=="function"&&Xi.successCallback(u),u}var cn=64,Er=16,vt=[],_t=[],xt=[],Et=[],bt=[],wt=[],It=[],St=[],Ct=[],Nt=[],Pt=[],Mt=[],Lt=[],Ot=[],Rt=[],Tt=[],At=[],Dt=[],Ft=[],kt=[],Gt=[],qt=[],Bt=[],zt=[];It[85]=Nt[85]=-1,St[85]=Pt[85]=0,Ct[85]=Mt[85]=1,Ft[85]=qt[85]=1,kt[85]=Bt[85]=0,Gt[85]=zt[85]=1,vt[85]=Et[85]=0,_t[85]=bt[85]=-1,xt[85]=Rt[85]=0,Tt[85]=Lt[85]=0,At[85]=Ot[85]=1,wt[85]=Dt[85]=1,qt[1]=qt[169]=0,Bt[1]=Bt[169]=-1,zt[1]=zt[169]=0,Lt[1]=Lt[169]=-1,Ot[1]=Ot[169]=0,Rt[1]=Rt[169]=0,Nt[4]=Nt[166]=0,Pt[4]=Pt[166]=-1,Mt[4]=Mt[166]=1,Tt[4]=Tt[166]=1,At[4]=At[166]=0,Dt[4]=Dt[166]=0,It[16]=It[154]=0,St[16]=St[154]=1,Ct[16]=Ct[154]=1,Et[16]=Et[154]=1,bt[16]=bt[154]=0,wt[16]=wt[154]=1,Ft[64]=Ft[106]=0,kt[64]=kt[106]=1,Gt[64]=Gt[106]=0,vt[64]=vt[106]=-1,_t[64]=_t[106]=0,xt[64]=xt[106]=1,Ft[2]=Ft[168]=0,kt[2]=kt[168]=-1,Gt[2]=Gt[168]=1,qt[2]=qt[168]=0,Bt[2]=Bt[168]=-1,zt[2]=zt[168]=0,Lt[2]=Lt[168]=-1,Ot[2]=Ot[168]=0,Rt[2]=Rt[168]=0,Tt[2]=Tt[168]=-1,At[2]=At[168]=0,Dt[2]=Dt[168]=1,It[8]=It[162]=0,St[8]=St[162]=-1,Ct[8]=Ct[162]=0,Nt[8]=Nt[162]=0,Pt[8]=Pt[162]=-1,Mt[8]=Mt[162]=1,Lt[8]=Lt[162]=1,Ot[8]=Ot[162]=0,Rt[8]=Rt[162]=1,Tt[8]=Tt[162]=1,At[8]=At[162]=0,Dt[8]=Dt[162]=0,It[32]=It[138]=0,St[32]=St[138]=1,Ct[32]=Ct[138]=1,Nt[32]=Nt[138]=0,Pt[32]=Pt[138]=1,Mt[32]=Mt[138]=0,vt[32]=vt[138]=1,_t[32]=_t[138]=0,xt[32]=xt[138]=0,Et[32]=Et[138]=1,bt[32]=bt[138]=0,wt[32]=wt[138]=1,qt[128]=qt[42]=0,Bt[128]=Bt[42]=1,zt[128]=zt[42]=1,Ft[128]=Ft[42]=0,kt[128]=kt[42]=1,Gt[128]=Gt[42]=0,vt[128]=vt[42]=-1,_t[128]=_t[42]=0,xt[128]=xt[42]=1,Et[128]=Et[42]=-1,bt[128]=bt[42]=0,wt[128]=wt[42]=0,Nt[5]=Nt[165]=-1,Pt[5]=Pt[165]=0,Mt[5]=Mt[165]=0,qt[5]=qt[165]=1,Bt[5]=Bt[165]=0,zt[5]=zt[165]=0,Tt[20]=Tt[150]=0,At[20]=At[150]=1,Dt[20]=Dt[150]=1,Et[20]=Et[150]=0,bt[20]=bt[150]=-1,wt[20]=wt[150]=1,It[80]=It[90]=-1,St[80]=St[90]=0,Ct[80]=Ct[90]=1,Ft[80]=Ft[90]=1,kt[80]=kt[90]=0,Gt[80]=Gt[90]=1,Lt[65]=Lt[105]=0,Ot[65]=Ot[105]=1,Rt[65]=Rt[105]=0,vt[65]=vt[105]=0,_t[65]=_t[105]=-1,xt[65]=xt[105]=0,It[160]=It[10]=-1,St[160]=St[10]=0,Ct[160]=Ct[10]=1,Nt[160]=Nt[10]=-1,Pt[160]=Pt[10]=0,Mt[160]=Mt[10]=0,qt[160]=qt[10]=1,Bt[160]=Bt[10]=0,zt[160]=zt[10]=0,Ft[160]=Ft[10]=1,kt[160]=kt[10]=0,Gt[160]=Gt[10]=1,Tt[130]=Tt[40]=0,At[130]=At[40]=1,Dt[130]=Dt[40]=1,Lt[130]=Lt[40]=0,Ot[130]=Ot[40]=1,Rt[130]=Rt[40]=0,vt[130]=vt[40]=0,_t[130]=_t[40]=-1,xt[130]=xt[40]=0,Et[130]=Et[40]=0,bt[130]=bt[40]=-1,wt[130]=wt[40]=1,Nt[37]=Nt[133]=0,Pt[37]=Pt[133]=1,Mt[37]=Mt[133]=1,qt[37]=qt[133]=0,Bt[37]=Bt[133]=1,zt[37]=zt[133]=0,vt[37]=vt[133]=-1,_t[37]=_t[133]=0,xt[37]=xt[133]=0,Et[37]=Et[133]=1,bt[37]=bt[133]=0,wt[37]=wt[133]=0,Tt[148]=Tt[22]=-1,At[148]=At[22]=0,Dt[148]=Dt[22]=0,qt[148]=qt[22]=0,Bt[148]=Bt[22]=-1,zt[148]=zt[22]=1,Ft[148]=Ft[22]=0,kt[148]=kt[22]=1,Gt[148]=Gt[22]=1,Et[148]=Et[22]=-1,bt[148]=bt[22]=0,wt[148]=wt[22]=1,It[82]=It[88]=0,St[82]=St[88]=-1,Ct[82]=Ct[88]=1,Tt[82]=Tt[88]=1,At[82]=At[88]=0,Dt[82]=Dt[88]=1,Lt[82]=Lt[88]=-1,Ot[82]=Ot[88]=0,Rt[82]=Rt[88]=1,Ft[82]=Ft[88]=0,kt[82]=kt[88]=-1,Gt[82]=Gt[88]=0,It[73]=It[97]=0,St[73]=St[97]=1,Ct[73]=Ct[97]=0,Nt[73]=Nt[97]=0,Pt[73]=Pt[97]=-1,Mt[73]=Mt[97]=0,Lt[73]=Lt[97]=1,Ot[73]=Ot[97]=0,Rt[73]=Rt[97]=0,vt[73]=vt[97]=1,_t[73]=_t[97]=0,xt[73]=xt[97]=1,It[145]=It[25]=0,St[145]=St[25]=-1,Ct[145]=Ct[25]=0,Lt[145]=Lt[25]=1,Ot[145]=Ot[25]=0,Rt[145]=Rt[25]=1,qt[145]=qt[25]=0,Bt[145]=Bt[25]=1,zt[145]=zt[25]=1,Et[145]=Et[25]=-1,bt[145]=bt[25]=0,wt[145]=wt[25]=0,Nt[70]=Nt[100]=0,Pt[70]=Pt[100]=1,Mt[70]=Mt[100]=0,Tt[70]=Tt[100]=-1,At[70]=At[100]=0,Dt[70]=Dt[100]=1,Ft[70]=Ft[100]=0,kt[70]=kt[100]=-1,Gt[70]=Gt[100]=1,vt[70]=vt[100]=1,_t[70]=_t[100]=0,xt[70]=xt[100]=0,Nt[101]=Nt[69]=0,Pt[101]=Pt[69]=1,Mt[101]=Mt[69]=0,vt[101]=vt[69]=1,_t[101]=_t[69]=0,xt[101]=xt[69]=0,qt[149]=qt[21]=0,Bt[149]=Bt[21]=1,zt[149]=zt[21]=1,Et[149]=Et[21]=-1,bt[149]=bt[21]=0,wt[149]=wt[21]=0,Tt[86]=Tt[84]=-1,At[86]=At[84]=0,Dt[86]=Dt[84]=1,Ft[86]=Ft[84]=0,kt[86]=kt[84]=-1,Gt[86]=Gt[84]=1,It[89]=It[81]=0,St[89]=St[81]=-1,Ct[89]=Ct[81]=0,Lt[89]=Lt[81]=1,Ot[89]=Ot[81]=0,Rt[89]=Rt[81]=1,It[96]=It[74]=0,St[96]=St[74]=1,Ct[96]=Ct[74]=0,Nt[96]=Nt[74]=-1,Pt[96]=Pt[74]=0,Mt[96]=Mt[74]=1,Ft[96]=Ft[74]=1,kt[96]=kt[74]=0,Gt[96]=Gt[74]=0,vt[96]=vt[74]=1,_t[96]=_t[74]=0,xt[96]=xt[74]=1,It[24]=It[146]=0,St[24]=St[146]=-1,Ct[24]=Ct[146]=1,Tt[24]=Tt[146]=1,At[24]=At[146]=0,Dt[24]=Dt[146]=1,Lt[24]=Lt[146]=0,Ot[24]=Ot[146]=1,Rt[24]=Rt[146]=1,Et[24]=Et[146]=0,bt[24]=bt[146]=-1,wt[24]=wt[146]=0,Nt[6]=Nt[164]=-1,Pt[6]=Pt[164]=0,Mt[6]=Mt[164]=1,Tt[6]=Tt[164]=-1,At[6]=At[164]=0,Dt[6]=Dt[164]=0,qt[6]=qt[164]=0,Bt[6]=Bt[164]=-1,zt[6]=zt[164]=1,Ft[6]=Ft[164]=1,kt[6]=kt[164]=0,Gt[6]=Gt[164]=0,Lt[129]=Lt[41]=0,Ot[129]=Ot[41]=1,Rt[129]=Rt[41]=1,qt[129]=qt[41]=0,Bt[129]=Bt[41]=1,zt[129]=zt[41]=0,vt[129]=vt[41]=-1,_t[129]=_t[41]=0,xt[129]=xt[41]=0,Et[129]=Et[41]=0,bt[129]=bt[41]=-1,wt[129]=wt[41]=0,Tt[66]=Tt[104]=0,At[66]=At[104]=1,Dt[66]=Dt[104]=0,Lt[66]=Lt[104]=-1,Ot[66]=Ot[104]=0,Rt[66]=Rt[104]=1,Ft[66]=Ft[104]=0,kt[66]=kt[104]=-1,Gt[66]=Gt[104]=0,vt[66]=vt[104]=0,_t[66]=_t[104]=-1,xt[66]=xt[104]=1,It[144]=It[26]=-1,St[144]=St[26]=0,Ct[144]=Ct[26]=0,qt[144]=qt[26]=1,Bt[144]=Bt[26]=0,zt[144]=zt[26]=1,Ft[144]=Ft[26]=0,kt[144]=kt[26]=1,Gt[144]=Gt[26]=1,Et[144]=Et[26]=-1,bt[144]=bt[26]=0,wt[144]=wt[26]=1,Nt[36]=Nt[134]=0,Pt[36]=Pt[134]=1,Mt[36]=Mt[134]=1,Tt[36]=Tt[134]=0,At[36]=At[134]=1,Dt[36]=Dt[134]=0,vt[36]=vt[134]=0,_t[36]=_t[134]=-1,xt[36]=xt[134]=1,Et[36]=Et[134]=1,bt[36]=bt[134]=0,wt[36]=wt[134]=0,It[9]=It[161]=-1,St[9]=St[161]=0,Ct[9]=Ct[161]=0,Nt[9]=Nt[161]=0,Pt[9]=Pt[161]=-1,Mt[9]=Mt[161]=0,Lt[9]=Lt[161]=1,Ot[9]=Ot[161]=0,Rt[9]=Rt[161]=0,qt[9]=qt[161]=1,Bt[9]=Bt[161]=0,zt[9]=zt[161]=1,It[136]=0,St[136]=1,Ct[136]=1,Nt[136]=0,Pt[136]=1,Mt[136]=0,Tt[136]=-1,At[136]=0,Dt[136]=1,Lt[136]=-1,Ot[136]=0,Rt[136]=0,qt[136]=0,Bt[136]=-1,zt[136]=0,Ft[136]=0,kt[136]=-1,Gt[136]=1,vt[136]=1,_t[136]=0,xt[136]=0,Et[136]=1,bt[136]=0,wt[136]=1,It[34]=0,St[34]=-1,Ct[34]=0,Nt[34]=0,Pt[34]=-1,Mt[34]=1,Tt[34]=1,At[34]=0,Dt[34]=0,Lt[34]=1,Ot[34]=0,Rt[34]=1,qt[34]=0,Bt[34]=1,zt[34]=1,Ft[34]=0,kt[34]=1,Gt[34]=0,vt[34]=-1,_t[34]=0,xt[34]=1,Et[34]=-1,bt[34]=0,wt[34]=0,It[35]=0,St[35]=1,Ct[35]=1,Nt[35]=0,Pt[35]=-1,Mt[35]=1,Tt[35]=1,At[35]=0,Dt[35]=0,Lt[35]=-1,Ot[35]=0,Rt[35]=0,qt[35]=0,Bt[35]=-1,zt[35]=0,Ft[35]=0,kt[35]=1,Gt[35]=0,vt[35]=-1,_t[35]=0,xt[35]=1,Et[35]=1,bt[35]=0,wt[35]=1,It[153]=0,St[153]=1,Ct[153]=1,Lt[153]=-1,Ot[153]=0,Rt[153]=0,qt[153]=0,Bt[153]=-1,zt[153]=0,Et[153]=1,bt[153]=0,wt[153]=1,Nt[102]=0,Pt[102]=-1,Mt[102]=1,Tt[102]=1,At[102]=0,Dt[102]=0,Ft[102]=0,kt[102]=1,Gt[102]=0,vt[102]=-1,_t[102]=0,xt[102]=1,It[155]=0,St[155]=-1,Ct[155]=0,Lt[155]=1,Ot[155]=0,Rt[155]=1,qt[155]=0,Bt[155]=1,zt[155]=1,Et[155]=-1,bt[155]=0,wt[155]=0,Nt[103]=0,Pt[103]=1,Mt[103]=0,Tt[103]=-1,At[103]=0,Dt[103]=1,Ft[103]=0,kt[103]=-1,Gt[103]=1,vt[103]=1,_t[103]=0,xt[103]=0,It[152]=0,St[152]=1,Ct[152]=1,Tt[152]=-1,At[152]=0,Dt[152]=1,Lt[152]=-1,Ot[152]=0,Rt[152]=0,qt[152]=0,Bt[152]=-1,zt[152]=0,Ft[152]=0,kt[152]=-1,Gt[152]=1,Et[152]=1,bt[152]=0,wt[152]=1,It[156]=0,St[156]=-1,Ct[156]=1,Tt[156]=1,At[156]=0,Dt[156]=1,Lt[156]=-1,Ot[156]=0,Rt[156]=0,qt[156]=0,Bt[156]=-1,zt[156]=0,Ft[156]=0,kt[156]=1,Gt[156]=1,Et[156]=-1,bt[156]=0,wt[156]=1,It[137]=0,St[137]=1,Ct[137]=1,Nt[137]=0,Pt[137]=1,Mt[137]=0,Lt[137]=-1,Ot[137]=0,Rt[137]=0,qt[137]=0,Bt[137]=-1,zt[137]=0,vt[137]=1,_t[137]=0,xt[137]=0,Et[137]=1,bt[137]=0,wt[137]=1,It[139]=0,St[139]=1,Ct[139]=1,Nt[139]=0,Pt[139]=-1,Mt[139]=0,Lt[139]=1,Ot[139]=0,Rt[139]=0,qt[139]=0,Bt[139]=1,zt[139]=0,vt[139]=-1,_t[139]=0,xt[139]=0,Et[139]=1,bt[139]=0,wt[139]=1,It[98]=0,St[98]=-1,Ct[98]=0,Nt[98]=0,Pt[98]=-1,Mt[98]=1,Tt[98]=1,At[98]=0,Dt[98]=0,Lt[98]=1,Ot[98]=0,Rt[98]=1,Ft[98]=0,kt[98]=1,Gt[98]=0,vt[98]=-1,_t[98]=0,xt[98]=1,It[99]=0,St[99]=1,Ct[99]=0,Nt[99]=0,Pt[99]=-1,Mt[99]=1,Tt[99]=1,At[99]=0,Dt[99]=0,Lt[99]=-1,Ot[99]=0,Rt[99]=1,Ft[99]=0,kt[99]=-1,Gt[99]=0,vt[99]=1,_t[99]=0,xt[99]=1,Nt[38]=0,Pt[38]=-1,Mt[38]=1,Tt[38]=1,At[38]=0,Dt[38]=0,qt[38]=0,Bt[38]=1,zt[38]=1,Ft[38]=0,kt[38]=1,Gt[38]=0,vt[38]=-1,_t[38]=0,xt[38]=1,Et[38]=-1,bt[38]=0,wt[38]=0,Nt[39]=0,Pt[39]=1,Mt[39]=1,Tt[39]=-1,At[39]=0,Dt[39]=0,qt[39]=0,Bt[39]=-1,zt[39]=1,Ft[39]=0,kt[39]=1,Gt[39]=0,vt[39]=-1,_t[39]=0,xt[39]=1,Et[39]=1,bt[39]=0,wt[39]=0;var Ju=function(t){return[[t.bottomleft,0],[0,0],[0,t.leftbottom]]},Zu=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0]]},Ku=function(t){return[[t.topright,1],[1,1],[1,t.righttop]]},Qu=function(t){return[[0,t.lefttop],[0,1],[t.topleft,1]]},$u=function(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop]]},tl=function(t){return[[t.bottomright,0],[t.bottomleft,0],[1,t.righttop],[1,t.rightbottom]]},el=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.topleft,1],[t.topright,1]]},nl=function(t){return[[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]},W=[],H=[],Q=[],K=[],ot=[],rt=[],jt=[],Ut=[];K[1]=ot[1]=18,K[169]=ot[169]=18,Q[4]=H[4]=12,Q[166]=H[166]=12,W[16]=Ut[16]=4,W[154]=Ut[154]=4,rt[64]=jt[64]=22,rt[106]=jt[106]=22,Q[2]=rt[2]=17,K[2]=ot[2]=18,Q[168]=rt[168]=17,K[168]=ot[168]=18,W[8]=K[8]=9,H[8]=Q[8]=12,W[162]=K[162]=9,H[162]=Q[162]=12,W[32]=Ut[32]=4,H[32]=jt[32]=1,W[138]=Ut[138]=4,H[138]=jt[138]=1,ot[128]=Ut[128]=21,rt[128]=jt[128]=22,ot[42]=Ut[42]=21,rt[42]=jt[42]=22,H[5]=ot[5]=14,H[165]=ot[165]=14,Q[20]=Ut[20]=6,Q[150]=Ut[150]=6,W[80]=rt[80]=11,W[90]=rt[90]=11,K[65]=jt[65]=3,K[105]=jt[105]=3,W[160]=rt[160]=11,H[160]=ot[160]=14,W[10]=rt[10]=11,H[10]=ot[10]=14,Q[130]=Ut[130]=6,K[130]=jt[130]=3,Q[40]=Ut[40]=6,K[40]=jt[40]=3,H[101]=jt[101]=1,H[69]=jt[69]=1,ot[149]=Ut[149]=21,ot[21]=Ut[21]=21,Q[86]=rt[86]=17,Q[84]=rt[84]=17,W[89]=K[89]=9,W[81]=K[81]=9,W[96]=jt[96]=0,H[96]=rt[96]=15,W[74]=jt[74]=0,H[74]=rt[74]=15,W[24]=Q[24]=8,K[24]=Ut[24]=7,W[146]=Q[146]=8,K[146]=Ut[146]=7,H[6]=rt[6]=15,Q[6]=ot[6]=16,H[164]=rt[164]=15,Q[164]=ot[164]=16,K[129]=Ut[129]=7,ot[129]=jt[129]=20,K[41]=Ut[41]=7,ot[41]=jt[41]=20,Q[66]=jt[66]=2,K[66]=rt[66]=19,Q[104]=jt[104]=2,K[104]=rt[104]=19,W[144]=ot[144]=10,rt[144]=Ut[144]=23,W[26]=ot[26]=10,rt[26]=Ut[26]=23,H[36]=Ut[36]=5,Q[36]=jt[36]=2,H[134]=Ut[134]=5,Q[134]=jt[134]=2,W[9]=ot[9]=10,H[9]=K[9]=13,W[161]=ot[161]=10,H[161]=K[161]=13,H[37]=Ut[37]=5,ot[37]=jt[37]=20,H[133]=Ut[133]=5,ot[133]=jt[133]=20,Q[148]=ot[148]=16,rt[148]=Ut[148]=23,Q[22]=ot[22]=16,rt[22]=Ut[22]=23,W[82]=Q[82]=8,K[82]=rt[82]=19,W[88]=Q[88]=8,K[88]=rt[88]=19,W[73]=jt[73]=0,H[73]=K[73]=13,W[97]=jt[97]=0,H[97]=K[97]=13,W[145]=K[145]=9,ot[145]=Ut[145]=21,W[25]=K[25]=9,ot[25]=Ut[25]=21,H[70]=jt[70]=1,Q[70]=rt[70]=17,H[100]=jt[100]=1,Q[100]=rt[100]=17,W[34]=K[34]=9,H[34]=Q[34]=12,ot[34]=Ut[34]=21,rt[34]=jt[34]=22,W[136]=Ut[136]=4,H[136]=jt[136]=1,Q[136]=rt[136]=17,K[136]=ot[136]=18,W[35]=Ut[35]=4,H[35]=Q[35]=12,K[35]=ot[35]=18,rt[35]=jt[35]=22,W[153]=Ut[153]=4,K[153]=ot[153]=18,H[102]=Q[102]=12,rt[102]=jt[102]=22,W[155]=K[155]=9,ot[155]=Ut[155]=23,H[103]=jt[103]=1,Q[103]=rt[103]=17,W[152]=Ut[152]=4,Q[152]=rt[152]=17,K[152]=ot[152]=18,W[156]=Q[156]=8,K[156]=ot[156]=18,rt[156]=Ut[156]=23,W[137]=Ut[137]=4,H[137]=jt[137]=1,K[137]=ot[137]=18,W[139]=Ut[139]=4,H[139]=K[139]=13,ot[139]=jt[139]=20,W[98]=K[98]=9,H[98]=Q[98]=12,rt[98]=jt[98]=22,W[99]=jt[99]=0,H[99]=Q[99]=12,K[99]=rt[99]=19,H[38]=Q[38]=12,ot[38]=Ut[38]=21,rt[38]=jt[38]=22,H[39]=Ut[39]=5,Q[39]=ot[39]=16,rt[39]=jt[39]=22;var Y=[];function w(t,e,n){return(t-e)/(n-e)}function rl(t){return t.constructor.toString().indexOf("Array")>-1}function kd(t,e,n,r,i,o){for(var s=t.cells[n][e],a=s.cval_real,u=e+r,l=n+i,h=[],c=!1;!c;){if(t.cells[l]===void 0||t.cells[l][u]===void 0)if(l-=i,u-=r,a=(s=t.cells[l][u]).cval_real,i===-1)if(o===0)if(1&a)h.push([u,l]),r=-1,i=0,o=0;else{if(!(4&a)){h.push([u+s.bottomright,l]),r=0,i=1,o=1,c=!0;break}h.push([u+1,l]),r=1,i=0,o=0}else{if(!(1&a)){if(4&a){h.push([u+s.bottomright,l]),r=0,i=1,o=1,c=!0;break}h.push([u+s.bottomleft,l]),r=0,i=1,o=0,c=!0;break}h.push([u,l]),r=-1,i=0,o=0}else if(i===1)if(o===0){if(!(a&Er)){if(a&cn){h.push([u+s.topleft,l+1]),r=0,i=-1,o=0,c=!0;break}h.push([u+s.topright,l+1]),r=0,i=-1,o=1,c=!0;break}h.push([u+1,l+1]),r=1,i=0,o=1}else h.push([u+1,l+1]),r=1,i=0,o=1;else if(r===-1)if(o===0){if(!(a&cn)){if(1&a){h.push([u,l+s.leftbottom]),r=1,i=0,o=0,c=!0;break}h.push([u,l+s.lefttop]),r=1,i=0,o=1,c=!0;break}h.push([u,l+1]),r=0,i=1,o=0}else{if(!(a&cn)){console.log("MarchingSquaresJS-isoBands: wtf");break}h.push([u,l+1]),r=0,i=1,o=0}else{if(r!==1){console.log("MarchingSquaresJS-isoBands: we came from nowhere!");break}if(o===0){if(!(4&a)){h.push([u+1,l+s.rightbottom]),r=-1,i=0,o=0,c=!0;break}h.push([u+1,l]),r=0,i=-1,o=1}else{if(!(4&a)){if(a&Er){h.push([u+1,l+s.righttop]),r=-1,i=0,o=1;break}h.push([u+1,l+s.rightbottom]),r=-1,i=0,o=0,c=!0;break}h.push([u+1,l]),r=0,i=-1,o=1}}else if(a=(s=t.cells[l][u]).cval_real,r===-1)if(o===0)if(t.cells[l-1]!==void 0&&t.cells[l-1][u]!==void 0)r=0,i=-1,o=1;else{if(!(1&a)){h.push([u+s.bottomright,l]),r=0,i=1,o=1,c=!0;break}h.push([u,l])}else{if(!(a&cn)){console.log("MarchingSquaresJS-isoBands: found entry from top at "+u+","+l);break}console.log("MarchingSquaresJS-isoBands: proceeding in x-direction!")}else if(r===1){if(o===0){console.log("MarchingSquaresJS-isoBands: wtf");break}if(t.cells[l+1]!==void 0&&t.cells[l+1][u]!==void 0)r=0,i=1,o=0;else{if(!(a&Er)){h.push([u+s.topleft,l+1]),r=0,i=-1,o=0,c=!0;break}h.push([u+1,l+1]),r=1,i=0,o=1}}else if(i===-1){if(o!==1){console.log("MarchingSquaresJS-isoBands: wtf");break}if(t.cells[l][u+1]!==void 0)r=1,i=0,o=1;else{if(!(4&a)){h.push([u+1,l+s.righttop]),r=-1,i=0,o=1,c=!0;break}h.push([u+1,l]),r=0,i=-1,o=1}}else{if(i!==1){console.log("MarchingSquaresJS-isoBands: where did we came from???");break}if(o!==0){console.log("MarchingSquaresJS-isoBands: wtf");break}if(t.cells[l][u-1]!==void 0)r=-1,i=0,o=0;else{if(!(a&cn)){h.push([u,l+s.leftbottom]),r=1,i=0,o=0,c=!0;break}h.push([u,l+1]),r=0,i=1,o=0}}if(l+=i,(u+=r)===e&&l===n)break}return{path:h,i:u,j:l,x:r,y:i,o}}function Gd(t){if(t.edges.length>0){var e=t.edges[t.edges.length-1],n=t.cval_real;switch(e){case 0:return n&Er?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 1:return 4&n?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 2:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 3:return 1&n?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 4:return n&Er?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 5:return 4&n?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 6:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 7:return 1&n?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 8:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.righttop],x:-1,y:0,o:1};case 9:return 1&n?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 10:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.righttop],x:-1,y:0,o:1};case 11:return n&cn?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 12:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 13:return 1&n?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 14:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 15:return n&cn?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 16:return 4&n?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 17:return n&cn?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 18:return 1&n?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 19:return n&cn?{p:[t.bottomleft,0],x:0,y:1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 20:return n&cn?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 21:return n&Er?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.topright,1],x:0,y:-1,o:1};case 22:return n&cn?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 23:return n&Er?{p:[0,t.lefttop],x:1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};default:console.log("MarchingSquaresJS-isoBands: edge index out of range!"),console.log(t)}}return null}function qd(t,e,n,r){var i,o,s,a,u,l=t.cval;switch(e){case-1:switch(r){case 0:i=H[l],s=Nt[l],a=Pt[l],u=Mt[l];break;default:i=W[l],s=It[l],a=St[l],u=Ct[l]}break;case 1:switch(r){case 0:i=ot[l],s=qt[l],a=Bt[l],u=zt[l];break;default:i=rt[l],s=Ft[l],a=kt[l],u=Gt[l]}break;default:switch(n){case-1:switch(r){case 0:i=jt[l],s=vt[l],a=_t[l],u=xt[l];break;default:i=Ut[l],s=Et[l],a=bt[l],u=wt[l]}break;case 1:switch(r){case 0:i=K[l],s=Lt[l],a=Ot[l],u=Rt[l];break;default:i=Q[l],s=Tt[l],a=At[l],u=Dt[l]}}}if(o=t.edges.indexOf(i),t.edges[o]===void 0)return null;switch(function(h,c){delete h.edges[c];for(var p=c+1;p0){var h=r[u-1],c=Vd(l,h);c!==!1&&(h[1]=c,l[0]=c),s.push(h[0]),u===o.length-2&&(s.push(l[0]),s.push(l[1]))}o.length===2&&(s.push(l[0]),s.push(l[1]))}var p,d,g,m,f,_,I,y}),Wt(s,t.properties)}function ol(t,e,n){var r=e[0]-t[0],i=e[1]-t[1],o=n[0]-e[0];return function(s){return(s>0)-(s<0)||+s}(r*(n[1]-e[1])-o*i)}function Hh(t,e){return e.geometry.coordinates[0].every(function(n){return le(ft(n),t)})}Y[1]=Y[169]=Ju,Y[4]=Y[166]=Zu,Y[16]=Y[154]=Ku,Y[64]=Y[106]=Qu,Y[168]=Y[2]=$u,Y[162]=Y[8]=tl,Y[138]=Y[32]=el,Y[42]=Y[128]=nl,Y[5]=Y[165]=function(t){return[[0,0],[0,t.leftbottom],[1,t.rightbottom],[1,0]]},Y[20]=Y[150]=function(t){return[[1,0],[t.bottomright,0],[t.topright,1],[1,1]]},Y[80]=Y[90]=function(t){return[[1,1],[1,t.righttop],[0,t.lefttop],[0,1]]},Y[65]=Y[105]=function(t){return[[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]]},Y[160]=Y[10]=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.leftbottom],[0,t.lefttop]]},Y[130]=Y[40]=function(t){return[[t.topleft,1],[t.topright,1],[t.bottomright,0],[t.bottomleft,0]]},Y[85]=function(){return[[0,0],[0,1],[1,1],[1,0]]},Y[101]=Y[69]=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,1],[t.topleft,1]]},Y[149]=Y[21]=function(t){return[[t.topright,1],[1,1],[1,0],[0,0],[0,t.leftbottom]]},Y[86]=Y[84]=function(t){return[[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[1,1]]},Y[89]=Y[81]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,1]]},Y[96]=Y[74]=function(t){return[[1,t.righttop],[1,t.rightbottom],[0,t.lefttop],[0,1],[t.topleft,1]]},Y[24]=Y[146]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[t.topright,1]]},Y[6]=Y[164]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop]]},Y[129]=Y[41]=function(t){return[[t.topright,1],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1]]},Y[66]=Y[104]=function(t){return[[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]]},Y[144]=Y[26]=function(t){return[[1,1],[1,t.righttop],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},Y[36]=Y[134]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[t.topleft,1],[t.topright,1]]},Y[9]=Y[161]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom]]},Y[37]=Y[133]=function(t){return[[1,t.rightbottom],[1,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]]},Y[148]=Y[22]=function(t){return[[1,1],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},Y[82]=Y[88]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1]]},Y[73]=Y[97]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,1],[t.topleft,1]]},Y[145]=Y[25]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]]},Y[70]=Y[100]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]]},Y[34]=function(t){return[nl(t),tl(t)]},Y[35]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]},Y[136]=function(t){return[el(t),$u(t)]},Y[153]=function(t){return[Ku(t),Ju(t)]},Y[102]=function(t){return[Zu(t),Qu(t)]},Y[155]=function(t){return[[1,1],[1,t.righttop],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topright,1]]},Y[103]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.lefttop],[0,1],[t.topleft,1]]},Y[152]=function(t){return[Ku(t),$u(t)]},Y[156]=function(t){return[[1,1],[1,t.righttop],[t.bottomright,0],[t.bottomleft,0],[0,t.leftbottom],[0,t.lefttop],[t.topright,1]]},Y[137]=function(t){return[el(t),Ju(t)]},Y[139]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomleft,0],[0,0],[0,t.leftbottom],[t.topleft,1],[t.topright,1]]},Y[98]=function(t){return[tl(t),Qu(t)]},Y[99]=function(t){return[[1,t.righttop],[1,t.rightbottom],[t.bottomright,0],[t.bottomleft,0],[0,t.lefttop],[0,1],[t.topleft,1]]},Y[38]=function(t){return[Zu(t),nl(t)]},Y[39]=function(t){return[[1,t.rightbottom],[1,0],[t.bottomright,0],[0,t.leftbottom],[0,t.lefttop],[t.topleft,1],[t.topright,1]]};var Wh=function(){function t(e){this.id=t.buildId(e),this.coordinates=e,this.innerEdges=[],this.outerEdges=[],this.outerEdgesSorted=!1}return t.buildId=function(e){return e.join(",")},t.prototype.removeInnerEdge=function(e){this.innerEdges=this.innerEdges.filter(function(n){return n.from.id!==e.from.id})},t.prototype.removeOuterEdge=function(e){this.outerEdges=this.outerEdges.filter(function(n){return n.to.id!==e.to.id})},t.prototype.addOuterEdge=function(e){this.outerEdges.push(e),this.outerEdgesSorted=!1},t.prototype.sortOuterEdges=function(){var e=this;this.outerEdgesSorted||(this.outerEdges.sort(function(n,r){var i=n.to,o=r.to;if(i.coordinates[0]-e.coordinates[0]>=0&&o.coordinates[0]-e.coordinates[0]<0)return 1;if(i.coordinates[0]-e.coordinates[0]<0&&o.coordinates[0]-e.coordinates[0]>=0)return-1;if(i.coordinates[0]-e.coordinates[0]==0&&o.coordinates[0]-e.coordinates[0]==0)return i.coordinates[1]-e.coordinates[1]>=0||o.coordinates[1]-e.coordinates[1]>=0?i.coordinates[1]-o.coordinates[1]:o.coordinates[1]-i.coordinates[1];var s=ol(e.coordinates,i.coordinates,o.coordinates);return s<0?1:s>0?-1:Math.pow(i.coordinates[0]-e.coordinates[0],2)+Math.pow(i.coordinates[1]-e.coordinates[1],2)-(Math.pow(o.coordinates[0]-e.coordinates[0],2)+Math.pow(o.coordinates[1]-e.coordinates[1],2))}),this.outerEdgesSorted=!0)},t.prototype.getOuterEdges=function(){return this.sortOuterEdges(),this.outerEdges},t.prototype.getOuterEdge=function(e){return this.sortOuterEdges(),this.outerEdges[e]},t.prototype.addInnerEdge=function(e){this.innerEdges.push(e)},t}(),Xd=function(){function t(e,n){this.from=e,this.to=n,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)}return t.prototype.getSymetric=function(){return this.symetric||(this.symetric=new t(this.to,this.from),this.symetric.symetric=this),this.symetric},t.prototype.deleteEdge=function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)},t.prototype.isEqual=function(e){return this.from.id===e.from.id&&this.to.id===e.to.id},t.prototype.toString=function(){return"Edge { "+this.from.id+" -> "+this.to.id+" }"},t.prototype.toLineString=function(){return Wt([this.from.coordinates,this.to.coordinates])},t.prototype.compareTo=function(e){return ol(e.from.coordinates,e.to.coordinates,this.to.coordinates)},t}(),Jh=function(){function t(){this.edges=[],this.polygon=void 0,this.envelope=void 0}return t.prototype.push=function(e){this[this.edges.length]=e,this.edges.push(e),this.polygon=this.envelope=void 0},t.prototype.get=function(e){return this.edges[e]},Object.defineProperty(t.prototype,"length",{get:function(){return this.edges.length},enumerable:!0,configurable:!0}),t.prototype.forEach=function(e){this.edges.forEach(e)},t.prototype.map=function(e){return this.edges.map(e)},t.prototype.some=function(e){return this.edges.some(e)},t.prototype.isValid=function(){return!0},t.prototype.isHole=function(){var e=this,n=this.edges.reduce(function(s,a,u){return a.from.coordinates[1]>e.edges[s].from.coordinates[1]&&(s=u),s},0),r=(n===0?this.length:n)-1,i=(n+1)%this.length,o=ol(this.edges[r].from.coordinates,this.edges[n].from.coordinates,this.edges[i].from.coordinates);return o===0?this.edges[r].from.coordinates[0]>this.edges[i].from.coordinates[0]:o>0},t.prototype.toMultiPoint=function(){return ta(this.edges.map(function(e){return e.from.coordinates}))},t.prototype.toPolygon=function(){if(this.polygon)return this.polygon;var e=this.edges.map(function(n){return n.from.coordinates});return e.push(this.edges[0].from.coordinates),this.polygon=ct([e])},t.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=Vc(this.toPolygon())},t.findEdgeRingContaining=function(e,n){var r,i,o=e.getEnvelope();return n.forEach(function(s){var a,u,l,h,c,p,d=s.getEnvelope();if(i&&(r=i.getEnvelope()),u=o,l=(a=d).geometry.coordinates.map(function(m){return m[0]}),h=a.geometry.coordinates.map(function(m){return m[1]}),c=u.geometry.coordinates.map(function(m){return m[0]}),p=u.geometry.coordinates.map(function(m){return m[1]}),(Math.max(null,l)!==Math.max(null,c)||Math.max(null,h)!==Math.max(null,p)||Math.min(null,l)!==Math.min(null,c)||Math.min(null,h)!==Math.min(null,p))&&Hh(d,o)){var g=e.map(function(m){return m.from.coordinates}).find(function(m){return!s.some(function(f){return _=m,I=f.from.coordinates,_[0]===I[0]&&_[1]===I[1];var _,I})});g&&s.inside(ft(g))&&(i&&!Hh(r,d)||(i=s))}}),i},t.prototype.inside=function(e){return le(e,this.toPolygon())},t}(),Yd=function(){function t(){this.edges=[],this.nodes={}}return t.fromGeoJson=function(e){(function(r){if(!r)throw new Error("No geojson passed");if(r.type!=="FeatureCollection"&&r.type!=="GeometryCollection"&&r.type!=="MultiLineString"&&r.type!=="LineString"&&r.type!=="Feature")throw new Error("Invalid input type '"+r.type+"'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature")})(e);var n=new t;return Ee(e,function(r){ts(r,"LineString","Graph::fromGeoJson"),lu(r,function(i,o){if(i){var s=n.getNode(i),a=n.getNode(o);n.addEdge(s,a)}return o})}),n},t.prototype.getNode=function(e){var n=Wh.buildId(e),r=this.nodes[n];return r||(r=this.nodes[n]=new Wh(e)),r},t.prototype.addEdge=function(e,n){var r=new Xd(e,n),i=r.getSymetric();this.edges.push(r),this.edges.push(i)},t.prototype.deleteDangles=function(){var e=this;Object.keys(this.nodes).map(function(n){return e.nodes[n]}).forEach(function(n){return e._removeIfDangle(n)})},t.prototype._removeIfDangle=function(e){var n=this;if(e.innerEdges.length<=1){var r=e.getOuterEdges().map(function(i){return i.to});this.removeNode(e),r.forEach(function(i){return n._removeIfDangle(i)})}},t.prototype.deleteCutEdges=function(){var e=this;this._computeNextCWEdges(),this._findLabeledEdgeRings(),this.edges.forEach(function(n){n.label===n.symetric.label&&(e.removeEdge(n.symetric),e.removeEdge(n))})},t.prototype._computeNextCWEdges=function(e){var n=this;e===void 0?Object.keys(this.nodes).forEach(function(r){return n._computeNextCWEdges(n.nodes[r])}):e.getOuterEdges().forEach(function(r,i){e.getOuterEdge((i===0?e.getOuterEdges().length:i)-1).symetric.next=r})},t.prototype._computeNextCCWEdges=function(e,n){for(var r,i,o=e.getOuterEdges(),s=o.length-1;s>=0;--s){var a=o[s],u=a.symetric,l=void 0,h=void 0;a.label===n&&(l=a),u.label===n&&(h=u),l&&h&&(h&&(i=h),l&&(i&&(i.next=l,i=void 0),r||(r=l)))}i&&(i.next=r)},t.prototype._findLabeledEdgeRings=function(){var e=[],n=0;return this.edges.forEach(function(r){if(!(r.label>=0)){e.push(r);var i=r;do i.label=n,i=i.next;while(!r.isEqual(i));n++}}),e},t.prototype.getEdgeRings=function(){var e=this;this._computeNextCWEdges(),this.edges.forEach(function(r){r.label=void 0}),this._findLabeledEdgeRings().forEach(function(r){e._findIntersectionNodes(r).forEach(function(i){e._computeNextCCWEdges(i,r.label)})});var n=[];return this.edges.forEach(function(r){r.ring||n.push(e._findEdgeRing(r))}),n},t.prototype._findIntersectionNodes=function(e){var n=[],r=e,i=function(){var o=0;r.from.getOuterEdges().forEach(function(s){s.label===e.label&&++o}),o>1&&n.push(r.from),r=r.next};do i();while(!e.isEqual(r));return n},t.prototype._findEdgeRing=function(e){var n=e,r=new Jh;do r.push(n),n.ring=r,n=n.next;while(!e.isEqual(n));return r},t.prototype.removeNode=function(e){var n=this;e.getOuterEdges().forEach(function(r){return n.removeEdge(r)}),e.innerEdges.forEach(function(r){return n.removeEdge(r)}),delete this.nodes[e.id]},t.prototype.removeEdge=function(e){this.edges=this.edges.filter(function(n){return!n.isEqual(e)}),e.deleteEdge()},t}();function Zh(t,e){var n=!0;return Ee(t,function(r){Ee(e,function(i){if(n===!1)return!1;n=function(o,s){switch(o.type){case"Point":switch(s.type){case"Point":return a=o.coordinates,u=s.coordinates,!(a[0]===u[0]&&a[1]===u[1]);case"LineString":return!Kh(s,o);case"Polygon":return!le(o,s)}break;case"LineString":switch(s.type){case"Point":return!Kh(o,s);case"LineString":return!function(l,h){return kr(l,h).features.length>0}(o,s);case"Polygon":return!Qh(s,o)}break;case"Polygon":switch(s.type){case"Point":return!le(s,o);case"LineString":return!Qh(o,s);case"Polygon":return!function(l,h){for(var c=0,p=l.coordinates[0];c0}(s,o)}}var a,u;return!1}(r.geometry,i.geometry)})}),n}function Kh(t,e){for(var n=0;n0}function Hd(t,e,n){var r=n[0]-t[0],i=n[1]-t[1],o=e[0]-t[0],s=e[1]-t[1];return r*s-i*o==0&&(Math.abs(o)>=Math.abs(s)?o>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:s>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1])}function $h(t,e){return!(t[0]>e[0])&&!(t[2]e[1])&&!(t[3]0}function np(t,e){for(var n=!1,r=!1,i=t.coordinates.length,o=0;o=Math.abs(a)?s>0?t[0]<=n[0]&&n[0]<=e[0]:e[0]<=n[0]&&n[0]<=t[0]:a>0?t[1]<=n[1]&&n[1]<=e[1]:e[1]<=n[1]&&n[1]<=t[1]:Math.abs(s)>=Math.abs(a)?s>0?t[0]0?t[1]=0&&(n=[].concat(t.slice(r,t.length),t.slice(1,r+1))),n},Gr.prototype.comparePath=function(t,e){var n=this;return t.every(function(r,i){return n.compareCoord(r,this[i])},e)},Gr.prototype.comparePolygon=function(t,e){if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){var n=t.coordinates.slice(1,t.coordinates.length),r=e.coordinates.slice(1,e.coordinates.length),i=this;return n.every(function(o){return this.some(function(s){return i.compareLine(o,s,1,!0)})},r)}return!1},Gr.prototype.compareFeature=function(t,e){return!(t.id!==e.id||!this.objectComparator(t.properties,e.properties)||!this.compareBBox(t,e))&&this.compare(t.geometry,e.geometry)},Gr.prototype.compareBBox=function(t,e){return!!(!t.bbox&&!e.bbox||t.bbox&&e.bbox&&this.compareCoord(t.bbox,e.bbox))},Gr.prototype.removePseudo=function(t){return t};var sp=Gr;function ap(t,e){var n=ae(t),r=ae(e),i=n.type,o=r.type;if(i==="MultiPoint"&&o!=="MultiPoint"||(i==="LineString"||i==="MultiLineString")&&o!=="LineString"&&o!=="MultiLineString"||(i==="Polygon"||i==="MultiPolygon")&&o!=="Polygon"&&o!=="MultiPolygon")throw new Error("features must be of the same type");if(i==="Point")throw new Error("Point geometry not supported");if(new sp({precision:6}).compare(t,e))return!1;var s=0;switch(i){case"MultiPoint":for(var a=0;a0}function up(t,e){var n=!1;return Ee(t,function(r){Ee(e,function(i){if(n===!0)return!0;n=!Zh(r.geometry,i.geometry)})}),n}var Zd=Dr(function(t){function e(n,r,i,o){this.dataset=[],this.epsilon=1,this.minPts=2,this.distance=this._euclideanDistance,this.clusters=[],this.noise=[],this._visited=[],this._assigned=[],this._datasetLength=0,this._init(n,r,i,o)}e.prototype.run=function(n,r,i,o){this._init(n,r,i,o);for(var s=0;s=this.minPts&&(r=this._mergeArrays(r,s))}this._assigned[o]!==1&&this._addToCluster(o,n)}},e.prototype._addToCluster=function(n,r){this.clusters[r].push(n),this._assigned[n]=1},e.prototype._regionQuery=function(n){for(var r=[],i=0;i0){for(h=0;h=0);return n},e.prototype.assign=function(){for(var n,r=!1,i=this.dataset.length,o=0;os&&(i=o):r=this.minPts)return o},n.prototype._regionQuery=function(r,i){i=i||this.epsilon;for(var o=[],s=0,a=this.dataset.length;s0;r.length0;){var a=t[Math.floor(Math.random()*o)],u=s?a.join("_"):""+a;n[u]||(n[u]=!0,r.push(a))}if(r.length0,s=t[Math.floor(Math.random()*i)];for(o&&s.join("_"),r.push(s);r.length0,d=[];if(n)i=n=="kmrand"?r0(t,e):n=="kmpp"?i0(t,e):n;else for(var g={};i.length0;){var u=s.pop();if(u===n)return fp(u);u.closed=!0;for(var l=t.neighbors(u),h=0,c=l.length;h0)){if(o/=p,p<0){if(o0){if(o>c)return;o>h&&(h=o)}if(o=r-u,p||!(o<0)){if(o/=p,p<0){if(o>c)return;o>h&&(h=o)}else if(p>0){if(o0)){if(o/=d,d<0){if(o0){if(o>c)return;o>h&&(h=o)}if(o=i-l,d||!(o<0)){if(o/=d,d<0){if(o>c)return;o>h&&(h=o)}else if(d>0){if(o0||c<1)||(h>0&&(t[0]=[u+h*p,l+h*d]),c<1&&(t[1]=[u+c*p,l+c*d]),!0)}}}}}function h0(t,e,n,r,i){var o=t[1];if(o)return!0;var s,a,u=t[0],l=t.left,h=t.right,c=l[0],p=l[1],d=h[0],g=h[1],m=(c+d)/2,f=(p+g)/2;if(g===p){if(m=r)return;if(c>d){if(u){if(u[1]>=i)return}else u=[m,n];o=[m,i]}else{if(u){if(u[1]1)if(c>d){if(u){if(u[1]>=i)return}else u=[(n-a)/s,n];o=[(i-a)/s,i]}else{if(u){if(u[1]=r)return}else u=[e,s*e+a];o=[r,s*r+a]}else{if(u){if(u[0]0&&(this.content[0]=e,this.bubbleUp(0)),t},remove:function(t){var e=this.content.indexOf(t),n=this.content.pop();e!==this.content.length-1&&(this.content[e]=n,this.scoreFunction(n)0;){var n=(t+1>>1)-1,r=this.content[n];if(!(this.scoreFunction(e)=-_0)){var d=u*u+l*l,g=h*h+c*c,m=(c*d-l*g)/p,f=(u*g-h*d)/p,_=vp.pop()||new g0;_.arc=t,_.site=i,_.x=m+s,_.y=(_.cy=f+a)+Math.sqrt(m*m+f*f),t.circle=_;for(var I=null,y=xs._;y;)if(_.yce)a=a.L;else{if(!((i=o-v0(a,s))>ce)){r>-ce?(e=a.P,n=a):i>-ce?(e=a,n=a.N):e=n=a;break}if(!a.R){e=a;break}a=a.R}(function(x){jn[x.index]={site:x,halfedges:[]}})(t);var u=xp(t);if(Io.insert(e,u),e||n){if(e===n)return wo(e),n=xp(e.site),Io.insert(u,n),u.edge=n.edge=vs(e.site,u.site),bo(e),void bo(n);if(n){wo(e),wo(n);var l=e.site,h=l[0],c=l[1],p=t[0]-h,d=t[1]-c,g=n.site,m=g[0]-h,f=g[1]-c,_=2*(p*f-d*m),I=p*p+d*d,y=m*m+f*f,v=[(f*I-d*y)/_+h,(p*y-m*I)/_+c];Sa(n.edge,l,g,v),u.edge=vs(l,t,null,v),n.edge=vs(t,g,null,v),bo(e),bo(n)}else u.edge=vs(e.site,u.site)}}function Ep(t,e){var n=t.site,r=n[0],i=n[1],o=i-e;if(!o)return r;var s=t.P;if(!s)return-1/0;var a=(n=s.site)[0],u=n[1],l=u-e;if(!l)return a;var h=a-r,c=1/o-1/l,p=h/l;return c?(-p+Math.sqrt(p*p-2*c*(h*h/(-2*l)-u+l/2+i-o/2)))/c+r:(r+a)/2}function v0(t,e){var n=t.N;if(n)return Ep(n,e);var r=t.site;return r[1]===e?r[0]:1/0}var Io,jn,xs,mn,ce=1e-6,_0=1e-12;function x0(t,e){return e[1]-t[1]||e[0]-t[0]}function ll(t,e){var n,r,i,o=t.sort(x0).pop();for(mn=[],jn=new Array(t.length),Io=new wa,xs=new wa;;)if(i=al,o&&(!i||o[1]ce||Math.abs(g[0][1]-g[1][1])>ce)||delete mn[m]})(s,a,u,l),function(h,c,p,d){var g,m,f,_,I,y,v,x,b,E,T,C,D=jn.length,M=!0;for(g=0;gce||Math.abs(C-b)>ce)&&(I.splice(_,0,mn.push(_s(f,E,Math.abs(T-h)ce?[h,Math.abs(x-h)ce?[Math.abs(b-d)ce?[p,Math.abs(x-p)ce?[Math.abs(b-c)=-270&&(g=-g),d<-180&&d>=-360&&(m=-m),o==="degrees"){var f=g*Math.cos(h)+m*Math.sin(h),_=m*Math.cos(h)-g*Math.sin(h);g=f,m=_}c.push([g+l[0],m+l[1]])}return c.push(c[0]),o==="degrees"?ct([c],u):Uh(ct([c],u),s,{pivot:a})}function wp(t){var e=t*Math.PI/180;return Math.tan(e)}function cl(t,e){e===void 0&&(e={});var n=0,r=0,i=0;return zn(t,function(o,s,a){var u=e.weight?a?.[e.weight]:void 0;if(!Ge(u=u??1))throw new Error("weight value must be a number for feature index "+s);(u=Number(u))>0&&Ce(o,function(l){n+=l[0]*u,r+=l[1]*u,i+=u})}),ft([n/i,r/i],e.properties,e)}function Ip(t,e,n,r,i){var o=r.tolerance||.001,s=0,a=0,u=0,l=0;if(Zt(n,function(p){var d,g=(d=p.properties)===null||d===void 0?void 0:d.weight,m=g??1;if(!Ge(m=Number(m)))throw new Error("weight value must be a number");if(m>0){l+=1;var f=m*$t(p,t);f===0&&(f=1);var _=m/f;s+=p.geometry.coordinates[0]*_,a+=p.geometry.coordinates[1]*_,u+=_}}),l<1)throw new Error("no features to measure");var h=s/u,c=a/u;return l===1||i===0||Math.abs(h-e[0])n&&(n=u,r=o,e.push([]));var l=o-r,h=t.coordinates[u][l+1],c=i[0],p=i[1],d=h[0],g=h[1];e[u].push([.75*c+.25*d,.75*p+.25*g]),e[u].push([.25*c+.75*d,.25*p+.75*g])},!0),e.forEach(function(i){i.push(i[0])})}function w0(t,e){var n=0,r=0,i=0;Ce(t,function(o,s,a,u,l){u>i&&(i=u,r=s,e.push([[]])),l>n&&(n=l,r=s,e[u].push([]));var h=s-r,c=t.coordinates[u][l][h+1],p=o[0],d=o[1],g=c[0],m=c[1];e[u][l].push([.75*p+.25*g,.75*d+.25*m]),e[u][l].push([.25*p+.75*g,.25*d+.75*m])},!0),e.forEach(function(o){o.forEach(function(s){s.push(s[0])})})}function I0(t,e,n){n===void 0&&(n=2);var r=re(t),i=re(e),o=r[0]-i[0],s=r[1]-i[1];return n===1?Math.abs(o)+Math.abs(s):Math.pow(Math.pow(o,n)+Math.pow(s,n),1/n)}function Cp(t,e){var n=(e=e||{}).threshold||1e4,r=e.p||2,i=e.binary||!1,o=e.alpha||-1,s=e.standardization||!1,a=[];Zt(t,function(d){a.push(_i(d))});for(var u=[],l=0;l0?1:0}(t[0]))*e,n*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return i[0]>r&&(i[0]=r),i[0]<-r&&(i[0]=-r),i[1]>r&&(i[1]=r),i[1]<-r&&(i[1]=-r),i}function Rp(t){var e=180/Math.PI,n=6378137;return[t[0]*e/n,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/n)))*e]}ll.prototype={constructor:ll,polygons:function(){var t=this.edges;return this.cells.map(function(e){var n=e.halfedges.map(function(r){return mp(e,t[r])});return n.data=e.site.data,n})},triangles:function(){var t=[],e=this.edges;return this.cells.forEach(function(n,r){if(o=(i=n.halfedges).length)for(var i,o,s,a,u,l,h=n.site,c=-1,p=e[i[o-1]],d=p.left===h?p.right:p.left;++c=a)return null;var u=t-i.site[0],l=e-i.site[1],h=u*u+l*l;do i=o.cells[r=s],s=null,i.halfedges.forEach(function(c){var p=o.edges[c],d=p.left;if(d!==i.site&&d||(d=p.right)){var g=t-d[0],m=e-d[1],f=g*g+m*m;f0?l+c[h-1]:l}),u.forEach(function(l){l=2*l*Math.PI/u[u.length-1];var h=Math.random();a.push([h*(e.max_radial_length||10)*Math.sin(l),h*(e.max_radial_length||10)*Math.cos(l)])}),a[a.length-1]=a[0],a=a.map((s=Es(e.bbox),function(l){return[l[0]+s[0],l[1]+s[1]]})),n.push(ct([a]))},i=0;i * @license MIT * @preserve */function P0(t,e){return t>e?1:t0)||e.right===null||n(t,e.right.key)>0&&(a=e.right,e.right=a.left,a.left=e,(e=a).right===null))break;i.right=e,i=e,e=e.right}}return i.right=e.left,o.left=e.right,e.left=r.right,e.right=r.left,e}function gl(t,e,n,r){var i=new xi(t,e);if(n===null)return i.left=i.right=null,i;var o=r(t,(n=Ei(t,n,r)).key);return o<0?(i.left=n.left,i.right=n,n.left=null):o>=0&&(i.right=n.right,i.left=n,n.right=null),i}function zp(t,e,n){var r=null,i=null;if(e){var o=n((e=Ei(t,e,n)).key,t);o===0?(r=e.left,i=e.right):o<0?(i=e.right,e.right=null,r=e):(r=e.left,e.left=null,i=e)}return{left:r,right:i}}function dl(t,e,n,r,i){if(t){r(e+(n?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ")+i(t)+` `);var o=e+(n?" ":"\u2502 ");t.left&&dl(t.left,o,!1,r,i),t.right&&dl(t.right,o,!0,r,i)}}var yl=function(){function t(e){e===void 0&&(e=P0),this._root=null,this._size=0,this._comparator=e}return t.prototype.insert=function(e,n){return this._size++,this._root=gl(e,n,this._root,this._comparator)},t.prototype.add=function(e,n){var r=new xi(e,n);this._root===null&&(r.left=r.right=null,this._size++,this._root=r);var i=this._comparator,o=Ei(e,this._root,i),s=i(e,o.key);return s===0?this._root=o:(s<0?(r.left=o.left,r.right=o,o.left=null):s>0&&(r.right=o.right,r.left=o,o.right=null),this._size++,this._root=r),this._root},t.prototype.remove=function(e){this._root=this._remove(e,this._root,this._comparator)},t.prototype._remove=function(e,n,r){var i;return n===null?null:r(e,(n=Ei(e,n,r)).key)===0?(n.left===null?i=n.right:(i=Ei(e,n.left,r)).right=n.right,this._size--,i):n},t.prototype.pop=function(){var e=this._root;if(e){for(;e.left;)e=e.left;return this._root=Ei(e.key,this._root,this._comparator),this._root=this._remove(e.key,this._root,this._comparator),{key:e.key,data:e.data}}return null},t.prototype.findStatic=function(e){for(var n=this._root,r=this._comparator;n;){var i=r(e,n.key);if(i===0)return n;n=i<0?n.left:n.right}return null},t.prototype.find=function(e){return this._root&&(this._root=Ei(e,this._root,this._comparator),this._comparator(e,this._root.key)!==0)?null:this._root},t.prototype.contains=function(e){for(var n=this._root,r=this._comparator;n;){var i=r(e,n.key);if(i===0)return!0;n=i<0?n.left:n.right}return!1},t.prototype.forEach=function(e,n){for(var r=this._root,i=[],o=!1;!o;)r!==null?(i.push(r),r=r.left):i.length!==0?(r=i.pop(),e.call(n,r),r=r.right):o=!0;return this},t.prototype.range=function(e,n,r,i){for(var o=[],s=this._comparator,a=this._root;o.length!==0||a;)if(a)o.push(a),a=a.left;else{if(s((a=o.pop()).key,n)>0)break;if(s(a.key,e)>=0&&r.call(i,a))return this;a=a.right}return this},t.prototype.keys=function(){var e=[];return this.forEach(function(n){var r=n.key;return e.push(r)}),e},t.prototype.values=function(){var e=[];return this.forEach(function(n){var r=n.data;return e.push(r)}),e},t.prototype.min=function(){return this._root?this.minNode(this._root).key:null},t.prototype.max=function(){return this._root?this.maxNode(this._root).key:null},t.prototype.minNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.left;)e=e.left;return e},t.prototype.maxNode=function(e){if(e===void 0&&(e=this._root),e)for(;e.right;)e=e.right;return e},t.prototype.at=function(e){for(var n=this._root,r=!1,i=0,o=[];!r;)if(n)o.push(n),n=n.left;else if(o.length>0){if(n=o.pop(),i===e)return n;i++,n=n.right}else r=!0;return null},t.prototype.next=function(e){var n=this._root,r=null;if(e.right){for(r=e.right;r.left;)r=r.left;return r}for(var i=this._comparator;n;){var o=i(e.key,n.key);if(o===0)break;o<0?(r=n,n=n.left):n=n.right}return r},t.prototype.prev=function(e){var n=this._root,r=null;if(e.left!==null){for(r=e.left;r.right;)r=r.right;return r}for(var i=this._comparator;n;){var o=i(e.key,n.key);if(o===0)break;o<0?n=n.left:(r=n,n=n.right)}return r},t.prototype.clear=function(){return this._root=null,this._size=0,this},t.prototype.toList=function(){return function(e){for(var n=e,r=[],i=!1,o=new xi(null,null),s=o;!i;)n?(r.push(n),n=n.left):r.length>0?n=(n=s=s.next=r.pop()).right:i=!0;return s.next=null,o.next}(this._root)},t.prototype.load=function(e,n,r){n===void 0&&(n=[]),r===void 0&&(r=!1);var i=e.length,o=this._comparator;if(r&&_l(e,n,0,i-1,o),this._root===null)this._root=ml(e,n,0,i),this._size=i;else{var s=function(a,u,l){for(var h=new xi(null,null),c=h,p=a,d=u;p!==null&&d!==null;)l(p.key,d.key)<0?(c.next=p,p=p.next):(c.next=d,d=d.next),c=c.next;return p!==null?c.next=p:d!==null&&(c.next=d),h.next}(this.toList(),function(a,u){for(var l=new xi(null,null),h=l,c=0;c0){var o=n+Math.floor(i/2),s=t[o],a=e[o],u=new xi(s,a);return u.left=ml(t,e,n,o),u.right=ml(t,e,o+1,r),u}return null}function vl(t,e,n){var r=n-e;if(r>0){var i=e+Math.floor(r/2),o=vl(t,e,i),s=t.head;return s.left=o,t.head=t.head.next,s.right=vl(t,i+1,n),s}return null}function _l(t,e,n,r,i){if(!(n>=r)){for(var o=t[n+r>>1],s=n-1,a=r+1;;){do s++;while(i(t[s],o)<0);do a--;while(i(t[a],o)>0);if(s>=a)break;var u=t[s];t[s]=t[a],t[a]=u,u=e[s],e[s]=e[a],e[a]=u}_l(t,e,n,a,i),_l(t,e,a+1,r,i)}}function er(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function jp(t,e){for(var n=0;nn.x?1:e.yn.y?1:0}}]),In(t,[{key:"link",value:function(e){if(e.point===this.point)throw new Error("Tried to link already linked events");for(var n=e.point.events,r=0,i=n.length;r=0&&c>=0?lp?-1:0:u<0&&c<0?lp?1:0:cu?1:0}}}]),t}(),R0=0,Pa=function(){function t(e,n,r,i){er(this,t),this.id=++R0,this.leftSE=e,e.segment=this,e.otherSE=n,this.rightSE=n,n.segment=this,n.otherSE=e,this.rings=r,this.windings=i}return In(t,null,[{key:"compare",value:function(e,n){var r=e.leftSE.point.x,i=n.leftSE.point.x,o=e.rightSE.point.x,s=n.rightSE.point.x;if(sa&&u>l)return-1;var c=e.comparePoint(n.leftSE.point);if(c<0)return 1;if(c>0)return-1;var p=n.comparePoint(e.rightSE.point);return p!==0?p:-1}if(r>i){if(au&&a>h)return 1;var d=n.comparePoint(e.leftSE.point);if(d!==0)return d;var g=e.comparePoint(n.rightSE.point);return g<0?1:g>0?-1:1}if(au)return 1;if(os){var f=e.comparePoint(n.rightSE.point);if(f<0)return 1;if(f>0)return-1}if(o!==s){var _=l-a,I=o-r,y=h-u,v=s-i;if(_>I&&yv)return-1}return o>s?1:oh?1:e.idn.id?1:0}}]),In(t,[{key:"replaceRightSE",value:function(e){this.rightSE=e,this.rightSE.segment=this,this.rightSE.otherSE=this.leftSE,this.leftSE.otherSE=this.rightSE}},{key:"bbox",value:function(){var e=this.leftSE.point.y,n=this.rightSE.point.y;return{ll:{x:this.leftSE.point.x,y:en?e:n}}}},{key:"vector",value:function(){return{x:this.rightSE.point.x-this.leftSE.point.x,y:this.rightSE.point.y-this.leftSE.point.y}}},{key:"isAnEndpoint",value:function(e){return e.x===this.leftSE.point.x&&e.y===this.leftSE.point.y||e.x===this.rightSE.point.x&&e.y===this.rightSE.point.y}},{key:"comparePoint",value:function(e){if(this.isAnEndpoint(e))return 0;var n=this.leftSE.point,r=this.rightSE.point,i=this.vector();if(n.x===r.x)return e.x===n.x?0:e.x0&&a.swapEvents(),qr.comparePoints(this.leftSE.point,this.rightSE.point)>0&&this.swapEvents(),r&&(i.checkForConsuming(),o.checkForConsuming()),n}},{key:"swapEvents",value:function(){var e=this.rightSE;this.rightSE=this.leftSE,this.leftSE=e,this.leftSE.isLeft=!0,this.rightSE.isLeft=!1;for(var n=0,r=this.windings.length;n0){var o=n;n=r,r=o}if(n.prev===r){var s=n;n=r,r=s}for(var a=0,u=r.rings.length;a0))throw new Error("Tried to create degenerate segment at [".concat(e.x,", ").concat(e.y,"]"));i=n,o=e,s=-1}return new t(new qr(i,!0),new qr(o,!1),[r],[s])}}]),t}(),Wp=function(){function t(e,n,r){if(er(this,t),!Array.isArray(e)||e.length===0)throw new Error("Input geometry is not a valid Polygon or MultiPolygon");if(this.poly=n,this.isExterior=r,this.segments=[],typeof e[0][0]!="number"||typeof e[0][1]!="number")throw new Error("Input geometry is not a valid Polygon or MultiPolygon");var i=ws.round(e[0][0],e[0][1]);this.bbox={ll:{x:i.x,y:i.y},ur:{x:i.x,y:i.y}};for(var o=i,s=1,a=e.length;sthis.bbox.ur.x&&(this.bbox.ur.x=u.x),u.y>this.bbox.ur.y&&(this.bbox.ur.y=u.y),o=u)}i.x===o.x&&i.y===o.y||this.segments.push(Pa.fromRing(o,i,this))}return In(t,[{key:"getSweepEvents",value:function(){for(var e=[],n=0,r=this.segments.length;nthis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.interiorRings.push(o)}this.multiPoly=n}return In(t,[{key:"getSweepEvents",value:function(){for(var e=this.exteriorRing.getSweepEvents(),n=0,r=this.interiorRings.length;nthis.bbox.ur.x&&(this.bbox.ur.x=o.bbox.ur.x),o.bbox.ur.y>this.bbox.ur.y&&(this.bbox.ur.y=o.bbox.ur.y),this.polys.push(o)}this.isSubject=n}return In(t,[{key:"getSweepEvents",value:function(){for(var e=[],n=0,r=this.polys.length;n0&&(e=i)}for(var o=e.segment.prevInResult(),s=o?o.prevInResult():null;;){if(!o)return null;if(!s)return o.ringOut;if(s.ringOut!==o.ringOut)return s.ringOut.enclosingRing()!==o.ringOut?o.ringOut:o.ringOut.enclosingRing();o=s.prevInResult(),s=o?o.prevInResult():null}}}]),t}(),Zp=function(){function t(e){er(this,t),this.exteriorRing=e,e.poly=this,this.interiorRings=[]}return In(t,[{key:"addInterior",value:function(e){this.interiorRings.push(e),e.poly=this}},{key:"getGeom",value:function(){var e=[this.exteriorRing.getGeom()];if(e[0]===null)return null;for(var n=0,r=this.interiorRings.length;n1&&arguments[1]!==void 0?arguments[1]:Pa.compare;er(this,t),this.queue=e,this.tree=new yl(n),this.segments=[]}return In(t,[{key:"process",value:function(e){var n=e.segment,r=[];if(e.consumedBy)return e.isLeft?this.queue.remove(e.otherSE):this.tree.remove(n),r;var i=e.isLeft?this.tree.insert(n):this.tree.find(n);if(!i)throw new Error("Unable to find segment #".concat(n.id," ")+"[".concat(n.leftSE.point.x,", ").concat(n.leftSE.point.y,"] -> ")+"[".concat(n.rightSE.point.x,", ").concat(n.rightSE.point.y,"] ")+"in SweepLine tree. Please submit a bug report.");for(var o=i,s=i,a=void 0,u=void 0;a===void 0;)(o=this.tree.prev(o))===null?a=null:o.key.consumedBy===void 0&&(a=o.key);for(;u===void 0;)(s=this.tree.next(s))===null?u=null:s.key.consumedBy===void 0&&(u=s.key);if(e.isLeft){var l=null;if(a){var h=a.getIntersection(n);if(h!==null&&(n.isAnEndpoint(h)||(l=h),!a.isAnEndpoint(h)))for(var c=this._splitSafely(a,h),p=0,d=c.length;p0?(this.tree.remove(n),r.push(e)):(this.segments.push(n),n.prev=a)}else{if(a&&u){var E=a.getIntersection(u);if(E!==null){if(!a.isAnEndpoint(E))for(var T=this._splitSafely(a,E),C=0,D=T.length;CKp)throw new Error("Infinite loop when putting segment endpoints in a priority queue (queue size too big). Please file a bug report.");for(var v=new F0(g),x=g.size,b=g.pop();b;){var E=b.key;if(g.size===x){var T=E.segment;throw new Error("Unable to pop() ".concat(E.isLeft?"left":"right"," SweepEvent ")+"[".concat(E.point.x,", ").concat(E.point.y,"] from segment #").concat(T.id," ")+"[".concat(T.leftSE.point.x,", ").concat(T.leftSE.point.y,"] -> ")+"[".concat(T.rightSE.point.x,", ").concat(T.rightSE.point.y,"] from queue. ")+"Please file a bug report.")}if(g.size>Kp)throw new Error("Infinite loop when passing sweep line over endpoints (queue size too big). Please file a bug report.");if(v.segments.length>k0)throw new Error("Infinite loop when passing sweep line over endpoints (too many sweep line segments). Please file a bug report.");for(var C=v.process(E),D=0,M=C.length;D1?e-1:0),r=1;r1?e-1:0),r=1;r1?e-1:0),r=1;re.x?1:this.ye.y?1:0},L.prototype.clone=function(){},L.prototype.copy=function(){return new L(this)},L.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+")"},L.prototype.distance3D=function(t){var e=this.x-t.x,n=this.y-t.y,r=this.z-t.z;return Math.sqrt(e*e+n*n+r*r)},L.prototype.distance=function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)},L.prototype.hashCode=function(){var t=17;return t=37*(t=37*t+L.hashCode(this.x))+L.hashCode(this.y)},L.prototype.setCoordinate=function(t){this.x=t.x,this.y=t.y,this.z=t.z},L.prototype.interfaces_=function(){return[Tn,Ma,An]},L.prototype.getClass=function(){return L},L.hashCode=function(){if(arguments.length===1){var t=arguments[0],e=st.doubleToLongBits(t);return Math.trunc((e^e)>>>32)}},Hi.DimensionalComparator.get=function(){return ii},Hi.serialVersionUID.get=function(){return 6683108902428367e3},Hi.NULL_ORDINATE.get=function(){return st.NaN},Hi.X.get=function(){return 0},Hi.Y.get=function(){return 1},Hi.Z.get=function(){return 2},Object.defineProperties(L,Hi);var ii=function(t){if(this._dimensionsToTest=2,arguments.length!==0){if(arguments.length===1){var e=arguments[0];if(e!==2&&e!==3)throw new he("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}}};ii.prototype.compare=function(t,e){var n=t,r=e,i=ii.compare(n.x,r.x);if(i!==0)return i;var o=ii.compare(n.y,r.y);return o!==0?o:this._dimensionsToTest<=2?0:ii.compare(n.z,r.z)},ii.prototype.interfaces_=function(){return[So]},ii.prototype.getClass=function(){return ii},ii.compare=function(t,e){return te?1:st.isNaN(t)?st.isNaN(e)?0:-1:st.isNaN(e)?1:0};var Co=function(){};Co.prototype.create=function(){},Co.prototype.interfaces_=function(){return[]},Co.prototype.getClass=function(){return Co};var A=function(){},Ss={INTERIOR:{configurable:!0},BOUNDARY:{configurable:!0},EXTERIOR:{configurable:!0},NONE:{configurable:!0}};A.prototype.interfaces_=function(){return[]},A.prototype.getClass=function(){return A},A.toLocationSymbol=function(t){switch(t){case A.EXTERIOR:return"e";case A.BOUNDARY:return"b";case A.INTERIOR:return"i";case A.NONE:return"-"}throw new he("Unknown location value: "+t)},Ss.INTERIOR.get=function(){return 0},Ss.BOUNDARY.get=function(){return 1},Ss.EXTERIOR.get=function(){return 2},Ss.NONE.get=function(){return-1},Object.defineProperties(A,Ss);var et=function(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1},Sn=function(){},$p={LOG_10:{configurable:!0}};Sn.prototype.interfaces_=function(){return[]},Sn.prototype.getClass=function(){return Sn},Sn.log10=function(t){var e=Math.log(t);return st.isInfinite(e)||st.isNaN(e)?e:e/Sn.LOG_10},Sn.min=function(t,e,n,r){var i=t;return en?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var r=arguments[0],i=arguments[1],o=arguments[2];return ro?o:r}},Sn.wrap=function(t,e){return t<0?e- -t%e:t%e},Sn.max=function(){if(arguments.length===3){var t=arguments[0],e=arguments[1],n=arguments[2],r=t;return e>r&&(r=e),n>r&&(r=n),r}if(arguments.length===4){var i=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3],u=i;return o>u&&(u=o),s>u&&(u=s),a>u&&(u=a),u}},Sn.average=function(t,e){return(t+e)/2},$p.LOG_10.get=function(){return Math.log(10)},Object.defineProperties(Sn,$p);var nr=function(t){this.str=t};nr.prototype.append=function(t){this.str+=t},nr.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)},nr.prototype.toString=function(t){return this.str};var rr=function(t){this.value=t};rr.prototype.intValue=function(){return this.value},rr.prototype.compareTo=function(t){return this.valuet?1:0},rr.isNaN=function(t){return Number.isNaN(t)};var Cs=function(){};Cs.isWhitespace=function(t){return t<=32&&t>=0||t===127},Cs.toUpperCase=function(t){return t.toUpperCase()};var G=function t(){if(this._hi=0,this._lo=0,arguments.length===0)this.init(0);else if(arguments.length===1){if(typeof arguments[0]=="number"){var e=arguments[0];this.init(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}else if(typeof arguments[0]=="string"){var r=arguments[0];t.call(this,t.parse(r))}}else if(arguments.length===2){var i=arguments[0],o=arguments[1];this.init(i,o)}},Un={PI:{configurable:!0},TWO_PI:{configurable:!0},PI_2:{configurable:!0},E:{configurable:!0},NaN:{configurable:!0},EPS:{configurable:!0},SPLIT:{configurable:!0},MAX_PRINT_DIGITS:{configurable:!0},TEN:{configurable:!0},ONE:{configurable:!0},SCI_NOT_EXPONENT_CHAR:{configurable:!0},SCI_NOT_ZERO:{configurable:!0}};G.prototype.le=function(t){return(this._hi9?(h=!0,c="9"):c="0"+l,s.append(c),n=n.subtract(G.valueOf(l)).multiply(G.TEN),h&&n.selfAdd(G.TEN);var p=!0,d=G.magnitude(n._hi);if(d<0&&Math.abs(d)>=a-u&&(p=!1),!p)break}return e[0]=r,s.toString()},G.prototype.sqr=function(){return this.multiply(this)},G.prototype.doubleValue=function(){return this._hi+this._lo},G.prototype.subtract=function(){if(arguments[0]instanceof G){var t=arguments[0];return this.add(t.negate())}if(typeof arguments[0]=="number"){var e=arguments[0];return this.add(-e)}},G.prototype.equals=function(){if(arguments.length===1){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}},G.prototype.isZero=function(){return this._hi===0&&this._lo===0},G.prototype.selfSubtract=function(){if(arguments[0]instanceof G){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo)}if(typeof arguments[0]=="number"){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0)}},G.prototype.getSpecialNumberString=function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null},G.prototype.min=function(t){return this.le(t)?this:t},G.prototype.selfDivide=function(){if(arguments.length===1){if(arguments[0]instanceof G){var t=arguments[0];return this.selfDivide(t._hi,t._lo)}if(typeof arguments[0]=="number"){var e=arguments[0];return this.selfDivide(e,0)}}else if(arguments.length===2){var n=arguments[0],r=arguments[1],i=null,o=null,s=null,a=null,u=null,l=null,h=null,c=null;return u=this._hi/n,c=(i=(l=G.SPLIT*u)-(i=l-u))*(s=(c=G.SPLIT*n)-(s=c-n))-(h=u*n)+i*(a=n-s)+(o=u-i)*s+o*a,c=u+(l=(this._hi-h-c+this._lo-u*r)/n),this._hi=c,this._lo=u-c+l,this}},G.prototype.dump=function(){return"DD<"+this._hi+", "+this._lo+">"},G.prototype.divide=function(){if(arguments[0]instanceof G){var t=arguments[0],e=null,n=null,r=null,i=null,o=null,s=null,a=null,u=null;n=(o=this._hi/t._hi)-(e=(s=G.SPLIT*o)-(e=s-o)),u=e*(r=(u=G.SPLIT*t._hi)-(r=u-t._hi))-(a=o*t._hi)+e*(i=t._hi-r)+n*r+n*i;var l=u=o+(s=(this._hi-a-u+this._lo-o*t._lo)/t._hi),h=o-u+s;return new G(l,h)}if(typeof arguments[0]=="number"){var c=arguments[0];return st.isNaN(c)?G.createNaN():G.copy(this).selfDivide(c,0)}},G.prototype.ge=function(t){return(this._hi>t._hi||this._hi===t._hi)&&this._lo>=t._lo},G.prototype.pow=function(t){if(t===0)return G.valueOf(1);var e=new G(this),n=G.valueOf(1),r=Math.abs(t);if(r>1)for(;r>0;)r%2==1&&n.selfMultiply(e),(r/=2)>0&&(e=e.sqr());else n=e;return t<0?n.reciprocal():n},G.prototype.ceil=function(){if(this.isNaN())return G.NaN;var t=Math.ceil(this._hi),e=0;return t===this._hi&&(e=Math.ceil(this._lo)),new G(t,e)},G.prototype.compareTo=function(t){var e=t;return this._hie._hi?1:this._loe._lo?1:0},G.prototype.rint=function(){return this.isNaN()?this:this.add(.5).floor()},G.prototype.setValue=function(){if(arguments[0]instanceof G){var t=arguments[0];return this.init(t),this}if(typeof arguments[0]=="number"){var e=arguments[0];return this.init(e),this}},G.prototype.max=function(t){return this.ge(t)?this:t},G.prototype.sqrt=function(){if(this.isZero())return G.valueOf(0);if(this.isNegative())return G.NaN;var t=1/Math.sqrt(this._hi),e=this._hi*t,n=G.valueOf(e),r=this.subtract(n.sqr())._hi*(.5*t);return n.add(r)},G.prototype.selfAdd=function(){if(arguments.length===1){if(arguments[0]instanceof G){var t=arguments[0];return this.selfAdd(t._hi,t._lo)}if(typeof arguments[0]=="number"){var e=arguments[0],n=null,r=null,i=null,o=null,s=null,a=null;return o=(i=this._hi+e)-(s=i-this._hi),r=(a=(o=e-s+(this._hi-o))+this._lo)+(i-(n=i+a)),this._hi=n+r,this._lo=r+(n-this._hi),this}}else if(arguments.length===2){var u=arguments[0],l=arguments[1],h=null,c=null,p=null,d=null,g=null,m=null,f=null;d=this._hi+u,c=this._lo+l,g=d-(m=d-this._hi),p=c-(f=c-this._lo);var _=(h=d+(m=(g=u-m+(this._hi-g))+c))+(m=(p=l-f+(this._lo-p))+(m+(d-h))),I=m+(h-_);return this._hi=_,this._lo=I,this}},G.prototype.selfMultiply=function(){if(arguments.length===1){if(arguments[0]instanceof G){var t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if(typeof arguments[0]=="number"){var e=arguments[0];return this.selfMultiply(e,0)}}else if(arguments.length===2){var n=arguments[0],r=arguments[1],i=null,o=null,s=null,a=null,u=null,l=null;i=(u=G.SPLIT*this._hi)-this._hi,l=G.SPLIT*n,i=u-i,o=this._hi-i,s=l-n;var h=(u=this._hi*n)+(l=i*(s=l-s)-u+i*(a=n-s)+o*s+o*a+(this._hi*r+this._lo*n)),c=l+(i=u-h);return this._hi=h,this._lo=c,this}},G.prototype.selfSqr=function(){return this.selfMultiply(this)},G.prototype.floor=function(){if(this.isNaN())return G.NaN;var t=Math.floor(this._hi),e=0;return t===this._hi&&(e=Math.floor(this._lo)),new G(t,e)},G.prototype.negate=function(){return this.isNaN()?this:new G(-this._hi,-this._lo)},G.prototype.clone=function(){},G.prototype.multiply=function(){if(arguments[0]instanceof G){var t=arguments[0];return t.isNaN()?G.createNaN():G.copy(this).selfMultiply(t)}if(typeof arguments[0]=="number"){var e=arguments[0];return st.isNaN(e)?G.createNaN():G.copy(this).selfMultiply(e,0)}},G.prototype.isNaN=function(){return st.isNaN(this._hi)},G.prototype.intValue=function(){return Math.trunc(this._hi)},G.prototype.toString=function(){var t=G.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()},G.prototype.toStandardNotation=function(){var t=this.getSpecialNumberString();if(t!==null)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!0,e),r=e[0]+1,i=n;if(n.charAt(0)===".")i="0"+n;else if(r<0)i="0."+G.stringOfChar("0",-r)+n;else if(n.indexOf(".")===-1){var o=r-n.length;i=n+G.stringOfChar("0",o)+".0"}return this.isNegative()?"-"+i:i},G.prototype.reciprocal=function(){var t,e,n,r,i=null,o=null,s=null,a=null;t=(n=1/this._hi)-(i=(s=G.SPLIT*n)-(i=s-n)),o=(a=G.SPLIT*this._hi)-this._hi;var u=n+(s=(1-(r=n*this._hi)-(a=i*(o=a-o)-r+i*(e=this._hi-o)+t*o+t*e)-n*this._lo)/this._hi);return new G(u,n-u+s)},G.prototype.toSciNotation=function(){if(this.isZero())return G.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(t!==null)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!1,e),r=G.SCI_NOT_EXPONENT_CHAR+e[0];if(n.charAt(0)==="0")throw new Error("Found leading zero: "+n);var i="";n.length>1&&(i=n.substring(1));var o=n.charAt(0)+"."+i;return this.isNegative()?"-"+o+r:o+r},G.prototype.abs=function(){return this.isNaN()?G.NaN:this.isNegative()?this.negate():new G(this)},G.prototype.isPositive=function(){return(this._hi>0||this._hi===0)&&this._lo>0},G.prototype.lt=function(t){return(this._hit._hi||this._hi===t._hi)&&this._lo>t._lo},G.prototype.isNegative=function(){return(this._hi<0||this._hi===0)&&this._lo<0},G.prototype.trunc=function(){return this.isNaN()?G.NaN:this.isPositive()?this.floor():this.ceil()},G.prototype.signum=function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0},G.prototype.interfaces_=function(){return[An,Tn,Ma]},G.prototype.getClass=function(){return G},G.sqr=function(t){return G.valueOf(t).selfMultiply(t)},G.valueOf=function(){if(typeof arguments[0]=="string"){var t=arguments[0];return G.parse(t)}if(typeof arguments[0]=="number"){var e=arguments[0];return new G(e)}},G.sqrt=function(t){return G.valueOf(t).sqrt()},G.parse=function(t){for(var e=0,n=t.length;Cs.isWhitespace(t.charAt(e));)e++;var r=!1;if(e=n);){var l=t.charAt(e);if(e++,Cs.isDigit(l)){var h=l-"0";o.selfMultiply(G.TEN),o.selfAdd(h),s++}else{if(l!=="."){if(l==="e"||l==="E"){var c=t.substring(e);try{u=rr.parseInt(c)}catch(f){throw f instanceof Error?new Error("Invalid exponent "+c+" in string "+t):f}break}throw new Error("Unexpected character '"+l+"' at position "+e+" in string "+t)}a=s}}var p=o,d=s-a-u;if(d===0)p=o;else if(d>0){var g=G.TEN.pow(d);p=o.divide(g)}else if(d<0){var m=G.TEN.pow(-d);p=o.multiply(m)}return r?p.negate():p},G.createNaN=function(){return new G(st.NaN,st.NaN)},G.copy=function(t){return new G(t)},G.magnitude=function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),r=Math.trunc(Math.floor(n));return 10*Math.pow(10,r)<=e&&(r+=1),r},G.stringOfChar=function(t,e){for(var n=new nr,r=0;r0){if(o<=0)return hn.signum(s);r=i+o}else{if(!(i<0)||o>=0)return hn.signum(s);r=-i-o}var a=hn.DP_SAFE_EPSILON*r;return s>=a||-s>=a?hn.signum(s):2},hn.signum=function(t){return t>0?1:t<0?-1:0},tf.DP_SAFE_EPSILON.get=function(){return 1e-15},Object.defineProperties(hn,tf);var mt=function(){},Ns={X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0},M:{configurable:!0}};Ns.X.get=function(){return 0},Ns.Y.get=function(){return 1},Ns.Z.get=function(){return 2},Ns.M.get=function(){return 3},mt.prototype.setOrdinate=function(t,e,n){},mt.prototype.size=function(){},mt.prototype.getOrdinate=function(t,e){},mt.prototype.getCoordinate=function(){},mt.prototype.getCoordinateCopy=function(t){},mt.prototype.getDimension=function(){},mt.prototype.getX=function(t){},mt.prototype.clone=function(){},mt.prototype.expandEnvelope=function(t){},mt.prototype.copy=function(){},mt.prototype.getY=function(t){},mt.prototype.toCoordinateArray=function(){},mt.prototype.interfaces_=function(){return[Ma]},mt.prototype.getClass=function(){return mt},Object.defineProperties(mt,Ns);var ef=function(){},No=function(t){function e(){t.call(this,"Projective point not representable on the Cartesian plane.")}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(ef),qe=function(){};qe.arraycopy=function(t,e,n,r,i){for(var o=0,s=e;st._minx?this._minx:t._minx,n=this._miny>t._miny?this._miny:t._miny,r=this._maxx=this._minx&&e.getMaxX()<=this._maxx&&e.getMinY()>=this._miny&&e.getMaxY()<=this._maxy}}else if(arguments.length===2){var n=arguments[0],r=arguments[1];return!this.isNull()&&n>=this._minx&&n<=this._maxx&&r>=this._miny&&r<=this._maxy}},J.prototype.intersects=function(){if(arguments.length===1){if(arguments[0]instanceof J){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxxthis._maxy||t._maxythis._maxx||nthis._maxy||rthis._maxx&&(this._maxx=e._maxx),e._minythis._maxy&&(this._maxy=e._maxy))}}else if(arguments.length===2){var n=arguments[0],r=arguments[1];this.isNull()?(this._minx=n,this._maxx=n,this._miny=r,this._maxy=r):(nthis._maxx&&(this._maxx=n),rthis._maxy&&(this._maxy=r))}},J.prototype.minExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return te._minx?1:this._minye._miny?1:this._maxxe._maxx?1:this._maxye._maxy?1:0},J.prototype.translate=function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)},J.prototype.toString=function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"},J.prototype.setToNull=function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1},J.prototype.getHeight=function(){return this.isNull()?0:this._maxy-this._miny},J.prototype.maxExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e},J.prototype.expandBy=function(){if(arguments.length===1){var t=arguments[0];this.expandBy(t,t)}else if(arguments.length===2){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=n,this._maxy+=n,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}},J.prototype.contains=function(){if(arguments.length===1){if(arguments[0]instanceof J){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof L){var e=arguments[0];return this.covers(e)}}else if(arguments.length===2){var n=arguments[0],r=arguments[1];return this.covers(n,r)}},J.prototype.centre=function(){return this.isNull()?null:new L((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)},J.prototype.init=function(){if(arguments.length===0)this.setToNull();else if(arguments.length===1){if(arguments[0]instanceof L){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof J){var e=arguments[0];this._minx=e._minx,this._maxx=e._maxx,this._miny=e._miny,this._maxy=e._maxy}}else if(arguments.length===2){var n=arguments[0],r=arguments[1];this.init(n.x,r.x,n.y,r.y)}else if(arguments.length===4){var i=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];it._maxx&&(e=this._minx-t._maxx);var n=0;return this._maxyt._maxy&&(n=this._miny-t._maxy),e===0?n:n===0?e:Math.sqrt(e*e+n*n)},J.prototype.hashCode=function(){var t=17;return t=37*(t=37*(t=37*(t=37*t+L.hashCode(this._minx))+L.hashCode(this._maxx))+L.hashCode(this._miny))+L.hashCode(this._maxy)},J.prototype.interfaces_=function(){return[Tn,An]},J.prototype.getClass=function(){return J},J.intersects=function(){if(arguments.length===3){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.xe.x?t.x:e.x)&&n.y>=(t.ye.y?t.y:e.y)}if(arguments.length===4){var r=arguments[0],i=arguments[1],o=arguments[2],s=arguments[3],a=Math.min(o.x,s.x),u=Math.max(o.x,s.x),l=Math.min(r.x,i.x),h=Math.max(r.x,i.x);return!(l>u)&&!(hu)&&!(hn?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}},pe.prototype.isProper=function(){return this.hasIntersection()&&this._isProper},pe.prototype.setPrecisionModel=function(t){this._precisionModel=t},pe.prototype.isInteriorIntersection=function(){var t=this;if(arguments.length===0)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(arguments.length===1){for(var e=arguments[0],n=0;ni?r:i;else{var s=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);(o=r>i?s:a)!==0||t.equals(e)||(o=Math.max(s,a))}return lt.isTrue(!(o===0&&!t.equals(e)),"Bad distance calculation"),o},pe.nonRobustComputeEdgeDistance=function(t,e,n){var r=t.x-e.x,i=t.y-e.y,o=Math.sqrt(r*r+i*i);return lt.isTrue(!(o===0&&!t.equals(e)),"Invalid distance calculation"),o},Wi.DONT_INTERSECT.get=function(){return 0},Wi.DO_INTERSECT.get=function(){return 1},Wi.COLLINEAR.get=function(){return 2},Wi.NO_INTERSECTION.get=function(){return 0},Wi.POINT_INTERSECTION.get=function(){return 1},Wi.COLLINEAR_INTERSECTION.get=function(){return 2},Object.defineProperties(pe,Wi);var wi=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isInSegmentEnvelopes=function(n){var r=new J(this._inputLines[0][0],this._inputLines[0][1]),i=new J(this._inputLines[1][0],this._inputLines[1][1]);return r.contains(n)&&i.contains(n)},e.prototype.computeIntersection=function(){if(arguments.length!==3)return t.prototype.computeIntersection.apply(this,arguments);var n=arguments[0],r=arguments[1],i=arguments[2];if(this._isProper=!1,J.intersects(r,i,n)&&X.orientationIndex(r,i,n)===0&&X.orientationIndex(i,r,n)===0)return this._isProper=!0,(n.equals(r)||n.equals(i))&&(this._isProper=!1),this._result=t.POINT_INTERSECTION,null;this._result=t.NO_INTERSECTION},e.prototype.normalizeToMinimum=function(n,r,i,o,s){s.x=this.smallestInAbsValue(n.x,r.x,i.x,o.x),s.y=this.smallestInAbsValue(n.y,r.y,i.y,o.y),n.x-=s.x,n.y-=s.y,r.x-=s.x,r.y-=s.y,i.x-=s.x,i.y-=s.y,o.x-=s.x,o.y-=s.y},e.prototype.safeHCoordinateIntersection=function(n,r,i,o){var s=null;try{s=Vn.intersection(n,r,i,o)}catch(a){if(!(a instanceof No))throw a;s=e.nearestEndpoint(n,r,i,o)}return s},e.prototype.intersection=function(n,r,i,o){var s=this.intersectionWithNormalization(n,r,i,o);return this.isInSegmentEnvelopes(s)||(s=new L(e.nearestEndpoint(n,r,i,o))),this._precisionModel!==null&&this._precisionModel.makePrecise(s),s},e.prototype.smallestInAbsValue=function(n,r,i,o){var s=n,a=Math.abs(s);return Math.abs(r)1e-4&&qe.out.println("Distance = "+s.distance(a))},e.prototype.intersectionWithNormalization=function(n,r,i,o){var s=new L(n),a=new L(r),u=new L(i),l=new L(o),h=new L;this.normalizeToEnvCentre(s,a,u,l,h);var c=this.safeHCoordinateIntersection(s,a,u,l);return c.x+=h.x,c.y+=h.y,c},e.prototype.computeCollinearIntersection=function(n,r,i,o){var s=J.intersects(n,r,i),a=J.intersects(n,r,o),u=J.intersects(i,o,n),l=J.intersects(i,o,r);return s&&a?(this._intPt[0]=i,this._intPt[1]=o,t.COLLINEAR_INTERSECTION):u&&l?(this._intPt[0]=n,this._intPt[1]=r,t.COLLINEAR_INTERSECTION):s&&u?(this._intPt[0]=i,this._intPt[1]=n,!i.equals(n)||a||l?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):s&&l?(this._intPt[0]=i,this._intPt[1]=r,!i.equals(r)||a||u?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):a&&u?(this._intPt[0]=o,this._intPt[1]=n,!o.equals(n)||s||l?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):a&&l?(this._intPt[0]=o,this._intPt[1]=r,!o.equals(r)||s||u?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):t.NO_INTERSECTION},e.prototype.normalizeToEnvCentre=function(n,r,i,o,s){var a=n.xr.x?n.x:r.x,h=n.y>r.y?n.y:r.y,c=i.xo.x?i.x:o.x,g=i.y>o.y?i.y:o.y,m=((a>c?a:c)+(lp?u:p)+(h0&&a>0||s<0&&a<0)return t.NO_INTERSECTION;var u=X.orientationIndex(i,o,n),l=X.orientationIndex(i,o,r);return u>0&&l>0||u<0&&l<0?t.NO_INTERSECTION:s===0&&a===0&&u===0&&l===0?this.computeCollinearIntersection(n,r,i,o):(s===0||a===0||u===0||l===0?(this._isProper=!1,n.equals2D(i)||n.equals2D(o)?this._intPt[0]=n:r.equals2D(i)||r.equals2D(o)?this._intPt[0]=r:s===0?this._intPt[0]=new L(i):a===0?this._intPt[0]=new L(o):u===0?this._intPt[0]=new L(n):l===0&&(this._intPt[0]=new L(r))):(this._isProper=!0,this._intPt[0]=this.intersection(n,r,i,o)),t.POINT_INTERSECTION)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.nearestEndpoint=function(n,r,i,o){var s=n,a=X.distancePointLine(n,i,o),u=X.distancePointLine(r,i,o);return u0?n>0?-i:i:n>0?i:-i;if(e===0||n===0)return r>0?t>0?i:-i:t>0?-i:i;if(e>0?r>0?e<=r||(i=-i,o=t,t=n,n=o,o=e,e=r,r=o):e<=-r?(i=-i,n=-n,r=-r):(o=t,t=-n,n=o,o=e,e=-r,r=o):r>0?-e<=r?(i=-i,t=-t,e=-e):(o=-t,t=n,n=o,o=-e,e=r,r=o):e>=r?(t=-t,e=-e,n=-n,r=-r):(i=-i,o=-t,t=-n,n=o,o=-e,e=-r,r=o),t>0){if(!(n>0)||!(t<=n))return i}else{if(n>0||!(t>=n))return-i;i=-i,t=-t,n=-n}for(;;){if((r-=(s=Math.floor(n/t))*e)<0)return-i;if(r>e)return i;if(t>(n-=s*t)+n){if(er+r)return-i;n=t-n,r=e-r,i=-i}if(r===0)return n===0?0:-i;if(n===0||(e-=(s=Math.floor(t/n))*r)<0)return i;if(e>r)return-i;if(n>(t-=s*n)+t){if(re+e)return i;t=n-t,e=r-e,i=-i}if(e===0)return t===0?0:i;if(t===0)return-i}};var or=function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var t=arguments[0];this._p=t};or.prototype.countSegment=function(t,e){if(t.xr&&(n=e.x,r=t.x),this._p.x>=n&&this._p.x<=r&&(this._isPointOnSegment=!0),null}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var i=t.x-this._p.x,o=t.y-this._p.y,s=e.x-this._p.x,a=e.y-this._p.y,u=Ji.signOfDet2x2(i,o,s,a);if(u===0)return this._isPointOnSegment=!0,null;a0&&this._crossingCount++}},or.prototype.isPointInPolygon=function(){return this.getLocation()!==A.EXTERIOR},or.prototype.getLocation=function(){return this._isPointOnSegment?A.BOUNDARY:this._crossingCount%2==1?A.INTERIOR:A.EXTERIOR},or.prototype.isOnSegment=function(){return this._isPointOnSegment},or.prototype.interfaces_=function(){return[]},or.prototype.getClass=function(){return or},or.locatePointInRing=function(){if(arguments[0]instanceof L&&et(arguments[1],mt)){for(var t=arguments[0],e=arguments[1],n=new or(t),r=new L,i=new L,o=1;o1||a<0||a>1)&&(i=!0)}}else i=!0;return i?Sn.min(X.distancePointLine(t,n,r),X.distancePointLine(e,n,r),X.distancePointLine(n,t,e),X.distancePointLine(r,t,e)):0},X.isPointInRing=function(t,e){return X.locatePointInRing(t,e)!==A.EXTERIOR},X.computeLength=function(t){var e=t.size();if(e<=1)return 0;var n=0,r=new L;t.getCoordinate(0,r);for(var i=r.x,o=r.y,s=1;sn.y&&(n=o,r=i)}var s=r;do(s-=1)<0&&(s=e);while(t[s].equals2D(n)&&s!==r);var a=r;do a=(a+1)%e;while(t[a].equals2D(n)&&a!==r);var u=t[s],l=t[a];if(u.equals2D(n)||l.equals2D(n)||u.equals2D(l))return!1;var h=X.computeOrientation(u,n,l),c=!1;return c=h===0?u.x>l.x:h>0,c},X.locatePointInRing=function(t,e){return or.locatePointInRing(t,e)},X.distancePointLinePerpendicular=function(t,e,n){var r=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),i=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/r;return Math.abs(i)*Math.sqrt(r)},X.computeOrientation=function(t,e,n){return X.orientationIndex(t,e,n)},X.distancePointLine=function(){if(arguments.length===2){var t=arguments[0],e=arguments[1];if(e.length===0)throw new he("Line array must contain at least one vertex");for(var n=t.distance(e[0]),r=0;r=1)return o.distance(a);var h=((s.y-o.y)*(a.x-s.x)-(s.x-o.x)*(a.y-s.y))/u;return Math.abs(h)*Math.sqrt(u)}},X.isOnLine=function(t,e){for(var n=new wi,r=1;r0},Lo.prototype.interfaces_=function(){return[Dn]},Lo.prototype.getClass=function(){return Lo};var Oo=function(){};Oo.prototype.isInBoundary=function(t){return t>1},Oo.prototype.interfaces_=function(){return[Dn]},Oo.prototype.getClass=function(){return Oo};var Ro=function(){};Ro.prototype.isInBoundary=function(t){return t===1},Ro.prototype.interfaces_=function(){return[Dn]},Ro.prototype.getClass=function(){return Ro};var Ne=function(){};function wl(t){this.message=t||""}Ne.prototype.add=function(){},Ne.prototype.addAll=function(){},Ne.prototype.isEmpty=function(){},Ne.prototype.iterator=function(){},Ne.prototype.size=function(){},Ne.prototype.toArray=function(){},Ne.prototype.remove=function(){},wl.prototype=new Error,wl.prototype.name="IndexOutOfBoundsException";var To=function(){};To.prototype.hasNext=function(){},To.prototype.next=function(){},To.prototype.remove=function(){};var Yn=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(){},e.prototype.set=function(){},e.prototype.isEmpty=function(){},e}(Ne);function Ao(t){this.message=t||""}Ao.prototype=new Error,Ao.prototype.name="NoSuchElementException";var U=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof Ne&&this.addAll(arguments[0])}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.ensureCapacity=function(){},e.prototype.interfaces_=function(){return[t,Ne]},e.prototype.add=function(n){return arguments.length===1?this.array_.push(n):this.array_.splice(arguments[0],arguments[1]),!0},e.prototype.clear=function(){this.array_=[]},e.prototype.addAll=function(n){for(var r=n.iterator();r.hasNext();)this.add(r.next());return!0},e.prototype.set=function(n,r){var i=this.array_[n];return this.array_[n]=r,i},e.prototype.iterator=function(){return new z0(this)},e.prototype.get=function(n){if(n<0||n>=this.size())throw new wl;return this.array_[n]},e.prototype.isEmpty=function(){return this.array_.length===0},e.prototype.size=function(){return this.array_.length},e.prototype.toArray=function(){for(var n=[],r=0,i=this.array_.length;r=1){var l=this.get(this.size()-1);if(l.equals2D(a))return null}t.prototype.add.call(this,a)}else if(arguments[0]instanceof Object&&typeof arguments[1]=="boolean"){var h=arguments[0],c=arguments[1];return this.add(h,c),!0}}else if(arguments.length===3){if(typeof arguments[2]=="boolean"&&arguments[0]instanceof Array&&typeof arguments[1]=="boolean"){var p=arguments[0],d=arguments[1],g=arguments[2];if(g)for(var m=0;m=0;f--)r.add(p[f],d);return!0}if(typeof arguments[2]=="boolean"&&Number.isInteger(arguments[0])&&arguments[1]instanceof L){var _=arguments[0],I=arguments[1],y=arguments[2];if(!y){var v=this.size();if(v>0){if(_>0){var x=this.get(_-1);if(x.equals2D(I))return null}if(_D&&(M=-1);for(var B=C;B!==D;B+=M)r.add(E[B],T);return!0}},e.prototype.closeRing=function(){this.size()>0&&this.add(new L(this.get(0)),!1)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},Object.defineProperties(e,n),e}(U),ht=function(){},Ra={ForwardComparator:{configurable:!0},BidirectionalComparator:{configurable:!0},coordArrayType:{configurable:!0}};Ra.ForwardComparator.get=function(){return Ms},Ra.BidirectionalComparator.get=function(){return Do},Ra.coordArrayType.get=function(){return new Array(0).fill(null)},ht.prototype.interfaces_=function(){return[]},ht.prototype.getClass=function(){return ht},ht.isRing=function(t){return!(t.length<4)&&!!t[0].equals2D(t[t.length-1])},ht.ptNotInList=function(t,e){for(var n=0;n=t?e:[]},ht.indexOf=function(t,e){for(var n=0;n0)&&(e=t[n]);return e},ht.extract=function(t,e,n){e=Sn.clamp(e,0,t.length);var r=(n=Sn.clamp(n,-1,t.length))-e+1;n<0&&(r=0),e>=t.length&&(r=0),nr.length)return 1;if(n.length===0)return 0;var i=ht.compare(n,r);return ht.isEqualReversed(n,r)?0:i},Do.prototype.OLDcompare=function(t,e){var n=t,r=e;if(n.lengthr.length)return 1;if(n.length===0)return 0;for(var i=ht.increasingDirection(n),o=ht.increasingDirection(r),s=i>0?0:n.length-1,a=o>0?0:n.length-1,u=0;u0))return e.value;e=e.right}}return null},He.prototype.put=function(t,e){if(this.root_===null)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,r,i=this.root_;do if(n=i,(r=t.compareTo(i.key))<0)i=i.left;else{if(!(r>0)){var o=i.value;return i.value=e,o}i=i.right}while(i!==null);var s={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return r<0?n.left=s:n.right=s,this.fixAfterInsertion(s),this.size_++,null},He.prototype.fixAfterInsertion=function(t){var e=this;for(t.color=1;t!=null&&t!==this.root_&&t.parent.color===1;)if(ie(t)===Sl(ie(ie(t)))){var n=of(ie(ie(t)));rf(n)===1?(Xr(ie(t),0),Xr(n,0),Xr(ie(ie(t)),1),t=ie(ie(t))):(t===of(ie(t))&&(t=ie(t),e.rotateLeft(t)),Xr(ie(t),0),Xr(ie(ie(t)),1),e.rotateRight(ie(ie(t))))}else{var r=Sl(ie(ie(t)));rf(r)===1?(Xr(ie(t),0),Xr(r,0),Xr(ie(ie(t)),1),t=ie(ie(t))):(t===Sl(ie(t))&&(t=ie(t),e.rotateRight(t)),Xr(ie(t),0),Xr(ie(ie(t)),1),e.rotateLeft(ie(ie(t))))}this.root_.color=0},He.prototype.values=function(){var t=new U,e=this.getFirstEntry();if(e!==null)for(t.add(e.value);(e=He.successor(e))!==null;)t.add(e.value);return t},He.prototype.entrySet=function(){var t=new Il,e=this.getFirstEntry();if(e!==null)for(t.add(e);(e=He.successor(e))!==null;)t.add(e);return t},He.prototype.rotateLeft=function(t){if(t!=null){var e=t.right;t.right=e.left,e.left!=null&&(e.left.parent=t),e.parent=t.parent,t.parent===null?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}},He.prototype.rotateRight=function(t){if(t!=null){var e=t.left;t.left=e.right,e.right!=null&&(e.right.parent=t),e.parent=t.parent,t.parent===null?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}},He.prototype.getFirstEntry=function(){var t=this.root_;if(t!=null)for(;t.left!=null;)t=t.left;return t},He.successor=function(t){if(t===null)return null;if(t.right!==null){for(var e=t.right;e.left!==null;)e=e.left;return e}for(var n=t.parent,r=t;n!==null&&r===n.right;)r=n,n=n.parent;return n},He.prototype.size=function(){return this.size_};var Os=function(){};function sf(){}function sr(){this.array_=[],arguments[0]instanceof Ne&&this.addAll(arguments[0])}Os.prototype.interfaces_=function(){return[]},Os.prototype.getClass=function(){return Os},sf.prototype=new Ta,sr.prototype=new sf,sr.prototype.contains=function(t){for(var e=0,n=this.array_.length;e=0;){var s=i.substring(0,o);r.add(s),o=(i=i.substring(o+n)).indexOf(e)}i.length>0&&r.add(i);for(var a=new Array(r.size()).fill(null),u=0;u0)for(var o=i;o0&&r.append(" ");for(var o=0;o0&&r.append(","),r.append(kn.toString(t.getOrdinate(i,o)))}return r.append(")"),r.toString()}},me.ensureValidRing=function(t,e){var n=e.size();return n===0?e:n<=3?me.createClosedRing(t,e,4):e.getOrdinate(0,mt.X)===e.getOrdinate(n-1,mt.X)&&e.getOrdinate(0,mt.Y)===e.getOrdinate(n-1,mt.Y)?e:me.createClosedRing(t,e,n+1)},me.createClosedRing=function(t,e,n){var r=t.create(n,e.getDimension()),i=e.size();me.copy(e,0,r,0,i);for(var o=i;o0&&me.reverse(r._points),null}},e.prototype.getCoordinate=function(){return this.isEmpty()?null:this._points.getCoordinate(0)},e.prototype.getBoundaryDimension=function(){return this.isClosed()?Vt.FALSE:0},e.prototype.isClosed=function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))},e.prototype.getEndPoint=function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)},e.prototype.getDimension=function(){return 1},e.prototype.getLength=function(){return X.computeLength(this._points)},e.prototype.getNumPoints=function(){return this._points.size()},e.prototype.reverse=function(){var r=this._points.copy();return me.reverse(r),this.getFactory().createLineString(r)},e.prototype.compareToSameClass=function(){var r=this;if(arguments.length===1){for(var i=arguments[0],o=i,s=0,a=0;s= 2)");this._points=r},e.prototype.isCoordinate=function(r){for(var i=0;i=1&&this.getCoordinateSequence().size()= 4)")},e.prototype.getGeometryType=function(){return"LinearRing"},e.prototype.copy=function(){return new e(this._points.copy(),this._factory)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.MINIMUM_VALID_SIZE.get=function(){return 4},n.serialVersionUID.get=function(){return-0x3b229e262367a600},Object.defineProperties(e,n),e}(ge),Sr=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return $.SORTINDEX_MULTIPOLYGON},e.prototype.equalsExact=function(){if(arguments.length===2){var r=arguments[0],i=arguments[1];return!!this.isEquivalentClass(r)&&t.prototype.equalsExact.call(this,r,i)}return t.prototype.equalsExact.apply(this,arguments)},e.prototype.getBoundaryDimension=function(){return 1},e.prototype.getDimension=function(){return 2},e.prototype.reverse=function(){for(var r=this._geometries.length,i=new Array(r).fill(null),o=0;o0?e.createPoint(n[0]):e.createPoint():t},As.prototype.interfaces_=function(){return[Gn.GeometryEditorOperation]},As.prototype.getClass=function(){return As};var Ds=function(){};Ds.prototype.edit=function(t,e){return t instanceof Ir?e.createLinearRing(this.edit(t.getCoordinateSequence(),t)):t instanceof ge?e.createLineString(this.edit(t.getCoordinateSequence(),t)):t instanceof vn?e.createPoint(this.edit(t.getCoordinateSequence(),t)):t},Ds.prototype.interfaces_=function(){return[Gn.GeometryEditorOperation]},Ds.prototype.getClass=function(){return Ds};var ve=function(){var t=this;if(this._dimension=3,this._coordinates=null,arguments.length===1){if(arguments[0]instanceof Array)this._coordinates=arguments[0],this._dimension=3;else if(Number.isInteger(arguments[0])){var e=arguments[0];this._coordinates=new Array(e).fill(null);for(var n=0;n0){var t=new nr(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e3&&(r=3),r<2?new ve(n):new ve(n,r)}},Cr.prototype.interfaces_=function(){return[Co,An]},Cr.prototype.getClass=function(){return Cr},Cr.instance=function(){return Cr.instanceObject},Nl.serialVersionUID.get=function(){return-0x38e49fa6cf6f2e00},Nl.instanceObject.get=function(){return new Cr},Object.defineProperties(Cr,Nl);var uf=function(t){function e(){t.call(this),this.map_=new Map}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.get=function(n){return this.map_.get(n)||null},e.prototype.put=function(n,r){return this.map_.set(n,r),r},e.prototype.values=function(){for(var n=new U,r=this.map_.values(),i=r.next();!i.done;)n.add(i.value),i=r.next();return n},e.prototype.entrySet=function(){var n=new Il;return this.map_.entries().forEach(function(r){return n.add(r)}),n},e.prototype.size=function(){return this.map_.size()},e}(Ki),Xt=function t(){if(this._modelType=null,this._scale=null,arguments.length===0)this._modelType=t.FLOATING;else if(arguments.length===1){if(arguments[0]instanceof ur){var e=arguments[0];this._modelType=e,e===t.FIXED&&this.setScale(1)}else if(typeof arguments[0]=="number"){var n=arguments[0];this._modelType=t.FIXED,this.setScale(n)}else if(arguments[0]instanceof t){var r=arguments[0];this._modelType=r._modelType,this._scale=r._scale}}},Pl={serialVersionUID:{configurable:!0},maximumPreciseValue:{configurable:!0}};Xt.prototype.equals=function(t){if(!(t instanceof Xt))return!1;var e=t;return this._modelType===e._modelType&&this._scale===e._scale},Xt.prototype.compareTo=function(t){var e=t,n=this.getMaximumSignificantDigits(),r=e.getMaximumSignificantDigits();return new rr(n).compareTo(new rr(r))},Xt.prototype.getScale=function(){return this._scale},Xt.prototype.isFloating=function(){return this._modelType===Xt.FLOATING||this._modelType===Xt.FLOATING_SINGLE},Xt.prototype.getType=function(){return this._modelType},Xt.prototype.toString=function(){var t="UNKNOWN";return this._modelType===Xt.FLOATING?t="Floating":this._modelType===Xt.FLOATING_SINGLE?t="Floating-Single":this._modelType===Xt.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t},Xt.prototype.makePrecise=function(){if(typeof arguments[0]=="number"){var t=arguments[0];return st.isNaN(t)||this._modelType===Xt.FLOATING_SINGLE?t:this._modelType===Xt.FIXED?Math.round(t*this._scale)/this._scale:t}if(arguments[0]instanceof L){var e=arguments[0];if(this._modelType===Xt.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y)}},Xt.prototype.getMaximumSignificantDigits=function(){var t=16;return this._modelType===Xt.FLOATING?t=16:this._modelType===Xt.FLOATING_SINGLE?t=6:this._modelType===Xt.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t},Xt.prototype.setScale=function(t){this._scale=Math.abs(t)},Xt.prototype.interfaces_=function(){return[An,Tn]},Xt.prototype.getClass=function(){return Xt},Xt.mostPrecise=function(t,e){return t.compareTo(e)>=0?t:e},Pl.serialVersionUID.get=function(){return 7777263578777804e3},Pl.maximumPreciseValue.get=function(){return 9007199254740992},Object.defineProperties(Xt,Pl);var ur=function t(e){this._name=e||null,t.nameToTypeMap.put(e,this)},Ml={serialVersionUID:{configurable:!0},nameToTypeMap:{configurable:!0}};ur.prototype.readResolve=function(){return ur.nameToTypeMap.get(this._name)},ur.prototype.toString=function(){return this._name},ur.prototype.interfaces_=function(){return[An]},ur.prototype.getClass=function(){return ur},Ml.serialVersionUID.get=function(){return-552860263173159e4},Ml.nameToTypeMap.get=function(){return new uf},Object.defineProperties(ur,Ml),Xt.Type=ur,Xt.FIXED=new ur("FIXED"),Xt.FLOATING=new ur("FLOATING"),Xt.FLOATING_SINGLE=new ur("FLOATING SINGLE");var pt=function t(){this._precisionModel=new Xt,this._SRID=0,this._coordinateSequenceFactory=t.getDefaultCoordinateSequenceFactory(),arguments.length===0||(arguments.length===1?et(arguments[0],Co)?this._coordinateSequenceFactory=arguments[0]:arguments[0]instanceof Xt&&(this._precisionModel=arguments[0]):arguments.length===2?(this._precisionModel=arguments[0],this._SRID=arguments[1]):arguments.length===3&&(this._precisionModel=arguments[0],this._SRID=arguments[1],this._coordinateSequenceFactory=arguments[2]))},lf={serialVersionUID:{configurable:!0}};pt.prototype.toGeometry=function(t){return t.isNull()?this.createPoint(null):t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new L(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new L(t.getMinX(),t.getMinY()),new L(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new L(t.getMinX(),t.getMinY()),new L(t.getMinX(),t.getMaxY()),new L(t.getMaxX(),t.getMaxY()),new L(t.getMaxX(),t.getMinY()),new L(t.getMinX(),t.getMinY())]),null)},pt.prototype.createLineString=function(t){return t?t instanceof Array?new ge(this.getCoordinateSequenceFactory().create(t),this):et(t,mt)?new ge(t,this):void 0:new ge(this.getCoordinateSequenceFactory().create([]),this)},pt.prototype.createMultiLineString=function(){if(arguments.length===0)return new Si(null,this);if(arguments.length===1){var t=arguments[0];return new Si(t,this)}},pt.prototype.buildGeometry=function(t){for(var e=null,n=!1,r=!1,i=t.iterator();i.hasNext();){var o=i.next(),s=o.getClass();e===null&&(e=s),s!==e&&(n=!0),o.isGeometryCollectionOrDerived()&&(r=!0)}if(e===null)return this.createGeometryCollection();if(n||r)return this.createGeometryCollection(pt.toGeometryArray(t));var a=t.iterator().next();if(t.size()>1){if(a instanceof Pe)return this.createMultiPolygon(pt.toPolygonArray(t));if(a instanceof ge)return this.createMultiLineString(pt.toLineStringArray(t));if(a instanceof vn)return this.createMultiPoint(pt.toPointArray(t));lt.shouldNeverReachHere("Unhandled class: "+a.getClass().getName())}return a},pt.prototype.createMultiPointFromCoords=function(t){return this.createMultiPoint(t!==null?this.getCoordinateSequenceFactory().create(t):null)},pt.prototype.createPoint=function(){if(arguments.length===0)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof L){var t=arguments[0];return this.createPoint(t!==null?this.getCoordinateSequenceFactory().create([t]):null)}if(et(arguments[0],mt)){var e=arguments[0];return new vn(e,this)}}},pt.prototype.getCoordinateSequenceFactory=function(){return this._coordinateSequenceFactory},pt.prototype.createPolygon=function(){if(arguments.length===0)return new Pe(null,null,this);if(arguments.length===1){if(et(arguments[0],mt)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof Ir){var n=arguments[0];return this.createPolygon(n,null)}}else if(arguments.length===2){var r=arguments[0],i=arguments[1];return new Pe(r,i,this)}},pt.prototype.getSRID=function(){return this._SRID},pt.prototype.createGeometryCollection=function(){if(arguments.length===0)return new Qe(null,this);if(arguments.length===1){var t=arguments[0];return new Qe(t,this)}},pt.prototype.createGeometry=function(t){return new Gn(this).edit(t,{edit:function(){if(arguments.length===2){var e=arguments[0];return this._coordinateSequenceFactory.create(e)}}})},pt.prototype.getPrecisionModel=function(){return this._precisionModel},pt.prototype.createLinearRing=function(){if(arguments.length===0)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(arguments.length===1){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(t!==null?this.getCoordinateSequenceFactory().create(t):null)}if(et(arguments[0],mt)){var e=arguments[0];return new Ir(e,this)}}},pt.prototype.createMultiPolygon=function(){if(arguments.length===0)return new Sr(null,this);if(arguments.length===1){var t=arguments[0];return new Sr(t,this)}},pt.prototype.createMultiPoint=function(){var t=this;if(arguments.length===0)return new Fo(null,this);if(arguments.length===1){if(arguments[0]instanceof Array){var e=arguments[0];return new Fo(e,this)}if(arguments[0]instanceof Array){var n=arguments[0];return this.createMultiPoint(n!==null?this.getCoordinateSequenceFactory().create(n):null)}if(et(arguments[0],mt)){var r=arguments[0];if(r===null)return this.createMultiPoint(new Array(0).fill(null));for(var i=new Array(r.size()).fill(null),o=0;o=this.size())throw new Error;return this.array_[t]},cr.prototype.push=function(t){return this.array_.push(t),t},cr.prototype.pop=function(t){if(this.array_.length===0)throw new qa;return this.array_.pop()},cr.prototype.peek=function(){if(this.array_.length===0)throw new qa;return this.array_[this.array_.length-1]},cr.prototype.empty=function(){return this.array_.length===0},cr.prototype.isEmpty=function(){return this.empty()},cr.prototype.search=function(t){return this.array_.indexOf(t)},cr.prototype.size=function(){return this.array_.length},cr.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e0&&this._minIndexthis._minCoord.y&&n.y>this._minCoord.y&&r===X.CLOCKWISE)&&(i=!0),i&&(this._minIndex=this._minIndex-1)},hr.prototype.getRightmostSideOfSegment=function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length||n[e].y===n[e+1].y)return-1;var r=z.LEFT;return n[e].ye._minCoord.x)&&(e._minDe=t,e._minIndex=r,e._minCoord=n[r])},hr.prototype.findRightmostEdgeAtNode=function(){var t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)},hr.prototype.findEdge=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}lt.isTrue(this._minIndex!==0||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),this._minIndex===0?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe,this.getRightmostSide(this._minDe,this._minIndex)===z.LEFT&&(this._orientedDe=this._minDe.getSym())},hr.prototype.interfaces_=function(){return[]},hr.prototype.getClass=function(){return hr};var Hr=function(t){function e(n,r){t.call(this,e.msgWithCoord(n,r)),this.pt=r?new L(r):null,this.name="TopologyException"}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getCoordinate=function(){return this.pt},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.msgWithCoord=function(n,r){return r?n:n+" [ "+r+" ]"},e}(jr),Ba=function(){this.array_=[]};Ba.prototype.addLast=function(t){this.array_.push(t)},Ba.prototype.removeFirst=function(){return this.array_.shift()},Ba.prototype.isEmpty=function(){return this.array_.length===0};var $e=function(){this._finder=null,this._dirEdgeList=new U,this._nodes=new U,this._rightMostCoord=null,this._env=null,this._finder=new hr};$e.prototype.clearVisitedEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();)t.next().setVisited(!1)},$e.prototype.getRightmostCoordinate=function(){return this._rightMostCoord},$e.prototype.computeNodeDepth=function(t){for(var e=null,n=t.getEdges().iterator();n.hasNext();){var r=n.next();if(r.isVisited()||r.getSym().isVisited()){e=r;break}}if(e===null)throw new Hr("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(var i=t.getEdges().iterator();i.hasNext();){var o=i.next();o.setVisited(!0),this.copySymDepths(o)}},$e.prototype.computeDepth=function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.setEdgeDepths(z.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)},$e.prototype.create=function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()},$e.prototype.findResultEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(z.RIGHT)>=1&&e.getDepth(z.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}},$e.prototype.computeDepths=function(t){var e=new Il,n=new Ba,r=t.getNode();for(n.addLast(r),e.add(r),t.setVisited(!0);!n.isEmpty();){var i=n.removeFirst();e.add(i),this.computeNodeDepth(i);for(var o=i.getEdges().iterator();o.hasNext();){var s=o.next().getSym();if(!s.isVisited()){var a=s.getNode();e.contains(a)||(n.addLast(a),e.add(a))}}}},$e.prototype.compareTo=function(t){var e=t;return this._rightMostCoord.xe._rightMostCoord.x?1:0},$e.prototype.getEnvelope=function(){if(this._env===null){for(var t=new J,e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),r=0;rthis.location.length){var e=new Array(3).fill(null);e[z.ON]=this.location[z.ON],e[z.LEFT]=A.NONE,e[z.RIGHT]=A.NONE,this.location=e}for(var n=0;n1&&t.append(A.toLocationSymbol(this.location[z.LEFT])),t.append(A.toLocationSymbol(this.location[z.ON])),this.location.length>1&&t.append(A.toLocationSymbol(this.location[z.RIGHT])),t.toString()},oe.prototype.setLocations=function(t,e,n){this.location[z.ON]=t,this.location[z.LEFT]=e,this.location[z.RIGHT]=n},oe.prototype.get=function(t){return t1},oe.prototype.isAnyNull=function(){for(var t=0;tt._maxNodeDegree&&(t._maxNodeDegree=n),e=t.getNext(e)}while(e!==this._startDe);this._maxNodeDegree*=2},be.prototype.addPoints=function(t,e,n){var r=t.getCoordinates();if(e){var i=1;n&&(i=0);for(var o=i;o=0;a--)this._pts.add(r[a])}},be.prototype.isHole=function(){return this._isHole},be.prototype.setInResult=function(){var t=this._startDe;do t.getEdge().setInResult(!0),t=t.getNext();while(t!==this._startDe)},be.prototype.containsPoint=function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t)||!X.isPointInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();)if(n.next().containsPoint(t))return!1;return!0},be.prototype.addHole=function(t){this._holes.add(t)},be.prototype.isShell=function(){return this._shell===null},be.prototype.getLabel=function(){return this._label},be.prototype.getEdges=function(){return this._edges},be.prototype.getMaxNodeDegree=function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree},be.prototype.getShell=function(){return this._shell},be.prototype.mergeLabel=function(){if(arguments.length===1){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(arguments.length===2){var e=arguments[0],n=arguments[1],r=e.getLocation(n,z.RIGHT);if(r===A.NONE)return null;if(this._label.getLocation(n)===A.NONE)return this._label.setLocation(n,r),null}},be.prototype.setShell=function(t){this._shell=t,t!==null&&t.addHole(this)},be.prototype.toPolygon=function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n=2,"found partial label"),this.computeIM(t)},Cn.prototype.isInResult=function(){return this._isInResult},Cn.prototype.isVisited=function(){return this._isVisited},Cn.prototype.interfaces_=function(){return[]},Cn.prototype.getClass=function(){return Cn};var za=function(t){function e(){t.call(this),this._coord=null,this._edges=null;var n=arguments[0],r=arguments[1];this._coord=n,this._edges=r,this._label=new Kt(0,A.NONE)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isIncidentEdgeInResult=function(){for(var n=this.getEdges().getEdges().iterator();n.hasNext();)if(n.next().getEdge().isInResult())return!0;return!1},e.prototype.isIsolated=function(){return this._label.getGeometryCount()===1},e.prototype.getCoordinate=function(){return this._coord},e.prototype.print=function(n){n.println("node "+this._coord+" lbl: "+this._label)},e.prototype.computeIM=function(n){},e.prototype.computeMergedLocation=function(n,r){var i=A.NONE;if(i=this._label.getLocation(r),!n.isNull(r)){var o=n.getLocation(r);i!==A.BOUNDARY&&(i=o)}return i},e.prototype.setLabel=function(){if(arguments.length!==2)return t.prototype.setLabel.apply(this,arguments);var n=arguments[0],r=arguments[1];this._label===null?this._label=new Kt(n,r):this._label.setLocation(n,r)},e.prototype.getEdges=function(){return this._edges},e.prototype.mergeLabel=function(){var n=this;if(arguments[0]instanceof e){var r=arguments[0];this.mergeLabel(r._label)}else if(arguments[0]instanceof Kt)for(var i=arguments[0],o=0;o<2;o++){var s=n.computeMergedLocation(i,o),a=n._label.getLocation(o);a===A.NONE&&n._label.setLocation(o,s)}},e.prototype.add=function(n){this._edges.insert(n),n.setNode(this)},e.prototype.setLabelBoundary=function(n){if(this._label===null)return null;var r=A.NONE;this._label!==null&&(r=this._label.getLocation(n));var i=null;switch(r){case A.BOUNDARY:i=A.INTERIOR;break;case A.INTERIOR:default:i=A.BOUNDARY}this._label.setLocation(n,i)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Cn),pr=function(){this.nodeMap=new He,this.nodeFact=null;var t=arguments[0];this.nodeFact=t};pr.prototype.find=function(t){return this.nodeMap.get(t)},pr.prototype.addNode=function(){if(arguments[0]instanceof L){var t=arguments[0],e=this.nodeMap.get(t);return e===null&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof za){var n=arguments[0],r=this.nodeMap.get(n.getCoordinate());return r===null?(this.nodeMap.put(n.getCoordinate(),n),n):(r.mergeLabel(n),r)}},pr.prototype.print=function(t){for(var e=this.iterator();e.hasNext();)e.next().print(t)},pr.prototype.iterator=function(){return this.nodeMap.values().iterator()},pr.prototype.values=function(){return this.nodeMap.values()},pr.prototype.getBoundaryNodes=function(t){for(var e=new U,n=this.iterator();n.hasNext();){var r=n.next();r.getLabel().getLocation(t)===A.BOUNDARY&&e.add(r)}return e},pr.prototype.add=function(t){var e=t.getCoordinate();this.addNode(e).add(t)},pr.prototype.interfaces_=function(){return[]},pr.prototype.getClass=function(){return pr};var te=function(){},Fs={NE:{configurable:!0},NW:{configurable:!0},SW:{configurable:!0},SE:{configurable:!0}};te.prototype.interfaces_=function(){return[]},te.prototype.getClass=function(){return te},te.isNorthern=function(t){return t===te.NE||t===te.NW},te.isOpposite=function(t,e){return t!==e&&(t-e+4)%4===2},te.commonHalfPlane=function(t,e){if(t===e)return t;if((t-e+4)%4===2)return-1;var n=te?t:e)===3?3:n},te.isInHalfPlane=function(t,e){return e===te.SE?t===te.SE||t===te.SW:t===e||t===e+1},te.quadrant=function(){if(typeof arguments[0]=="number"&&typeof arguments[1]=="number"){var t=arguments[0],e=arguments[1];if(t===0&&e===0)throw new he("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?te.NE:te.SE:e>=0?te.NW:te.SW}if(arguments[0]instanceof L&&arguments[1]instanceof L){var n=arguments[0],r=arguments[1];if(r.x===n.x&&r.y===n.y)throw new he("Cannot compute the quadrant for two identical points "+n);return r.x>=n.x?r.y>=n.y?te.NE:te.SE:r.y>=n.y?te.NW:te.SW}},Fs.NE.get=function(){return 0},Fs.NW.get=function(){return 1},Fs.SW.get=function(){return 2},Fs.SE.get=function(){return 3},Object.defineProperties(te,Fs);var We=function(){if(this._edge=null,this._label=null,this._node=null,this._p0=null,this._p1=null,this._dx=null,this._dy=null,this._quadrant=null,arguments.length===1){var t=arguments[0];this._edge=t}else if(arguments.length===3){var e=arguments[0],n=arguments[1],r=arguments[2],i=null;this._edge=e,this.init(n,r),this._label=i}else if(arguments.length===4){var o=arguments[0],s=arguments[1],a=arguments[2],u=arguments[3];this._edge=o,this.init(s,a),this._label=u}};We.prototype.compareDirection=function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant2){o.linkDirectedEdgesForMinimalEdgeRings();var s=o.buildMinimalRings(),a=this.findShell(s);a!==null?(this.placePolygonHoles(a,s),e.add(a)):n.addAll(s)}else r.add(o)}return r},_n.prototype.containsPoint=function(t){for(var e=this._shellList.iterator();e.hasNext();)if(e.next().containsPoint(t))return!0;return!1},_n.prototype.buildMaximalEdgeRings=function(t){for(var e=new U,n=t.iterator();n.hasNext();){var r=n.next();if(r.isInResult()&&r.getLabel().isArea()&&r.getEdgeRing()===null){var i=new Q0(r,this._geometryFactory);e.add(i),i.setInResult()}}return e},_n.prototype.placePolygonHoles=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next();r.isHole()&&r.setShell(t)}},_n.prototype.getPolygons=function(){return this.computePolygons(this._shellList)},_n.prototype.findEdgeRingContaining=function(t,e){for(var n=t.getLinearRing(),r=n.getEnvelopeInternal(),i=n.getCoordinateN(0),o=null,s=null,a=e.iterator();a.hasNext();){var u=a.next(),l=u.getLinearRing(),h=l.getEnvelopeInternal();o!==null&&(s=o.getLinearRing().getEnvelopeInternal());var c=!1;h.contains(r)&&X.isPointInRing(i,l.getCoordinates())&&(c=!0),c&&(o===null||s.contains(h))&&(o=u)}return o},_n.prototype.findShell=function(t){for(var e=0,n=null,r=t.iterator();r.hasNext();){var i=r.next();i.isHole()||(n=i,e++)}return lt.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n},_n.prototype.add=function(){if(arguments.length===1){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(arguments.length===2){var e=arguments[0],n=arguments[1];fe.linkResultDirectedEdges(n);var r=this.buildMaximalEdgeRings(e),i=new U,o=this.buildMinimalEdgeRings(r,this._shellList,i);this.sortShellsAndHoles(o,this._shellList,i),this.placeFreeHoles(this._shellList,i)}},_n.prototype.interfaces_=function(){return[]},_n.prototype.getClass=function(){return _n};var Go=function(){};Go.prototype.getBounds=function(){},Go.prototype.interfaces_=function(){return[]},Go.prototype.getClass=function(){return Go};var Jn=function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e};Jn.prototype.getItem=function(){return this._item},Jn.prototype.getBounds=function(){return this._bounds},Jn.prototype.interfaces_=function(){return[Go,An]},Jn.prototype.getClass=function(){return Jn};var Wr=function(){this._size=null,this._items=null,this._size=0,this._items=new U,this._items.add(null)};Wr.prototype.poll=function(){if(this.isEmpty())return null;var t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t},Wr.prototype.size=function(){return this._size},Wr.prototype.reorder=function(t){for(var e=this,n=null,r=this._items.get(t);2*t<=this._size&&((n=2*t)!==e._size&&e._items.get(n+1).compareTo(e._items.get(n))<0&&n++,e._items.get(n).compareTo(r)<0);t=n)e._items.set(t,e._items.get(n));this._items.set(t,r)},Wr.prototype.clear=function(){this._size=0,this._items.clear()},Wr.prototype.isEmpty=function(){return this._size===0},Wr.prototype.add=function(t){this._items.add(null),this._size+=1;var e=this._size;for(this._items.set(0,t);t.compareTo(this._items.get(Math.trunc(e/2)))<0;e/=2)this._items.set(e,this._items.get(Math.trunc(e/2)));this._items.set(e,t)},Wr.prototype.interfaces_=function(){return[]},Wr.prototype.getClass=function(){return Wr};var si=function(){};si.prototype.visitItem=function(t){},si.prototype.interfaces_=function(){return[]},si.prototype.getClass=function(){return si};var Qi=function(){};Qi.prototype.insert=function(t,e){},Qi.prototype.remove=function(t,e){},Qi.prototype.query=function(){},Qi.prototype.interfaces_=function(){return[]},Qi.prototype.getClass=function(){return Qi};var Me=function(){if(this._childBoundables=new U,this._bounds=null,this._level=null,arguments.length!==0){if(arguments.length===1){var t=arguments[0];this._level=t}}},hf={serialVersionUID:{configurable:!0}};Me.prototype.getLevel=function(){return this._level},Me.prototype.size=function(){return this._childBoundables.size()},Me.prototype.getChildBoundables=function(){return this._childBoundables},Me.prototype.addChildBoundable=function(t){lt.isTrue(this._bounds===null),this._childBoundables.add(t)},Me.prototype.isEmpty=function(){return this._childBoundables.isEmpty()},Me.prototype.getBounds=function(){return this._bounds===null&&(this._bounds=this.computeBounds()),this._bounds},Me.prototype.interfaces_=function(){return[Go,An]},Me.prototype.getClass=function(){return Me},hf.serialVersionUID.get=function(){return 6493722185909574e3},Object.defineProperties(Me,hf);var Zn=function(){};Zn.reverseOrder=function(){return{compare:function(t,e){return e.compareTo(t)}}},Zn.min=function(t){return Zn.sort(t),t.get(0)},Zn.sort=function(t,e){var n=t.toArray();e?Ii.sort(n,e):Ii.sort(n);for(var r=t.iterator(),i=0,o=n.length;iwe.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,t,e),null):(this.expand(this._boundable2,this._boundable1,t,e),null);if(n)return this.expand(this._boundable1,this._boundable2,t,e),null;if(r)return this.expand(this._boundable2,this._boundable1,t,e),null;throw new he("neither boundable is composite")},we.prototype.isLeaves=function(){return!(we.isComposite(this._boundable1)||we.isComposite(this._boundable2))},we.prototype.compareTo=function(t){var e=t;return this._distancee._distance?1:0},we.prototype.expand=function(t,e,n,r){for(var i=t.getChildBoundables().iterator();i.hasNext();){var o=i.next(),s=new we(o,e,this._itemDistance);s.getDistance()1,"Node capacity must be greater than 1"),this._nodeCapacity=n}},ja={IntersectsOp:{configurable:!0},serialVersionUID:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};Ae.prototype.getNodeCapacity=function(){return this._nodeCapacity},Ae.prototype.lastNode=function(t){return t.get(t.size()-1)},Ae.prototype.size=function(){var t=this;if(arguments.length===0)return this.isEmpty()?0:(this.build(),this.size(this._root));if(arguments.length===1){for(var e=arguments[0],n=0,r=e.getChildBoundables().iterator();r.hasNext();){var i=r.next();i instanceof Me?n+=t.size(i):i instanceof Jn&&(n+=1)}return n}},Ae.prototype.removeItem=function(t,e){for(var n=null,r=t.getChildBoundables().iterator();r.hasNext();){var i=r.next();i instanceof Jn&&i.getItem()===e&&(n=i)}return n!==null&&(t.getChildBoundables().remove(n),!0)},Ae.prototype.itemsTree=function(){var t=this;if(arguments.length===0){this.build();var e=this.itemsTree(this._root);return e===null?new U:e}if(arguments.length===1){for(var n=arguments[0],r=new U,i=n.getChildBoundables().iterator();i.hasNext();){var o=i.next();if(o instanceof Me){var s=t.itemsTree(o);s!==null&&r.add(s)}else o instanceof Jn?r.add(o.getItem()):lt.shouldNeverReachHere()}return r.size()<=0?null:r}},Ae.prototype.insert=function(t,e){lt.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new Jn(t,e))},Ae.prototype.boundablesAtLevel=function(){var t=this;if(arguments.length===1){var e=arguments[0],n=new U;return this.boundablesAtLevel(e,this._root,n),n}if(arguments.length===3){var r=arguments[0],i=arguments[1],o=arguments[2];if(lt.isTrue(r>-2),i.getLevel()===r)return o.add(i),null;for(var s=i.getChildBoundables().iterator();s.hasNext();){var a=s.next();a instanceof Me?t.boundablesAtLevel(r,a,o):(lt.isTrue(a instanceof Jn),r===-1&&o.add(a))}return null}},Ae.prototype.query=function(){var t=this;if(arguments.length===1){var e=arguments[0];this.build();var n=new U;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),e)&&this.query(e,this._root,n),n}if(arguments.length===2){var r=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),r)&&this.query(r,this._root,i)}else if(arguments.length===3){if(et(arguments[2],si)&&arguments[0]instanceof Object&&arguments[1]instanceof Me)for(var o=arguments[0],s=arguments[1],a=arguments[2],u=s.getChildBoundables(),l=0;ln&&(n=o)}}return n+1}},Ae.prototype.createParentBoundables=function(t,e){var n=this;lt.isTrue(!t.isEmpty());var r=new U;r.add(this.createNode(e));var i=new U(t);Zn.sort(i,this.getComparator());for(var o=i.iterator();o.hasNext();){var s=o.next();n.lastNode(r).getChildBoundables().size()===n.getNodeCapacity()&&r.add(n.createNode(e)),n.lastNode(r).addChildBoundable(s)}return r},Ae.prototype.isEmpty=function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()},Ae.prototype.interfaces_=function(){return[An]},Ae.prototype.getClass=function(){return Ae},Ae.compareDoubles=function(t,e){return t>e?1:t0);for(var o=new U,s=0;s0;){var g=d.poll(),m=g.getDistance();if(m>=c)break;g.isLeaves()?(c=m,p=g):g.expandToQueue(d,c)}return[p.getBoundable(0).getItem(),p.getBoundable(1).getItem()]}}else if(arguments.length===3){var f=arguments[0],_=arguments[1],I=arguments[2],y=new Jn(f,_),v=new we(this.getRoot(),y,I);return this.nearestNeighbour(v)[0]}},e.prototype.interfaces_=function(){return[Qi,An]},e.prototype.getClass=function(){return e},e.centreX=function(r){return e.avg(r.getMinX(),r.getMaxX())},e.avg=function(r,i){return(r+i)/2},e.centreY=function(r){return e.avg(r.getMinY(),r.getMaxY())},n.STRtreeNode.get=function(){return ff},n.serialVersionUID.get=function(){return 0x39920f7d5f261e0},n.xComparator.get=function(){return{interfaces_:function(){return[So]},compare:function(r,i){return t.compareDoubles(e.centreX(r.getBounds()),e.centreX(i.getBounds()))}}},n.yComparator.get=function(){return{interfaces_:function(){return[So]},compare:function(r,i){return t.compareDoubles(e.centreY(r.getBounds()),e.centreY(i.getBounds()))}}},n.intersectsOp.get=function(){return{interfaces_:function(){return[t.IntersectsOp]},intersects:function(r,i){return r.intersects(i)}}},n.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(e,n),e}(Ae),ff=function(t){function e(){var n=arguments[0];t.call(this,n)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.computeBounds=function(){for(var n=null,r=this.getChildBoundables().iterator();r.hasNext();){var i=r.next();n===null?n=new J(i.getBounds()):n.expandToInclude(i.getBounds())}return n},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Me),pn=function(){};pn.prototype.interfaces_=function(){return[]},pn.prototype.getClass=function(){return pn},pn.relativeSign=function(t,e){return te?1:0},pn.compare=function(t,e,n){if(e.equals2D(n))return 0;var r=pn.relativeSign(e.x,n.x),i=pn.relativeSign(e.y,n.y);switch(t){case 0:return pn.compareValue(r,i);case 1:return pn.compareValue(i,r);case 2:return pn.compareValue(i,-r);case 3:return pn.compareValue(-r,i);case 4:return pn.compareValue(-r,-i);case 5:return pn.compareValue(-i,-r);case 6:return pn.compareValue(-i,r);case 7:return pn.compareValue(r,-i)}return lt.shouldNeverReachHere("invalid octant value"),0},pn.compareValue=function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0};var ai=function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this._segString=t,this.coord=new L(e),this.segmentIndex=n,this._segmentOctant=r,this._isInterior=!e.equals2D(t.getCoordinate(n))};ai.prototype.getCoordinate=function(){return this.coord},ai.prototype.print=function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)},ai.prototype.compareTo=function(t){var e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:pn.compare(this._segmentOctant,this.coord,e.coord)},ai.prototype.isEndPoint=function(t){return this.segmentIndex===0&&!this._isInterior||this.segmentIndex===t},ai.prototype.isInterior=function(){return this._isInterior},ai.prototype.interfaces_=function(){return[Tn]},ai.prototype.getClass=function(){return ai};var tn=function(){this._nodeMap=new He,this._edge=null;var t=arguments[0];this._edge=t};tn.prototype.getSplitCoordinates=function(){var t=new Ps;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var r=e.next();this.addEdgeCoordinates(n,r,t),n=r}return t.toCoordinateArray()},tn.prototype.addCollapsedNodes=function(){var t=new U;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this._edge.getCoordinate(n),n)}},tn.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();)e.next().print(t)},tn.prototype.findCollapsesFromExistingVertices=function(t){for(var e=0;e=0?e>=0?n>=r?0:1:n>=r?7:6:e>=0?n>=r?3:2:n>=r?4:5}if(arguments[0]instanceof L&&arguments[1]instanceof L){var i=arguments[0],o=arguments[1],s=o.x-i.x,a=o.y-i.y;if(s===0&&a===0)throw new he("Cannot compute the octant for two identical points "+i);return $i.octant(s,a)}};var Nr=function(){};Nr.prototype.getCoordinates=function(){},Nr.prototype.size=function(){},Nr.prototype.getCoordinate=function(t){},Nr.prototype.isClosed=function(){},Nr.prototype.setData=function(t){},Nr.prototype.getData=function(){},Nr.prototype.interfaces_=function(){return[]},Nr.prototype.getClass=function(){return Nr};var ks=function(){};ks.prototype.addIntersection=function(t,e){},ks.prototype.interfaces_=function(){return[Nr]},ks.prototype.getClass=function(){return ks};var _e=function(){this._nodeList=new tn(this),this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};_e.prototype.getCoordinates=function(){return this._pts},_e.prototype.size=function(){return this._pts.length},_e.prototype.getCoordinate=function(t){return this._pts[t]},_e.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},_e.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))},_e.prototype.setData=function(t){this._data=t},_e.prototype.safeOctant=function(t,e){return t.equals2D(e)?0:$i.octant(t,e)},_e.prototype.getData=function(){return this._data},_e.prototype.addIntersection=function(){if(arguments.length===2){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(arguments.length===4){var n=arguments[0],r=arguments[1],i=arguments[3],o=new L(n.getIntersection(i));this.addIntersection(o,r)}},_e.prototype.toString=function(){return Xn.toLineString(new ve(this._pts))},_e.prototype.getNodeList=function(){return this._nodeList},_e.prototype.addIntersectionNode=function(t,e){var n=e,r=n+1;if(r=0&&n>=0||e<=0&&n<=0?Math.max(e,n):0}if(arguments[0]instanceof L){var r=arguments[0];return X.orientationIndex(this.p0,this.p1,r)}},Z.prototype.toGeometry=function(t){return t.createLineString([this.p0,this.p1])},Z.prototype.isVertical=function(){return this.p0.x===this.p1.x},Z.prototype.equals=function(t){if(!(t instanceof Z))return!1;var e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1)},Z.prototype.intersection=function(t){var e=new wi;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null},Z.prototype.project=function(){if(arguments[0]instanceof L){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new L(t);var e=this.projectionFactor(t),n=new L;return n.x=this.p0.x+e*(this.p1.x-this.p0.x),n.y=this.p0.y+e*(this.p1.y-this.p0.y),n}if(arguments[0]instanceof Z){var r=arguments[0],i=this.projectionFactor(r.p0),o=this.projectionFactor(r.p1);if(i>=1&&o>=1||i<=0&&o<=0)return null;var s=this.project(r.p0);i<0&&(s=this.p0),i>1&&(s=this.p1);var a=this.project(r.p1);return o<0&&(a=this.p0),o>1&&(a=this.p1),new Z(s,a)}},Z.prototype.normalize=function(){this.p1.compareTo(this.p0)<0&&this.reverse()},Z.prototype.angle=function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)},Z.prototype.getCoordinate=function(t){return t===0?this.p0:this.p1},Z.prototype.distancePerpendicular=function(t){return X.distancePointLinePerpendicular(t,this.p0,this.p1)},Z.prototype.minY=function(){return Math.min(this.p0.y,this.p1.y)},Z.prototype.midPoint=function(){return Z.midPoint(this.p0,this.p1)},Z.prototype.projectionFactor=function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,r=e*e+n*n;return r<=0?st.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/r},Z.prototype.closestPoints=function(t){var e=this.intersection(t);if(e!==null)return[e,e];var n=new Array(2).fill(null),r=st.MAX_VALUE,i=null,o=this.closestPoint(t.p0);r=o.distance(t.p0),n[0]=o,n[1]=t.p0;var s=this.closestPoint(t.p1);(i=s.distance(t.p1))0&&e<1?this.project(t):this.p0.distance(t)1||st.isNaN(e))&&(e=1),e},Z.prototype.toString=function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"},Z.prototype.isHorizontal=function(){return this.p0.y===this.p1.y},Z.prototype.distance=function(){if(arguments[0]instanceof Z){var t=arguments[0];return X.distanceLineLine(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof L){var e=arguments[0];return X.distancePointLine(e,this.p0,this.p1)}},Z.prototype.pointAlong=function(t){var e=new L;return e.x=this.p0.x+t*(this.p1.x-this.p0.x),e.y=this.p0.y+t*(this.p1.y-this.p0.y),e},Z.prototype.hashCode=function(){var t=st.doubleToLongBits(this.p0.x);t^=31*st.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=st.doubleToLongBits(this.p1.x);return n^=31*st.doubleToLongBits(this.p1.y),e^(Math.trunc(n)^Math.trunc(n>>32))},Z.prototype.interfaces_=function(){return[Tn,An]},Z.prototype.getClass=function(){return Z},Z.midPoint=function(t,e){return new L((t.x+e.x)/2,(t.y+e.y)/2)},gf.serialVersionUID.get=function(){return 0x2d2172135f411c00},Object.defineProperties(Z,gf);var Gs=function(){this.tempEnv1=new J,this.tempEnv2=new J,this._overlapSeg1=new Z,this._overlapSeg2=new Z};Gs.prototype.overlap=function(){if(arguments.length!==2){if(arguments.length===4){var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];t.getLineSegment(e,this._overlapSeg1),n.getLineSegment(r,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}},Gs.prototype.interfaces_=function(){return[]},Gs.prototype.getClass=function(){return Gs};var xn=function(){this._pts=null,this._start=null,this._end=null,this._env=null,this._context=null,this._id=null;var t=arguments[0],e=arguments[1],n=arguments[2],r=arguments[3];this._pts=t,this._start=e,this._end=n,this._context=r};xn.prototype.getLineSegment=function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]},xn.prototype.computeSelect=function(t,e,n,r){var i=this._pts[e],o=this._pts[n];if(r.tempEnv1.init(i,o),n-e==1)return r.select(this,e),null;if(!t.intersects(r.tempEnv1))return null;var s=Math.trunc((e+n)/2);e=t.length-1)return t.length-1;for(var r=te.quadrant(t[n],t[n+1]),i=e+1;is.getId()&&(s.computeOverlaps(u,i),r._nOverlaps++),r._segInt.isDone())return null}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.SegmentOverlapAction.get=function(){return df},Object.defineProperties(e,n),e}(qs),df=function(t){function e(){t.call(this),this._si=null;var n=arguments[0];this._si=n}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.overlap=function(){if(arguments.length!==4)return t.prototype.overlap.apply(this,arguments);var n=arguments[0],r=arguments[1],i=arguments[2],o=arguments[3],s=n.getContext(),a=i.getContext();this._si.processIntersections(s,r,a,o)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Gs),Yt=function t(){if(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=t.CAP_ROUND,this._joinStyle=t.JOIN_ROUND,this._mitreLimit=t.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=t.DEFAULT_SIMPLIFY_FACTOR,arguments.length!==0){if(arguments.length===1){var e=arguments[0];this.setQuadrantSegments(e)}else if(arguments.length===2){var n=arguments[0],r=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(r)}else if(arguments.length===4){var i=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this.setQuadrantSegments(i),this.setEndCapStyle(o),this.setJoinStyle(s),this.setMitreLimit(a)}}},Jr={CAP_ROUND:{configurable:!0},CAP_FLAT:{configurable:!0},CAP_SQUARE:{configurable:!0},JOIN_ROUND:{configurable:!0},JOIN_MITRE:{configurable:!0},JOIN_BEVEL:{configurable:!0},DEFAULT_QUADRANT_SEGMENTS:{configurable:!0},DEFAULT_MITRE_LIMIT:{configurable:!0},DEFAULT_SIMPLIFY_FACTOR:{configurable:!0}};Yt.prototype.getEndCapStyle=function(){return this._endCapStyle},Yt.prototype.isSingleSided=function(){return this._isSingleSided},Yt.prototype.setQuadrantSegments=function(t){this._quadrantSegments=t,this._quadrantSegments===0&&(this._joinStyle=Yt.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=Yt.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==Yt.JOIN_ROUND&&(this._quadrantSegments=Yt.DEFAULT_QUADRANT_SEGMENTS)},Yt.prototype.getJoinStyle=function(){return this._joinStyle},Yt.prototype.setJoinStyle=function(t){this._joinStyle=t},Yt.prototype.setSimplifyFactor=function(t){this._simplifyFactor=t<0?0:t},Yt.prototype.getSimplifyFactor=function(){return this._simplifyFactor},Yt.prototype.getQuadrantSegments=function(){return this._quadrantSegments},Yt.prototype.setEndCapStyle=function(t){this._endCapStyle=t},Yt.prototype.getMitreLimit=function(){return this._mitreLimit},Yt.prototype.setMitreLimit=function(t){this._mitreLimit=t},Yt.prototype.setSingleSided=function(t){this._isSingleSided=t},Yt.prototype.interfaces_=function(){return[]},Yt.prototype.getClass=function(){return Yt},Yt.bufferDistanceError=function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)},Jr.CAP_ROUND.get=function(){return 1},Jr.CAP_FLAT.get=function(){return 2},Jr.CAP_SQUARE.get=function(){return 3},Jr.JOIN_ROUND.get=function(){return 1},Jr.JOIN_MITRE.get=function(){return 2},Jr.JOIN_BEVEL.get=function(){return 3},Jr.DEFAULT_QUADRANT_SEGMENTS.get=function(){return 8},Jr.DEFAULT_MITRE_LIMIT.get=function(){return 5},Jr.DEFAULT_SIMPLIFY_FACTOR.get=function(){return .01},Object.defineProperties(Yt,Jr);var de=function(t){this._distanceTol=null,this._isDeleted=null,this._angleOrientation=X.COUNTERCLOCKWISE,this._inputLine=t||null},Bs={INIT:{configurable:!0},DELETE:{configurable:!0},KEEP:{configurable:!0},NUM_PTS_TO_CHECK:{configurable:!0}};de.prototype.isDeletable=function(t,e,n,r){var i=this._inputLine[t],o=this._inputLine[e],s=this._inputLine[n];return!!this.isConcave(i,o,s)&&!!this.isShallow(i,o,s,r)&&this.isShallowSampled(i,o,t,n,r)},de.prototype.deleteShallowConcavities=function(){for(var t=this,e=1,n=this.findNextNonDeletedIndex(e),r=this.findNextNonDeletedIndex(n),i=!1;r=0;r--)this.addPt(t[r])},Nn.prototype.isRedundant=function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)Math.PI;)t-=dt.PI_TIMES_2;for(;t<=-Math.PI;)t+=dt.PI_TIMES_2;return t},dt.angle=function(){if(arguments.length===1){var t=arguments[0];return Math.atan2(t.y,t.x)}if(arguments.length===2){var e=arguments[0],n=arguments[1],r=n.x-e.x,i=n.y-e.y;return Math.atan2(i,r)}},dt.isAcute=function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)>0},dt.isObtuse=function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)<0},dt.interiorAngle=function(t,e,n){var r=dt.angle(e,t),i=dt.angle(e,n);return Math.abs(i-r)},dt.normalizePositive=function(t){if(t<0){for(;t<0;)t+=dt.PI_TIMES_2;t>=dt.PI_TIMES_2&&(t=0)}else{for(;t>=dt.PI_TIMES_2;)t-=dt.PI_TIMES_2;t<0&&(t=0)}return t},dt.angleBetween=function(t,e,n){var r=dt.angle(e,t),i=dt.angle(e,n);return dt.diff(r,i)},dt.diff=function(t,e){var n=null;return(n=tMath.PI&&(n=2*Math.PI-n),n},dt.toRadians=function(t){return t*Math.PI/180},dt.getTurn=function(t,e){var n=Math.sin(e-t);return n>0?dt.COUNTERCLOCKWISE:n<0?dt.CLOCKWISE:dt.NONE},dt.angleBetweenOriented=function(t,e,n){var r=dt.angle(e,t),i=dt.angle(e,n)-r;return i<=-Math.PI?i+dt.PI_TIMES_2:i>Math.PI?i-dt.PI_TIMES_2:i},to.PI_TIMES_2.get=function(){return 2*Math.PI},to.PI_OVER_2.get=function(){return Math.PI/2},to.PI_OVER_4.get=function(){return Math.PI/4},to.COUNTERCLOCKWISE.get=function(){return X.COUNTERCLOCKWISE},to.CLOCKWISE.get=function(){return X.CLOCKWISE},to.NONE.get=function(){return X.COLLINEAR},Object.defineProperties(dt,to);var ue=function t(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new Z,this._seg1=new Z,this._offset0=new Z,this._offset1=new Z,this._side=0,this._hasNarrowConcaveAngle=!1;var e=arguments[0],n=arguments[1],r=arguments[2];this._precisionModel=e,this._bufParams=n,this._li=new wi,this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===Yt.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(r)},zs={OFFSET_SEGMENT_SEPARATION_FACTOR:{configurable:!0},INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},CURVE_VERTEX_SNAP_DISTANCE_FACTOR:{configurable:!0},MAX_CLOSING_SEG_LEN_FACTOR:{configurable:!0}};ue.prototype.addNextSegment=function(t,e){if(this._s0=this._s1,this._s1=this._s2,this._s2=t,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var n=X.computeOrientation(this._s0,this._s1,this._s2),r=n===X.CLOCKWISE&&this._side===z.LEFT||n===X.COUNTERCLOCKWISE&&this._side===z.RIGHT;n===0?this.addCollinear(e):r?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)},ue.prototype.addLineEndCap=function(t,e){var n=new Z(t,e),r=new Z;this.computeOffsetSegment(n,z.LEFT,this._distance,r);var i=new Z;this.computeOffsetSegment(n,z.RIGHT,this._distance,i);var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o);switch(this._bufParams.getEndCapStyle()){case Yt.CAP_ROUND:this._segList.addPt(r.p1),this.addFilletArc(e,a+Math.PI/2,a-Math.PI/2,X.CLOCKWISE,this._distance),this._segList.addPt(i.p1);break;case Yt.CAP_FLAT:this._segList.addPt(r.p1),this._segList.addPt(i.p1);break;case Yt.CAP_SQUARE:var u=new L;u.x=Math.abs(this._distance)*Math.cos(a),u.y=Math.abs(this._distance)*Math.sin(a);var l=new L(r.p1.x+u.x,r.p1.y+u.y),h=new L(i.p1.x+u.x,i.p1.y+u.y);this._segList.addPt(l),this._segList.addPt(h)}},ue.prototype.getCoordinates=function(){return this._segList.getCoordinates()},ue.prototype.addMitreJoin=function(t,e,n,r){var i=!0,o=null;try{o=Vn.intersection(e.p0,e.p1,n.p0,n.p1),(r<=0?1:o.distance(t)/Math.abs(r))>this._bufParams.getMitreLimit()&&(i=!1)}catch(s){if(!(s instanceof No))throw s;o=new L(0,0),i=!1}i?this._segList.addPt(o):this.addLimitedMitreJoin(e,n,r,this._bufParams.getMitreLimit())},ue.prototype.addFilletCorner=function(t,e,n,r,i){var o=e.x-t.x,s=e.y-t.y,a=Math.atan2(s,o),u=n.x-t.x,l=n.y-t.y,h=Math.atan2(l,u);r===X.CLOCKWISE?a<=h&&(a+=2*Math.PI):a>=h&&(a-=2*Math.PI),this._segList.addPt(e),this.addFilletArc(t,a,h,r,i),this._segList.addPt(n)},ue.prototype.addOutsideTurn=function(t,e){if(this._offset0.p1.distance(this._offset1.p0)0){var n=new L((this._closingSegLengthFactor*this._offset0.p1.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset0.p1.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(n);var r=new L((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(r)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}},ue.prototype.createCircle=function(t){var e=new L(t.x+this._distance,t.y);this._segList.addPt(e),this.addFilletArc(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()},ue.prototype.addBevelJoin=function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)},ue.prototype.init=function(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Nn,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*ue.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},ue.prototype.addCollinear=function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===Yt.JOIN_BEVEL||this._bufParams.getJoinStyle()===Yt.JOIN_MITRE?(t&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addFilletCorner(this._s1,this._offset0.p1,this._offset1.p0,X.CLOCKWISE,this._distance))},ue.prototype.closeRing=function(){this._segList.closeRing()},ue.prototype.hasNarrowConcaveAngle=function(){return this._hasNarrowConcaveAngle},ue.prototype.interfaces_=function(){return[]},ue.prototype.getClass=function(){return ue},zs.OFFSET_SEGMENT_SEPARATION_FACTOR.get=function(){return .001},zs.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return .001},zs.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return 1e-6},zs.MAX_CLOSING_SEG_LEN_FACTOR.get=function(){return 80},Object.defineProperties(ue,zs);var fn=function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e};fn.prototype.getOffsetCurve=function(t,e){if(this._distance=e,e===0)return null;var n=e<0,r=Math.abs(e),i=this.getSegGen(r);t.length<=1?this.computePointCurve(t[0],i):this.computeOffsetCurve(t,n,i);var o=i.getCoordinates();return n&&ht.reverse(o),o},fn.prototype.computeSingleSidedBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var i=de.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],z.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(i[s],!0)}else{n.addSegments(t,!1);var a=de.simplify(t,r),u=a.length-1;n.initSideSegments(a[0],a[1],z.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(a[l],!0)}n.addLastSegment(),n.closeRing()},fn.prototype.computeRingBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);e===z.RIGHT&&(r=-r);var i=de.simplify(t,r),o=i.length-1;n.initSideSegments(i[o-1],i[0],e);for(var s=1;s<=o;s++){var a=s!==1;n.addNextSegment(i[s],a)}n.closeRing()},fn.prototype.computeLineBufferCurve=function(t,e){var n=this.simplifyTolerance(this._distance),r=de.simplify(t,n),i=r.length-1;e.initSideSegments(r[0],r[1],z.LEFT);for(var o=2;o<=i;o++)e.addNextSegment(r[o],!0);e.addLastSegment(),e.addLineEndCap(r[i-1],r[i]);var s=de.simplify(t,-n),a=s.length-1;e.initSideSegments(s[a],s[a-1],z.LEFT);for(var u=a-2;u>=0;u--)e.addNextSegment(s[u],!0);e.addLastSegment(),e.addLineEndCap(s[1],s[0]),e.closeRing()},fn.prototype.computePointCurve=function(t,e){switch(this._bufParams.getEndCapStyle()){case Yt.CAP_ROUND:e.createCircle(t);break;case Yt.CAP_SQUARE:e.createSquare(t)}},fn.prototype.getLineCurve=function(t,e){if(this._distance=e,e<0&&!this._bufParams.isSingleSided()||e===0)return null;var n=Math.abs(e),r=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],r);else if(this._bufParams.isSingleSided()){var i=e<0;this.computeSingleSidedBufferCurve(t,i,r)}else this.computeLineBufferCurve(t,r);return r.getCoordinates()},fn.prototype.getBufferParameters=function(){return this._bufParams},fn.prototype.simplifyTolerance=function(t){return t*this._bufParams.getSimplifyFactor()},fn.prototype.getRingCurve=function(t,e,n){if(this._distance=n,t.length<=2)return this.getLineCurve(t,n);if(n===0)return fn.copyCoordinates(t);var r=this.getSegGen(n);return this.computeRingBufferCurve(t,e,r),r.getCoordinates()},fn.prototype.computeOffsetCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){var i=de.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],z.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(i[s],!0)}else{var a=de.simplify(t,r),u=a.length-1;n.initSideSegments(a[0],a[1],z.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(a[l],!0)}n.addLastSegment()},fn.prototype.getSegGen=function(t){return new ue(this._precisionModel,this._bufParams,t)},fn.prototype.interfaces_=function(){return[]},fn.prototype.getClass=function(){return fn},fn.copyCoordinates=function(t){for(var e=new Array(t.length).fill(null),n=0;no.getMaxY()||t.findStabbedSegments(e,i.getDirectedEdges(),n)}return n}if(arguments.length===3){if(et(arguments[2],Yn)&&arguments[0]instanceof L&&arguments[1]instanceof Ol)for(var s=arguments[0],a=arguments[1],u=arguments[2],l=a.getEdge().getCoordinates(),h=0;ht._seg.p1.y&&t._seg.reverse();var c=Math.max(t._seg.p0.x,t._seg.p1.x);if(!(ct._seg.p1.y||X.computeOrientation(t._seg.p0,t._seg.p1,s)===X.RIGHT)){var p=a.getDepth(z.LEFT);t._seg.p0.equals(l[h])||(p=a.getDepth(z.RIGHT));var d=new Ni(t._seg,p);u.add(d)}}else if(et(arguments[2],Yn)&&arguments[0]instanceof L&&et(arguments[1],Yn))for(var g=arguments[0],m=arguments[1],f=arguments[2],_=m.iterator();_.hasNext();){var I=_.next();I.isForward()&&t.findStabbedSegments(g,I,f)}}},eo.prototype.getDepth=function(t){var e=this.findStabbedSegments(t);return e.size()===0?0:Zn.min(e)._leftDepth},eo.prototype.interfaces_=function(){return[]},eo.prototype.getClass=function(){return eo},mf.DepthSegment.get=function(){return Ni},Object.defineProperties(eo,mf);var Ni=function(){this._upwardSeg=null,this._leftDepth=null;var t=arguments[0],e=arguments[1];this._upwardSeg=new Z(t),this._leftDepth=e};Ni.prototype.compareTo=function(t){var e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;var n=this._upwardSeg.orientationIndex(e._upwardSeg);return n!==0||(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))!==0?n:this._upwardSeg.compareTo(e._upwardSeg)},Ni.prototype.compareX=function(t,e){var n=t.p0.compareTo(e.p0);return n!==0?n:t.p1.compareTo(e.p1)},Ni.prototype.toString=function(){return this._upwardSeg.toString()},Ni.prototype.interfaces_=function(){return[Tn]},Ni.prototype.getClass=function(){return Ni};var Ht=function(t,e,n){this.p0=t||null,this.p1=e||null,this.p2=n||null};Ht.prototype.area=function(){return Ht.area(this.p0,this.p1,this.p2)},Ht.prototype.signedArea=function(){return Ht.signedArea(this.p0,this.p1,this.p2)},Ht.prototype.interpolateZ=function(t){if(t===null)throw new he("Supplied point is null.");return Ht.interpolateZ(t,this.p0,this.p1,this.p2)},Ht.prototype.longestSideLength=function(){return Ht.longestSideLength(this.p0,this.p1,this.p2)},Ht.prototype.isAcute=function(){return Ht.isAcute(this.p0,this.p1,this.p2)},Ht.prototype.circumcentre=function(){return Ht.circumcentre(this.p0,this.p1,this.p2)},Ht.prototype.area3D=function(){return Ht.area3D(this.p0,this.p1,this.p2)},Ht.prototype.centroid=function(){return Ht.centroid(this.p0,this.p1,this.p2)},Ht.prototype.inCentre=function(){return Ht.inCentre(this.p0,this.p1,this.p2)},Ht.prototype.interfaces_=function(){return[]},Ht.prototype.getClass=function(){return Ht},Ht.area=function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)},Ht.signedArea=function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2},Ht.det=function(t,e,n,r){return t*r-e*n},Ht.interpolateZ=function(t,e,n,r){var i=e.x,o=e.y,s=n.x-i,a=r.x-i,u=n.y-o,l=r.y-o,h=s*l-a*u,c=t.x-i,p=t.y-o,d=(l*c-a*p)/h,g=(-u*c+s*p)/h;return e.z+d*(n.z-e.z)+g*(r.z-e.z)},Ht.longestSideLength=function(t,e,n){var r=t.distance(e),i=e.distance(n),o=n.distance(t),s=r;return i>s&&(s=i),o>s&&(s=o),s},Ht.isAcute=function(t,e,n){return!!dt.isAcute(t,e,n)&&!!dt.isAcute(e,n,t)&&!!dt.isAcute(n,t,e)},Ht.circumcentre=function(t,e,n){var r=n.x,i=n.y,o=t.x-r,s=t.y-i,a=e.x-r,u=e.y-i,l=2*Ht.det(o,s,a,u),h=Ht.det(s,o*o+s*s,u,a*a+u*u),c=Ht.det(o,o*o+s*s,a,a*a+u*u);return new L(r-h/l,i+c/l)},Ht.perpendicularBisector=function(t,e){var n=e.x-t.x,r=e.y-t.y,i=new Vn(t.x+n/2,t.y+r/2,1),o=new Vn(t.x-r+n/2,t.y+n+r/2,1);return new Vn(i,o)},Ht.angleBisector=function(t,e,n){var r=e.distance(t),i=r/(r+e.distance(n)),o=n.x-t.x,s=n.y-t.y;return new L(t.x+i*o,t.y+i*s)},Ht.area3D=function(t,e,n){var r=e.x-t.x,i=e.y-t.y,o=e.z-t.z,s=n.x-t.x,a=n.y-t.y,u=n.z-t.z,l=i*u-o*a,h=o*s-r*u,c=r*a-i*s,p=l*l+h*h+c*c,d=Math.sqrt(p)/2;return d},Ht.centroid=function(t,e,n){var r=(t.x+e.x+n.x)/3,i=(t.y+e.y+n.y)/3;return new L(r,i)},Ht.inCentre=function(t,e,n){var r=e.distance(n),i=t.distance(n),o=t.distance(e),s=r+i+o,a=(r*t.x+i*e.x+o*n.x)/s,u=(r*t.y+i*e.y+o*n.y)/s;return new L(a,u)};var qn=function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new U;var t=arguments[0],e=arguments[1],n=arguments[2];this._inputGeom=t,this._distance=e,this._curveBuilder=n};qn.prototype.addPoint=function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,A.EXTERIOR,A.INTERIOR)},qn.prototype.addPolygon=function(t){var e=this,n=this._distance,r=z.LEFT;this._distance<0&&(n=-this._distance,r=z.RIGHT);var i=t.getExteriorRing(),o=ht.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance)||this._distance<=0&&o.length<3)return null;this.addPolygonRing(o,n,r,A.EXTERIOR,A.INTERIOR);for(var s=0;s0&&e.isErodedCompletely(a,-e._distance)||e.addPolygonRing(u,n,z.opposite(r),A.INTERIOR,A.EXTERIOR)}},qn.prototype.isTriangleErodedCompletely=function(t,e){var n=new Ht(t[0],t[1],t[2]),r=n.inCentre();return X.distancePointLine(r,n.p0,n.p1)=Ir.MINIMUM_VALID_SIZE&&X.isCCW(t)&&(o=i,s=r,n=z.opposite(n));var a=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(a,o,s)},qn.prototype.add=function(t){if(t.isEmpty())return null;t instanceof Pe?this.addPolygon(t):t instanceof ge?this.addLineString(t):t instanceof vn?this.addPoint(t):(t instanceof Fo||t instanceof Si||t instanceof Sr||t instanceof Qe)&&this.addCollection(t)},qn.prototype.isErodedCompletely=function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(n.length===4)return this.isTriangleErodedCompletely(n,e);var r=t.getEnvelopeInternal(),i=Math.min(r.getHeight(),r.getWidth());return e<0&&2*Math.abs(e)>i},qn.prototype.addCollection=function(t){for(var e=0;e=this._max)throw new Ao;var t=this._parent.getGeometryN(this._index++);return t instanceof Qe?(this._subcollectionIterator=new Pr(t),this._subcollectionIterator.next()):t},Pr.prototype.remove=function(){throw new Error(this.getClass().getName())},Pr.prototype.hasNext=function(){if(this._atStart)return!0;if(this._subcollectionIterator!==null){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)},Pr.prototype.interfaces_=function(){return[To]},Pr.prototype.getClass=function(){return Pr},Pr.isAtomic=function(t){return!(t instanceof Qe)};var Pn=function(){this._geom=null;var t=arguments[0];this._geom=t};Pn.prototype.locate=function(t){return Pn.locate(t,this._geom)},Pn.prototype.interfaces_=function(){return[Bo]},Pn.prototype.getClass=function(){return Pn},Pn.isPointInRing=function(t,e){return!!e.getEnvelopeInternal().intersects(t)&&X.isPointInRing(t,e.getCoordinates())},Pn.containsPointInPolygon=function(t,e){if(e.isEmpty())return!1;var n=e.getExteriorRing();if(!Pn.isPointInRing(t,n))return!1;for(var r=0;r=0;i--){var o=this._edgeList.get(i),s=o.getSym();r===null&&(r=s),n!==null&&s.setNext(n),n=o}r.setNext(n)},e.prototype.computeDepths=function(){var n=this;if(arguments.length===1){var r=arguments[0],i=this.findIndex(r),o=r.getDepth(z.LEFT),s=r.getDepth(z.RIGHT),a=this.computeDepths(i+1,this._edgeList.size(),o),u=this.computeDepths(0,i,a);if(u!==s)throw new Hr("depth mismatch at "+r.getCoordinate())}else if(arguments.length===3){for(var l=arguments[0],h=arguments[1],c=arguments[2],p=c,d=l;d=0;a--){var u=r._resultAreaEdgeList.get(a),l=u.getSym();switch(i===null&&u.getEdgeRing()===n&&(i=u),s){case r._SCANNING_FOR_INCOMING:if(l.getEdgeRing()!==n)continue;o=l,s=r._LINKING_TO_OUTGOING;break;case r._LINKING_TO_OUTGOING:if(u.getEdgeRing()!==n)continue;o.setNextMin(u),s=r._SCANNING_FOR_INCOMING}}s===this._LINKING_TO_OUTGOING&&(lt.isTrue(i!==null,"found null for first outgoing dirEdge"),lt.isTrue(i.getEdgeRing()===n,"unable to link last incoming dirEdge"),o.setNextMin(i))},e.prototype.getOutgoingDegree=function(){if(arguments.length===0){for(var n=0,r=this.iterator();r.hasNext();){var i=r.next();i.isInResult()&&n++}return n}if(arguments.length===1){for(var o=arguments[0],s=0,a=this.iterator();a.hasNext();){var u=a.next();u.getEdgeRing()===o&&s++}return s}},e.prototype.getLabel=function(){return this._label},e.prototype.findCoveredLineEdges=function(){for(var n=A.NONE,r=this.iterator();r.hasNext();){var i=r.next(),o=i.getSym();if(!i.isLineEdge()){if(i.isInResult()){n=A.INTERIOR;break}if(o.isInResult()){n=A.EXTERIOR;break}}}if(n===A.NONE)return null;for(var s=n,a=this.iterator();a.hasNext();){var u=a.next(),l=u.getSym();u.isLineEdge()?u.getEdge().setCovered(s===A.INTERIOR):(u.isInResult()&&(s=A.EXTERIOR),l.isInResult()&&(s=A.INTERIOR))}},e.prototype.computeLabelling=function(n){t.prototype.computeLabelling.call(this,n),this._label=new Kt(A.NONE);for(var r=this.iterator();r.hasNext();)for(var i=r.next().getEdge().getLabel(),o=0;o<2;o++){var s=i.getLocation(o);s!==A.INTERIOR&&s!==A.BOUNDARY||this._label.setLocation(o,A.INTERIOR)}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Je),vf=function(t){function e(){t.apply(this,arguments)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.createNode=function(n){return new za(n,new ty)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(ko),ui=function t(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e)};ui.prototype.compareTo=function(t){var e=t;return ui.compareOriented(this._pts,this._orientation,e._pts,e._orientation)},ui.prototype.interfaces_=function(){return[Tn]},ui.prototype.getClass=function(){return ui},ui.orientation=function(t){return ht.increasingDirection(t)===1},ui.compareOriented=function(t,e,n,r){for(var i=e?1:-1,o=r?1:-1,s=e?t.length:-1,a=r?n.length:-1,u=e?0:t.length-1,l=r?0:n.length-1;;){var h=t[u].compareTo(n[l]);if(h!==0)return h;var c=(u+=i)===s,p=(l+=o)===a;if(c&&!p)return-1;if(!c&&p)return 1;if(c&&p)return 0}};var Kn=function(){this._edges=new U,this._ocaMap=new He};Kn.prototype.print=function(t){t.print("MULTILINESTRING ( ");for(var e=0;e0&&t.print(","),t.print("(");for(var r=n.getCoordinates(),i=0;i0&&t.print(","),t.print(r[i].x+" "+r[i].y);t.println(")")}t.print(") ")},Kn.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())},Kn.prototype.findEdgeIndex=function(t){for(var e=0;e0||!e.coord.equals2D(r);i||n--;var o=new Array(n).fill(null),s=0;o[s++]=new L(t.coord);for(var a=t.segmentIndex+1;a<=e.segmentIndex;a++)o[s++]=this.edge.pts[a];return i&&(o[s]=e.coord),new Ua(o,new Kt(this.edge._label))},Mr.prototype.add=function(t,e,n){var r=new gr(t,e,n),i=this._nodeMap.get(r);return i!==null?i:(this._nodeMap.put(r,r),r)},Mr.prototype.isIntersection=function(t){for(var e=this.iterator();e.hasNext();)if(e.next().coord.equals(t))return!0;return!1},Mr.prototype.interfaces_=function(){return[]},Mr.prototype.getClass=function(){return Mr};var Mi=function(){};Mi.prototype.getChainStartIndices=function(t){var e=0,n=new U;n.add(new rr(e));do{var r=this.findChainEnd(t,e);n.add(new rr(r)),e=r}while(en?e:n},Zr.prototype.getMinX=function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return en&&(i=1),t._depth[e][r]=i}}},Be.prototype.getDelta=function(t){return this._depth[t][z.RIGHT]-this._depth[t][z.LEFT]},Be.prototype.getLocation=function(t,e){return this._depth[t][e]<=0?A.EXTERIOR:A.INTERIOR},Be.prototype.toString=function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]},Be.prototype.add=function(){var t=this;if(arguments.length===1)for(var e=arguments[0],n=0;n<2;n++)for(var r=1;r<3;r++){var i=e.getLocation(n,r);i!==A.EXTERIOR&&i!==A.INTERIOR||(t.isNull(n,r)?t._depth[n][r]=Be.depthAtLocation(i):t._depth[n][r]+=Be.depthAtLocation(i))}else if(arguments.length===3){var o=arguments[0],s=arguments[1],a=arguments[2];a===A.INTERIOR&&this._depth[o][s]++}},Be.prototype.interfaces_=function(){return[]},Be.prototype.getClass=function(){return Be},Be.depthAtLocation=function(t){return t===A.EXTERIOR?0:t===A.INTERIOR?1:Be.NULL_VALUE},_f.NULL_VALUE.get=function(){return-1},Object.defineProperties(Be,_f);var Ua=function(t){function e(){if(t.call(this),this.pts=null,this._env=null,this.eiList=new Mr(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new Be,this._depthDelta=0,arguments.length===1){var n=arguments[0];e.call(this,n,null)}else if(arguments.length===2){var r=arguments[0],i=arguments[1];this.pts=r,this._label=i}}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.getDepth=function(){return this._depth},e.prototype.getCollapsedEdge=function(){var n=new Array(2).fill(null);return n[0]=this.pts[0],n[1]=this.pts[1],new e(n,Kt.toLineLabel(this._label))},e.prototype.isIsolated=function(){return this._isIsolated},e.prototype.getCoordinates=function(){return this.pts},e.prototype.setIsolated=function(n){this._isIsolated=n},e.prototype.setName=function(n){this._name=n},e.prototype.equals=function(n){if(!(n instanceof e))return!1;var r=n;if(this.pts.length!==r.pts.length)return!1;for(var i=!0,o=!0,s=this.pts.length,a=0;a0?this.pts[0]:null;if(arguments.length===1){var n=arguments[0];return this.pts[n]}},e.prototype.print=function(n){n.print("edge "+this._name+": "),n.print("LINESTRING (");for(var r=0;r0&&n.print(","),n.print(this.pts[r].x+" "+this.pts[r].y);n.print(") "+this._label+" "+this._depthDelta)},e.prototype.computeIM=function(n){e.updateIM(this._label,n)},e.prototype.isCollapsed=function(){return!!this._label.isArea()&&this.pts.length===3&&!!this.pts[0].equals(this.pts[2])},e.prototype.isClosed=function(){return this.pts[0].equals(this.pts[this.pts.length-1])},e.prototype.getMaximumSegmentIndex=function(){return this.pts.length-1},e.prototype.getDepthDelta=function(){return this._depthDelta},e.prototype.getNumPoints=function(){return this.pts.length},e.prototype.printReverse=function(n){n.print("edge "+this._name+": ");for(var r=this.pts.length-1;r>=0;r--)n.print(this.pts[r]+" ");n.println("")},e.prototype.getMonotoneChainEdge=function(){return this._mce===null&&(this._mce=new Zr(this)),this._mce},e.prototype.getEnvelope=function(){if(this._env===null){this._env=new J;for(var n=0;n0&&n.append(","),n.append(this.pts[r].x+" "+this.pts[r].y);return n.append(") "+this._label+" "+this._depthDelta),n.toString()},e.prototype.isPointwiseEqual=function(n){if(this.pts.length!==n.pts.length)return!1;for(var r=0;rr||this._maxyo;if(s)return!1;var a=this.intersectsToleranceSquare(t,e);return lt.isTrue(!(s&&a),"Found bad envelope test"),a},gn.prototype.initCorners=function(t){var e=.5;this._minx=t.x-e,this._maxx=t.x+e,this._miny=t.y-e,this._maxy=t.y+e,this._corner[0]=new L(this._maxx,this._maxy),this._corner[1]=new L(this._minx,this._maxy),this._corner[2]=new L(this._minx,this._miny),this._corner[3]=new L(this._maxx,this._miny)},gn.prototype.intersects=function(t,e){return this._scaleFactor===1?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))},gn.prototype.scale=function(t){return Math.round(t*this._scaleFactor)},gn.prototype.getCoordinate=function(){return this._originalPt},gn.prototype.copyScaled=function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)},gn.prototype.getSafeEnvelope=function(){if(this._safeEnv===null){var t=gn.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new J(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}return this._safeEnv},gn.prototype.intersectsPixelClosure=function(t,e){return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),!!this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),!!this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),!!this._li.hasIntersection())))},gn.prototype.intersectsToleranceSquare=function(t,e){var n=!1,r=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),!!this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(r=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),!!this._li.isProper()||!(!n||!r)||!!t.equals(this._pt)||!!e.equals(this._pt))))},gn.prototype.addSnappedNode=function(t,e){var n=t.getCoordinate(e),r=t.getCoordinate(e+1);return!!this.intersects(n,r)&&(t.addIntersection(this.getCoordinate(),e),!0)},gn.prototype.interfaces_=function(){return[]},gn.prototype.getClass=function(){return gn},Ef.SAFE_ENV_EXPANSION_FACTOR.get=function(){return .75},Object.defineProperties(gn,Ef);var js=function(){this.tempEnv1=new J,this.selectedSegment=new Z};js.prototype.select=function(){if(arguments.length!==1){if(arguments.length===2){var t=arguments[0],e=arguments[1];t.getLineSegment(e,this.selectedSegment),this.select(this.selectedSegment)}}},js.prototype.interfaces_=function(){return[]},js.prototype.getClass=function(){return js};var zo=function(){this._index=null;var t=arguments[0];this._index=t},bf={HotPixelSnapAction:{configurable:!0}};zo.prototype.snap=function(){if(arguments.length===1){var t=arguments[0];return this.snap(t,null,-1)}if(arguments.length===3){var e=arguments[0],n=arguments[1],r=arguments[2],i=e.getSafeEnvelope(),o=new wf(e,n,r);return this._index.query(i,{interfaces_:function(){return[si]},visitItem:function(s){s.select(i,o)}}),o.isNodeAdded()}},zo.prototype.interfaces_=function(){return[]},zo.prototype.getClass=function(){return zo},bf.HotPixelSnapAction.get=function(){return wf},Object.defineProperties(zo,bf);var wf=function(t){function e(){t.call(this),this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var n=arguments[0],r=arguments[1],i=arguments[2];this._hotPixel=n,this._parentEdge=r,this._hotPixelVertexIndex=i}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isNodeAdded=function(){return this._isNodeAdded},e.prototype.select=function(){if(arguments.length!==2)return t.prototype.select.apply(this,arguments);var n=arguments[0],r=arguments[1],i=n.getContext();if(this._parentEdge!==null&&i===this._parentEdge&&r===this._hotPixelVertexIndex)return null;this._isNodeAdded=this._hotPixel.addSnappedNode(i,r)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(js),no=function(){this._li=null,this._interiorIntersections=null;var t=arguments[0];this._li=t,this._interiorIntersections=new U};no.prototype.processIntersections=function(t,e,n,r){if(t===n&&e===r)return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[r],a=n.getCoordinates()[r+1];if(this._li.computeIntersection(i,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var u=0;u=0;e--){try{t.bufferReducedPrecision(e)}catch(o){if(!(o instanceof Hr))throw o;t._saveException=o}if(t._resultGeometry!==null)return null}throw this._saveException}if(arguments.length===1){var n=arguments[0],r=ze.precisionScaleFactor(this._argGeom,this._distance,n),i=new Xt(r);this.bufferFixedPrecision(i)}},ze.prototype.computeGeometry=function(){if(this.bufferOriginalPrecision(),this._resultGeometry!==null)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===Xt.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()},ze.prototype.setQuadrantSegments=function(t){this._bufParams.setQuadrantSegments(t)},ze.prototype.bufferOriginalPrecision=function(){try{var t=new en(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(e){if(!(e instanceof jr))throw e;this._saveException=e}},ze.prototype.getResultGeometry=function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry},ze.prototype.setEndCapStyle=function(t){this._bufParams.setEndCapStyle(t)},ze.prototype.interfaces_=function(){return[]},ze.prototype.getClass=function(){return ze},ze.bufferOp=function(){if(arguments.length===2){var t=arguments[0],e=arguments[1],n=new ze(t),r=n.getResultGeometry(e);return r}if(arguments.length===3){if(Number.isInteger(arguments[2])&&arguments[0]instanceof $&&typeof arguments[1]=="number"){var i=arguments[0],o=arguments[1],s=arguments[2],a=new ze(i);a.setQuadrantSegments(s);var u=a.getResultGeometry(o);return u}if(arguments[2]instanceof Yt&&arguments[0]instanceof $&&typeof arguments[1]=="number"){var l=arguments[0],h=arguments[1],c=arguments[2],p=new ze(l,c),d=p.getResultGeometry(h);return d}}else if(arguments.length===4){var g=arguments[0],m=arguments[1],f=arguments[2],_=arguments[3],I=new ze(g);I.setQuadrantSegments(f),I.setEndCapStyle(_);var y=I.getResultGeometry(m);return y}},ze.precisionScaleFactor=function(t,e,n){var r=t.getEnvelopeInternal(),i=Sn.max(Math.abs(r.getMaxX()),Math.abs(r.getMaxY()),Math.abs(r.getMinX()),Math.abs(r.getMinY()))+2*(e>0?e:0),o=n-Math.trunc(Math.log(i)/Math.log(10)+1);return Math.pow(10,o)},jo.CAP_ROUND.get=function(){return Yt.CAP_ROUND},jo.CAP_BUTT.get=function(){return Yt.CAP_FLAT},jo.CAP_FLAT.get=function(){return Yt.CAP_FLAT},jo.CAP_SQUARE.get=function(){return Yt.CAP_SQUARE},jo.MAX_PRECISION_DIGITS.get=function(){return 12},Object.defineProperties(ze,jo);var nn=function(){this._pt=[new L,new L],this._distance=st.NaN,this._isNull=!0};nn.prototype.getCoordinates=function(){return this._pt},nn.prototype.getCoordinate=function(t){return this._pt[t]},nn.prototype.setMinimum=function(){if(arguments.length===1){var t=arguments[0];this.setMinimum(t._pt[0],t._pt[1])}else if(arguments.length===2){var e=arguments[0],n=arguments[1];if(this._isNull)return this.initialize(e,n),null;var r=e.distance(n);rthis._distance&&this.initialize(e,n,r)}},nn.prototype.interfaces_=function(){return[]},nn.prototype.getClass=function(){return nn};var Or=function(){};Or.prototype.interfaces_=function(){return[]},Or.prototype.getClass=function(){return Or},Or.computeDistance=function(){if(arguments[2]instanceof nn&&arguments[0]instanceof ge&&arguments[1]instanceof L)for(var t=arguments[0],e=arguments[1],n=arguments[2],r=t.getCoordinates(),i=new Z,o=0;o0||this._isIn?A.INTERIOR:A.EXTERIOR)},Qn.prototype.interfaces_=function(){return[]},Qn.prototype.getClass=function(){return Qn};var rn=function t(){if(this._component=null,this._segIndex=null,this._pt=null,arguments.length===2){var e=arguments[0],n=arguments[1];t.call(this,e,t.INSIDE_AREA,n)}else if(arguments.length===3){var r=arguments[0],i=arguments[1],o=arguments[2];this._component=r,this._segIndex=i,this._pt=o}},If={INSIDE_AREA:{configurable:!0}};rn.prototype.isInsideArea=function(){return this._segIndex===rn.INSIDE_AREA},rn.prototype.getCoordinate=function(){return this._pt},rn.prototype.getGeometryComponent=function(){return this._component},rn.prototype.getSegmentIndex=function(){return this._segIndex},rn.prototype.interfaces_=function(){return[]},rn.prototype.getClass=function(){return rn},If.INSIDE_AREA.get=function(){return-1},Object.defineProperties(rn,If);var hi=function(t){this._pts=t||null};hi.prototype.filter=function(t){t instanceof vn&&this._pts.add(t)},hi.prototype.interfaces_=function(){return[ar]},hi.prototype.getClass=function(){return hi},hi.getPoints=function(){if(arguments.length===1){var t=arguments[0];return t instanceof vn?Zn.singletonList(t):hi.getPoints(t,new U)}if(arguments.length===2){var e=arguments[0],n=arguments[1];return e instanceof vn?n.add(e):e instanceof Qe&&e.apply(new hi(n)),n}};var io=function(){this._locations=null;var t=arguments[0];this._locations=t};io.prototype.filter=function(t){(t instanceof vn||t instanceof ge||t instanceof Pe)&&this._locations.add(new rn(t,0,t.getCoordinate()))},io.prototype.interfaces_=function(){return[ar]},io.prototype.getClass=function(){return io},io.getLocations=function(t){var e=new U;return t.apply(new io(e)),e};var Ue=function(){if(this._geom=null,this._terminateDistance=0,this._ptLocator=new Qn,this._minDistanceLocation=null,this._minDistance=st.MAX_VALUE,arguments.length===2){var t=arguments[0],e=arguments[1];this._geom=[t,e],this._terminateDistance=0}else if(arguments.length===3){var n=arguments[0],r=arguments[1],i=arguments[2];this._geom=new Array(2).fill(null),this._geom[0]=n,this._geom[1]=r,this._terminateDistance=i}};Ue.prototype.computeContainmentDistance=function(){var t=this;if(arguments.length===0){var e=new Array(2).fill(null);if(this.computeContainmentDistance(0,e),this._minDistance<=this._terminateDistance)return null;this.computeContainmentDistance(1,e)}else if(arguments.length===2){var n=arguments[0],r=arguments[1],i=1-n,o=Kr.getPolygons(this._geom[n]);if(o.size()>0){var s=io.getLocations(this._geom[i]);if(this.computeContainmentDistance(s,o,r),this._minDistance<=this._terminateDistance)return this._minDistanceLocation[i]=r[0],this._minDistanceLocation[n]=r[1],null}}else if(arguments.length===3){if(arguments[2]instanceof Array&&et(arguments[0],Yn)&&et(arguments[1],Yn)){for(var a=arguments[0],u=arguments[1],l=arguments[2],h=0;hthis._minDistance)return null;for(var i=e.getCoordinates(),o=n.getCoordinate(),s=0;sthis._minDistance)return null;for(var d=h.getCoordinates(),g=c.getCoordinates(),m=0;mthis._distance&&this.initialize(e,n,r)}},Ze.prototype.interfaces_=function(){return[]},Ze.prototype.getClass=function(){return Ze};var yr=function(){};yr.prototype.interfaces_=function(){return[]},yr.prototype.getClass=function(){return yr},yr.computeDistance=function(){if(arguments[2]instanceof Ze&&arguments[0]instanceof ge&&arguments[1]instanceof L)for(var t=arguments[0],e=arguments[1],n=arguments[2],r=new Z,i=t.getCoordinates(),o=0;o1||t<=0)throw new he("Fraction is not in range (0.0 - 1.0]");this._densifyFrac=t},Bn.prototype.compute=function(t,e){this.computeOrientedDistance(t,e,this._ptDist),this.computeOrientedDistance(e,t,this._ptDist)},Bn.prototype.distance=function(){return this.compute(this._g0,this._g1),this._ptDist.getDistance()},Bn.prototype.computeOrientedDistance=function(t,e,n){var r=new oo(e);if(t.apply(r),n.setMaximum(r.getMaxPointDistance()),this._densifyFrac>0){var i=new pi(e,this._densifyFrac);t.apply(i),n.setMaximum(i.getMaxPointDistance())}},Bn.prototype.orientedDistance=function(){return this.computeOrientedDistance(this._g0,this._g1,this._ptDist),this._ptDist.getDistance()},Bn.prototype.interfaces_=function(){return[]},Bn.prototype.getClass=function(){return Bn},Bn.distance=function(){if(arguments.length===2){var t=arguments[0],e=arguments[1],n=new Bn(t,e);return n.distance()}if(arguments.length===3){var r=arguments[0],i=arguments[1],o=arguments[2],s=new Bn(r,i);return s.setDensifyFraction(o),s.distance()}},Al.MaxPointDistanceFilter.get=function(){return oo},Al.MaxDensifiedByFractionDistanceFilter.get=function(){return pi},Object.defineProperties(Bn,Al);var oo=function(){this._maxPtDist=new Ze,this._minPtDist=new Ze,this._euclideanDist=new yr,this._geom=null;var t=arguments[0];this._geom=t};oo.prototype.filter=function(t){this._minPtDist.initialize(),yr.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},oo.prototype.getMaxPointDistance=function(){return this._maxPtDist},oo.prototype.interfaces_=function(){return[wr]},oo.prototype.getClass=function(){return oo};var pi=function(){this._maxPtDist=new Ze,this._minPtDist=new Ze,this._geom=null,this._numSubSegs=0;var t=arguments[0],e=arguments[1];this._geom=t,this._numSubSegs=Math.trunc(Math.round(1/e))};pi.prototype.filter=function(t,e){var n=this;if(e===0)return null;for(var r=t.getCoordinate(e-1),i=t.getCoordinate(e),o=(i.x-r.x)/this._numSubSegs,s=(i.y-r.y)/this._numSubSegs,a=0;an){this._isValid=!1;var i=r.getCoordinates();this._errorLocation=i[1],this._errorIndicator=t.getFactory().createLineString(i),this._errMsg="Distance between buffer curve and input is too large ("+this._maxDistanceFound+" at "+Xn.toLineString(i[0],i[1])+")"}},En.prototype.isValid=function(){var t=Math.abs(this._bufDistance),e=En.MAX_DISTANCE_DIFF_FRAC*t;return this._minValidDistance=t-e,this._maxValidDistance=t+e,!(!this._input.isEmpty()&&!this._result.isEmpty())||(this._bufDistance>0?this.checkPositiveValid():this.checkNegativeValid(),En.VERBOSE&&qe.out.println("Min Dist= "+this._minDistanceFound+" err= "+(1-this._minDistanceFound/this._bufDistance)+" Max Dist= "+this._maxDistanceFound+" err= "+(this._maxDistanceFound/this._bufDistance-1)),this._isValid)},En.prototype.checkNegativeValid=function(){if(!(this._input instanceof Pe||this._input instanceof Sr||this._input instanceof Qe))return null;var t=this.getPolygonLines(this._input);if(this.checkMinimumDistance(t,this._result,this._minValidDistance),!this._isValid)return null;this.checkMaximumDistance(t,this._result,this._maxValidDistance)},En.prototype.getErrorIndicator=function(){return this._errorIndicator},En.prototype.checkMinimumDistance=function(t,e,n){var r=new Ue(t,e,n);if(this._minDistanceFound=r.distance(),this._minDistanceFound0&&t>e&&(this._isValid=!1,this._errorMsg="Area of positive buffer is smaller than input",this._errorIndicator=this._result),this._distance<0&&t=2||this._distance>0?null:(this._result.isEmpty()||(this._isValid=!1,this._errorMsg="Result is non-empty",this._errorIndicator=this._result),void this.report("ExpectedEmpty"))},Ve.prototype.report=function(t){if(!Ve.VERBOSE)return null;qe.out.println("Check "+t+": "+(this._isValid?"passed":"FAILED"))},Ve.prototype.getErrorMessage=function(){return this._errorMsg},Ve.prototype.interfaces_=function(){return[]},Ve.prototype.getClass=function(){return Ve},Ve.isValidMsg=function(t,e,n){var r=new Ve(t,e,n);return r.isValid()?null:r.getErrorMessage()},Ve.isValid=function(t,e,n){return!!new Ve(t,e,n).isValid()},Fl.VERBOSE.get=function(){return!1},Fl.MAX_ENV_DIFF_FRAC.get=function(){return .012},Object.defineProperties(Ve,Fl);var mr=function(){this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};mr.prototype.getCoordinates=function(){return this._pts},mr.prototype.size=function(){return this._pts.length},mr.prototype.getCoordinate=function(t){return this._pts[t]},mr.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},mr.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:$i.octant(this.getCoordinate(t),this.getCoordinate(t+1))},mr.prototype.setData=function(t){this._data=t},mr.prototype.getData=function(){return this._data},mr.prototype.toString=function(){return Xn.toLineString(new ve(this._pts))},mr.prototype.interfaces_=function(){return[Nr]},mr.prototype.getClass=function(){return mr};var De=function(){this._findAllIntersections=!1,this._isCheckEndSegmentsOnly=!1,this._li=null,this._interiorIntersection=null,this._intSegments=null,this._intersections=new U,this._intersectionCount=0,this._keepIntersections=!0;var t=arguments[0];this._li=t,this._interiorIntersection=null};De.prototype.getInteriorIntersection=function(){return this._interiorIntersection},De.prototype.setCheckEndSegmentsOnly=function(t){this._isCheckEndSegmentsOnly=t},De.prototype.getIntersectionSegments=function(){return this._intSegments},De.prototype.count=function(){return this._intersectionCount},De.prototype.getIntersections=function(){return this._intersections},De.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},De.prototype.setKeepIntersections=function(t){this._keepIntersections=t},De.prototype.processIntersections=function(t,e,n,r){if(!this._findAllIntersections&&this.hasIntersection()||t===n&&e===r||this._isCheckEndSegmentsOnly&&!(this.isEndSegment(t,e)||this.isEndSegment(n,r)))return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[r],a=n.getCoordinates()[r+1];this._li.computeIntersection(i,o,s,a),this._li.hasIntersection()&&this._li.isInteriorIntersection()&&(this._intSegments=new Array(4).fill(null),this._intSegments[0]=i,this._intSegments[1]=o,this._intSegments[2]=s,this._intSegments[3]=a,this._interiorIntersection=this._li.getIntersection(0),this._keepIntersections&&this._intersections.add(this._interiorIntersection),this._intersectionCount++)},De.prototype.isEndSegment=function(t,e){return e===0||e>=t.size()-2},De.prototype.hasIntersection=function(){return this._interiorIntersection!==null},De.prototype.isDone=function(){return!this._findAllIntersections&&this._interiorIntersection!==null},De.prototype.interfaces_=function(){return[Pi]},De.prototype.getClass=function(){return De},De.createAllIntersectionsFinder=function(t){var e=new De(t);return e.setFindAllIntersections(!0),e},De.createAnyIntersectionFinder=function(t){return new De(t)},De.createIntersectionCounter=function(t){var e=new De(t);return e.setFindAllIntersections(!0),e.setKeepIntersections(!1),e};var $n=function(){this._li=new wi,this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0;var t=arguments[0];this._segStrings=t};$n.prototype.execute=function(){if(this._segInt!==null)return null;this.checkInteriorIntersections()},$n.prototype.getIntersections=function(){return this._segInt.getIntersections()},$n.prototype.isValid=function(){return this.execute(),this._isValid},$n.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},$n.prototype.checkInteriorIntersections=function(){this._isValid=!0,this._segInt=new De(this._li),this._segInt.setFindAllIntersections(this._findAllIntersections);var t=new Rl;if(t.setSegmentIntersector(this._segInt),t.computeNodes(this._segStrings),this._segInt.hasIntersection())return this._isValid=!1,null},$n.prototype.checkValid=function(){if(this.execute(),!this._isValid)throw new Hr(this.getErrorMessage(),this._segInt.getInteriorIntersection())},$n.prototype.getErrorMessage=function(){if(this._isValid)return"no intersections found";var t=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+Xn.toLineString(t[0],t[1])+" and "+Xn.toLineString(t[2],t[3])},$n.prototype.interfaces_=function(){return[]},$n.prototype.getClass=function(){return $n},$n.computeIntersections=function(t){var e=new $n(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()};var Oi=function t(){this._nv=null;var e=arguments[0];this._nv=new $n(t.toSegmentStrings(e))};Oi.prototype.checkValid=function(){this._nv.checkValid()},Oi.prototype.interfaces_=function(){return[]},Oi.prototype.getClass=function(){return Oi},Oi.toSegmentStrings=function(t){for(var e=new U,n=t.iterator();n.hasNext();){var r=n.next();e.add(new mr(r.getCoordinates(),r))}return e},Oi.checkValid=function(t){new Oi(t).checkValid()};var so=function(t){this._mapOp=t};so.prototype.map=function(t){for(var e=new U,n=0;n0&&r<4&&!this._preserveType?this._factory.createLineString(n):this._factory.createLinearRing(n)},dn.prototype.interfaces_=function(){return[]},dn.prototype.getClass=function(){return dn};var Rr=function t(){if(this._snapTolerance=0,this._srcPts=null,this._seg=new Z,this._allowSnappingToSourceVertices=!1,this._isClosed=!1,arguments[0]instanceof ge&&typeof arguments[1]=="number"){var e=arguments[0],n=arguments[1];t.call(this,e.getCoordinates(),n)}else if(arguments[0]instanceof Array&&typeof arguments[1]=="number"){var r=arguments[0],i=arguments[1];this._srcPts=r,this._isClosed=t.isClosed(r),this._snapTolerance=i}};Rr.prototype.snapVertices=function(t,e){for(var n=this._isClosed?t.size()-1:t.size(),r=0;r=0&&t.add(o+1,new L(i),!1)}},Rr.prototype.findSegmentIndexToSnap=function(t,e){for(var n=this,r=st.MAX_VALUE,i=-1,o=0;oe&&(e=r)}return e}if(arguments.length===2){var i=arguments[0],o=arguments[1];return Math.min(xe.computeOverlaySnapTolerance(i),xe.computeOverlaySnapTolerance(o))}},xe.computeSizeBasedSnapTolerance=function(t){var e=t.getEnvelopeInternal();return Math.min(e.getHeight(),e.getWidth())*xe.SNAP_PRECISION_FACTOR},xe.snapToSelf=function(t,e,n){return new xe(t).snapToSelf(e,n)},Sf.SNAP_PRECISION_FACTOR.get=function(){return 1e-9},Object.defineProperties(xe,Sf);var Cf=function(t){function e(n,r,i){t.call(this),this._snapTolerance=n||null,this._snapPts=r||null,this._isSelfSnap=i!==void 0&&i}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.snapLine=function(n,r){var i=new Rr(n,this._snapTolerance);return i.setAllowSnappingToSourceVertices(this._isSelfSnap),i.snapTo(r)},e.prototype.transformCoordinates=function(n,r){var i=n.toCoordinateArray(),o=this.snapLine(i,this._snapPts);return this._factory.getCoordinateSequenceFactory().create(o)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(dn),on=function(){this._isFirst=!0,this._commonMantissaBitsCount=53,this._commonBits=0,this._commonSignExp=null};on.prototype.getCommon=function(){return st.longBitsToDouble(this._commonBits)},on.prototype.add=function(t){var e=st.doubleToLongBits(t);return this._isFirst?(this._commonBits=e,this._commonSignExp=on.signExpBits(this._commonBits),this._isFirst=!1,null):on.signExpBits(e)!==this._commonSignExp?(this._commonBits=0,null):(this._commonMantissaBitsCount=on.numCommonMostSigMantissaBits(this._commonBits,e),void(this._commonBits=on.zeroLowerBits(this._commonBits,64-(12+this._commonMantissaBitsCount))))},on.prototype.toString=function(){if(arguments.length===1){var t=arguments[0],e=st.longBitsToDouble(t),n=st.toBinaryString(t),r="0000000000000000000000000000000000000000000000000000000000000000"+n,i=r.substring(r.length-64),o=i.substring(0,1)+" "+i.substring(1,12)+"(exp) "+i.substring(12)+" [ "+e+" ]";return o}},on.prototype.interfaces_=function(){return[]},on.prototype.getClass=function(){return on},on.getBit=function(t,e){return(t&1<>52},on.zeroLowerBits=function(t,e){return t&~((1<=0;r--){if(on.getBit(t,r)!==on.getBit(e,r))return n;n++}return 52};var fi=function(){this._commonCoord=null,this._ccFilter=new uo},kl={CommonCoordinateFilter:{configurable:!0},Translater:{configurable:!0}};fi.prototype.addCommonBits=function(t){var e=new gi(this._commonCoord);t.apply(e),t.geometryChanged()},fi.prototype.removeCommonBits=function(t){if(this._commonCoord.x===0&&this._commonCoord.y===0)return t;var e=new L(this._commonCoord);e.x=-e.x,e.y=-e.y;var n=new gi(e);return t.apply(n),t.geometryChanged(),t},fi.prototype.getCommonCoordinate=function(){return this._commonCoord},fi.prototype.add=function(t){t.apply(this._ccFilter),this._commonCoord=this._ccFilter.getCommonCoordinate()},fi.prototype.interfaces_=function(){return[]},fi.prototype.getClass=function(){return fi},kl.CommonCoordinateFilter.get=function(){return uo},kl.Translater.get=function(){return gi},Object.defineProperties(fi,kl);var uo=function(){this._commonBitsX=new on,this._commonBitsY=new on};uo.prototype.filter=function(t){this._commonBitsX.add(t.x),this._commonBitsY.add(t.y)},uo.prototype.getCommonCoordinate=function(){return new L(this._commonBitsX.getCommon(),this._commonBitsY.getCommon())},uo.prototype.interfaces_=function(){return[wr]},uo.prototype.getClass=function(){return uo};var gi=function(){this.trans=null;var t=arguments[0];this.trans=t};gi.prototype.filter=function(t,e){var n=t.getOrdinate(e,0)+this.trans.x,r=t.getOrdinate(e,1)+this.trans.y;t.setOrdinate(e,0,n),t.setOrdinate(e,1,r)},gi.prototype.isDone=function(){return!1},gi.prototype.isGeometryChanged=function(){return!0},gi.prototype.interfaces_=function(){return[Wn]},gi.prototype.getClass=function(){return gi};var Fe=function(t,e){this._geom=new Array(2).fill(null),this._snapTolerance=null,this._cbr=null,this._geom[0]=t,this._geom[1]=e,this.computeSnapTolerance()};Fe.prototype.selfSnap=function(t){return new xe(t).snapTo(t,this._snapTolerance)},Fe.prototype.removeCommonBits=function(t){this._cbr=new fi,this._cbr.add(t[0]),this._cbr.add(t[1]);var e=new Array(2).fill(null);return e[0]=this._cbr.removeCommonBits(t[0].copy()),e[1]=this._cbr.removeCommonBits(t[1].copy()),e},Fe.prototype.prepareResult=function(t){return this._cbr.addCommonBits(t),t},Fe.prototype.getResultGeometry=function(t){var e=this.snap(this._geom),n=ut.overlayOp(e[0],e[1],t);return this.prepareResult(n)},Fe.prototype.checkValid=function(t){t.isValid()||qe.out.println("Snapped geometry is invalid")},Fe.prototype.computeSnapTolerance=function(){this._snapTolerance=xe.computeOverlaySnapTolerance(this._geom[0],this._geom[1])},Fe.prototype.snap=function(t){var e=this.removeCommonBits(t);return xe.snap(e[0],e[1],this._snapTolerance)},Fe.prototype.interfaces_=function(){return[]},Fe.prototype.getClass=function(){return Fe},Fe.overlayOp=function(t,e,n){return new Fe(t,e).getResultGeometry(n)},Fe.union=function(t,e){return Fe.overlayOp(t,e,ut.UNION)},Fe.intersection=function(t,e){return Fe.overlayOp(t,e,ut.INTERSECTION)},Fe.symDifference=function(t,e){return Fe.overlayOp(t,e,ut.SYMDIFFERENCE)},Fe.difference=function(t,e){return Fe.overlayOp(t,e,ut.DIFFERENCE)};var sn=function(t,e){this._geom=new Array(2).fill(null),this._geom[0]=t,this._geom[1]=e};sn.prototype.getResultGeometry=function(t){var e=null,n=!1,r=null;try{e=ut.overlayOp(this._geom[0],this._geom[1],t),n=!0}catch(i){if(!(i instanceof jr))throw i;r=i}if(!n)try{e=Fe.overlayOp(this._geom[0],this._geom[1],t)}catch(i){throw i instanceof jr?r:i}return e},sn.prototype.interfaces_=function(){return[]},sn.prototype.getClass=function(){return sn},sn.overlayOp=function(t,e,n){return new sn(t,e).getResultGeometry(n)},sn.union=function(t,e){return sn.overlayOp(t,e,ut.UNION)},sn.intersection=function(t,e){return sn.overlayOp(t,e,ut.INTERSECTION)},sn.symDifference=function(t,e){return sn.overlayOp(t,e,ut.SYMDIFFERENCE)},sn.difference=function(t,e){return sn.overlayOp(t,e,ut.DIFFERENCE)};var Us=function(){this.mce=null,this.chainIndex=null;var t=arguments[0],e=arguments[1];this.mce=t,this.chainIndex=e};Us.prototype.computeIntersections=function(t,e){this.mce.computeIntersectsForChain(this.chainIndex,t.mce,t.chainIndex,e)},Us.prototype.interfaces_=function(){return[]},Us.prototype.getClass=function(){return Us};var bn=function t(){if(this._label=null,this._xValue=null,this._eventType=null,this._insertEvent=null,this._deleteEventIndex=null,this._obj=null,arguments.length===2){var e=arguments[0],n=arguments[1];this._eventType=t.DELETE,this._xValue=e,this._insertEvent=n}else if(arguments.length===3){var r=arguments[0],i=arguments[1],o=arguments[2];this._eventType=t.INSERT,this._label=r,this._xValue=i,this._obj=o}},Gl={INSERT:{configurable:!0},DELETE:{configurable:!0}};bn.prototype.isDelete=function(){return this._eventType===bn.DELETE},bn.prototype.setDeleteEventIndex=function(t){this._deleteEventIndex=t},bn.prototype.getObject=function(){return this._obj},bn.prototype.compareTo=function(t){var e=t;return this._xValuee._xValue?1:this._eventTypee._eventType?1:0},bn.prototype.getInsertEvent=function(){return this._insertEvent},bn.prototype.isInsert=function(){return this._eventType===bn.INSERT},bn.prototype.isSameLabel=function(t){return this._label!==null&&this._label===t._label},bn.prototype.getDeleteEventIndex=function(){return this._deleteEventIndex},bn.prototype.interfaces_=function(){return[Tn]},bn.prototype.getClass=function(){return bn},Gl.INSERT.get=function(){return 1},Gl.DELETE.get=function(){return 2},Object.defineProperties(bn,Gl);var Va=function(){};Va.prototype.interfaces_=function(){return[]},Va.prototype.getClass=function(){return Va};var Xe=function(){this._hasIntersection=!1,this._hasProper=!1,this._hasProperInterior=!1,this._properIntersectionPoint=null,this._li=null,this._includeProper=null,this._recordIsolated=null,this._isSelfIntersection=null,this._numIntersections=0,this.numTests=0,this._bdyNodes=null,this._isDone=!1,this._isDoneWhenProperInt=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this._li=t,this._includeProper=e,this._recordIsolated=n};Xe.prototype.isTrivialIntersection=function(t,e,n,r){if(t===n&&this._li.getIntersectionNum()===1){if(Xe.isAdjacentSegments(e,r))return!0;if(t.isClosed()){var i=t.getNumPoints()-1;if(e===0&&r===i||r===0&&e===i)return!0}}return!1},Xe.prototype.getProperIntersectionPoint=function(){return this._properIntersectionPoint},Xe.prototype.setIsDoneIfProperInt=function(t){this._isDoneWhenProperInt=t},Xe.prototype.hasProperInteriorIntersection=function(){return this._hasProperInterior},Xe.prototype.isBoundaryPointInternal=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next().getCoordinate();if(t.isIntersection(r))return!0}return!1},Xe.prototype.hasProperIntersection=function(){return this._hasProper},Xe.prototype.hasIntersection=function(){return this._hasIntersection},Xe.prototype.isDone=function(){return this._isDone},Xe.prototype.isBoundaryPoint=function(t,e){return e!==null&&(!!this.isBoundaryPointInternal(t,e[0])||!!this.isBoundaryPointInternal(t,e[1]))},Xe.prototype.setBoundaryNodes=function(t,e){this._bdyNodes=new Array(2).fill(null),this._bdyNodes[0]=t,this._bdyNodes[1]=e},Xe.prototype.addIntersections=function(t,e,n,r){if(t===n&&e===r)return null;this.numTests++;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],s=n.getCoordinates()[r],a=n.getCoordinates()[r+1];this._li.computeIntersection(i,o,s,a),this._li.hasIntersection()&&(this._recordIsolated&&(t.setIsolated(!1),n.setIsolated(!1)),this._numIntersections++,this.isTrivialIntersection(t,e,n,r)||(this._hasIntersection=!0,!this._includeProper&&this._li.isProper()||(t.addIntersections(this._li,e,0),n.addIntersections(this._li,r,1)),this._li.isProper()&&(this._properIntersectionPoint=this._li.getIntersection(0).copy(),this._hasProper=!0,this._isDoneWhenProperInt&&(this._isDone=!0),this.isBoundaryPoint(this._li,this._bdyNodes)||(this._hasProperInterior=!0))))},Xe.prototype.interfaces_=function(){return[]},Xe.prototype.getClass=function(){return Xe},Xe.isAdjacentSegments=function(t,e){return Math.abs(t-e)===1};var ey=function(t){function e(){t.call(this),this.events=new U,this.nOverlaps=null}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.prepareEvents=function(){Zn.sort(this.events);for(var n=0;ne||this._maxo?1:0},Vs.prototype.interfaces_=function(){return[So]},Vs.prototype.getClass=function(){return Vs};var ny=function(t){function e(){t.call(this),this._item=null;var n=arguments[0],r=arguments[1],i=arguments[2];this._min=n,this._max=r,this._item=i}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.query=function(n,r,i){if(!this.intersects(n,r))return null;i.visitItem(this._item)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Tr),ry=function(t){function e(){t.call(this),this._node1=null,this._node2=null;var n=arguments[0],r=arguments[1];this._node1=n,this._node2=r,this.buildExtent(this._node1,this._node2)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.buildExtent=function(n,r){this._min=Math.min(n._min,r._min),this._max=Math.max(n._max,r._max)},e.prototype.query=function(n,r,i){if(!this.intersects(n,r))return null;this._node1!==null&&this._node1.query(n,r,i),this._node2!==null&&this._node2.query(n,r,i)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Tr),Ar=function(){this._leaves=new U,this._root=null,this._level=0};Ar.prototype.buildTree=function(){Zn.sort(this._leaves,new Tr.NodeComparator);for(var t=this._leaves,e=null,n=new U;;){if(this.buildLevel(t,n),n.size()===1)return n.get(0);e=t,t=n,n=e}},Ar.prototype.insert=function(t,e,n){if(this._root!==null)throw new Error("Index cannot be added to once it has been queried");this._leaves.add(new ny(t,e,n))},Ar.prototype.query=function(t,e,n){this.init(),this._root.query(t,e,n)},Ar.prototype.buildRoot=function(){if(this._root!==null)return null;this._root=this.buildTree()},Ar.prototype.printNode=function(t){qe.out.println(Xn.toLineString(new L(t._min,this._level),new L(t._max,this._level)))},Ar.prototype.init=function(){if(this._root!==null)return null;this.buildRoot()},Ar.prototype.buildLevel=function(t,e){this._level++,e.clear();for(var n=0;n=2,"found LineString with single point"),this.insertBoundaryPoint(this._argIndex,r[0]),this.insertBoundaryPoint(this._argIndex,r[r.length-1])},e.prototype.getInvalidPoint=function(){return this._invalidPoint},e.prototype.getBoundaryPoints=function(){for(var n=this.getBoundaryNodes(),r=new Array(n.size()).fill(null),i=0,o=n.iterator();o.hasNext();){var s=o.next();r[i++]=s.getCoordinate().copy()}return r},e.prototype.getBoundaryNodes=function(){return this._boundaryNodes===null&&(this._boundaryNodes=this._nodes.getBoundaryNodes(this._argIndex)),this._boundaryNodes},e.prototype.addSelfIntersectionNode=function(n,r,i){if(this.isBoundaryNode(n,r))return null;i===A.BOUNDARY&&this._useBoundaryDeterminationRule?this.insertBoundaryPoint(n,r):this.insertPoint(n,r,i)},e.prototype.addPolygonRing=function(n,r,i){if(n.isEmpty())return null;var o=ht.removeRepeatedPoints(n.getCoordinates());if(o.length<4)return this._hasTooFewPoints=!0,this._invalidPoint=o[0],null;var s=r,a=i;X.isCCW(o)&&(s=i,a=r);var u=new Ua(o,new Kt(this._argIndex,A.BOUNDARY,s,a));this._lineEdgeMap.put(n,u),this.insertEdge(u),this.insertPoint(this._argIndex,o[0],A.BOUNDARY)},e.prototype.insertPoint=function(n,r,i){var o=this._nodes.addNode(r),s=o.getLabel();s===null?o._label=new Kt(n,i):s.setLocation(n,i)},e.prototype.createEdgeSetIntersector=function(){return new ey},e.prototype.addSelfIntersectionNodes=function(n){for(var r=this._edges.iterator();r.hasNext();)for(var i=r.next(),o=i.getLabel().getLocation(n),s=i.eiList.iterator();s.hasNext();){var a=s.next();this.addSelfIntersectionNode(n,a.coord,o)}},e.prototype.add=function(){if(arguments.length!==1)return t.prototype.add.apply(this,arguments);var n=arguments[0];if(n.isEmpty())return null;if(n instanceof Sr&&(this._useBoundaryDeterminationRule=!1),n instanceof Pe)this.addPolygon(n);else if(n instanceof ge)this.addLineString(n);else if(n instanceof vn)this.addPoint(n);else if(n instanceof Fo)this.addCollection(n);else if(n instanceof Si)this.addCollection(n);else if(n instanceof Sr)this.addCollection(n);else{if(!(n instanceof Qe))throw new Error(n.getClass().getName());this.addCollection(n)}},e.prototype.addCollection=function(n){for(var r=0;r50?(this._areaPtLocator===null&&(this._areaPtLocator=new Vo(this._parentGeom)),this._areaPtLocator.locate(n)):this._ptLocator.locate(n,this._parentGeom)},e.prototype.findEdge=function(){if(arguments.length===1){var n=arguments[0];return this._lineEdgeMap.get(n)}return t.prototype.findEdge.apply(this,arguments)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.determineBoundary=function(n,r){return n.isInBoundary(r)?A.BOUNDARY:A.INTERIOR},e}(fe),Yo=function(){if(this._li=new wi,this._resultPrecisionModel=null,this._arg=null,arguments.length===1){var t=arguments[0];this.setComputationPrecision(t.getPrecisionModel()),this._arg=new Array(1).fill(null),this._arg[0]=new Xs(0,t)}else if(arguments.length===2){var e=arguments[0],n=arguments[1],r=Dn.OGC_SFS_BOUNDARY_RULE;e.getPrecisionModel().compareTo(n.getPrecisionModel())>=0?this.setComputationPrecision(e.getPrecisionModel()):this.setComputationPrecision(n.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new Xs(0,e,r),this._arg[1]=new Xs(1,n,r)}else if(arguments.length===3){var i=arguments[0],o=arguments[1],s=arguments[2];i.getPrecisionModel().compareTo(o.getPrecisionModel())>=0?this.setComputationPrecision(i.getPrecisionModel()):this.setComputationPrecision(o.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new Xs(0,i,s),this._arg[1]=new Xs(1,o,s)}};Yo.prototype.getArgGeometry=function(t){return this._arg[t].getGeometry()},Yo.prototype.setComputationPrecision=function(t){this._resultPrecisionModel=t,this._li.setPrecisionModel(this._resultPrecisionModel)},Yo.prototype.interfaces_=function(){return[]},Yo.prototype.getClass=function(){return Yo};var Ti=function(){};Ti.prototype.interfaces_=function(){return[]},Ti.prototype.getClass=function(){return Ti},Ti.map=function(){if(arguments[0]instanceof $&&et(arguments[1],Ti.MapOp)){for(var t=arguments[0],e=arguments[1],n=new U,r=0;r=t.size()?null:t.get(e)},Ie.union=function(t){return new Ie(t).union()},Mf.STRTREE_NODE_CAPACITY.get=function(){return 4},Object.defineProperties(Ie,Mf);var Xa=function(){};function Di(){return new Ya}function Ya(){this.reset()}Xa.prototype.interfaces_=function(){return[]},Xa.prototype.getClass=function(){return Xa},Xa.union=function(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return ut.createEmptyResult(ut.UNION,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),sn.overlayOp(t,e,ut.UNION)},Ya.prototype={constructor:Ya,reset:function(){this.s=this.t=0},add:function(t){Lf(Ha,t,this.t),Lf(this,Ha.s,this.s),this.s?this.t+=Ha.t:this.s=Ha.t},valueOf:function(){return this.s}};var Ha=new Ya;function Lf(t,e,n){var r=t.s=e+n,i=r-e,o=r-i;t.t=e-o+(n-i)}var Se=1e-6,ne=Math.PI,Qr=ne/2,Of=ne/4,$r=2*ne,Fi=180/ne,_r=ne/180,an=Math.abs,iy=Math.atan,Wo=Math.atan2,Le=Math.cos,Oe=Math.sin,Ys=Math.sqrt;function Rf(t){return t>1?0:t<-1?ne:Math.acos(t)}function Jo(t){return t>1?Qr:t<-1?-Qr:Math.asin(t)}function Hs(){}function Wa(t,e){t&&Af.hasOwnProperty(t.type)&&Af[t.type](t,e)}var Tf={Feature:function(t,e){Wa(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++rne?t-$r:t<-ne?t+$r:t,e]}function kf(t){return function(e,n){return[(e+=t)>ne?e-$r:e<-ne?e+$r:e,n]}}function Gf(t){var e=kf(t);return e.invert=kf(-t),e}function qf(t,e){var n=Le(t),r=Oe(t),i=Le(e),o=Oe(e);function s(a,u){var l=Le(u),h=Le(a)*l,c=Oe(a)*l,p=Oe(u),d=p*n+h*r;return[Wo(c*i-d*o,h*n-p*r),Jo(d*i+c*o)]}return s.invert=function(a,u){var l=Le(u),h=Le(a)*l,c=Oe(a)*l,p=Oe(u),d=p*i-c*o;return[Wo(c*i+p*o,h*n+d*r),Jo(d*n-h*r)]},s}function Bf(t,e){(e=Zo(e))[0]-=t,Ul(e);var n=Rf(-e[1]);return((-e[2]<0?-n:n)+$r-Se)%$r}function zf(){var t,e=[];return{point:function(n,r){t.push([n,r])},lineStart:function(){e.push(t=[])},lineEnd:Hs,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function Qa(t,e){return an(t[0]-e[0])=0;--o)i.point((h=l[o])[0],h[1]);else r(p.x,p.p.x,-1,i);p=p.p}l=(p=p.o).z,d=!d}while(!p.v);i.lineEnd()}}}function Uf(t){if(e=t.length){for(var e,n,r=0,i=t[0];++re?1:t>=e?0:NaN}Vl.invert=Vl;var Xl,Xf;(Xl=Vf).length===1&&(Xf=Xl,Xl=function(t,e){return Vf(Xf(t),e)});function Yf(t){for(var e,n,r,i=t.length,o=-1,s=0;++o=0;)for(e=(r=t[i]).length;--e>=0;)n[--s]=r[e];return n}var Ws=1e9,tu=-Ws;function oy(t,e,n,r){function i(l,h){return t<=l&&l<=n&&e<=h&&h<=r}function o(l,h,c,p){var d=0,g=0;if(l==null||(d=s(l,c))!==(g=s(h,c))||u(l,h)<0^c>0)do p.point(d===0||d===3?t:n,d>1?r:e);while((d=(d+c+4)%4)!==g);else p.point(h[0],h[1])}function s(l,h){return an(l[0]-t)0?0:3:an(l[0]-n)0?2:1:an(l[1]-e)0?1:0:h>0?3:2}function a(l,h){return u(l.x,h.x)}function u(l,h){var c=s(l,1),p=s(h,1);return c!==p?c-p:c===0?h[1]-l[1]:c===1?l[0]-h[0]:c===2?l[1]-h[1]:h[0]-l[0]}return function(l){var h,c,p,d,g,m,f,_,I,y,v,x=l,b=zf(),E={point:T,lineStart:function(){E.point=C,c&&c.push(p=[]),y=!0,I=!1,f=_=NaN},lineEnd:function(){h&&(C(d,g),m&&I&&b.rejoin(),h.push(b.result())),E.point=T,I&&x.lineEnd()},polygonStart:function(){x=b,h=[],c=[],v=!0},polygonEnd:function(){var D=function(){for(var O=0,R=0,P=c.length;Rr&&(tt-F)*(r-k)>(at-k)*(t-F)&&++O:at<=r&&(tt-F)*(r-k)<(at-k)*(t-F)&&--O;return O}(),M=v&&D,B=(h=Yf(h)).length;(M||B)&&(l.polygonStart(),M&&(l.lineStart(),o(null,null,1,l),l.lineEnd()),B&&jf(h,a,D,o,l),l.polygonEnd()),x=l,h=c=p=null}};function T(D,M){i(D,M)&&x.point(D,M)}function C(D,M){var B=i(D,M);if(c&&p.push([D,M]),y)d=D,g=M,m=B,y=!1,B&&(x.lineStart(),x.point(D,M));else if(B&&I)x.point(D,M);else{var O=[f=Math.max(tu,Math.min(Ws,f)),_=Math.max(tu,Math.min(Ws,_))],R=[D=Math.max(tu,Math.min(Ws,D)),M=Math.max(tu,Math.min(Ws,M))];(function(P,F,k,q,S,V){var j,tt=P[0],at=P[1],Jt=0,se=1,gt=F[0]-tt,yt=F[1]-at;if(j=k-tt,gt||!(j>0)){if(j/=gt,gt<0){if(j0){if(j>se)return;j>Jt&&(Jt=j)}if(j=S-tt,gt||!(j<0)){if(j/=gt,gt<0){if(j>se)return;j>Jt&&(Jt=j)}else if(gt>0){if(j0)){if(j/=yt,yt<0){if(j0){if(j>se)return;j>Jt&&(Jt=j)}if(j=V-at,yt||!(j<0)){if(j/=yt,yt<0){if(j>se)return;j>Jt&&(Jt=j)}else if(yt>0){if(j0&&(P[0]=tt+Jt*gt,P[1]=at+Jt*yt),se<1&&(F[0]=tt+se*gt,F[1]=at+se*yt),!0}}}}})(O,R,t,e,n,r)?(I||(x.lineStart(),x.point(O[0],O[1])),x.point(R[0],R[1]),B||x.lineEnd(),v=!1):B&&(x.lineStart(),x.point(D,M),v=!1)}f=D,_=M,I=B}return E}}var Yl=Di();Di();function Hf(t){return t}Di(),Di();var Ko=1/0,eu=Ko,Js=-Ko,nu=Js,Wf={point:function(t,e){tJs&&(Js=t),enu&&(nu=e)},lineStart:Hs,lineEnd:Hs,polygonStart:Hs,polygonEnd:Hs,result:function(){var t=[[Ko,eu],[Js,nu]];return Js=nu=-(eu=Ko=1/0),t}};Di();function Jf(t,e,n,r){return function(i,o){var s,a,u,l=e(o),h=i.invert(r[0],r[1]),c=zf(),p=e(c),d=!1,g={point:m,lineStart:_,lineEnd:I,polygonStart:function(){g.point=y,g.lineStart=v,g.lineEnd=x,a=[],s=[]},polygonEnd:function(){g.point=m,g.lineStart=_,g.lineEnd=I,a=Yf(a);var b=function(E,T){var C=T[0],D=T[1],M=[Oe(C),-Le(C),0],B=0,O=0;Yl.reset();for(var R=0,P=E.length;R=0?1:-1,Ks=lo*Re,Qo=Ks>ne,iu=j*yt;if(Yl.add(Wo(iu*lo*Oe(Ks),tt*yn+iu*Le(Ks))),B+=Qo?Re+lo*$r:Re,Qo^S>=C^se>=C){var $o=Za(Zo(q),Zo(Jt));Ul($o);var ou=Za(M,$o);Ul(ou);var su=(Qo^Re>=0?-1:1)*Jo(ou[2]);(D>su||D===su&&($o[0]||$o[1]))&&(O+=Qo^Re>=0?1:-1)}}return(B<-1e-6||B0){for(d||(o.polygonStart(),d=!0),o.lineStart(),b=0;b1&&2&D&&M.push(M.pop().concat(M.shift())),a.push(M.filter(sy))}return g}}function sy(t){return t.length>1}function ay(t,e){return((t=t.x)[0]<0?t[1]-Qr-Se:Qr-t[1])-((e=e.x)[0]<0?e[1]-Qr-Se:Qr-e[1])}var Zf=Jf(function(){return!0},function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,s){var a=o>0?ne:-ne,u=an(o-n);an(u-ne)0?Qr:-Qr),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),t.point(o,r),e=0):i!==a&&u>=ne&&(an(n-i)Se?iy((Oe(h)*(g=Le(p))*Oe(c)-Oe(p)*(d=Le(h))*Oe(l))/(d*g*m)):(h+p)/2}(n,r,o,s),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),e=0),t.point(n=o,r=s),i=a},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}},function(t,e,n,r){var i;if(t==null)i=n*Qr,r.point(-ne,i),r.point(0,i),r.point(ne,i),r.point(ne,0),r.point(ne,-i),r.point(0,-i),r.point(-ne,-i),r.point(-ne,0),r.point(-ne,i);else if(an(t[0]-e[0])>Se){var o=t[0]0,i=an(n)>Se;function o(u,l){return Le(u)*Le(l)>n}function s(u,l,h){var c=[1,0,0],p=Za(Zo(u),Zo(l)),d=Ja(p,p),g=p[0],m=d-g*g;if(!m)return!h&&u;var f=n*d/m,_=-n*g/m,I=Za(c,p),y=Ka(c,f);jl(y,Ka(p,_));var v=I,x=Ja(y,v),b=Ja(v,v),E=x*x-b*(Ja(y,y)-1);if(!(E<0)){var T=Ys(E),C=Ka(v,(-x-T)/b);if(jl(C,y),C=zl(C),!h)return C;var D,M=u[0],B=l[0],O=u[1],R=l[1];B0^C[1]<(an(C[0]-M)ne^(M<=C[0]&&C[0]<=B)){var k=Ka(v,(-x+T)/b);return jl(k,y),[C,zl(k)]}}}function a(u,l){var h=r?t:ne-t,c=0;return u<-h?c|=1:u>h&&(c|=2),l<-h?c|=4:l>h&&(c|=8),c}return Jf(o,function(u){var l,h,c,p,d;return{lineStart:function(){p=c=!1,d=1},point:function(g,m){var f,_=[g,m],I=o(g,m),y=r?I?0:a(g,m):I?a(g+(g<0?ne:-ne),m):0;if(!l&&(p=c=I)&&u.lineStart(),I!==c&&(!(f=s(l,_))||Qa(l,f)||Qa(_,f))&&(_[0]+=Se,_[1]+=Se,I=o(_[0],_[1])),I!==c)d=0,I?(u.lineStart(),f=s(_,l),u.point(f[0],f[1])):(f=s(l,_),u.point(f[0],f[1]),u.lineEnd()),l=f;else if(i&&l&&r^I){var v;y&h||!(v=s(_,l,!0))||(d=0,r?(u.lineStart(),u.point(v[0][0],v[0][1]),u.point(v[1][0],v[1][1]),u.lineEnd()):(u.point(v[1][0],v[1][1]),u.lineEnd(),u.lineStart(),u.point(v[0][0],v[0][1])))}!I||l&&Qa(l,_)||u.point(_[0],_[1]),l=_,c=I,h=y},lineEnd:function(){c&&u.lineEnd(),l=null},clean:function(){return d|(p&&c)<<1}}},function(u,l,h,c){(function(p,d,g,m,f,_){if(g){var I=Le(d),y=Oe(d),v=m*g;f==null?(f=d+m*$r,_=d-v/2):(f=Bf(I,f),_=Bf(I,_),(m>0?f<_:f>_)&&(f+=m*$r));for(var x,b=f;m>0?b>_:b<_;b-=v)x=zl([I,-y*Le(b),-y*Oe(b)]),p.point(x[0],x[1])}})(c,t,e,h,u,l)},r?[0,-t]:[-ne,t-ne])}function Kf(t){return function(e){var n=new Hl;for(var r in t)n[r]=t[r];return n.stream=e,n}}function Hl(){}function Qf(t,e,n){var r=e[1][0]-e[0][0],i=e[1][1]-e[0][1],o=t.clipExtent&&t.clipExtent();t.scale(150).translate([0,0]),o!=null&&t.clipExtent(null),function(h,c){h&&Tf.hasOwnProperty(h.type)?Tf[h.type](h,c):Wa(h,c)}(n,t.stream(Wf));var s=Wf.result(),a=Math.min(r/(s[1][0]-s[0][0]),i/(s[1][1]-s[0][1])),u=+e[0][0]+(r-a*(s[1][0]+s[0][0]))/2,l=+e[0][1]+(i-a*(s[1][1]+s[0][1]))/2;return o!=null&&t.clipExtent(o),t.scale(150*a).translate([u,l])}Hl.prototype={constructor:Hl,point:function(t,e){this.stream.point(t,e)},sphere:function(){this.stream.sphere()},lineStart:function(){this.stream.lineStart()},lineEnd:function(){this.stream.lineEnd()},polygonStart:function(){this.stream.polygonStart()},polygonEnd:function(){this.stream.polygonEnd()}};var ly=Le(30*_r);function $f(t,e){return+e?function(n,r){function i(o,s,a,u,l,h,c,p,d,g,m,f,_,I){var y=c-o,v=p-s,x=y*y+v*v;if(x>4*r&&_--){var b=u+g,E=l+m,T=h+f,C=Ys(b*b+E*E+T*T),D=Jo(T/=C),M=an(an(T)-1)r||an((y*P+v*F)/x-.5)>.3||u*g+l*m+h*f2?P[2]%360*_r:0,O()):[_*Fi,I*Fi,y*Fi]},D.precision=function(P){return arguments.length?(C=$f(B,T=P*P),R()):Ys(T)},D.fitExtent=function(P,F){return Qf(D,P,F)},D.fitSize=function(P,F){return function(k,q,S){return Qf(k,[[0,0],q],S)}(D,P,F)},function(){return n=e.apply(this,arguments),D.invert=n.invert&&M,O()}}(function(){return t})()}var tg=function(t){return function(e,n){var r=Le(e),i=Le(n),o=t(r*i);return[o*i*Oe(e),o*Oe(n)]}}(function(t){return(t=Rf(t))&&t/Oe(t)});function py(){return hy(tg).scale(79.4188).clipAngle(179.999)}function ru(t,e,n,r){var i=t.properties||{},o=t.type==="Feature"?t.geometry:t;if(o.type==="GeometryCollection"){var s=[];return zn(t,function(p){var d=ru(p,e,n,r);d&&s.push(d)}),nt(s)}var a=function(p){var d=ha(p).geometry.coordinates,g=[-d[0],-d[1]];return py().rotate(g).scale(tr)}(o),u={type:o.type,coordinates:ng(o.coordinates,a)},l=new Ll().read(u),h=co(ki(e,n),"meters"),c=ze.bufferOp(l,h,r);if(!eg((c=new cf().write(c)).coordinates))return Te({type:c.type,coordinates:rg(c.coordinates,a)},i)}function eg(t){return Array.isArray(t[0])?eg(t[0]):isNaN(t[0])}function ng(t,e){return typeof t[0]!="object"?e(t):t.map(function(n){return ng(n,e)})}function rg(t,e){return typeof t[0]!="object"?e.invert(t):t.map(function(n){return rg(n,e)})}function Wl(t,e,n){n===void 0&&(n={});var r=ae(t),i=ae(e),o=G0(r.coordinates,i.coordinates);return o.length===0?null:o.length===1?ct(o[0],n.properties):xr(o,n.properties)}function Zs(t,e,n){n===void 0&&(n={});var r=ae(t),i=ae(e),o=q0(r.coordinates,i.coordinates);return o.length===0?null:o.length===1?ct(o[0],n.properties):xr(o,n.properties)}/** * @license get-closest https://github.com/cosmosio/get-closest * * The MIT License (MIT) * * Copyright (c) 2014-2017 Olivier Scherrer */function fy(t,e){return function(n,r,i){var o,s;if(!Array.isArray(r))throw new Error("Get closest expects an array as second argument");return r.forEach(function(a,u){var l=i(a,n);l>=0&&(s===void 0||l0}function ig(t,e,n){n===void 0&&(n={});var r=JSON.stringify(n.properties||{}),i=t[0],o=t[1],s=t[2],a=t[3],u=(o+a)/2,l=(i+s)/2,h=2*e/$t([i,u],[s,u],n)*(s-i),c=2*e/$t([l,o],[l,a],n)*(a-o),p=h/2,d=2*p,g=Math.sqrt(3)/2*c,m=s-i,f=a-o,_=3/4*d,I=g,y=(m-d)/(d-p/2),v=Math.floor(y),x=(v*_-p/2-m)/2-p/2+_/2,b=Math.floor((f-g)/g),E=(f-b*g)/2,T=b*g-f>g/2;T&&(E-=g/4);for(var C=[],D=[],M=0;M<6;M++){var B=2*Math.PI/6*M;C.push(Math.cos(B)),D.push(Math.sin(B))}for(var O=[],R=0;R<=v;R++)for(var P=0;P<=b;P++){var F=R%2==1;if((P!==0||!F)&&(P!==0||!T)){var k=R*_+i-x,q=P*I+o+E;if(F&&(q-=g/2),n.triangles===!0)yy([k,q],h/2,c/2,JSON.parse(r),C,D).forEach(function(V){n.mask?Zs(n.mask,V)&&O.push(V):O.push(V)});else{var S=dy([k,q],h/2,c/2,JSON.parse(r),C,D);n.mask?Zs(n.mask,S)&&O.push(S):O.push(S)}}}return nt(O)}function dy(t,e,n,r,i,o){for(var s=[],a=0;a<6;a++){var u=t[0]+e*i[a],l=t[1]+n*o[a];s.push([u,l])}return s.push(s[0].slice()),ct([s],r)}function yy(t,e,n,r,i,o){for(var s=[],a=0;a<6;a++){var u=[];u.push(t),u.push([t[0]+e*i[a],t[1]+n*o[a]]),u.push([t[0]+e*i[(a+1)%6],t[1]+n*o[(a+1)%6]]),u.push(t),s.push(ct([u],r))}return s}function og(t){if(t.features.length<=1)return t;var e=function(i){var o=un(),s=[];return Ee(i,function(a,u){var l=ye(a);s.push({minX:l[0],minY:l[1],maxX:l[2],maxY:l[3],geojson:a,index:u})}),o.load(s),o}(t),n=[],r={};return Ee(t,function(i,o){if(r[o])return!0;for(e.remove({index:o},sg),r[o]=!0;;){var s=ye(i),a=e.search({minX:s[0],minY:s[1],maxX:s[2],maxY:s[3]});if(a.length>0)for(var u=a.map(function(c){return r[c.index]=!0,e.remove({index:c.index},sg),c.geojson}),l=0,h=u.length;l=i&&o===r.length-1);o++){if(i>=e){var s=e-i;if(s){var a=ni(r[o],r[o-1])-180;return Fr(r[o],s,a,n)}return ft(r[o])}i+=$t(r[o],r[o+1],n)}return ft(r[r.length-1])},N.angle=function(t,e,n,r){if(r===void 0&&(r={}),!Qt(r))throw new Error("options is invalid");if(!t)throw new Error("startPoint is required");if(!e)throw new Error("midPoint is required");if(!n)throw new Error("endPoint is required");var i=t,o=e,s=n,a=Gi(r.mercator!==!0?ni(i,o):Vi(i,o)),u=Gi(r.mercator!==!0?ni(s,o):Vi(s,o)),l=Math.abs(a-u);return r.explementary===!0?360-l:l},N.applyFilter=Ca,N.area=zu,N.areaFactors=$s,N.bbox=ye,N.bboxClip=function(t,e){var n=ae(t),r=n.type,i=t.type==="Feature"?t.properties:{},o=n.coordinates;switch(r){case"LineString":case"MultiLineString":var s=[];return r==="LineString"&&(o=[o]),o.forEach(function(a){(function(u,l,h){var c,p,d,g,m,f=u.length,_=vo(u[0],l),I=[];for(h||(h=[]),c=1;c0)for(var u=0;un&&(e.numberOfClusters=n),e.mutate!==!0&&(t=Ye(t));var r=vi(t),i=r.slice(0,e.numberOfClusters),o=o0(r,e.numberOfClusters,i),s={};return o.centroids.forEach(function(a,u){s[u]=a}),Zt(t,function(a,u){var l=o.idxs[u];a.properties.cluster=l,a.properties.centroid=s[l]}),t},N.collect=function(t,e,n,r){var i=un(6),o=e.features.map(function(s){var a;return{minX:s.geometry.coordinates[0],minY:s.geometry.coordinates[1],maxX:s.geometry.coordinates[0],maxY:s.geometry.coordinates[1],property:(a=s.properties)===null||a===void 0?void 0:a[n]}});return i.load(o),t.features.forEach(function(s){s.properties||(s.properties={});var a=ye(s),u=i.search({minX:a[0],minY:a[1],maxX:a[2],maxY:a[3]}),l=[];u.forEach(function(h){le([h.minX,h.minY],s)&&l.push(h.property)}),s.properties[r]=l}),t},N.collectionOf=ti,N.combine=function(t){var e={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}};return Zt(t,function(n){var r,i,o,s;switch((s=n.geometry)===null||s===void 0?void 0:s.type){case"Point":e.MultiPoint.coordinates.push(n.geometry.coordinates),e.MultiPoint.properties.push(n.properties);break;case"MultiPoint":(r=e.MultiPoint.coordinates).push.apply(r,n.geometry.coordinates),e.MultiPoint.properties.push(n.properties);break;case"LineString":e.MultiLineString.coordinates.push(n.geometry.coordinates),e.MultiLineString.properties.push(n.properties);break;case"MultiLineString":(i=e.MultiLineString.coordinates).push.apply(i,n.geometry.coordinates),e.MultiLineString.properties.push(n.properties);break;case"Polygon":e.MultiPolygon.coordinates.push(n.geometry.coordinates),e.MultiPolygon.properties.push(n.properties);break;case"MultiPolygon":(o=e.MultiPolygon.coordinates).push.apply(o,n.geometry.coordinates),e.MultiPolygon.properties.push(n.properties)}}),nt(Object.keys(e).filter(function(n){return e[n].coordinates.length}).sort().map(function(n){return Te({type:n,coordinates:e[n].coordinates},{collectedProperties:e[n].properties})}))},N.concave=function(t,e){e===void 0&&(e={});var n=e.maxEdge||1/0,r=Lc(function(o){var s=[],a={};return Zt(o,function(u){if(u.geometry){var l=u.geometry.coordinates.join("-");a.hasOwnProperty(l)||(s.push(u),a[l]=!0)}}),nt(s)}(t));if(r.features=r.features.filter(function(o){var s=o.geometry.coordinates[0][0],a=o.geometry.coordinates[0][1],u=o.geometry.coordinates[0][2],l=$t(s,a,e),h=$t(a,u,e),c=$t(s,u,e);return l<=n&&h<=n&&c<=n}),r.features.length<1)return null;var i=Wg(r);return i.coordinates.length===1&&(i.coordinates=i.coordinates[0],i.type="Polygon"),Te(i)},N.containsNumber=uu,N.convertArea=ec,N.convertDistance=qi,N.convertLength=qi,N.convex=Pc,N.coordAll=vi,N.coordEach=Ce,N.coordReduce=lu,N.createBins=pl,N.degrees2radians=ke,N.degreesToRadians=ke,N.destination=Fr,N.difference=function(t,e){var n=ae(t),r=ae(e),i=t.properties||{},o=B0(n.coordinates,r.coordinates);return o.length===0?null:o.length===1?ct(o[0],i):xr(o,i)},N.dissolve=function(t,e){if(!Qt(e=e||{}))throw new Error("options is invalid");var n=e.propertyName;ti(t,"Polygon","dissolve");var r=Ye(t),i=r.features,o=[];i.forEach(function(h,c){h.properties.origIndexPosition=c});var s=yo();for(var a in s.load(r),i){var u=i[a],l=!1;if(s.search(u).features.forEach(function(h){u=i[a];var c=h.properties.origIndexPosition;if(o.length>0&&c!==0)if(c>o[o.length-1])c-=o.length;else{var p=fy(c,o);p!==0&&(c-=p)}if(c!==+a){var d=i[c];d&&u&&(n!==void 0&&d.properties[n]!==u.properties[n]||ap(u,d)&&gy(u,d)&&(i[a]=Wl(u,d),o.push(h.properties.origIndexPosition),o.sort(function(g,m){return g-m}),s.remove(h),i.splice(c,1),u.properties.origIndexPosition=a,s.remove(u,function(g,m){return g.properties.origIndexPosition===m.properties.origIndexPosition}),l=!0))}}),l){if(!u)continue;u.properties.origIndexPosition=a,s.insert(u),a--}}return i.forEach(function(h){delete h.properties.origIndexPosition,delete h.bbox}),r},N.distance=$t,N.distanceToDegrees=ea,N.distanceToRadians=ki,N.distanceWeight=Cp,N.earthRadius=tr,N.ellipse=bp,N.envelope=Vc,N.explode=pa,N.factors=Qs,N.feature=Te,N.featureCollection=nt,N.featureEach=Zt,N.featureOf=ts,N.featureReduce=hu,N.filterProperties=Bp,N.findPoint=uc,N.findSegment=ac,N.flatten=function(t){if(!t)throw new Error("geojson is required");var e=[];return Ee(t,function(n){e.push(n)}),nt(e)},N.flattenEach=Ee,N.flattenReduce=sc,N.flip=function(t,e){if(!Qt(e=e||{}))throw new Error("options is invalid");var n=e.mutate;if(!t)throw new Error("geojson is required");return n!==!1&&n!==void 0||(t=Ye(t)),Ce(t,function(r){var i=r[0],o=r[1];r[0]=o,r[1]=i}),t},N.geojsonType=ic,N.geomEach=zn,N.geomReduce=pu,N.geometry=Zl,N.geometryCollection=au,N.getCluster=Gp,N.getCoord=re,N.getCoords=it,N.getGeom=ae,N.getType=wn,N.greatCircle=function(t,e,n){if(typeof(n=n||{})!="object")throw new Error("options is invalid");var r=n.properties,i=n.npoints,o=n.offset;return t=re(t),e=re(e),r=r||{},i=i||100,o=o||10,new Xu({x:t[0],y:t[1]},{x:e[0],y:e[1]},r).Arc(i,{offset:o}).json()},N.helpers=cg,N.hexGrid=ig,N.inside=le,N.interpolate=function(t,e,n){if(typeof(n=n||{})!="object")throw new Error("options is invalid");var r=n.gridType,i=n.property,o=n.weight;if(!t)throw new Error("points is required");if(ti(t,"Point","input must contain Points"),!e)throw new Error("cellSize is required");if(o!==void 0&&typeof o!="number")throw new Error("weight must be a number");i=i||"elevation",r=r||"square",o=o||1;var s,a=ye(t);switch(r){case"point":case"points":s=yh(a,e,n);break;case"square":case"squares":s=ag(a,e,n);break;case"hex":case"hexes":s=ig(a,e,n);break;case"triangle":case"triangles":s=ug(a,e,n);break;default:throw new Error("invalid gridType")}var u=[];return Zt(s,function(l){var h=0,c=0;Zt(t,function(d){var g,m=$t(r==="point"?l:_i(l),d,n);if(i!==void 0&&(g=d.properties[i]),g===void 0&&(g=d.geometry.coordinates[2]),g===void 0)throw new Error("zValue is missing");m===0&&(h=g);var f=1/Math.pow(m,o);c+=f,h+=f*g});var p=Ye(l);p.properties[i]=h/c,u.push(p)}),nt(u)},N.intersect=Zs,N.invariant=hg,N.isNumber=Ge,N.isObject=Qt,N.isobands=function(t,e,n){if(!Qt(n=n||{}))throw new Error("options is invalid");var r=n.zProperty||"elevation",i=n.commonProperties||{},o=n.breaksProperties||[];if(ti(t,"Point","Input must contain Points"),!e)throw new Error("breaks is required");if(!Array.isArray(e))throw new Error("breaks is not an Array");if(!Qt(i))throw new Error("commonProperties is not an Object");if(!Array.isArray(o))throw new Error("breaksProperties is not an Array");var s=Dd(t,{zProperty:r,flip:!0}),a=function(u,l,h){for(var c=[],p=1;p0&&(u=ct(a).geometry),b0(u,l),a=l.slice(0);n.push(ct(a,s));break;case"MultiPolygon":a=[[[]]];for(var c=0;c0&&(u=xr(a).geometry),w0(u,l),a=l.slice(0);n.push(xr(a,s));break;default:throw new Error("geometry is invalid, must be Polygon or MultiPolygon")}}),nt(n)},N.polygonTangents=function(t,e){var n,r,i,o,s=it(t),a=it(e),u=ye(e),l=0,h=null;switch(s[0]>u[0]&&s[0]u[1]&&s[1] is required");if(typeof n!="boolean")throw new Error(" must be a boolean");if(typeof r!="boolean")throw new Error(" must be a boolean");r===!1&&(t=Ye(t));var i=[];switch(t.type){case"GeometryCollection":return zn(t,function(o){_a(o,n)}),t;case"FeatureCollection":return Zt(t,function(o){Zt(_a(o,n),function(s){i.push(s)})}),nt(i)}return _a(t,n)},N.rhumbBearing=Vi,N.rhumbDestination=xo,N.rhumbDistance=ya,N.round=tc,N.sample=function(t,e){if(!t)throw new Error("featurecollection is required");if(e==null)throw new Error("num is required");if(typeof e!="number")throw new Error("num must be a number");return nt(function(n,r){for(var i,o,s=n.slice(0),a=n.length,u=a-r;a-- >u;)i=s[o=Math.floor((a+1)*Math.random())],s[o]=s[a],s[a]=i;return s.slice(u)}(t.features,e))},N.sector=function(t,e,n,r,i){if(!Qt(i=i||{}))throw new Error("options is invalid");var o=i.properties;if(!t)throw new Error("center is required");if(n==null)throw new Error("bearing1 is required");if(r==null)throw new Error("bearing2 is required");if(!e)throw new Error("radius is required");if(typeof i!="object")throw new Error("options must be an object");if(kh(n)===kh(r))return Tu(t,e,i);var s=it(t),a=Sh(t,e,n,r,i),u=[[s]];return Ce(a,function(l){u[0].push(l)}),u[0].push(s),ct(u,o)},N.segmentEach=ei,N.segmentReduce=fu,N.shortestPath=function(t,e,n){if(!Qt(n=n||{}))throw new Error("options is invalid");var r=n.resolution,i=n.minDistance,o=n.obstacles||nt([]);if(!t)throw new Error("start is required");if(!e)throw new Error("end is required");if(r&&!Ge(r)||r<=0)throw new Error("options.resolution must be a number, greater than 0");if(i)throw new Error("options.minDistance is not yet implemented");var s=re(t),a=re(e);switch(t=ft(s),e=ft(a),wn(o)){case"FeatureCollection":if(o.features.length===0)return Wt([s,a]);break;case"Polygon":o=nt([Te(ae(o))]);break;default:throw new Error("invalid obstacles")}var u=o;u.features.push(t),u.features.push(e);var l=ye(Vh(Ru(ye(u)),1.15));r||(r=$t([l[0],l[1]],[l[2],l[1]],n)/100),u.features.pop(),u.features.pop();for(var h=l[0],c=l[1],p=l[2],d=l[3],g=r/$t([h,c],[p,c],n)*(p-h),m=r/$t([h,c],[h,d],n)*(d-c),f=p-h,_=d-c,I=Math.floor(f/g),y=Math.floor(_/m),v=(f-I*g)/2,x=[],b=[],E=[],T=[],C=1/0,D=1/0,M=d-(_-y*m)/2,B=0;M>=c;){for(var O=[],R=[],P=h+v,F=0;P<=p;){var k=ft([P,M]),q=a0(k,o);O.push(q?0:1),R.push(P+"|"+M);var S=$t(k,t);!q&&Sg[yt.isect].coord?-1:1}),c=[];E.length>0;){var B=E.pop(),O=B.isect,R=B.parent,P=B.winding,F=c.length,k=[g[O].coord],q=O;if(g[O].ringAndEdge1Walkable)var S=g[O].ringAndEdge1,V=g[O].nxtIsectAlongRingAndEdge1;else S=g[O].ringAndEdge2,V=g[O].nxtIsectAlongRingAndEdge2;for(;!ps(g[O].coord,g[V].coord);){k.push(g[V].coord);var j=void 0;for(s=0;s1)for(yt=0;yt