!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e(t.turf={})}(this,function(t){"use strict";function e(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.bbox,i=n.id;if(void 0===t)throw new Error("geometry is required");if(e&&e.constructor!==Object)throw new Error("properties must be an Object");r&&N(r),i&&C(i);var o={type:"Feature"};return i&&(o.id=i),r&&(o.bbox=r),o.properties=e||{},o.geometry=t,o}function n(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var i=n.bbox;if(!t)throw new Error("type is required");if(!e)throw new Error("coordinates is required");if(!Array.isArray(e))throw new Error("coordinates must be an Array");i&&N(i);var s;switch(t){case"Point":s=r(e).geometry;break;case"LineString":s=a(e).geometry;break;case"Polygon":s=o(e).geometry;break;case"MultiPoint":s=l(e).geometry;break;case"MultiLineString":s=h(e).geometry;break;case"MultiPolygon":s=p(e).geometry;break;default:throw new Error(t+" is invalid")}return i&&(s.bbox=i),s}function r(t,n,r){if(!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(!b(t[0])||!b(t[1]))throw new Error("coordinates must contain numbers");return e({type:"Point",coordinates:t},n,r)}function i(t,e,n){if(!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");return c(t.map(function(t){return r(t,e)}),n)}function o(t,n,r){if(!t)throw new Error("coordinates is required");for(var i=0;i=0))throw new Error("precision must be a positive number");var n=Math.pow(10,e||0);return Math.round(t*n)/n}function d(t,e){if(void 0===t||null===t)throw new Error("radians is required");if(e&&"string"!=typeof e)throw new Error("units must be a string");var n=Bo[e||"kilometers"];if(!n)throw new Error(e+" units is invalid");return t*n}function y(t,e){if(void 0===t||null===t)throw new Error("distance is required");if(e&&"string"!=typeof e)throw new Error("units must be a string");var n=Bo[e||"kilometers"];if(!n)throw new Error(e+" units is invalid");return t/n}function _(t,e){return v(y(t,e))}function m(t){if(null===t||void 0===t)throw new Error("bearing is required");var e=t%360;return e<0&&(e+=360),e}function v(t){if(null===t||void 0===t)throw new Error("radians is required");return 180*(t%(2*Math.PI))/Math.PI}function x(t){if(null===t||void 0===t)throw new Error("degrees is required");return t%360*Math.PI/180}function E(t,e,n){if(null===t||void 0===t)throw new Error("length is required");if(!(t>=0))throw new Error("length must be a positive number");return d(y(t,e),n||"kilometers")}function w(t,e,n){if(null===t||void 0===t)throw new Error("area is required");if(!(t>=0))throw new Error("area must be a positive number");var r=zo[e||"meters"];if(!r)throw new Error("invalid original units");var i=zo[n||"kilometers"];if(!i)throw new Error("invalid final units");return t/r*i}function b(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function I(t){return!!t&&t.constructor===Object}function N(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach(function(t){if(!b(t))throw new Error("bbox must only contain numbers")})}function C(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}function S(t,e,n){if(null!==t)for(var r,i,o,s,a,u,c,h,l=0,p=0,f=t.type,g="FeatureCollection"===f,d="Feature"===f,y=g?t.features.length:1,_=0;_t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]1&&b(e[0])&&b(e[1]))return e;throw new Error("Coordinate is not a valid Point")}function U(t){if(!t)throw new Error("obj is required");var e;if(t.length?e=t:t.coordinates?e=t.coordinates:t.geometry&&t.geometry.coordinates&&(e=t.geometry.coordinates),e)return Y(e),e;throw new Error("No valid coordinates")}function Y(t){if(t.length>1&&b(t[0])&&b(t[1]))return!0;if(Array.isArray(t[0])&&t[0].length)return Y(t[0]);throw new Error("coordinates must only contain numbers")}function V(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 H(t,e,n){if(!t)throw new Error("No feature passed");if(!n)throw new Error(".featureOf() requires a name");if(!t||"Feature"!==t.type||!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 W(t,e,n){if(!t)throw new Error("No featureCollection passed");if(!n)throw new Error(".collectionOf() requires a name");if(!t||"FeatureCollection"!==t.type)throw new Error("Invalid input to "+n+", FeatureCollection required");for(var r=0;r=0&&d>=0&&d=0;h--)if(Math.abs(e[h][0][0]-u)<=1e-7&&Math.abs(e[h][0][1]-c)<=1e-7){for(var l=s.path.length-2;l>=0;--l)e[h].unshift(s.path[l]);a=!0;break}a||(e[n++]=s.path)}})}),e}(function(t,e){for(var n=t.length-1,r=t[0].length-1,i={rows:n,cols:r,cells:[]},o=0;o=e?8:0,a|=c>=e?4:0,a|=h>=e?2:0;var p=!1;if(5===(a|=l>=e?1:0)||10===a){var f=(u+c+h+l)/4;5===a&&fe?1:0};r>n;){if(r-n>600){var o=r-n+1,s=e-n+1,a=Math.log(o),u=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*u*(o-u)/o)*(s-o/2<0?-1:1);it(t,e,Math.max(n,Math.floor(e-s*u/o+c)),Math.min(r,Math.floor(e+(o-s)*u/o+c)),i)}var h=t[e],l=n,p=r;for(ot(t,n,e),i(t[r],h)>0&&ot(t,n,r);l0;)p--}0===i(t[n],h)?ot(t,n,p):ot(t,++p,r),p<=e&&(n=p+1),e<=p&&(r=p-1)}}function ot(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function st(t,e){if(!(this instanceof st))return new st(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 at(t,e){ut(t,0,t.children.length,e,t)}function ut(t,e,n,r,i){i||(i=yt(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var o,s=e;s=t.minX&&e.maxY>=t.minY}function yt(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function _t(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,Ho(t,o,e,n,i),s.push(e,o,o,n))}function mt(t,e){return e={exports:{}},t(e,e.exports),e.exports}function vt(t,e){if(!(this instanceof vt))return new vt(t,e);if(this.data=t||[],this.length=this.data.length,this.compare=e||function(t,e){return te?1:0},this.length>0)for(var n=(this.length>>1)-1;n>=0;n--)this._down(n)}function xt(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;for(var r,i=function(t){for(var e=t[0],n=t[0],r=t[0],i=t[0],o=0;or[0]&&(r=s),s[1]i[1]&&(i=s)}var a=[e,n,r,i],u=a.slice();for(o=0;oo||a.push({node:h,dist:l})}for(;a.length&&!a.peek().node.children;){var p=a.pop(),f=p.node,g=St(f,e,n),d=St(f,r,i);if(p.dist=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function bt(t,e,n){for(var r=Math.min(t[0],e[0]),i=Math.min(t[1],e[1]),o=Math.max(t[0],e[0]),s=Math.max(t[1],e[1]),a=n.search({minX:r,minY:i,maxX:o,maxY:s}),u=0;u0!=as(t,e,r)>0&&as(n,r,t)>0!=as(n,r,e)>0}(a[u].p,a[u].next.p,t,e))return!1;return!0}function It(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 Nt(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 Ct(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function St(t,e,n){var r=e[0],i=e[1],o=n[0]-r,s=n[1]-i;if(0!==o||0!==s){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,s=t[1]-i,o*o+s*s}function Mt(t,e,n,r,i,o,s,a){var u,c,h,l,p=n-t,f=r-e,g=s-i,d=a-o,y=t-i,_=e-o,m=p*p+f*f,v=p*g+f*d,x=g*g+d*d,E=p*y+f*_,w=g*y+d*_,b=m*x-v*v,I=b,N=b;0===b?(c=0,I=1,l=w,N=x):(l=m*w-v*E,(c=v*w-x*E)<0?(c=0,l=w,N=x):c>I&&(c=I,l=w+v,N=x)),l<0?(l=0,-E<0?c=0:-E>m?c=I:(c=-E,I=m)):l>N&&(l=N,-E+v<0?c=0:-E+v>m?c=I:(c=-E+v,I=m)),u=0===c?0:c/I;var C=(1-(h=0===l?0:l/N))*i+h*s-((1-u)*t+u*n),S=(1-h)*o+h*a-((1-u)*e+u*r);return C*C+S*S}function Lt(t,e){if(e=e||{},!I(e))throw new Error("options is invalid");var n=e.concavity||1/0,r=[];if(S(t,function(t){r.push([t[0],t[1]])}),!r.length)return null;var i=us(r,n);return i.length>3?o([i]):null}function Pt(t,e,n){if("object"!=typeof(n=n||{}))throw new Error("options is invalid");var r=n.ignoreBoundary;if(!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var i=X(t),o=U(e),s=e.geometry?e.geometry.type:e.type,a=e.bbox;if(a&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(i,a))return!1;"Polygon"===s&&(o=[o]);for(var u=0,c=!1;ut[1]!=c>t[1]&&t[0]<(u-s)*(t[1]-a)/(c-a)+s&&(r=!r)}return r}function Rt(t,e){var n=[];return A(e,function(e){O(t,function(t){Pt(t,e)&&n.push(t)})}),c(n)}function Tt(t,e){if("FeatureCollection"!==t.type)throw new Error("points must be a FeatureCollection");var n=!1;return c(function(t){if(t.length<3)return[];t.sort(Dt);var e,n,r,i,o,s,a=t.length-1,u=t[a].x,c=t[0].x,h=t[a].y,l=h;for(;a--;)t[a].yl&&(l=t[a].y);var p,f=c-u,g=l-h,d=f>g?f:g,y=.5*(c+u),_=.5*(l+h),m=[new At({x:y-20*d,y:_-d,__sentinel:!0},{x:y,y:_+20*d,__sentinel:!0},{x:y+20*d,y:_-d,__sentinel:!0})],v=[],x=[];a=t.length;for(;a--;){for(x.length=0,p=m.length;p--;)(f=t[a].x-m[p].x)>0&&f*f>m[p].r?(v.push(m[p]),m.splice(p,1)):(g=t[a].y-m[p].y,f*f+g*g>m[p].r||(x.push(m[p].a,m[p].b,m[p].b,m[p].c,m[p].c,m[p].a),m.splice(p,1)));for(Ft(x),p=x.length;p;)n=x[--p],e=x[--p],r=t[a],i=n.x-e.x,o=n.y-e.y,s=2*(i*(r.y-n.y)-o*(r.x-n.x)),Math.abs(s)>1e-12&&m.push(new At(e,n,r))}Array.prototype.push.apply(v,m),a=v.length;for(;a--;)(v[a].a.__sentinel||v[a].b.__sentinel||v[a].c.__sentinel)&&v.splice(a,1);return v}(t.features.map(function(t){var r={x:t.geometry.coordinates[0],y:t.geometry.coordinates[1]};return e?r.z=t.properties[e]:3===t.geometry.coordinates.length&&(n=!0,r.z=t.geometry.coordinates[2]),r})).map(function(t){var e=[t.a.x,t.a.y],r=[t.b.x,t.b.y],i=[t.c.x,t.c.y],s={};return n?(e.push(t.a.z),r.push(t.b.z),i.push(t.c.z)):s={a:t.a.z,b:t.b.z,c:t.c.z},o([[e,r,i,e]],s)}))}function At(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,c=o*(t.x+e.x)+s*(t.y+e.y),h=a*(t.x+n.x)+u*(t.y+n.y),l=2*(o*(n.y-e.y)-s*(n.x-e.x));this.x=(u*c-s*h)/l,this.y=(o*h-a*c)/l,r=this.x-t.x,i=this.y-t.y,this.r=r*r+i*i}function Dt(t,e){return e.x-t.x}function Ft(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],i=t[--r],e===i&&n===o||e===o&&n===i){t.splice(s,2),t.splice(r,2),s-=2;continue t}}function qt(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.units,i=X(t),o=X(e),s=x(o[1]-i[1]),a=x(o[0]-i[0]),u=x(i[1]),c=x(o[1]),h=Math.pow(Math.sin(s/2),2)+Math.pow(Math.sin(a/2),2)*Math.cos(u)*Math.cos(c);return d(2*Math.atan2(Math.sqrt(h),Math.sqrt(1-h)),r)}function Gt(t){if(!t)throw new Error("geojson is required");switch(t.type){case"Feature":return Bt(t);case"FeatureCollection":return function(t){var e={type:"FeatureCollection"};return Object.keys(t).forEach(function(n){switch(n){case"type":case"features":return;default:e[n]=t[n]}}),e.features=t.features.map(function(t){return Bt(t)}),e}(t);case"Point":case"LineString":case"Polygon":case"MultiPoint":case"MultiLineString":case"MultiPolygon":case"GeometryCollection":return zt(t);default:throw new Error("unknown GeoJSON type")}}function Bt(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=kt(t.properties),e.geometry=zt(t.geometry),e}function kt(t){var e={};return t?(Object.keys(t).forEach(function(n){var r=t[n];"object"==typeof r?null===r?e[n]=null:r.length?e[n]=r.map(function(t){return t}):e[n]=kt(r):e[n]=r}),e):e}function zt(t){var e={type:t.type};return t.bbox&&(e.bbox=t.bbox),"GeometryCollection"===t.type?(e.geometries=t.geometries.map(function(t){return zt(t)}),e):(e.coordinates=jt(t.coordinates),e)}function jt(t){return"object"!=typeof t[0]?t.slice():t.map(function(t){return jt(t)})}function Xt(t,e){function n(t,e){e.length&&e.pop();for(var n=c[t<0?~t:t],r=0,i=n.length;r1)for(var s,a,u=1,c=i(r[0]);uc&&(a=r[0],r[0]=r[u],r[u]=a,c=s);return r})}}function Yt(t,e,n){for(var r,i=e+(n---e>>1);e=Math.abs(h)?c>0?o<=r&&r<=a:a<=r&&r<=o:h>0?s<=i&&i<=u:u<=i&&i<=s)}(n,i=e[a+1],r)||o.push(r);return o.push(i),o}function ne(t,e){var n=t.x-e.x,r=t.y-e.y;return n*n+r*r}function re(t,e,n){var r=e.x,i=e.y,o=n.x-r,s=n.y-i;if(0!==o||0!==s){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,s=t.y-i,o*o+s*s}function ie(t,e,n,r,i){for(var o,s=r,a=e+1;as&&(o=a,s=u)}s>r&&(o-e>1&&ie(t,e,o,r,i),i.push(t[o]),n-o>1&&ie(t,o,n,r,i))}function oe(t,e,n){if(t.length<=2)return t;var r=void 0!==e?e*e:1;return t=n?t:function(t,e){for(var n,r=t[0],i=[r],o=1,s=t.length;oe&&(i.push(n),r=n);return r!==n&&i.push(n),i}(t,r),t=function(t,e){var n=t.length-1,r=[t[0]];return ie(t,0,n,e,r),r.push(t[n]),r}(t,r)}function se(t,e,n){return oe(t.map(function(t){return{x:t[0],y:t[1],z:t[2]}}),e,n).map(function(t){return t.z?[t.x,t.y,t.z]:[t.x,t.y]})}function ae(t,e,n){return t.map(function(t){var r=t.map(function(t){return{x:t[0],y:t[1]}});if(r.length<4)throw new Error("invalid polygon");for(var i=oe(r,e,n).map(function(t){return[t.x,t.y]});!function(t){return!(t.length<3||3===t.length&&t[2][0]===t[0][0]&&t[2][1]===t[0][1])}(i);)i=oe(r,e-=.01*e,n).map(function(t){return[t.x,t.y]});return i[i.length-1][0]===i[0][0]&&i[i.length-1][1]===i[0][1]||i.push(i[0]),i})}function ue(t,e){if(e=e||{},!I(e))throw new Error("options is invalid");var n=e.resolution||1e4,r=e.sharpness||.85;if(!t)throw new Error("line is required");if(!b(n))throw new Error("resolution must be an number");if(!b(r))throw new Error("sharpness must be an number");for(var i=[],o=new Ns({points:J(t).coordinates.map(function(t){return{x:t[0],y:t[1]}}),duration:n,sharpness:r}),s=0;s=qt(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 pe(t,e,n,i){if(i=i||{},!I(i))throw new Error("options is invalid");var o=i.units,s=i.properties,a=X(t),u=x(a[0]),c=x(a[1]),h=x(n),l=y(e,o),p=Math.asin(Math.sin(c)*Math.cos(l)+Math.cos(c)*Math.sin(l)*Math.cos(h));return r([v(u+Math.atan2(Math.sin(h)*Math.sin(l)*Math.cos(c),Math.cos(l)-Math.sin(c)*Math.sin(p))),v(p)],s)}function fe(t,e,n){var r=(n=n||{}).steps||64,i=n.properties;if(!t)throw new Error("center is required");if(!e)throw new Error("radius is required");if("object"!=typeof n)throw new Error("options must be an object");if("number"!=typeof r)throw new Error("steps must be a number");r=r||64,i=i||t.properties||{};for(var s=[],a=0;a=r.next.y&&r.next.y!==r.y){var a=r.x+(o-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(a<=i&&a>s){if(s=a,a===i){if(o===r.y)return r;if(o===r.next.y)return r.next}n=r.x=r.x&&r.x>=h&&i!==r.x&&Ne(on.x)&&Le(r,t)&&(n=r,p=u),r=r.next;return n}(t,e)){var n=Pe(e,t);Ee(n,n.next)}}(c[i],n),n=Ee(n,n.next);return n}(t,e,o,n)),t.length>80*n){a=c=t[0],u=h=t[1];for(var g=n;gc&&(c=l),p>h&&(h=p);f=0!==(f=Math.max(c-a,h-u))?1/f:0}return we(o,s,n,a,u,f),s}function xe(t,e,n,r,i){var o,s;if(i===Ae(t,e,n,r)>0)for(o=e;o=e;o-=r)s=Oe(o,t[o],t[o+1],s);return s&&Se(s,s.next)&&(Re(s),s=s.next),s}function Ee(t,e){if(!t)return t;e||(e=t);var n,r=t;do{if(n=!1,r.steiner||!Se(r,r.next)&&0!==Ce(r.prev,r,r.next))r=r.next;else{if(Re(r),(r=e=r.prev)===r.next)break;n=!0}}while(n||r!==e);return e}function we(t,e,n,r,i,o,s){if(t){!s&&o&&function(t,e,n,r){var i=t;do{null===i.z&&(i.z=Ie(i.x,i.y,e,n,r)),i.prevZ=i.prev,i.nextZ=i.next,i=i.next}while(i!==t);i.prevZ.nextZ=null,i.prevZ=null,function(t){var e,n,r,i,o,s,a,u,c=1;do{for(n=t,t=null,o=null,s=0;n;){for(s++,r=n,a=0,e=0;e0||u>0&&r;)0!==a&&(0===u||!r||n.z<=r.z)?(i=n,n=n.nextZ,a--):(i=r,r=r.nextZ,u--),o?o.nextZ=i:t=i,i.prevZ=o,o=i;n=r}o.nextZ=null,c*=2}while(s>1)}(i)}(t,r,i,o);for(var a,u,c=t;t.prev!==t.next;)if(a=t.prev,u=t.next,o?function(t,e,n,r){var i=t.prev,o=t,s=t.next;if(Ce(i,o,s)>=0)return!1;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,l=Ie(a,u,e,n,r),p=Ie(c,h,e,n,r),f=t.nextZ;for(;f&&f.z<=p;){if(f!==t.prev&&f!==t.next&&Ne(i.x,i.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ce(f.prev,f,f.next)>=0)return!1;f=f.nextZ}f=t.prevZ;for(;f&&f.z>=l;){if(f!==t.prev&&f!==t.next&&Ne(i.x,i.y,o.x,o.y,s.x,s.y,f.x,f.y)&&Ce(f.prev,f,f.next)>=0)return!1;f=f.prevZ}return!0}(t,r,i,o):function(t){var e=t.prev,n=t,r=t.next;if(Ce(e,n,r)>=0)return!1;var i=t.next.next;for(;i!==t.prev;){if(Ne(e.x,e.y,n.x,n.y,r.x,r.y,i.x,i.y)&&Ce(i.prev,i,i.next)>=0)return!1;i=i.next}return!0}(t))e.push(a.i/n),e.push(t.i/n),e.push(u.i/n),Re(t),t=u.next,c=u.next;else if((t=u)===c){s?1===s?we(t=function(t,e,n){var r=t;do{var i=r.prev,o=r.next.next;!Se(i,o)&&Me(i,r,r.next,o)&&Le(i,o)&&Le(o,i)&&(e.push(i.i/n),e.push(r.i/n),e.push(o.i/n),Re(r),Re(r.next),r=t=o),r=r.next}while(r!==t);return r}(t,e,n),e,n,r,i,o,2):2===s&&function(t,e,n,r,i,o){var s=t;do{for(var a=s.next.next;a!==s.prev;){if(s.i!==a.i&&function(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!function(t,e){var n=t;do{if(n.i!==t.i&&n.next.i!==t.i&&n.i!==e.i&&n.next.i!==e.i&&Me(n,n.next,t,e))return!0;n=n.next}while(n!==t);return!1}(t,e)&&Le(t,e)&&Le(e,t)&&function(t,e){var n=t,r=!1,i=(t.x+e.x)/2,o=(t.y+e.y)/2;do{n.y>o!=n.next.y>o&&n.next.y!==n.y&&i<(n.next.x-n.x)*(o-n.y)/(n.next.y-n.y)+n.x&&(r=!r),n=n.next}while(n!==t);return r}(t,e)}(s,a)){var u=Pe(s,a);return s=Ee(s,s.next),u=Ee(u,u.next),we(s,e,n,r,i,o),void we(u,e,n,r,i,o)}a=a.next}s=s.next}while(s!==t)}(t,e,n,r,i,o):we(Ee(t),e,n,r,i,o,1);break}}}function be(t,e){return t.x-e.x}function Ie(t,e,n,r,i){return t=32767*(t-n)*i,e=32767*(e-r)*i,t=16711935&(t|t<<8),t=252645135&(t|t<<4),t=858993459&(t|t<<2),t=1431655765&(t|t<<1),e=16711935&(e|e<<8),e=252645135&(e|e<<4),e=858993459&(e|e<<2),e=1431655765&(e|e<<1),t|e<<1}function Ne(t,e,n,r,i,o,s,a){return(i-s)*(e-a)-(t-s)*(o-a)>=0&&(t-s)*(r-a)-(n-s)*(e-a)>=0&&(n-s)*(o-a)-(i-s)*(r-a)>=0}function Ce(t,e,n){return(e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y)}function Se(t,e){return t.x===e.x&&t.y===e.y}function Me(t,e,n,r){return!!(Se(t,e)&&Se(n,r)||Se(t,r)&&Se(n,e))||Ce(t,e,n)>0!=Ce(t,e,r)>0&&Ce(n,r,t)>0!=Ce(n,r,e)>0}function Le(t,e){return Ce(t.prev,t,t.next)<0?Ce(t,e,t.next)>=0&&Ce(t,t.prev,e)>=0:Ce(t,e,t.prev)<0||Ce(t,t.next,e)<0}function Pe(t,e){var n=new Te(t.i,t.x,t.y),r=new Te(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 Oe(t,e,n,r){var i=new Te(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 Re(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 Te(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 Ae(t,e,n,r){for(var i=0,o=e,s=n-r;o0&&(r+=t[i-1].length,n.holes.push(r))}return n}(t),n=Cs(e.vertices,e.holes,2),r=[],i=[];n.forEach(function(t,r){var o=n[r];i.push([e.vertices[2*o],e.vertices[2*o+1]])});for(var s=0;se?1:0})}function Ge(t,e,n,r,i){for(;r>n;){if(r-n>600){var o=r-n+1,s=e-n+1,a=Math.log(o),u=.5*Math.exp(2*a/3),c=.5*Math.sqrt(a*u*(o-u)/o)*(s-o/2<0?-1:1);Ge(t,e,Math.max(n,Math.floor(e-s*u/o+c)),Math.min(r,Math.floor(e+(o-s)*u/o+c)),i)}var h=t[e],l=n,p=r;for(Be(t,n,e),i(t[r],h)>0&&Be(t,n,r);l0;)p--}0===i(t[n],h)?Be(t,n,p):Be(t,++p,r),p<=e&&(n=p+1),e<=p&&(r=p-1)}}function Be(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function ke(t,e){if(!(this instanceof ke))return new ke(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 ze(t,e){je(t,0,t.children.length,e,t)}function je(t,e,n,r,i){i||(i=Ze(null)),i.minX=1/0,i.minY=1/0,i.maxX=-1/0,i.maxY=-1/0;for(var o,s=e;s=t.minX&&e.maxY>=t.minY}function Ze(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Ke(t,e,n,r,i){for(var o,s=[e,n];s.length;)(n=s.pop())-(e=s.pop())<=r||(qe(t,o=e+Math.ceil((n-e)/r/2)*r,e,n,i),s.push(e,o,o,n))}function Qe(t){var e=ke(t);return e.insert=function(t){if(Array.isArray(t)){var e=t;(t=$e(e)).bbox=e}else t.bbox=t.bbox?t.bbox:tn(t);return ke.prototype.insert.call(this,t)},e.load=function(t){var e=[];return Array.isArray(t)?t.forEach(function(t){var n=$e(t);n.bbox=t,e.push(n)}):O(t,function(t){t.bbox=t.bbox?t.bbox:tn(t),e.push(t)}),ke.prototype.load.call(this,e)},e.remove=function(t){if(Array.isArray(t)){var e=t;(t=$e(e)).bbox=e}return ke.prototype.remove.call(this,t)},e.clear=function(){return ke.prototype.clear.call(this)},e.search=function(t){return{type:"FeatureCollection",features:ke.prototype.search.call(this,this.toBBox(t))}},e.collides=function(t){return ke.prototype.collides.call(this,this.toBBox(t))},e.all=function(){return{type:"FeatureCollection",features:ke.prototype.all.call(this)}},e.toJSON=function(){return ke.prototype.toJSON.call(this)},e.fromJSON=function(t){return ke.prototype.fromJSON.call(this,t)},e.toBBox=function(t){var e;return e=t.bbox?t.bbox:Array.isArray(t)&&4===t.length?t:tn(t),{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}function $e(t){var e=[t[0],t[1]],n=[t[0],t[3]],r=[t[2],t[3]];return{type:"Feature",bbox:t,properties:{},geometry:{type:"Polygon",coordinates:[[e,[t[2],t[1]],r,n,e]]}}}function tn(t){var e=[1/0,1/0,-1/0,-1/0];return S(t,function(t){e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]i?n:i,r>o?r:o]}(t,r),n.push(i),r}),n}(n,t.properties);r.forEach(function(t){t.id=e.length,e.push(t)})})}(t,e)}),c(e)}function nn(t,n){var r={},i=[];if("LineString"===t.type&&(t=e(t)),"LineString"===n.type&&(n=e(n)),"Feature"===t.type&&"Feature"===n.type&&"LineString"===t.geometry.type&&"LineString"===n.geometry.type&&2===t.geometry.coordinates.length&&2===n.geometry.coordinates.length){var o=rn(t,n);return o&&i.push(o),c(i)}var s=Qe();return s.load(en(n)),O(en(t),function(t){O(s.search(t),function(e){var n=rn(t,e);if(n){var o=U(n).join(",");r[o]||(r[o]=!0,i.push(n))}})}),c(i)}function rn(t,e){var n=U(t),i=U(e);if(2!==n.length)throw new Error(" line1 must only contain 2 coordinates");if(2!==i.length)throw new Error(" line2 must only contain 2 coordinates");var o=n[0][0],s=n[0][1],a=n[1][0],u=n[1][1],c=i[0][0],h=i[0][1],l=i[1][0],p=i[1][1],f=(p-h)*(a-o)-(l-c)*(u-s),g=(l-c)*(s-h)-(p-h)*(o-c),d=(a-o)*(s-h)-(u-s)*(o-c);if(0===f)return null;var y=g/f,_=d/f;if(y>=0&&y<=1&&_>=0&&_<=1){return r([o+y*(a-o),s+y*(u-s)])}return null}function on(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var i=t.geometry?t.geometry.type:t.type;if("LineString"!==i&&"MultiLineString"!==i)throw new Error("lines must be LineString or MultiLineString");var o=r([1/0,1/0],{dist:1/0}),s=0;return F(t,function(t){for(var i=U(t),u=0;u0&&((_=y.features[0]).properties.dist=qt(e,_,n),_.properties.location=s+qt(c,_,n)),c.properties.dist180?-(360-i):i}function an(t,e){var n=x(t[1]),r=x(e[1]),i=x(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(v(Math.atan2(i,o))+360)%360}function un(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.units;if(!t)throw new Error("from point is required");if(!e)throw new Error("to point is required");var i=X(t),o=X(e);o[0]+=o[0]-i[0]>180?-360:i[0]-o[0]>180?360:0;return E(function(t,e,n){var r=n=void 0===n?Go:Number(n),i=t[1]*Math.PI/180,o=e[1]*Math.PI/180,s=o-i,a=Math.abs(e[0]-t[0])*Math.PI/180;a>Math.PI&&(a-=2*Math.PI);var u=Math.log(Math.tan(o/2+Math.PI/4)/Math.tan(i/2+Math.PI/4)),c=Math.abs(u)>1e-11?s/u:Math.cos(i);return Math.sqrt(s*s+c*c*a*a)*r}(i,o),"meters",r)}function cn(t,e){return ln(t,"mercator",e)}function hn(t,e){return ln(t,"wgs84",e)}function ln(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.mutate;if(!t)throw new Error("geojson is required");return Array.isArray(t)&&b(t[0])?t="mercator"===e?pn(t):fn(t):(!0!==r&&(t=Gt(t)),S(t,function(t){var n="mercator"===e?pn(t):fn(t);t[0]=n[0],t[1]=n[1]})),t}function pn(t){var e=Math.PI/180,n=20037508.342789244,r=[6378137*(Math.abs(t[0])<=180?t[0]:t[0]-360*function(t){return t<0?-1:t>0?1:0}(t[0]))*e,6378137*Math.log(Math.tan(.25*Math.PI+.5*t[1]*e))];return r[0]>n&&(r[0]=n),r[0]<-n&&(r[0]=-n),r[1]>n&&(r[1]=n),r[1]<-n&&(r[1]=-n),r}function fn(t){var e=180/Math.PI;return[t[0]*e/6378137,(.5*Math.PI-2*Math.atan(Math.exp(-t[1]/6378137)))*e]}function gn(t,n,i){if(i=i||{},!I(i))throw new Error("options is invalid");if(!t)throw new Error("pt is required");if(Array.isArray(t)?t=r(t):"Point"===t.type?t=e(t):H(t,"Point","point"),!n)throw new Error("line is required");Array.isArray(n)?n=a(n):"LineString"===n.type?n=e(n):H(n,"LineString","line");var o=1/0,s=t.geometry.coordinates;return G(n,function(t){var e=t.geometry.coordinates[0],n=t.geometry.coordinates[1],a=function(t,e,n,i){var o=i.mercator,s=!0!==o?qt(e,t,i):dn(e,t,i),a=m(!0!==o?ge(e,t):sn(e,t)),u=m(!0!==o?ge(e,n):sn(e,n)),c=Math.abs(a-u);if(c>90)return s;var h=(u+180)%360,l=m(!0!==o?ge(n,t):sn(n,t)),p=Math.abs(l-h);p>180&&(p=Math.abs(p-360));return p>90?!0!==o?qt(t,n,i):dn(t,n,i):!0!==o?s*Math.sin(x(c)):function(t,e,n,i){var o=0;(Math.abs(t[0])>=180||Math.abs(e[0])>=180||Math.abs(n[0])>=180)&&(o=t[0]>0||e[0]>0||n[0]>0?-180:180);var s=r(n),a=cn([t[0]+o,t[1]]),u=cn([e[0]+o,e[1]]),c=cn([n[0]+o,n[1]]),h=hn(function(t,e,n){var r=t[0],i=t[1],o=e[0],s=e[1],a=n[0],u=n[1],c=o-r,h=s-i,l=((a-r)*c+(u-i)*h)/(c*c+h*h);return[r+l*c,i+l*h]}(a,u,c));return 0!==o&&(h[0]-=o),un(s,h,i)}(e,n,t,i)}(s,e,n,i);o>a&&(o=a)}),o}function dn(t,e,n){var r=n.units,i=0;Math.abs(t[0])>=180&&(i=t[0]>0?-180:180),Math.abs(e[0])>=180&&(i=e[0]>0?-180:180);var o=cn([t[0]+i,t[1]]),s=cn([e[0]+i,e[1]]),a=function(t){return t*t},u=a(o[0]-s[0])+a(o[1]-s[1]);return E(Math.sqrt(u),"meters",r)}function yn(t){for(var n=function(t){if("FeatureCollection"!==t.type)return c("Feature"!==t.type?[e(t)]:[t]);return t}(t),i=de(n),o=!1,s=0;!o&&s0){e+=Math.abs(En(t[0]));for(var n=1;n2){for(s=0;s=h&&l===i.length-1);l++){if(h>e&&0===o.length){if(!(s=e-h))return o.push(i[l]),a(o);u=ge(i[l],i[l-1])-180,c=pe(i[l],s,u,r),o.push(c.geometry.coordinates)}if(h>=n)return(s=n-h)?(u=ge(i[l],i[l-1])-180,c=pe(i[l],s,u,r),o.push(c.geometry.coordinates),a(o)):(o.push(i[l]),a(o));if(h>=e&&o.push(i[l]),l===i.length-1)return a(o);h+=qt(i[l],i[l+1],r)}return a(i[i.length-1])}function Nn(t,e,n){var r=(n=n||{}).ignoreEndVertices;if(!I(n))throw new Error("invalid options");if(!t)throw new Error("pt is required");if(!e)throw new Error("line is required");for(var i=X(t),o=U(e),s=0;s=Math.abs(f)?p>0?s<=i&&i<=u:u<=i&&i<=s:f>0?a<=o&&o<=c:c<=o&&o<=a;if("start"===r)return Math.abs(p)>=Math.abs(f)?p>0?s0?a=Math.abs(f)?p>0?s<=i&&i0?a<=o&&o=Math.abs(f)?p>0?s0?ae[0])&&(!(t[2]e[1])&&!(t[3] is required");if("number"!=typeof n)throw new Error(" must be a number");if("number"!=typeof r)throw new Error(" must be a number");!1!==i&&void 0!==i||(t=JSON.parse(JSON.stringify(t)));var o=Math.pow(10,n);return S(t,function(t){!function(t,e,n){t.length>n&&t.splice(n,t.length);for(var r=0;r=0==e}function Tn(t,e){if(!t||!e)return!1;if(t.length!=e.length)return!1;for(var n=0,r=t.length;n1&&n.push(a(l)),c(n)}function Fn(t,e){if(!e.features.length)throw new Error("lines must contain features");if(1===e.features.length)return e.features[0];var n,r=1/0;return O(e,function(e){var i=on(e,t).properties.dist;ip&&g.push(pe(t,e,p,s).geometry.coordinates),a(g,h)}function Bn(t){var e=t%360;return e<0&&(e+=360),e}function kn(t,e){if(e=e||{},!I(e))throw new Error("options is invalid");var n=e.properties,r=K(t),i=U(t);if(n=n||t.properties||{},!i.length)throw new Error("polygon must contain coordinates");switch(r){case"Polygon":return zn(i,n);case"MultiPolygon":var o=[];return i.forEach(function(t){o.push(zn(t,n))}),c(o);default:throw new Error("geom "+r+" not supported")}}function zn(t,e){return t.length>1?h(t,e):a(t[0],e)}function jn(t,e){if(e=e||{},!I(e))throw new Error("options is invalid");var n=e.properties,r=e.autoComplete,i=e.orderCoords;if(!t)throw new Error("lines is required");r=void 0===r||r,i=void 0===i||i;switch(K(t)){case"FeatureCollection":case"GeometryCollection":var o=[];return(t.features?t.features:t.geometries).forEach(function(t){o.push(U(Xn(t,{},r,i)))}),p(o,n)}return Xn(t,n,r,i)}function Xn(t,e,n,r){e=e||t.properties||{};var i=U(t),s=K(t);if(!i.length)throw new Error("line must contain coordinates");switch(s){case"LineString":return n&&(i=Un(i)),o([i],e);case"MultiLineString":var u=[],c=0;return i.forEach(function(t){if(n&&(t=Un(t)),r){var e=function(t){var e=t[0],n=t[1],r=t[2],i=t[3];return Math.abs(e-r)*Math.abs(n-i)}(j(a(t)));e>c?(u.unshift(t),c=e):u.push(t)}else u.push(t)}),o(u,e);default:throw new Error("geometry type "+s+" is not supported")}}function Un(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 Yn(t,e,n){var r,i,o,s,a,u=t.length,c=Hn(t[0],e),h=[];for(n||(n=[]),r=1;re[2]&&(n|=2),t[1]e[3]&&(n|=8),n}function Wn(t,e){for(var n=[],r=0;r0&&(i[0][0]===i[i.length-1][0]&&i[0][1]===i[i.length-1][1]||i.push(i[0]),i.length>=4&&n.push(i))}return n}function Jn(t){return"[object Arguments]"===Object.prototype.toString.call(t)}function Zn(t,e,n){return n||(n={}),t===e||(t instanceof Date&&e instanceof Date?t.getTime()===e.getTime():!t||!e||"object"!=typeof t&&"object"!=typeof e?(n.strict,t===e):function(t,e,n){var r,i;if(Kn(t)||Kn(e))return!1;if(t.prototype!==e.prototype)return!1;if(Jn(t))return!!Jn(e)&&(t=zs.call(t),e=zs.call(e),Zn(t,e,n));if(Qn(t)){if(!Qn(e))return!1;if(t.length!==e.length)return!1;for(r=0;r=0;r--)if(o[r]!==s[r])return!1;for(r=o.length-1;r>=0;r--)if(i=o[r],!Zn(t[i],e[i],n))return!1;return typeof t==typeof e}(t,e,n))}function Kn(t){return null===t||void 0===t}function Qn(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]))}function $n(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.tolerance||0,i=[],o=Qe();o.load(en(t));var s;return G(e,function(t){var e=!1;O(o.search(t),function(n){if(!1===e){var i=U(t).sort(),o=U(n).sort();Zn(i,o)?(e=!0,s=s?tr(s,t):t):(0===r?Nn(i[0],n)&&Nn(i[1],n):on(n,i[0]).properties.dist<=r&&on(n,i[1]).properties.dist<=r)?(e=!0,s=s?tr(s,t):t):(0===r?Nn(o[0],t)&&Nn(o[1],t):on(t,o[0]).properties.dist<=r&&on(t,o[1]).properties.dist<=r)&&(s=s?tr(s,n):n)}}),!1===e&&s&&(i.push(s),s=void 0)}),s&&i.push(s),c(i)}function tr(t,e){var n=U(e),r=U(t),i=r[0],o=r[r.length-1],s=t.geometry.coordinates;return Zn(n[0],i)?s.unshift(n[1]):Zn(n[0],o)?s.push(n[1]):Zn(n[1],i)?s.unshift(n[0]):Zn(n[1],o)&&s.push(n[0]),t}function er(t){var e=t%360;return e<0&&(e+=360),e}function nr(t,e,n,i){if(i=i||{},!I(i))throw new Error("options is invalid");var o=i.units,s=i.properties;if(!t)throw new Error("origin is required");if(void 0===e||null===e)throw new Error("distance is required");if(void 0===n||null===n)throw new Error("bearing is required");if(!(e>=0))throw new Error("distance must be greater than 0");var a=E(e,o,"meters"),u=X(t),c=function(t,e,n,r){r=void 0===r?Go:Number(r);var i=e/r,o=t[0]*Math.PI/180,s=x(t[1]),a=x(n),u=i*Math.cos(a),c=s+u;Math.abs(c)>Math.PI/2&&(c=c>0?Math.PI-c:-Math.PI-c);var h=Math.log(Math.tan(c/2+Math.PI/4)/Math.tan(s/2+Math.PI/4)),l=Math.abs(h)>1e-11?u/h:Math.cos(s),p=i*Math.sin(a)/l;return[(180*(o+p)/Math.PI+540)%360-180,180*c/Math.PI]}(u,a,n);return c[0]+=c[0]-u[0]>180?-360:u[0]-c[0]>180?360:0,r(c,s)}function rr(t,e,n,r,i,o){for(var s=0;s0?function(t,e,n){return ir(t,e,n)<0}(e,a,i)||(i=a):n>0&&r<=0&&(function(t,e,n){return ir(t,e,n)>0}(e,a,o)||(o=a)),n=r}return[i,o]}function ir(t,e,n){return(e[0]-t[0])*(n[1]-t[1])-(n[0]-t[0])*(e[1]-t[1])}function or(t){if(!t)throw new Error("line is required");var e=t.geometry?t.geometry.type:t.type;if(!Array.isArray(t)&&"LineString"!==e)throw new Error("geometry must be a LineString");for(var n,r,i=U(t),o=0,s=1;s0}function sr(t,e){switch("Feature"===t.type?t.geometry.type:t.type){case"GeometryCollection":return A(t,function(t){sr(t,e)}),t;case"LineString":return ar(U(t),e),t;case"Polygon":return ur(U(t),e),t;case"MultiLineString":return U(t).forEach(function(t){ar(t,e)}),t;case"MultiPolygon":return U(t).forEach(function(t){ur(t,e)}),t;case"Point":case"MultiPoint":return t}}function ar(t,e){or(t)===e&&t.reverse()}function ur(t,e){or(t[0])!==e&&t[0].reverse();for(var n=1;ns?128:64,c|=ls?32:16,c|=ps?8:4;var g=+(c|=fs?2:1),d=0;if(17===c||18===c||33===c||34===c||38===c||68===c||72===c||98===c||102===c||132===c||136===c||137===c||152===c||153===c){var y=(h+l+p+f)/4;d=y>s?2:y0?(c=156,d=4):c=152:33===c?d>0?(c=139,d=4):c=137:72===c?d>0?(c=99,d=4):c=98:132===c&&(d>0?(c=39,d=4):c=38)}if(0!=c&&170!=c){var _,m,v,x,E,w,b,I;_=m=v=x=E=w=b=I=.5;var N=[];1===c?(v=1-lr(e,p,f),I=1-lr(e,h,f),N.push(La[c])):169===c?(v=lr(s,f,p),I=lr(s,f,h),N.push(La[c])):4===c?(w=1-lr(e,l,p),x=lr(e,f,p),N.push(Sa[c])):166===c?(w=lr(s,p,l),x=1-lr(s,p,f),N.push(Sa[c])):16===c?(E=lr(e,p,l),m=lr(e,h,l),N.push(Ca[c])):154===c?(E=1-lr(s,l,p),m=1-lr(s,l,h),N.push(Ca[c])):64===c?(b=lr(e,f,h),_=1-lr(e,l,h),N.push(Oa[c])):106===c?(b=1-lr(s,h,f),_=lr(s,h,l),N.push(Oa[c])):168===c?(x=lr(s,f,p),v=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),N.push(Ma[c]),N.push(La[c])):2===c?(x=1-lr(e,p,f),v=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),N.push(Ma[c]),N.push(La[c])):162===c?(E=lr(s,p,l),w=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),N.push(Ma[c]),N.push(La[c])):8===c?(E=1-lr(e,l,p),w=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),N.push(Ca[c]),N.push(Sa[c])):138===c?(E=1-lr(e,l,p),w=1-lr(s,l,p),_=1-lr(s,l,h),m=1-lr(e,l,h),N.push(Ca[c]),N.push(Sa[c])):32===c?(E=lr(s,p,l),w=lr(e,p,l),_=lr(e,h,l),m=lr(s,h,l),N.push(Ca[c]),N.push(Sa[c])):42===c?(I=1-lr(s,h,f),b=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l),N.push(Pa[c]),N.push(Oa[c])):128===c&&(I=lr(e,f,h),b=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h),N.push(Pa[c]),N.push(Oa[c])),5===c?(w=1-lr(e,l,p),I=1-lr(e,h,f),N.push(Sa[c])):165===c?(w=lr(s,p,l),I=lr(s,f,h),N.push(Sa[c])):20===c?(x=lr(e,f,p),m=lr(e,h,l),N.push(Ma[c])):150===c?(x=1-lr(s,p,f),m=1-lr(s,l,h),N.push(Ma[c])):80===c?(E=lr(e,p,l),b=lr(e,f,h),N.push(Ca[c])):90===c?(E=1-lr(s,l,p),b=1-lr(s,h,f),N.push(Ca[c])):65===c?(v=1-lr(e,p,f),_=1-lr(e,l,h),N.push(La[c])):105===c?(v=lr(s,f,p),_=lr(s,h,l),N.push(La[c])):160===c?(E=lr(s,p,l),w=lr(e,p,l),I=lr(e,f,h),b=lr(s,f,h),N.push(Ca[c]),N.push(Sa[c])):10===c?(E=1-lr(e,l,p),w=1-lr(s,l,p),I=1-lr(s,h,f),b=1-lr(e,h,f),N.push(Ca[c]),N.push(Sa[c])):130===c?(x=1-lr(e,p,f),v=1-lr(s,p,f),_=1-lr(s,l,h),m=1-lr(e,l,h),N.push(Ma[c]),N.push(La[c])):40===c?(x=lr(s,f,p),v=lr(e,f,p),_=lr(e,h,l),m=lr(s,h,l),N.push(Ma[c]),N.push(La[c])):101===c?(w=lr(s,p,l),_=lr(s,h,l),N.push(Sa[c])):69===c?(w=1-lr(e,l,p),_=1-lr(e,l,h),N.push(Sa[c])):149===c?(I=lr(s,f,h),m=1-lr(s,l,h),N.push(Pa[c])):21===c?(I=1-lr(e,h,f),m=lr(e,h,l),N.push(Pa[c])):86===c?(x=1-lr(s,p,f),b=1-lr(s,h,f),N.push(Ma[c])):84===c?(x=lr(e,f,p),b=lr(e,f,h),N.push(Ma[c])):89===c?(E=1-lr(s,l,p),v=lr(s,f,p),N.push(La[c])):81===c?(E=lr(e,p,l),v=1-lr(e,p,f),N.push(La[c])):96===c?(E=lr(s,p,l),w=lr(e,p,l),b=lr(e,f,h),_=lr(s,h,l),N.push(Ca[c]),N.push(Sa[c])):74===c?(E=1-lr(e,l,p),w=1-lr(s,l,p),b=1-lr(s,h,f),_=1-lr(e,l,h),N.push(Ca[c]),N.push(Sa[c])):24===c?(E=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),m=lr(e,h,l),N.push(Ca[c]),N.push(La[c])):146===c?(E=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),m=1-lr(s,l,h),N.push(Ca[c]),N.push(La[c])):6===c?(w=1-lr(e,l,p),x=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),N.push(Sa[c]),N.push(Ma[c])):164===c?(w=lr(s,p,l),x=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),N.push(Sa[c]),N.push(Ma[c])):129===c?(v=1-lr(e,p,f),I=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h),N.push(La[c]),N.push(Pa[c])):41===c?(v=lr(s,f,p),I=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l),N.push(La[c]),N.push(Pa[c])):66===c?(x=1-lr(e,p,f),v=1-lr(s,p,f),b=1-lr(s,h,f),_=1-lr(e,l,h),N.push(Ma[c]),N.push(La[c])):104===c?(x=lr(s,f,p),v=lr(e,f,p),b=lr(e,f,h),_=lr(s,h,l),N.push(La[c]),N.push(Ra[c])):144===c?(E=lr(e,p,l),I=lr(e,f,h),b=lr(s,f,h),m=1-lr(s,l,h),N.push(Ca[c]),N.push(Oa[c])):26===c?(E=1-lr(s,l,p),I=1-lr(s,h,f),b=1-lr(e,h,f),m=lr(e,h,l),N.push(Ca[c]),N.push(Oa[c])):36===c?(w=lr(s,p,l),x=lr(e,f,p),_=lr(e,h,l),m=lr(s,h,l),N.push(Sa[c]),N.push(Ma[c])):134===c?(w=1-lr(e,l,p),x=1-lr(s,p,f),_=1-lr(s,l,h),m=1-lr(e,l,h),N.push(Sa[c]),N.push(Ma[c])):9===c?(E=1-lr(e,l,p),w=1-lr(s,l,p),v=lr(s,f,p),I=1-lr(e,h,f),N.push(Ca[c]),N.push(Sa[c])):161===c?(E=lr(s,p,l),w=lr(e,p,l),v=1-lr(e,p,f),I=lr(s,f,h),N.push(Ca[c]),N.push(Sa[c])):37===c?(w=lr(s,p,l),I=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l),N.push(Sa[c]),N.push(Pa[c])):133===c?(w=1-lr(e,l,p),I=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h),N.push(Sa[c]),N.push(Pa[c])):148===c?(x=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),m=1-lr(s,l,h),N.push(Ma[c]),N.push(Oa[c])):22===c?(x=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),m=lr(e,h,l),N.push(Ma[c]),N.push(Oa[c])):82===c?(E=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),b=1-lr(s,h,f),N.push(Ca[c]),N.push(La[c])):88===c?(E=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),b=lr(e,f,h),N.push(Ca[c]),N.push(La[c])):73===c?(E=1-lr(e,l,p),w=1-lr(s,l,p),v=lr(s,f,p),_=1-lr(e,l,h),N.push(Ca[c]),N.push(Sa[c])):97===c?(E=lr(s,p,l),w=lr(e,p,l),v=1-lr(e,p,f),_=lr(s,h,l),N.push(Ca[c]),N.push(Sa[c])):145===c?(E=lr(e,p,l),v=1-lr(e,p,f),I=lr(s,f,h),m=1-lr(s,l,h),N.push(Ca[c]),N.push(Pa[c])):25===c?(E=1-lr(s,l,p),v=lr(s,f,p),I=1-lr(e,h,f),m=lr(e,h,l),N.push(Ca[c]),N.push(Pa[c])):70===c?(w=1-lr(e,l,p),x=1-lr(s,p,f),b=1-lr(s,h,f),_=1-lr(e,l,h),N.push(Sa[c]),N.push(Ma[c])):100===c?(w=lr(s,p,l),x=lr(e,f,p),b=lr(e,f,h),_=lr(s,h,l),N.push(Sa[c]),N.push(Ma[c])):34===c?(0===d?(E=1-lr(e,l,p),w=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h)):(E=lr(s,p,l),w=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l)),N.push(Ca[c]),N.push(Sa[c]),N.push(Pa[c]),N.push(Oa[c])):35===c?(4===d?(E=1-lr(e,l,p),w=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h)):(E=lr(s,p,l),w=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l)),N.push(Ca[c]),N.push(Sa[c]),N.push(La[c]),N.push(Oa[c])):136===c?(0===d?(E=lr(s,p,l),w=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l)):(E=1-lr(e,l,p),w=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h)),N.push(Ca[c]),N.push(Sa[c]),N.push(Pa[c]),N.push(Oa[c])):153===c?(0===d?(E=lr(e,p,l),v=1-lr(e,p,f),I=1-lr(e,h,f),m=lr(e,h,l)):(E=1-lr(s,l,p),v=lr(s,f,p),I=lr(s,f,h),m=1-lr(s,l,h)),N.push(Ca[c]),N.push(La[c])):102===c?(0===d?(w=1-lr(e,l,p),x=lr(e,f,p),b=lr(e,f,h),_=1-lr(e,l,h)):(w=lr(s,p,l),x=1-lr(s,p,f),b=1-lr(s,h,f),_=lr(s,h,l)),N.push(Sa[c]),N.push(Oa[c])):155===c?(4===d?(E=lr(e,p,l),v=1-lr(e,p,f),I=1-lr(e,h,f),m=lr(e,h,l)):(E=1-lr(s,l,p),v=lr(s,f,p),I=lr(s,f,h),m=1-lr(s,l,h)),N.push(Ca[c]),N.push(Pa[c])):103===c?(4===d?(w=1-lr(e,l,p),x=lr(e,f,p),b=lr(e,f,h),_=1-lr(e,l,h)):(w=lr(s,p,l),x=1-lr(s,p,f),b=1-lr(s,h,f),_=lr(s,h,l)),N.push(Sa[c]),N.push(Ma[c])):152===c?(0===d?(E=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),m=lr(e,h,l)):(E=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),m=1-lr(s,l,h)),N.push(Ca[c]),N.push(Ma[c]),N.push(La[c])):156===c?(4===d?(E=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),m=lr(e,h,l)):(E=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),m=1-lr(s,l,h)),N.push(Ca[c]),N.push(La[c]),N.push(Oa[c])):137===c?(0===d?(E=lr(s,p,l),w=lr(e,p,l),v=1-lr(e,p,f),I=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l)):(E=1-lr(e,l,p),w=1-lr(s,l,p),v=lr(s,f,p),I=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h)),N.push(Ca[c]),N.push(Sa[c]),N.push(La[c])):139===c?(4===d?(E=lr(s,p,l),w=lr(e,p,l),v=1-lr(e,p,f),I=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l)):(E=1-lr(e,l,p),w=1-lr(s,l,p),v=lr(s,f,p),I=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h)),N.push(Ca[c]),N.push(Sa[c]),N.push(Pa[c])):98===c?(0===d?(E=1-lr(e,l,p),w=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),b=lr(e,f,h),_=1-lr(e,l,h)):(E=lr(s,p,l),w=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),b=1-lr(s,h,f),_=lr(s,h,l)),N.push(Ca[c]),N.push(Sa[c]),N.push(Oa[c])):99===c?(4===d?(E=1-lr(e,l,p),w=1-lr(s,l,p),x=lr(s,f,p),v=lr(e,f,p),b=lr(e,f,h),_=1-lr(e,l,h)):(E=lr(s,p,l),w=lr(e,p,l),x=1-lr(e,p,f),v=1-lr(s,p,f),b=1-lr(s,h,f),_=lr(s,h,l)),N.push(Ca[c]),N.push(Sa[c]),N.push(La[c])):38===c?(0===d?(w=1-lr(e,l,p),x=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h)):(w=lr(s,p,l),x=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l)),N.push(Sa[c]),N.push(Pa[c]),N.push(Oa[c])):39===c?(4===d?(w=1-lr(e,l,p),x=lr(e,f,p),I=lr(e,f,h),b=lr(s,f,h),_=1-lr(s,l,h),m=1-lr(e,l,h)):(w=lr(s,p,l),x=1-lr(s,p,f),I=1-lr(s,h,f),b=1-lr(e,h,f),_=lr(e,h,l),m=lr(s,h,l)),N.push(Sa[c]),N.push(Ma[c]),N.push(Oa[c])):85===c&&(E=1,w=0,x=1,v=0,I=0,b=1,_=0,m=1),(_<0||_>1||m<0||m>1||E<0||E>1||x<0||x>1||I<0||I>1||b<0||b>1)&&console.log("MarchingSquaresJS-isoBands: "+c+" "+g+" "+h+","+l+","+p+","+f+" "+d+" "+_+" "+m+" "+E+" "+w+" "+x+" "+v+" "+I+" "+b),o.cells[a][u]={cval:c,cval_real:g,flipped:d,topleft:_,topright:m,righttop:E,rightbottom:w,bottomright:x,bottomleft:v,leftbottom:I,lefttop:b,edges:N}}}}}return o}(t,e,n);return Xs.polygons?(Xs.verbose&&console.log("MarchingSquaresJS-isoBands: returning single polygons for each grid cell"),u=function(t){var e=[],n=0;return t.cells.forEach(function(t,r){t.forEach(function(t,i){if(void 0!==t){var o=Aa[t.cval](t);"object"==typeof o&&pr(o)?"object"==typeof o[0]&&pr(o[0])?"object"==typeof o[0][0]&&pr(o[0][0])?o.forEach(function(t){t.forEach(function(t){t[0]+=i,t[1]+=r}),e[n++]=t}):(o.forEach(function(t){t[0]+=i,t[1]+=r}),e[n++]=o):console.log("MarchingSquaresJS-isoBands: bandcell polygon with malformed coordinates"):console.log("MarchingSquaresJS-isoBands: bandcell polygon with null coordinates")}})}),e}(c)):(Xs.verbose&&console.log("MarchingSquaresJS-isoBands: returning polygon paths for entire data grid"),u=function(t){for(var e=[],n=t.rows,r=t.cols,i=[],o=0;o0){var a=t.cells[o][s],u=function(t){if(t.edges.length>0){var e=t.edges[t.edges.length-1],n=t.cval_real;switch(e){case 0:return n&Ys?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 1:return n&Vs?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 2:return n&Vs?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topleft,1],x:0,y:-1,o:0};case 3:return n&Hs?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 4:return n&Ys?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 5:return n&Vs?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 6:return n&Vs?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[t.topright,1],x:0,y:-1,o:1};case 7:return n&Hs?{p:[t.topright,1],x:0,y:-1,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 8:return n&Vs?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.righttop],x:-1,y:0,o:1};case 9:return n&Hs?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 10:return n&Hs?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.righttop],x:-1,y:0,o:1};case 11:return n&Us?{p:[1,t.righttop],x:-1,y:0,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 12:return n&Vs?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 13:return n&Hs?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 14:return n&Hs?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[1,t.rightbottom],x:-1,y:0,o:0};case 15:return n&Us?{p:[1,t.rightbottom],x:-1,y:0,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 16:return n&Vs?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 17:return n&Us?{p:[t.bottomright,0],x:0,y:1,o:1}:{p:[0,t.lefttop],x:1,y:0,o:1};case 18:return n&Hs?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.bottomleft,0],x:0,y:1,o:0};case 19:return n&Us?{p:[t.bottomleft,0],x:0,y:1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 20:return n&Us?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.leftbottom],x:1,y:0,o:0};case 21:return n&Ys?{p:[0,t.leftbottom],x:1,y:0,o:0}:{p:[t.topright,1],x:0,y:-1,o:1};case 22:return n&Us?{p:[t.topleft,1],x:0,y:-1,o:0}:{p:[0,t.lefttop],x:1,y:0,o:1};case 23:return n&Ys?{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}(a),c=null,h=s,l=o;null!==u&&i.push([u.p[0]+h,u.p[1]+l]);do{if(null===(c=function(t,e,n,r){var i,o,s,a,u,c=t.cval;switch(e){case-1:switch(r){case 0:i=Sa[c],s=ra[c],a=ia[c],u=oa[c];break;default:i=Ca[c],s=ta[c],a=ea[c],u=na[c]}break;case 1:switch(r){case 0:i=Pa[c],s=da[c],a=ya[c],u=_a[c];break;default:i=Oa[c],s=pa[c],a=fa[c],u=ga[c]}break;default:switch(n){case-1:switch(r){case 0:i=Ra[c],s=Ws[c],a=Js[c],u=Zs[c];break;default:i=Ta[c],s=Ks[c],a=Qs[c],u=$s[c]}break;case 1:switch(r){case 0:i=La[c],s=sa[c],a=aa[c],u=ua[c];break;default:i=Ma[c],s=ca[c],a=ha[c],u=la[c]}}}{if(o=t.edges.indexOf(i),void 0===t.edges[o])return null;!function(t,e){delete t.edges[e];for(var n=e+1;n=n||h<0||h>=r||void 0===t.cells[l][h]){h-=c.x,l-=c.y;var p=function(t,e,n,r,i,o){var s=t.cells[n][e],a=s.cval_real,u=e+r,c=n+i,h=[],l=!1;for(;!l;){if(void 0===t.cells[c]||void 0===t.cells[c][u])if(c-=i,u-=r,s=t.cells[c][u],a=s.cval_real,-1===i)if(0===o)if(a&Hs)h.push([u,c]),r=-1,i=0,o=0;else{if(!(a&Vs)){h.push([u+s.bottomright,c]),r=0,i=1,o=1,l=!0;break}h.push([u+1,c]),r=1,i=0,o=0}else{if(!(a&Hs)){if(a&Vs){h.push([u+s.bottomright,c]),r=0,i=1,o=1,l=!0;break}h.push([u+s.bottomleft,c]),r=0,i=1,o=0,l=!0;break}h.push([u,c]),r=-1,i=0,o=0}else if(1===i)if(0===o){if(!(a&Ys)){if(a&Us){h.push([u+s.topleft,c+1]),r=0,i=-1,o=0,l=!0;break}h.push([u+s.topright,c+1]),r=0,i=-1,o=1,l=!0;break}h.push([u+1,c+1]),r=1,i=0,o=1}else h.push([u+1,c+1]),r=1,i=0,o=1;else if(-1===r)if(0===o){if(!(a&Us)){if(a&Hs){h.push([u,c+s.leftbottom]),r=1,i=0,o=0,l=!0;break}h.push([u,c+s.lefttop]),r=1,i=0,o=1,l=!0;break}h.push([u,c+1]),r=0,i=1,o=0}else{if(!(a&Us)){console.log("MarchingSquaresJS-isoBands: wtf");break}h.push([u,c+1]),r=0,i=1,o=0}else{if(1!==r){console.log("MarchingSquaresJS-isoBands: we came from nowhere!");break}if(0===o){if(!(a&Vs)){h.push([u+1,c+s.rightbottom]),r=-1,i=0,o=0,l=!0;break}h.push([u+1,c]),r=0,i=-1,o=1}else{if(!(a&Vs)){if(a&Ys){h.push([u+1,c+s.righttop]),r=-1,i=0,o=1;break}h.push([u+1,c+s.rightbottom]),r=-1,i=0,o=0,l=!0;break}h.push([u+1,c]),r=0,i=-1,o=1}}else if(s=t.cells[c][u],a=s.cval_real,-1===r)if(0===o)if(void 0!==t.cells[c-1]&&void 0!==t.cells[c-1][u])r=0,i=-1,o=1;else{if(!(a&Hs)){h.push([u+s.bottomright,c]),r=0,i=1,o=1,l=!0;break}h.push([u,c])}else{if(!(a&Us)){console.log("MarchingSquaresJS-isoBands: found entry from top at "+u+","+c);break}console.log("MarchingSquaresJS-isoBands: proceeding in x-direction!")}else if(1===r){if(0===o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[c+1]&&void 0!==t.cells[c+1][u])r=0,i=1,o=0;else{if(!(a&Ys)){h.push([u+s.topleft,c+1]),r=0,i=-1,o=0,l=!0;break}h.push([u+1,c+1]),r=1,i=0,o=1}}else if(-1===i){if(1!==o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[c][u+1])r=1,i=0,o=1;else{if(!(a&Vs)){h.push([u+1,c+s.righttop]),r=-1,i=0,o=1,l=!0;break}h.push([u+1,c]),r=0,i=-1,o=1}}else{if(1!==i){console.log("MarchingSquaresJS-isoBands: where did we came from???");break}if(0!==o){console.log("MarchingSquaresJS-isoBands: wtf");break}if(void 0!==t.cells[c][u-1])r=-1,i=0,o=0;else{if(!(a&Us)){h.push([u,c+s.leftbottom]),r=1,i=0,o=0,l=!0;break}h.push([u,c+1]),r=0,i=1,o=0}}if(u+=r,c+=i,u===e&&c===n)break}return{path:h,i:u,j:c,x:r,y:i,o:o}}(t,h,l,c.x,c.y,c.o);if(null===p)break;p.path.forEach(function(t){i.push(t)}),h=p.i,l=p.j,u=p}}while(void 0!==t.cells[l][h]&&t.cells[l][h].edges.length>0);e.push(i),i=[],t.cells[o][s].edges.length>0&&s--}return e}(c)),"function"==typeof Xs.successCallback&&Xs.successCallback(u),u}function lr(t,e,n){return(t-e)/(n-e)}function pr(t){return t.constructor.toString().indexOf("Array")>-1}function fr(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.pivot,i=n.mutate;if(!t)throw new Error("geojson is required");if(void 0===e||null===e||isNaN(e))throw new Error("angle is required");return 0===e?t:(r||(r=ye(t)),!1!==i&&void 0!==i||(t=Gt(t)),S(t,function(t){var n=sn(r,t)+e,i=un(r,t),o=U(nr(r,i,n));t[0]=o[0],t[1]=o[1]}),t)}function gr(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.origin,i=n.mutate;if(!t)throw new Error("geojson required");if("number"!=typeof e||0===e)throw new Error("invalid factor");var o=Array.isArray(r)||"object"==typeof r;return!0!==i&&(t=Gt(t)),"FeatureCollection"!==t.type||o?dr(t,e,r):(O(t,function(n,i){t.features[i]=dr(n,e,r)}),t)}function dr(t,e,n){var i="Point"===K(t);return n=function(t,e){void 0!==e&&null!==e||(e="centroid");if(Array.isArray(e)||"object"==typeof e)return X(e);var n=t.bbox?t.bbox:j(t),i=n[0],o=n[1],s=n[2],a=n[3];switch(e){case"sw":case"southwest":case"westsouth":case"bottomleft":return r([i,o]);case"se":case"southeast":case"eastsouth":case"bottomright":return r([s,o]);case"nw":case"northwest":case"westnorth":case"topleft":return r([i,a]);case"ne":case"northeast":case"eastnorth":case"topright":return r([s,a]);case"center":return de(t);case void 0:case null:case"centroid":return ye(t);default:throw new Error("invalid origin")}}(t,n),1===e||i?t:(S(t,function(t){var r=un(n,t),i=sn(n,t),o=U(nr(n,r*e,i));t[0]=o[0],t[1]=o[1],3===t.length&&(t[2]*=e)}),t)}function yr(t){var e=t[0],n=t[1];return[n[0]-e[0],n[1]-e[1]]}function _r(t,e){return t[0]*e[1]-e[0]*t[1]}function mr(t,e){return!function(t,e){return 0===_r(yr(t),yr(e))}(t,e)&&function(t,e){var n=t[0],r=yr(t),i=e[0],o=yr(e),s=_r(r,o);return function(t,e){return[t[0]+e[0],t[1]+e[1]]}(n,function(t,e){return[t*e[0],t*e[1]]}(_r(function(t,e){return[t[0]-e[0],t[1]-e[1]]}(i,n),o)/s,r))}(t,e)}function vr(t,e,n){var r=[],i=_(e,n),o=U(t),s=[];return o.forEach(function(t,e){if(e!==o.length-1){var n=function(t,e,n){var r=Math.sqrt((t[0]-e[0])*(t[0]-e[0])+(t[1]-e[1])*(t[1]-e[1])),i=t[0]+n*(e[1]-t[1])/r,o=e[0]+n*(e[1]-t[1])/r,s=t[1]+n*(t[0]-e[0])/r,a=e[1]+n*(t[0]-e[0])/r;return[[i,s],[o,a]]}(t,o[e+1],i);if(r.push(n),e>0){var a=r[e-1],u=mr(n,a);!1!==u&&(a[1]=u,n[0]=u),s.push(a[0]),e===o.length-2&&(s.push(n[0]),s.push(n[1]))}2===o.length&&(s.push(n[0]),s.push(n[1]))}}),a(s,t.properties)}function xr(t,e,n){var r=e[0]-t[0],i=e[1]-t[1],o=n[0]-e[0],s=n[1]-e[1];return Math.sign(r*s-o*i)}function Er(t,e){return e.geometry.coordinates[0].every(function(e){return Pt(r(e),t)})}function wr(t,e){for(var n=0;n=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]}(t.coordinates[n],t.coordinates[n+1],e.coordinates))return!0;return!1}function br(t,e){return nn(e,kn(t)).features.length>0}function Ir(t,e){return!(t[0]>e[0])&&(!(t[2]e[1])&&!(t[3]0}function Mr(t,e){for(var n=!1,i=!1,o=t.coordinates[0].length,s=0;s=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}function Tr(t,e,n){n=n||[];for(var r=0;r0)){if(o/=p,p<0){if(o0){if(o>l)return;o>h&&(h=o)}if(o=r-u,p||!(o<0)){if(o/=p,p<0){if(o>l)return;o>h&&(h=o)}else if(p>0){if(o0)){if(o/=f,f<0){if(o0){if(o>l)return;o>h&&(h=o)}if(o=i-c,f||!(o<0)){if(o/=f,f<0){if(o>l)return;o>h&&(h=o)}else if(f>0){if(o0||l<1)||(h>0&&(t[0]=[u+h*p,c+h*f]),l<1&&(t[1]=[u+l*p,c+l*f]),!0)}}}}}function Zr(t,e,n,r,i){var o=t[1];if(o)return!0;var s,a,u=t[0],c=t.left,h=t.right,l=c[0],p=c[1],f=h[0],g=h[1],d=(l+f)/2,y=(p+g)/2;if(g===p){if(d=r)return;if(l>f){if(u){if(u[1]>=i)return}else u=[d,n];o=[d,i]}else{if(u){if(u[1]1)if(l>f){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]=-gu)){var f=u*u+c*c,g=h*h+l*l,d=(l*f-c*g)/p,y=(u*g-h*f)/p,_=lu.pop()||new function(){jr(this),this.x=this.y=this.arc=this.site=this.cy=null};_.arc=t,_.site=i,_.x=d+s,_.y=(_.cy=y+a)+Math.sqrt(d*d+y*y),t.circle=_;for(var m=null,v=cu._;v;)if(_.yfu)a=a.L;else{if(!((i=o-function(t,e){var n=t.N;if(n)return si(n,e);var r=t.site;return r[1]===e?r[0]:1/0}(a,s))>fu)){r>-fu?(e=a.P,n=a):i>-fu?(e=a,n=a.N):e=n=a;break}if(!a.R){e=a;break}a=a.R}!function(t){uu[t.index]={site:t,halfedges:[]}}(t);var u=ni(t);if(au.insert(e,u),e||n){if(e===n)return ei(e),n=ni(e.site),au.insert(u,n),u.edge=n.edge=Vr(e.site,u.site),ti(e),void ti(n);if(n){ei(e),ei(n);var c=e.site,h=c[0],l=c[1],p=t[0]-h,f=t[1]-l,g=n.site,d=g[0]-h,y=g[1]-l,_=2*(p*y-f*d),m=p*p+f*f,v=d*d+y*y,x=[(y*m-f*v)/_+h,(p*v-d*m)/_+l];Wr(n.edge,c,g,x),u.edge=Vr(c,t,null,x),n.edge=Vr(t,g,null,x),ti(e),ti(n)}else u.edge=Vr(e.site,u.site)}}function si(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],c=u-e;if(!c)return a;var h=a-r,l=1/o-1/c,p=h/c;return l?(-p+Math.sqrt(p*p-2*l*(h*h/(-2*c)-u+c/2+i-o/2)))/l+r:(r+a)/2}function ai(t,e,n){return(t[0]-n[0])*(e[1]-t[1])-(t[0]-e[0])*(n[1]-t[1])}function ui(t,e){return e[1]-t[1]||e[0]-t[0]}function ci(t,e){var n,r,i,o=t.sort(ui).pop();for(hu=[],uu=new Array(t.length),au=new zr,cu=new zr;;)if(i=su,o&&(!i||o[1]fu||Math.abs(i[0][1]-i[1][1])>fu)||delete hu[o]}(s,a,u,c),function(t,e,n,r){var i,o,s,a,u,c,h,l,p,f,g,d,y=uu.length,_=!0;for(i=0;ifu||Math.abs(d-p)>fu)&&(u.splice(a,0,hu.push(Hr(s,f,Math.abs(g-t)fu?[t,Math.abs(l-t)fu?[Math.abs(p-r)fu?[n,Math.abs(l-n)fu?[Math.abs(p-e)=-270&&(d=-d),g<-180&&g>=-360&&(y=-y),"degrees"===s){var _=d*Math.cos(l)+y*Math.sin(l),m=y*Math.cos(l)-d*Math.sin(l);d=_,y=m}p.push([d+h[0],y+h[1]])}return p.push(p[0]),"degrees"===s?o([p],c):fr(o([p],c),a,{pivot:u})}function pi(t){var e=t*Math.PI/180;return Math.tan(e)}function fi(t,e){if(e=e||{},!I(e))throw new Error("options is invalid");var n=e.properties,i=e.weight;if(!t)throw new Error("geojson is required");var o=0,s=0,a=0;return A(t,function(t,e,n){var r=n[i];if(r=void 0===r||null===r?1:r,!b(r))throw new Error("weight value must be a number for feature index "+e);(r=Number(r))>0&&S(t,function(t){o+=t[0]*r,s+=t[1]*r,a+=r})}),r([o/a,s/a],n)}function gi(t,e,n,i){var o=n.properties.tolerance||.001,s=0,a=0,u=0,c=0;if(O(n,function(e){var n=e.properties.weight,r=void 0===n||null===n?1:n;if(r=Number(r),!b(r))throw new Error("weight value must be a number");if(r>0){c+=1;var i=r*qt(e,t);0===i&&(i=1);var o=r/i;s+=e.geometry.coordinates[0]*o,a+=e.geometry.coordinates[1]*o,u+=o}}),c<1)throw new Error("no features to measure");var h=s/u,l=a/u;return 1===c||0===i||Math.abs(h-e[0])0?t+n[e-1]:t}),h.forEach(function(t){t=2*t*Math.PI/h[h.length-1];var e=Math.random();u.push([e*i*Math.sin(t),e*i*Math.cos(t)])}),u[u.length-1]=u[0],u=u.map(function(t){return function(e){return[e[0]+t[0],e[1]+t[1]]}}(yi(n))),s.push(o([u]))}return c(s)}function vi(t,e){if(e=e||{},!I(e))throw new Error("options is invalid");var n=e.bbox,r=e.num_vertices,i=e.max_length,o=e.max_rotation;void 0!==t&&null!==t||(t=1),(!b(r)||r<2)&&(r=10),b(i)||(i=1e-4),b(o)||(o=Math.PI/8);for(var s=[],u=0;u1?t:null;case"MultiPolygon":var e=[];if(F(t,function(t){mn(t)>1&&e.push(t.geometry.coordinates)}),e.length)return{type:"MultiPolygon",coordinates:e}}}function Ui(){this.reset()}function Yi(t,e,n){var r=t.s=e+n,i=r-e,o=r-i;t.t=e-o+(n-i)}function Vi(t){return t>1?0:t<-1?zf:Math.acos(t)}function Hi(t){return t>1?jf:t<-1?-jf:Math.asin(t)}function Wi(){}function Ji(t,e){t&&rg.hasOwnProperty(t.type)&&rg[t.type](t,e)}function Zi(t,e,n){var r,i=-1,o=t.length-n;for(e.lineStart();++izf?t-Uf:t<-zf?t+Uf:t,e]}function so(t,e,n){return(t%=Uf)?e||n?og(uo(t),co(e,n)):uo(t):e||n?co(e,n):oo}function ao(t){return function(e,n){return e+=t,[e>zf?e-Uf:e<-zf?e+Uf:e,n]}}function uo(t){var e=ao(t);return e.invert=ao(-t),e}function co(t,e){function n(t,e){var n=Zf(e),a=Zf(t)*n,u=$f(t)*n,c=$f(e),h=c*r+a*i;return[Jf(u*o-h*s,a*r-c*i),Hi(h*o+u*s)]}var r=Zf(t),i=$f(t),o=Zf(e),s=$f(e);return n.invert=function(t,e){var n=Zf(e),a=Zf(t)*n,u=$f(t)*n,c=$f(e),h=c*o-u*s;return[Jf(u*o+c*s,a*r+h*i),Hi(h*r-a*i)]},n}function ho(t,e){(e=$i(e))[0]-=t,io(e);var n=Vi(-e[1]);return((-e[2]<0?-n:n)+Uf-kf)%Uf}function lo(t,e,n,r){this.x=t,this.z=e,this.o=n,this.e=r,this.v=!1,this.n=this.p=null}function po(t){if(e=t.length){for(var e,n,r=0,i=t[0];++r0)do{c.point(0===h||3===h?t:n,h>1?r:e)}while((h=(h+a+4)%4)!==l);else c.point(o[0],o[1])}function s(r,i){return Hf(r[0]-t)0?0:3:Hf(r[0]-n)0?2:1:Hf(r[1]-e)0?1:0:i>0?3:2}function a(t,e){return u(t.x,e.x)}function u(t,e){var n=s(t,1),r=s(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(s){function u(t,e){i(t,e)&&E.point(t,e)}function c(o,s){var a=i(o,s);if(l&&p.push([o,s]),v)f=o,g=s,d=a,v=!1,a&&(E.lineStart(),E.point(o,s));else if(a&&m)E.point(o,s);else{var u=[y=Math.max(fg,Math.min(pg,y)),_=Math.max(fg,Math.min(pg,_))],c=[o=Math.max(fg,Math.min(pg,o)),s=Math.max(fg,Math.min(pg,s))];ug(u,c,t,e,n,r)?(m||(E.lineStart(),E.point(u[0],u[1])),E.point(c[0],c[1]),a||E.lineEnd(),x=!1):a&&(E.lineStart(),E.point(o,s),x=!1)}y=o,_=s,m=a}var h,l,p,f,g,d,y,_,m,v,x,E=s,w=ag(),b={point:u,lineStart:function(){b.point=c,l&&l.push(p=[]),v=!0,m=!1,y=_=NaN},lineEnd:function(){h&&(c(f,g),d&&m&&w.rejoin(),h.push(w.result())),b.point=u,m&&E.lineEnd()},polygonStart:function(){E=w,h=[],l=[],x=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=l.length;nr&&(p-o)*(r-s)>(f-s)*(t-o)&&++e:f<=r&&(p-o)*(r-s)<(f-s)*(t-o)&&--e;return e}(),n=x&&e,i=(h=lg(h)).length;(n||i)&&(s.polygonStart(),n&&(s.lineStart(),o(null,null,1,s),s.lineEnd()),i&&hg(h,a,e,o,s),s.polygonEnd()),E=s,h=l=p=null}};return b}}function go(t){return t.length>1}function yo(t,e){return((t=t.x)[0]<0?t[1]-jf-kf:jf-t[1])-((e=e.x)[0]<0?e[1]-jf-kf:jf-e[1])}function _o(t){return function(e){var n=new mo;for(var r in t)n[r]=t[r];return n.stream=e,n}}function mo(){}function vo(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]),null!=o&&t.clipExtent(null),ig(n,t.stream(xg));var s=xg.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,c=+e[0][1]+(i-a*(s[1][1]+s[0][1]))/2;return null!=o&&t.clipExtent(o),t.scale(150*a).translate([u,c])}function xo(t){return function(t){function e(t){return t=c(t[0]*Vf,t[1]*Vf),[t[0]*d+s,a-t[1]*d]}function n(t,e){return t=o(t,e),[t[0]*d+s,a-t[1]*d]}function r(){c=og(u=so(x,E,w),o);var t=o(m,v);return s=y-t[0]*d,a=_+t[1]*d,i()}function i(){return f=g=null,e}var o,s,a,u,c,h,l,p,f,g,d=150,y=480,_=250,m=0,v=0,x=0,E=0,w=0,b=null,I=wg,N=null,C=dg,S=.5,M=Cg(n,S);e.stream=function(t){return f&&g===t?f:f=Sg(I(u,M(C(g=t))))},e.clipAngle=function(t){return arguments.length?(I=+t?bg(b=t*Vf,6*Vf):(b=null,wg),i()):b*Yf},e.clipExtent=function(t){return arguments.length?(C=null==t?(N=h=l=p=null,dg):fo(N=+t[0][0],h=+t[0][1],l=+t[1][0],p=+t[1][1]),i()):null==N?null:[[N,h],[l,p]]},e.scale=function(t){return arguments.length?(d=+t,r()):d},e.translate=function(t){return arguments.length?(y=+t[0],_=+t[1],r()):[y,_]},e.center=function(t){return arguments.length?(m=t[0]%360*Vf,v=t[1]%360*Vf,r()):[m*Yf,v*Yf]},e.rotate=function(t){return arguments.length?(x=t[0]%360*Vf,E=t[1]%360*Vf,w=t.length>2?t[2]%360*Vf:0,r()):[x*Yf,E*Yf,w*Yf]},e.precision=function(t){return arguments.length?(M=Cg(n,S=t*t),i()):tg(S)},e.fitExtent=function(t,n){return vo(e,t,n)},e.fitSize=function(t,n){return function(t,e,n){return vo(t,[[0,0],e],n)}(e,t,n)};return function(){return o=t.apply(this,arguments),e.invert=o.invert&&function(t){return(t=c.invert((t[0]-s)/d,(a-t[1])/d))&&[t[0]*Yf,t[1]*Yf]},r()}}(function(){return t})()}function Eo(t){return function(e,n){var r=Zf(e),i=Zf(n),o=t(r*i);return[o*i*$f(e),o*$f(n)]}}function wo(t){return function(e,n){var r=tg(e*e+n*n),i=t(r),o=$f(i),s=Zf(i);return[Jf(e*o,r*s),Hi(r&&n*o/r)]}}function bo(t,e){return[t,Qf(eg((jf+e)/2))]}function Io(t,e){return[Qf(eg((jf+e)/2)),-t]}function No(t,n,r,i){var o=t.properties||{},s="Feature"===t.type?t.geometry:t;if("GeometryCollection"===s.type){var a=[];return A(t,function(t){var e=No(t,n,r,i);e&&a.push(e)}),c(a)}var u,h=j(t),l=h[1]>50&&h[3]>50;u=l?{type:s.type,coordinates:So(s.coordinates,Lo(s))}:cn(s);var p=(new Nh).read(u),f=d(y(n,r),"meters"),g=yp.bufferOp(p,f);if(g=(new Ch).write(g),!Co(g.coordinates)){var _;return(_=l?{type:g.type,coordinates:Mo(g.coordinates,Lo(s))}:hn(g)).geometry?_:e(_,o)}}function Co(t){return Array.isArray(t[0])?Co(t[0]):isNaN(t[0])}function So(t,e){return"object"!=typeof t[0]?e(t):t.map(function(t){return So(t,e)})}function Mo(t,e){return"object"!=typeof t[0]?e.invert(t):t.map(function(t){return Mo(t,e)})}function Lo(t){var e=de(t).geometry.coordinates.reverse(),n=e.map(function(t){return-t});return Mg().center(e).rotate(n).scale(Go)}function Po(){for(var t=new Nh,e=t.read(JSON.stringify(arguments[0].geometry)),n=1;n=0&&(void 0===i||sm/2;P&&(L-=m/4);for(var O=[],R=[],T=0;T<6;T++){var A=2*Math.PI/6*T;O.push(Math.cos(A)),R.push(Math.sin(A))}for(var D=[],F=0;F<=C;F++)for(var q=0;q<=M;q++){var G=F%2==1;if((0!==q||!G)&&(0!==q||!P)){var B=F*E+a-S,k=q*w+u+L;if(G&&(k-=m/2),!0===i)(function(t,e,n,r,i,s){for(var a=[],u=0;u<6;u++){var c=[];c.push(t),c.push([t[0]+e*i[u],t[1]+n*s[u]]),c.push([t[0]+e*i[(u+1)%6],t[1]+n*s[(u+1)%6]]),c.push(t),a.push(o([c],r))}return a})([B,k],g/2,d/2,r,O,R).forEach(function(t){s?Oo(s,t)&&D.push(t):D.push(t)});else{var z=function(t,e,n,r,i,s){for(var a=[],u=0;u<6;u++){var c=t[0]+e*i[u],h=t[1]+n*s[u];a.push([c,h])}return a.push(a[0].slice()),o([a],r)}([B,k],g/2,d/2,r,O,R);s?Oo(s,z)&&D.push(z):D.push(z)}}}return c(D)}function Ao(t){if(t.features.length<=1)return t;var e=function(t){var e=Wo(),n=[];return F(t,function(t,e){var r=j(t);n.push({minX:r[0],minY:r[1],maxX:r[2],maxY:r[3],geojson:t,index:e})}),e.load(n),e}(t),n=[],r={};return F(t,function(t,i){if(r[i])return!0;for(e.remove({index:i},Do),r[i]=!0;;){var o=j(t),s=e.search({minX:o[0],minY:o[1],maxX:o[2],maxY:o[3]});if(s.length>0){var a=s.map(function(t){return r[t.index]=!0,e.remove({index:t.index},Do),t.geojson});a.push(t),t=Po.apply(this,a)}if(0===s.length)break}n.push(t)}),c(n)}function Do(t,e){return t.index===e.index}function Fo(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.properties,i=n.mask,s=[];if(null===e||void 0===e)throw new Error("cellSide is required");if(!b(e))throw new Error("cellSide is invalid");if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be array");if(4!==t.length)throw new Error("bbox must contain 4 numbers");if(i&&-1===["Polygon","MultiPolygon"].indexOf(K(i)))throw new Error("options.mask must be a (Multi)Polygon");for(var a=t[0],u=t[1],h=t[2],l=t[3],p=e/qt([a,u],[h,u],n)*(h-a),f=e/qt([a,u],[a,l],n)*(l-u),g=h-a,d=l-u,y=Math.floor(g/p),_=Math.floor(d/f),m=(d-_*f)/2,v=a+(g-y*p)/2,x=0;x=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=yt(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,at(n,this.toBBox),at(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},_splitRoot:function(t,e){this.data=yt([t,e]),this.data.height=t.height+1,this.data.leaf=!1,at(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,n){var r,i,o,s,a,u,c,h;for(u=c=1/0,r=e;r<=n-e;r++)s=function(t,e){var n=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,o-r)}(i=ut(t,0,r,this.toBBox),o=ut(t,r,n,this.toBBox)),a=pt(i)+pt(o),s=e;i--)o=t.children[i],ct(u,t.leaf?s(o):o),c+=ft(u);return c},_adjustParentBBoxes:function(t,e,n){for(var r=n;r>=0;r--)ct(e[r],t)},_condense:function(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children).splice(e.indexOf(t[n]),1):this.clear():at(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]+"};")}};var Jo=function(t,e,n){var r=t*e,i=Zo*t,o=i-(i-t),s=t-o,a=Zo*e,u=a-(a-e),c=e-u,h=s*c-(r-o*u-s*u-o*c);return n?(n[0]=h,n[1]=r,n):[h,r]},Zo=+(Math.pow(2,27)+1),Ko=function(t,e){var n=0|t.length,r=0|e.length;if(1===n&&1===r)return function(t,e){var n=t+e,r=n-t,i=t-(n-r)+(e-r);return i?[i,n]:[n]}(t[0],e[0]);var i,o,s=n+r,a=new Array(s),u=0,c=0,h=0,l=Math.abs,p=t[c],f=l(p),g=e[h],d=l(g);f=r?(i=p,(c+=1)=r?(i=p,(c+=1)>1;return["sum(",r(t.slice(0,e)),",",r(t.slice(e)),")"].join("")}function i(t){if(2===t.length)return[["sum(prod(",t[0][0],",",t[1][1],"),prod(-",t[0][1],",",t[1][0],"))"].join("")];for(var o=[],s=0;s0){if(o<=0)return s;r=i+o}else{if(!(i<0))return s;if(o>=0)return s;r=-(i+o)}var u=3.3306690738754716e-16*r;return s>=u||s<=-u?s:a(t,e,n)},function(t,e,n,r){var i=t[0]-r[0],o=e[0]-r[0],s=n[0]-r[0],a=t[1]-r[1],c=e[1]-r[1],h=n[1]-r[1],l=t[2]-r[2],p=e[2]-r[2],f=n[2]-r[2],g=o*h,d=s*c,y=s*a,_=i*h,m=i*c,v=o*a,x=l*(g-d)+p*(y-_)+f*(m-v),E=7.771561172376103e-16*((Math.abs(g)+Math.abs(d))*Math.abs(l)+(Math.abs(y)+Math.abs(_))*Math.abs(p)+(Math.abs(m)+Math.abs(v))*Math.abs(f));return x>E||-x>E?x:u(t,e,n,r)}];!function(){for(;c.length<=s;)c.push(o(c.length));for(var e=[],n=["slow"],r=0;r<=s;++r)e.push("a"+r),n.push("o"+r);var i=["function getOrientation(",e.join(),"){switch(arguments.length){case 0:case 1:return 0;"];for(r=2;r<=s;++r)i.push("case ",r,":return o",r,"(",e.slice(0,r).join(),");");i.push("}var s=new Array(arguments.length);for(var i=0;i1&&rs(t[o[c-2]],t[o[c-1]],u)<=0;)c-=1,o.pop();for(o.push(a),c=s.length;c>1&&rs(t[s[c-2]],t[s[c-1]],u)>=0;)c-=1,s.pop();s.push(a)}n=new Array(s.length+o.length-2);for(var h=0,l=(r=0,o.length);r0;--p)n[h++]=s[p];return n},rs=es[3],is=vt,os=vt;vt.prototype={push:function(t){this.data.push(t),this.length++,this._up(this.length-1)},pop:function(){if(0!==this.length){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}},is.default=os;var ss=function(t,e){for(var n=t[0],r=t[1],i=!1,o=0,s=e.length-1;or!=h>r&&n<(c-a)*(r-u)/(h-u)+a&&(i=!i)}return i},as=es[3],us=xt,cs=xt;us.default=cs;var hs=function(t){return t},ls=function(t){if(null==t)return hs;var e,n,r=t.scale[0],i=t.scale[1],o=t.translate[0],s=t.translate[1];return function(t,a){a||(e=n=0);var u=2,c=t.length,h=new Array(c);for(h[0]=(e+=t[0])*r+o,h[1]=(n+=t[1])*i+s;u=t)throw new Error("full hashmap");h=s[c=c+1&u]}return s[c]=r,a[c]=o,o},maybeSet:function(r,o){for(var c=e(r)&u,h=s[c],l=0;h!=i;){if(n(h,r))return a[c];if(++l>=t)throw new Error("full hashmap");h=s[c=c+1&u]}return s[c]=r,a[c]=o,o},get:function(r,o){for(var c=e(r)&u,h=s[c],l=0;h!=i;){if(n(h,r))return a[c];if(++l>=t)break;h=s[c=c+1&u]}return o},keys:function(){for(var t=[],e=0,n=s.length;e>7^vs[2]^vs[3])},Es=function(t){function e(t,e,n,r){if(p[n]!==t){p[n]=t;var i=f[n];if(i>=0){var o=g[n];i===e&&o===r||i===r&&o===e||(++y,d[n]=1)}else f[n]=e,g[n]=r}}function n(t){return xs(u[t])}function r(t,e){return ys(u[t],u[e])}var i,o,s,a,u=t.coordinates,c=t.lines,h=t.rings,l=function(){for(var t=ds(1.4*u.length,n,r,Int32Array,-1,Int32Array),e=new Int32Array(u.length),i=0,o=u.length;i=t)throw new Error("full hashset");u=o[a=a+1&s]}return o[a]=r,!0},has:function(r){for(var a=e(r)&s,u=o[a],c=0;u!=i;){if(n(u,r))return!0;if(++c>=t)break;u=o[a=a+1&s]}return!1},values:function(){for(var t=[],e=0,n=o.length;ea&&(a=e),nu&&(u=n)}function r(t){t.forEach(n)}function i(t){t.forEach(r)}var o=1/0,s=1/0,a=-1/0,u=-1/0,c={GeometryCollection:function(t){t.geometries.forEach(e)},Point:function(t){n(t.coordinates)},MultiPoint:function(t){t.coordinates.forEach(n)},LineString:function(t){r(t.arcs)},MultiLineString:function(t){t.arcs.forEach(r)},Polygon:function(t){t.arcs.forEach(r)},MultiPolygon:function(t){t.arcs.forEach(i)}};for(var h in t)e(t[h]);return a>=o&&u>=s?[o,s,a,u]:void 0}(t=function(t){var e,n={};for(e in t)n[e]=Vt(t[e]);return n}(t)),s=e>0&&o&&function(t,e,n){function r(t){return[Math.round((t[0]-c)*f),Math.round((t[1]-h)*g)]}function i(t,e){for(var n,r,i,o,s,a=-1,u=0,l=t.length,p=new Array(l);++at&&(e.push(r),n=i)}return e},Ns.prototype.vector=function(t){var e=this.pos(t+10),n=this.pos(t-10);return{angle:180*Math.atan2(e.y-n.y,e.x-n.x)/3.14,speed:Math.sqrt((n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y)+(n.z-e.z)*(n.z-e.z))}},Ns.prototype.pos=function(t){var e=t-this.delay;e<0&&(e=0),e>this.duration&&(e=this.duration-1);var n=e/this.duration;if(n>=1)return this.points[this.length-1];var r=Math.floor((this.points.length-1)*n);return function(t,e,n,r,i){var o=function(t){var e=t*t;return[e*t,3*e*(1-t),3*t*(1-t)*(1-t),(1-t)*(1-t)*(1-t)]}(t);return{x:i.x*o[0]+r.x*o[1]+n.x*o[2]+e.x*o[3],y:i.y*o[0]+r.y*o[1]+n.y*o[2]+e.y*o[3],z:i.z*o[0]+r.z*o[1]+n.z*o[2]+e.z*o[3]}}((this.length-1)*n-r,this.points[r],this.controls[r][1],this.controls[r+1][0],this.points[r+1])};var Cs=ve,Ss=ve;ve.deviation=function(t,e,n,r){var i=e&&e.length,o=i?e[0]*n:t.length,s=Math.abs(Ae(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},Cs.default=Ss,ke.prototype={all:function(){return this._all(this.data,[])},search:function(t){var e=this.data,n=[],r=this.toBBox;if(!Je(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=Ze(n.children.splice(o,n.children.length-o));s.height=n.height,s.leaf=n.leaf,ze(n,this.toBBox),ze(s,this.toBBox),e?t[e-1].children.push(s):this._splitRoot(n,s)},_splitRoot:function(t,e){this.data=Ze([t,e]),this.data.height=t.height+1,this.data.leaf=!1,ze(this.data,this.toBBox)},_chooseSplitIndex:function(t,e,n){var r,i,o,s,a,u,c,h;for(u=c=1/0,r=e;r<=n-e;r++)s=function(t,e){var n=Math.max(t.minX,e.minX),r=Math.max(t.minY,e.minY),i=Math.min(t.maxX,e.maxX),o=Math.min(t.maxY,e.maxY);return Math.max(0,i-n)*Math.max(0,o-r)}(i=je(t,0,r,this.toBBox),o=je(t,r,n,this.toBBox)),a=Ve(i)+Ve(o),s=e;i--)o=t.children[i],Xe(u,t.leaf?s(o):o),c+=He(u);return c},_adjustParentBBoxes:function(t,e,n){for(var r=n;r>=0;r--)Xe(e[r],t)},_condense:function(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children).splice(e.indexOf(t[n]),1):this.clear():ze(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]+"};")}};var Ms=Object.freeze({toMercator:cn,toWgs84:hn}),Ls=6378137,Ps=function(t,e,n){function r(t,n,r,i){var u=o[t][n],c=o[t][n+1],h=o[r][i],l=o[r][i+1],p=function(t,e,n,r){if(On(t,n)||On(t,r)||On(e,n)||On(r,n))return null;var i=t[0],o=t[1],s=e[0],a=e[1],u=n[0],c=n[1],h=r[0],l=r[1],p=(i-s)*(c-l)-(o-a)*(u-h);return 0===p?null:[((i*a-o*s)*(u-h)-(i-s)*(u*l-c*h))/p,((i*a-o*s)*(c-l)-(o-a)*(u*l-c*h))/p]}(u,c,h,l);if(null!==p){var f,g;if(f=c[0]!==u[0]?(p[0]-u[0])/(c[0]-u[0]):(p[1]-u[1])/(c[1]-u[1]),g=l[0]!==h[0]?(p[0]-h[0])/(l[0]-h[0]):(p[1]-h[1])/(l[1]-h[1]),!(f>=1||f<=0||g>=1||g<=0)){var d=p,y=!a[d];y&&(a[d]=!0),e?s.push(e(p,t,n,u,c,f,r,i,h,l,g,y)):s.push(p)}}}function i(t,e){var n,r,i,s,a=o[t][e],u=o[t][e+1];return a[0]1)for(e=0;ey[e.isect].coord?-1:1});for(f=[];N.length>0;){var P=N.pop(),O=P.isect,R=P.parent,T=P.winding,A=f.length,D=[y[O].coord],F=O;if(y[O].ringAndEdge1Walkable)var q=y[O].ringAndEdge1,G=y[O].nxtIsectAlongRingAndEdge1;else q=y[O].ringAndEdge2,G=y[O].nxtIsectAlongRingAndEdge2;for(;!Tn(y[O].coord,y[G].coord);){D.push(y[G].coord);var B=void 0;for(a=0;ap&&(d>h&&gh&&du&&(u=y)}var _=[];if(a&&u0&&Math.abs(x-n[v-1][0])>p){var E=parseFloat(n[v-1][0]),w=parseFloat(n[v-1][1]),b=parseFloat(n[v][0]),I=parseFloat(n[v][1]);if(E>-180&&E-180&&n[v-1][0]h&&E<180&&-180===b&&v+1h&&n[v-1][0]<180){m.push([180,n[v][1]]),v++,m.push([n[v][0],n[v][1]]);continue}if(Eh){var N=E;E=b,b=N;var C=w;w=I,I=C}if(E>h&&b=180&&Eh?180:-180,M]),(m=[]).push([n[v-1][0]>h?-180:180,M]),_.push(m)}else m=[],_.push(m);m.push([x,n[v][1]])}else m.push([n[v][0],n[v][1]])}}else{var L=[];_.push(L);for(var P=0;P=0&&i.coordinates[0]-t.coordinates[0]<0)return 1;if(r.coordinates[0]-t.coordinates[0]<0&&i.coordinates[0]-t.coordinates[0]>=0)return-1;if(r.coordinates[0]-t.coordinates[0]==0&&i.coordinates[0]-t.coordinates[0]==0)return r.coordinates[1]-t.coordinates[1]>=0||i.coordinates[1]-t.coordinates[1]>=0?r.coordinates[1]-i.coordinates[1]:i.coordinates[1]-r.coordinates[1];var o=xr(t.coordinates,r.coordinates,i.coordinates);if(o<0)return 1;if(o>0)return-1;return Math.pow(r.coordinates[0]-t.coordinates[0],2)+Math.pow(r.coordinates[1]-t.coordinates[1],2)-(Math.pow(i.coordinates[0]-t.coordinates[0],2)+Math.pow(i.coordinates[1]-t.coordinates[1],2))}),this.outerEdgesSorted=!0)},Da.prototype.getOuterEdges=function(){return this.sortOuterEdges(),this.outerEdges},Da.prototype.getOuterEdge=function(t){return this.sortOuterEdges(),this.outerEdges[t]},Da.prototype.addInnerEdge=function(t){this.innerEdges.push(t)};var Fa=function(t,e){this.from=t,this.to=e,this.next=void 0,this.label=void 0,this.symetric=void 0,this.ring=void 0,this.from.addOuterEdge(this),this.to.addInnerEdge(this)};Fa.prototype.getSymetric=function(){return this.symetric||(this.symetric=new Fa(this.to,this.from),this.symetric.symetric=this),this.symetric},Fa.prototype.deleteEdge=function(){this.from.removeOuterEdge(this),this.to.removeInnerEdge(this)},Fa.prototype.isEqual=function(t){return this.from.id===t.from.id&&this.to.id===t.to.id},Fa.prototype.toString=function(){return"Edge { "+this.from.id+" -> "+this.to.id+" }"},Fa.prototype.toLineString=function(){return a([this.from.coordinates,this.to.coordinates])},Fa.prototype.compareTo=function(t){return xr(t.from.coordinates,t.to.coordinates,this.to.coordinates)};var qa=function(){this.edges=[],this.polygon=void 0,this.envelope=void 0},Ga={length:{configurable:!0}};qa.prototype.push=function(t){this[this.edges.length]=t,this.edges.push(t),this.polygon=this.envelope=void 0},qa.prototype.get=function(t){return this.edges[t]},Ga.length.get=function(){return this.edges.length},qa.prototype.forEach=function(t){this.edges.forEach(t)},qa.prototype.map=function(t){return this.edges.map(t)},qa.prototype.some=function(t){return this.edges.some(t)},qa.prototype.isValid=function(){return!0},qa.prototype.isHole=function(){var t=this,e=this.edges.reduce(function(e,n,r){return n.from.coordinates[1]>t.edges[e].from.coordinates[1]&&(e=r),e},0),n=(0===e?this.length:e)-1,r=(e+1)%this.length,i=xr(this.edges[n].from.coordinates,this.edges[e].from.coordinates,this.edges[r].from.coordinates);return 0===i?this.edges[n].from.coordinates[0]>this.edges[r].from.coordinates[0]:i>0},qa.prototype.toMultiPoint=function(){return l(this.edges.map(function(t){return t.from.coordinates}))},qa.prototype.toPolygon=function(){if(this.polygon)return this.polygon;var t=this.edges.map(function(t){return t.from.coordinates});return t.push(this.edges[0].from.coordinates),this.polygon=o([t])},qa.prototype.getEnvelope=function(){return this.envelope?this.envelope:this.envelope=he(this.toPolygon())},qa.findEdgeRingContaining=function(t,e){var n,i,o=t.getEnvelope();return e.forEach(function(e){var s=e.getEnvelope();if(i&&(n=i.getEnvelope()),!function(t,e){var n=t.geometry.coordinates.map(function(t){return t[0]}),r=t.geometry.coordinates.map(function(t){return t[1]}),i=e.geometry.coordinates.map(function(t){return t[0]}),o=e.geometry.coordinates.map(function(t){return t[1]});return Math.max(null,n)===Math.max(null,i)&&Math.max(null,r)===Math.max(null,o)&&Math.min(null,n)===Math.min(null,i)&&Math.min(null,r)===Math.min(null,o)}(s,o)&&Er(s,o)){var a=t.map(function(t){return t.from.coordinates}).find(function(t){return!e.some(function(e){return function(t,e){return t[0]===e[0]&&t[1]===e[1]}(t,e.from.coordinates)})});a&&e.inside(r(a))&&(i&&!Er(n,s)||(i=e))}}),i},qa.prototype.inside=function(t){return Pt(t,this.toPolygon())},Object.defineProperties(qa.prototype,Ga);var Ba=function(){this.edges=[],this.nodes={}};Ba.fromGeoJson=function(t){!function(t){if(!t)throw new Error("No geojson passed");if("FeatureCollection"!==t.type&&"GeometryCollection"!==t.type&&"MultiLineString"!==t.type&&"LineString"!==t.type&&"Feature"!==t.type)throw new Error("Invalid input type '"+t.type+"'. Geojson must be FeatureCollection, GeometryCollection, LineString, MultiLineString or Feature")}(t);var e=new Ba;return F(t,function(t){H(t,"LineString","Graph::fromGeoJson"),M(t,function(t,n){if(t){var r=e.getNode(t),i=e.getNode(n);e.addEdge(r,i)}return n})}),e},Ba.prototype.getNode=function(t){var e=Da.buildId(t),n=this.nodes[e];return n||(n=this.nodes[e]=new Da(t)),n},Ba.prototype.addEdge=function(t,e){var n=new Fa(t,e),r=n.getSymetric();this.edges.push(n),this.edges.push(r)},Ba.prototype.deleteDangles=function(){var t=this;Object.keys(this.nodes).map(function(e){return t.nodes[e]}).forEach(function(e){return t._removeIfDangle(e)})},Ba.prototype._removeIfDangle=function(t){var e=this;if(t.innerEdges.length<=1){var n=t.getOuterEdges().map(function(t){return t.to});this.removeNode(t),n.forEach(function(t){return e._removeIfDangle(t)})}},Ba.prototype.deleteCutEdges=function(){var t=this;this._computeNextCWEdges(),this._findLabeledEdgeRings(),this.edges.forEach(function(e){e.label===e.symetric.label&&(t.removeEdge(e.symetric),t.removeEdge(e))})},Ba.prototype._computeNextCWEdges=function(t){var e=this;void 0===t?Object.keys(this.nodes).forEach(function(t){return e._computeNextCWEdges(e.nodes[t])}):t.getOuterEdges().forEach(function(e,n){t.getOuterEdge((0===n?t.getOuterEdges().length:n)-1).symetric.next=e})},Ba.prototype._computeNextCCWEdges=function(t,e){for(var n,r,i=t.getOuterEdges(),o=i.length-1;o>=0;--o){var s=i[o],a=s.symetric,u=void 0,c=void 0;s.label===e&&(u=s),a.label===e&&(c=a),u&&c&&(c&&(r=c),u&&(r&&(r.next=u,r=void 0),n||(n=u)))}r&&(r.next=n)},Ba.prototype._findLabeledEdgeRings=function(){var t=[],e=0;return this.edges.forEach(function(n){if(!(n.label>=0)){t.push(n);var r=n;do{r.label=e,r=r.next}while(!n.isEqual(r));e++}}),t},Ba.prototype.getEdgeRings=function(){var t=this;this._computeNextCWEdges(),this.edges.forEach(function(t){t.label=void 0}),this._findLabeledEdgeRings().forEach(function(e){t._findIntersectionNodes(e).forEach(function(n){t._computeNextCCWEdges(n,e.label)})});var e=[];return this.edges.forEach(function(n){n.ring||e.push(t._findEdgeRing(n))}),e},Ba.prototype._findIntersectionNodes=function(t){var e=[],n=t,r=function(){var r=0;n.from.getOuterEdges().forEach(function(e){e.label===t.label&&++r}),r>1&&e.push(n.from),n=n.next};do{r()}while(!t.isEqual(n));return e},Ba.prototype._findEdgeRing=function(t){var e=t,n=new qa;do{n.push(e),e.ring=n,e=e.next}while(!t.isEqual(e));return n},Ba.prototype.removeNode=function(t){var e=this;t.getOuterEdges().forEach(function(t){return e.removeEdge(t)}),t.innerEdges.forEach(function(t){return e.removeEdge(t)}),delete this.nodes[t.id]},Ba.prototype.removeEdge=function(t){this.edges=this.edges.filter(function(e){return!e.isEqual(t)}),t.deleteEdge()};var ka=mt(function(t,e){function n(t){var e=[];for(var n in t)e.push(n);return e}(t.exports="function"==typeof Object.keys?Object.keys:n).shim=n}),za=mt(function(t,e){function n(t){return"[object Arguments]"==Object.prototype.toString.call(t)}function r(t){return t&&"object"==typeof t&&"number"==typeof t.length&&Object.prototype.hasOwnProperty.call(t,"callee")&&!Object.prototype.propertyIsEnumerable.call(t,"callee")||!1}var i="[object Arguments]"==function(){return Object.prototype.toString.call(arguments)}();(e=t.exports=i?n:r).supported=n,e.unsupported=r}),ja=mt(function(t){function e(t){return null===t||void 0===t}function n(t){return!(!t||"object"!=typeof t||"number"!=typeof t.length)&&("function"==typeof t.copy&&"function"==typeof t.slice&&!(t.length>0&&"number"!=typeof t[0]))}var r=Array.prototype.slice,i=t.exports=function(t,o,s){return s||(s={}),t===o||(t instanceof Date&&o instanceof Date?t.getTime()===o.getTime():!t||!o||"object"!=typeof t&&"object"!=typeof o?s.strict?t===o:t==o:function(t,o,s){var a,u;if(e(t)||e(o))return!1;if(t.prototype!==o.prototype)return!1;if(za(t))return!!za(o)&&(t=r.call(t),o=r.call(o),i(t,o,s));if(n(t)){if(!n(o))return!1;if(t.length!==o.length)return!1;for(a=0;a=0;a--)if(c[a]!=h[a])return!1;for(a=c.length-1;a>=0;a--)if(u=c[a],!i(t[u],o[u],s))return!1;return typeof t==typeof o}(t,o,s))}}),Xa=function(t){this.precision=t&&t.precision?t.precision:17,this.direction=!(!t||!t.direction)&&t.direction,this.pseudoNode=!(!t||!t.pseudoNode)&&t.pseudoNode,this.objectComparator=t&&t.objectComparator?t.objectComparator:function(t,e){return ja(t,e,{strict:!0})}};Xa.prototype.compare=function(t,e){if(t.type!==e.type||!Or(t,e))return!1;switch(t.type){case"Point":return this.compareCoord(t.coordinates,e.coordinates);case"LineString":return this.compareLine(t.coordinates,e.coordinates,0,!1);case"Polygon":return this.comparePolygon(t,e);case"Feature":return this.compareFeature(t,e);default:if(0===t.type.indexOf("Multi")){var n=this,r=Pr(t),i=Pr(e);return r.every(function(t){return this.some(function(e){return n.compare(t,e)})},i)}}return!1},Xa.prototype.compareCoord=function(t,e){if(t.length!==e.length)return!1;for(var n=0;n=0&&(n=[].concat(t.slice(r,t.length),t.slice(1,r+1))),n},Xa.prototype.comparePath=function(t,e){var n=this;return t.every(function(t,e){return n.compareCoord(t,this[e])},e)},Xa.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(t){return this.some(function(e){return i.compareLine(t,e,1,!0)})},r)}return!1},Xa.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)},Xa.prototype.compareBBox=function(t,e){return!!(!t.bbox&&!e.bbox||t.bbox&&e.bbox&&this.compareCoord(t.bbox,e.bbox))},Xa.prototype.removePseudo=function(t){return t};var Ua=Xa,Ya=mt(function(t){function e(t,e,n,r){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(t,e,n,r)}e.prototype.run=function(t,e,n,r){this._init(t,e,n,r);for(var i=0;i=this.minPts&&(e=this._mergeArrays(e,i))}1!==this._assigned[r]&&this._addToCluster(r,t)}},e.prototype._addToCluster=function(t,e){this.clusters[e].push(t),this._assigned[t]=1},e.prototype._regionQuery=function(t){for(var e=[],n=0;n0){for(u=0;u=0);return t},e.prototype.assign=function(){for(var t,e=!1,n=this.dataset.length,r=0;ri&&(n=r):e=this.minPts)return n}},e.prototype._regionQuery=function(t,e){e=e||this.epsilon;for(var n=[],r=0,i=this.dataset.length;r0;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)];o&&s.join("_");for(r.push(s);r.length0,f=[];if(n)i="kmrand"==n?tu(t,e):"kmpp"==n?eu(t,e):n;else for(var g={};i.length0;){var u=s.pop();if(u===n)return Dr(u);u.closed=!0;for(var c=t.neighbors(u),h=0,l=c.length;h0&&(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)=a)return null;var u=t-i.site[0],c=e-i.site[1],h=u*u+c*c;do{i=o.cells[r=s],s=null,i.halfedges.forEach(function(n){var r=o.edges[n],a=r.left;if(a!==i.site&&a||(a=r.right)){var u=t-a[0],c=e-a[1],l=u*u+c*c;le.x?1:this.ye.y?1:0},Nu.prototype.clone=function(){},Nu.prototype.copy=function(){return new Nu(this)},Nu.prototype.toString=function(){return"("+this.x+", "+this.y+", "+this.z+")"},Nu.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)},Nu.prototype.distance=function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)},Nu.prototype.hashCode=function(){var t=17;return t=37*t+Nu.hashCode(this.x),t=37*t+Nu.hashCode(this.y)},Nu.prototype.setCoordinate=function(t){this.x=t.x,this.y=t.y,this.z=t.z},Nu.prototype.interfaces_=function(){return[wu,bu,Mi]},Nu.prototype.getClass=function(){return Nu},Nu.hashCode=function(){if(1===arguments.length){var t=arguments[0],e=xu.doubleToLongBits(t);return Math.trunc((e^e)>>>32)}},Cu.DimensionalComparator.get=function(){return Su},Cu.serialVersionUID.get=function(){return 0x5cbf2c235c7e5800},Cu.NULL_ORDINATE.get=function(){return xu.NaN},Cu.X.get=function(){return 0},Cu.Y.get=function(){return 1},Cu.Z.get=function(){return 2},Object.defineProperties(Nu,Cu);var Su=function(t){if(this._dimensionsToTest=2,0===arguments.length);else if(1===arguments.length){var e=arguments[0];if(2!==e&&3!==e)throw new vu("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}};Su.prototype.compare=function(t,e){var n=t,r=e,i=Su.compare(n.x,r.x);if(0!==i)return i;var o=Su.compare(n.y,r.y);if(0!==o)return o;if(this._dimensionsToTest<=2)return 0;return Su.compare(n.z,r.z)},Su.prototype.interfaces_=function(){return[Iu]},Su.prototype.getClass=function(){return Su},Su.compare=function(t,e){return te?1:xu.isNaN(t)?xu.isNaN(e)?0:-1:xu.isNaN(e)?1:0};var Mu=function(){};Mu.prototype.create=function(){},Mu.prototype.interfaces_=function(){return[]},Mu.prototype.getClass=function(){return Mu};var Lu=function(){},Pu={INTERIOR:{configurable:!0},BOUNDARY:{configurable:!0},EXTERIOR:{configurable:!0},NONE:{configurable:!0}};Lu.prototype.interfaces_=function(){return[]},Lu.prototype.getClass=function(){return Lu},Lu.toLocationSymbol=function(t){switch(t){case Lu.EXTERIOR:return"e";case Lu.BOUNDARY:return"b";case Lu.INTERIOR:return"i";case Lu.NONE:return"-"}throw new vu("Unknown location value: "+t)},Pu.INTERIOR.get=function(){return 0},Pu.BOUNDARY.get=function(){return 1},Pu.EXTERIOR.get=function(){return 2},Pu.NONE.get=function(){return-1},Object.defineProperties(Lu,Pu);var Ou=function(t,e){return t.interfaces_&&t.interfaces_().indexOf(e)>-1},Ru=function(){},Tu={LOG_10:{configurable:!0}};Ru.prototype.interfaces_=function(){return[]},Ru.prototype.getClass=function(){return Ru},Ru.log10=function(t){var e=Math.log(t);return xu.isInfinite(e)?e:xu.isNaN(e)?e:e/Ru.LOG_10},Ru.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}},Ru.wrap=function(t,e){return t<0?e- -t%e:t%e},Ru.max=function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2],r=t;return e>r&&(r=e),n>r&&(r=n),r}if(4===arguments.length){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}},Ru.average=function(t,e){return(t+e)/2},Tu.LOG_10.get=function(){return Math.log(10)},Object.defineProperties(Ru,Tu);var Au=function(t){this.str=t};Au.prototype.append=function(t){this.str+=t},Au.prototype.setCharAt=function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)},Au.prototype.toString=function(t){return this.str};var Du=function(t){this.value=t};Du.prototype.intValue=function(){return this.value},Du.prototype.compareTo=function(t){return this.valuet?1:0},Du.isNaN=function(t){return Number.isNaN(t)};var Fu=function(){};Fu.isWhitespace=function(t){return t<=32&&t>=0||127===t},Fu.toUpperCase=function(t){return t.toUpperCase()};var qu=function t(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var e=arguments[0];this.init(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){var r=arguments[0];t.call(this,t.parse(r))}}else if(2===arguments.length){var i=arguments[0],o=arguments[1];this.init(i,o)}},Gu={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}};qu.prototype.le=function(t){return(this._hi9?(h=!0,l="9"):l="0"+c,s.append(l),n=n.subtract(qu.valueOf(c)).multiply(qu.TEN),h&&n.selfAdd(qu.TEN);var p=!0,f=qu.magnitude(n._hi);if(f<0&&Math.abs(f)>=a-u&&(p=!1),!p)break}return e[0]=r,s.toString()},qu.prototype.sqr=function(){return this.multiply(this)},qu.prototype.doubleValue=function(){return this._hi+this._lo},qu.prototype.subtract=function(){if(arguments[0]instanceof qu){var t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){var e=arguments[0];return this.add(-e)}},qu.prototype.equals=function(){if(1===arguments.length){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}},qu.prototype.isZero=function(){return 0===this._hi&&0===this._lo},qu.prototype.selfSubtract=function(){if(arguments[0]instanceof qu){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e,0)}},qu.prototype.getSpecialNumberString=function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null},qu.prototype.min=function(t){return this.le(t)?this:t},qu.prototype.selfDivide=function(){if(1===arguments.length){if(arguments[0]instanceof qu){var t=arguments[0];return this.selfDivide(t._hi,t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfDivide(e,0)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1],i=null,o=null,s=null,a=null,u=null,c=null,h=null,l=null;return u=this._hi/n,c=qu.SPLIT*u,i=c-u,l=qu.SPLIT*n,i=c-i,o=u-i,s=l-n,h=u*n,s=l-s,a=n-s,l=i*s-h+i*a+o*s+o*a,c=(this._hi-h-l+this._lo-u*r)/n,l=u+c,this._hi=l,this._lo=u-l+c,this}},qu.prototype.dump=function(){return"DD<"+this._hi+", "+this._lo+">"},qu.prototype.divide=function(){if(arguments[0]instanceof qu){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=qu.SPLIT*o)-(e=s-o)),u=e*(r=(u=qu.SPLIT*t._hi)-(r=u-t._hi))-(a=o*t._hi)+e*(i=t._hi-r)+n*r+n*i,s=(this._hi-a-u+this._lo-o*t._lo)/t._hi;return new qu(u=o+s,o-u+s)}if("number"==typeof arguments[0]){var c=arguments[0];return xu.isNaN(c)?qu.createNaN():qu.copy(this).selfDivide(c,0)}},qu.prototype.ge=function(t){return(this._hi>t._hi||this._hi===t._hi)&&this._lo>=t._lo},qu.prototype.pow=function(t){if(0===t)return qu.valueOf(1);var e=new qu(this),n=qu.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},qu.prototype.ceil=function(){if(this.isNaN())return qu.NaN;var t=Math.ceil(this._hi),e=0;return t===this._hi&&(e=Math.ceil(this._lo)),new qu(t,e)},qu.prototype.compareTo=function(t){var e=t;return this._hie._hi?1:this._loe._lo?1:0},qu.prototype.rint=function(){if(this.isNaN())return this;return this.add(.5).floor()},qu.prototype.setValue=function(){if(arguments[0]instanceof qu){var t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){var e=arguments[0];return this.init(e),this}},qu.prototype.max=function(t){return this.ge(t)?this:t},qu.prototype.sqrt=function(){if(this.isZero())return qu.valueOf(0);if(this.isNegative())return qu.NaN;var t=1/Math.sqrt(this._hi),e=this._hi*t,n=qu.valueOf(e),r=this.subtract(n.sqr())._hi*(.5*t);return n.add(r)},qu.prototype.selfAdd=function(){if(1===arguments.length){if(arguments[0]instanceof qu){var t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){var e=arguments[0],n=null,r=null,i=null,o=null,s=null,a=null;return i=this._hi+e,s=i-this._hi,o=i-s,o=e-s+(this._hi-o),a=o+this._lo,n=i+a,r=a+(i-n),this._hi=n+r,this._lo=r+(n-this._hi),this}}else if(2===arguments.length){var u=arguments[0],c=arguments[1],h=null,l=null,p=null,f=null,g=null,d=null,y=null;f=this._hi+u,l=this._lo+c,g=f-(d=f-this._hi),p=l-(y=l-this._lo);var _=(h=f+(d=(g=u-d+(this._hi-g))+l))+(d=(p=c-y+(this._lo-p))+(d+(f-h))),m=d+(h-_);return this._hi=_,this._lo=m,this}},qu.prototype.selfMultiply=function(){if(1===arguments.length){if(arguments[0]instanceof qu){var t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if("number"==typeof arguments[0]){var e=arguments[0];return this.selfMultiply(e,0)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1],i=null,o=null,s=null,a=null,u=null,c=null;i=(u=qu.SPLIT*this._hi)-this._hi,c=qu.SPLIT*n,i=u-i,o=this._hi-i,s=c-n;var h=(u=this._hi*n)+(c=i*(s=c-s)-u+i*(a=n-s)+o*s+o*a+(this._hi*r+this._lo*n)),l=c+(i=u-h);return this._hi=h,this._lo=l,this}},qu.prototype.selfSqr=function(){return this.selfMultiply(this)},qu.prototype.floor=function(){if(this.isNaN())return qu.NaN;var t=Math.floor(this._hi),e=0;return t===this._hi&&(e=Math.floor(this._lo)),new qu(t,e)},qu.prototype.negate=function(){return this.isNaN()?this:new qu(-this._hi,-this._lo)},qu.prototype.clone=function(){},qu.prototype.multiply=function(){if(arguments[0]instanceof qu){var t=arguments[0];return t.isNaN()?qu.createNaN():qu.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var e=arguments[0];return xu.isNaN(e)?qu.createNaN():qu.copy(this).selfMultiply(e,0)}},qu.prototype.isNaN=function(){return xu.isNaN(this._hi)},qu.prototype.intValue=function(){return Math.trunc(this._hi)},qu.prototype.toString=function(){var t=qu.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()},qu.prototype.toStandardNotation=function(){var t=this.getSpecialNumberString();if(null!==t)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."+qu.stringOfChar("0",-r)+n;else if(-1===n.indexOf(".")){var o=r-n.length;i=n+qu.stringOfChar("0",o)+".0"}return this.isNegative()?"-"+i:i},qu.prototype.reciprocal=function(){var t=null,e=null,n=null,r=null,i=null,o=null,s=null,a=null;e=(i=1/this._hi)-(t=(o=qu.SPLIT*i)-(t=o-i)),n=(a=qu.SPLIT*this._hi)-this._hi;var u=i+(o=(1-(s=i*this._hi)-(a=t*(n=a-n)-s+t*(r=this._hi-n)+e*n+e*r)-i*this._lo)/this._hi);return new qu(u,i-u+o)},qu.prototype.toSciNotation=function(){if(this.isZero())return qu.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var e=new Array(1).fill(null),n=this.extractSignificantDigits(!1,e),r=qu.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===n.charAt(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},qu.prototype.abs=function(){return this.isNaN()?qu.NaN:this.isNegative()?this.negate():new qu(this)},qu.prototype.isPositive=function(){return(this._hi>0||0===this._hi)&&this._lo>0},qu.prototype.lt=function(t){return(this._hit._hi||this._hi===t._hi)&&this._lo>t._lo},qu.prototype.isNegative=function(){return(this._hi<0||0===this._hi)&&this._lo<0},qu.prototype.trunc=function(){return this.isNaN()?qu.NaN:this.isPositive()?this.floor():this.ceil()},qu.prototype.signum=function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0},qu.prototype.interfaces_=function(){return[Mi,wu,bu]},qu.prototype.getClass=function(){return qu},qu.sqr=function(t){return qu.valueOf(t).selfMultiply(t)},qu.valueOf=function(){if("string"==typeof arguments[0]){var t=arguments[0];return qu.parse(t)}if("number"==typeof arguments[0]){var e=arguments[0];return new qu(e)}},qu.sqrt=function(t){return qu.valueOf(t).sqrt()},qu.parse=function(t){for(var e=0,n=t.length;Fu.isWhitespace(t.charAt(e));)e++;var r=!1;if(e=n);){var c=t.charAt(e);if(e++,Fu.isDigit(c)){var h=c-"0";o.selfMultiply(qu.TEN),o.selfAdd(h),s++}else{if("."!==c){if("e"===c||"E"===c){var l=t.substring(e);try{u=Du.parseInt(l)}catch(e){throw e instanceof Error?new Error("Invalid exponent "+l+" in string "+t):e}break}throw new Error("Unexpected character '"+c+"' at position "+e+" in string "+t)}a=s}}var p=o,f=s-a-u;if(0===f)p=o;else if(f>0){var g=qu.TEN.pow(f);p=o.divide(g)}else if(f<0){var d=qu.TEN.pow(-f);p=o.multiply(d)}return r?p.negate():p},qu.createNaN=function(){return new qu(xu.NaN,xu.NaN)},qu.copy=function(t){return new qu(t)},qu.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},qu.stringOfChar=function(t,e){for(var n=new Au,r=0;r0){if(o<=0)return Bu.signum(s);r=i+o}else{if(!(i<0))return Bu.signum(s);if(o>=0)return Bu.signum(s);r=-i-o}var a=Bu.DP_SAFE_EPSILON*r;return s>=a||-s>=a?Bu.signum(s):2},Bu.signum=function(t){return t>0?1:t<0?-1:0},ku.DP_SAFE_EPSILON.get=function(){return 1e-15},Object.defineProperties(Bu,ku);var zu=function(){},ju={X:{configurable:!0},Y:{configurable:!0},Z:{configurable:!0},M:{configurable:!0}};ju.X.get=function(){return 0},ju.Y.get=function(){return 1},ju.Z.get=function(){return 2},ju.M.get=function(){return 3},zu.prototype.setOrdinate=function(t,e,n){},zu.prototype.size=function(){},zu.prototype.getOrdinate=function(t,e){},zu.prototype.getCoordinate=function(){},zu.prototype.getCoordinateCopy=function(t){},zu.prototype.getDimension=function(){},zu.prototype.getX=function(t){},zu.prototype.clone=function(){},zu.prototype.expandEnvelope=function(t){},zu.prototype.copy=function(){},zu.prototype.getY=function(t){},zu.prototype.toCoordinateArray=function(){},zu.prototype.interfaces_=function(){return[bu]},zu.prototype.getClass=function(){return zu},Object.defineProperties(zu,ju);var Xu=function(){},Uu=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}(Xu),Yu=function(){};Yu.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(2===arguments.length){var n=arguments[0],r=arguments[1];return!this.isNull()&&(n>=this._minx&&n<=this._maxx&&r>=this._miny&&r<=this._maxy)}},Hu.prototype.intersects=function(){if(1===arguments.length){if(arguments[0]instanceof Hu){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(2===arguments.length){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))}},Hu.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},Hu.prototype.translate=function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)},Hu.prototype.toString=function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"},Hu.prototype.setToNull=function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1},Hu.prototype.getHeight=function(){return this.isNull()?0:this._maxy-this._miny},Hu.prototype.maxExtent=function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return t>e?t:e},Hu.prototype.expandBy=function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){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()}},Hu.prototype.contains=function(){if(1===arguments.length){if(arguments[0]instanceof Hu){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof Nu){var e=arguments[0];return this.covers(e)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];return this.covers(n,r)}},Hu.prototype.centre=function(){return this.isNull()?null:new Nu((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)},Hu.prototype.init=function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof Nu){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof Hu){var e=arguments[0];this._minx=e._minx,this._maxx=e._maxx,this._miny=e._miny,this._maxy=e._maxy}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.init(n.x,r.x,n.y,r.y)}else if(4===arguments.length){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),0===e?n:0===n?e:Math.sqrt(e*e+n*n)},Hu.prototype.hashCode=function(){var t=17;return t=37*t+Nu.hashCode(this._minx),t=37*t+Nu.hashCode(this._maxx),t=37*t+Nu.hashCode(this._miny),t=37*t+Nu.hashCode(this._maxy)},Hu.prototype.interfaces_=function(){return[wu,Mi]},Hu.prototype.getClass=function(){return Hu},Hu.intersects=function(){if(3===arguments.length){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(4===arguments.length){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),c=Math.min(r.x,i.x),h=Math.max(r.x,i.x);return!(c>u)&&(!(hu)&&!(hthis.getEdgeDistance(t,1)?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}},rc.prototype.isProper=function(){return this.hasIntersection()&&this._isProper},rc.prototype.setPrecisionModel=function(t){this._precisionModel=t},rc.prototype.isInteriorIntersection=function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],e=0;ei?r:i;else{var s=Math.abs(t.x-e.x),a=Math.abs(t.y-e.y);0!==(o=r>i?s:a)||t.equals(e)||(o=Math.max(s,a))}return nc.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o},rc.nonRobustComputeEdgeDistance=function(t,e,n){var r=t.x-e.x,i=t.y-e.y,o=Math.sqrt(r*r+i*i);return nc.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o},ic.DONT_INTERSECT.get=function(){return 0},ic.DO_INTERSECT.get=function(){return 1},ic.COLLINEAR.get=function(){return 2},ic.NO_INTERSECTION.get=function(){return 0},ic.POINT_INTERSECTION.get=function(){return 1},ic.COLLINEAR_INTERSECTION.get=function(){return 2},Object.defineProperties(rc,ic);var oc=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(t){var e=new Hu(this._inputLines[0][0],this._inputLines[0][1]),n=new Hu(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t)},e.prototype.computeIntersection=function(){if(3!==arguments.length)return t.prototype.computeIntersection.apply(this,arguments);var e=arguments[0],n=arguments[1],r=arguments[2];if(this._isProper=!1,Hu.intersects(n,r,e)&&0===uc.orientationIndex(n,r,e)&&0===uc.orientationIndex(r,n,e))return this._isProper=!0,(e.equals(n)||e.equals(r))&&(this._isProper=!1),this._result=t.POINT_INTERSECTION,null;this._result=t.NO_INTERSECTION},e.prototype.normalizeToMinimum=function(t,e,n,r,i){i.x=this.smallestInAbsValue(t.x,e.x,n.x,r.x),i.y=this.smallestInAbsValue(t.y,e.y,n.y,r.y),t.x-=i.x,t.y-=i.y,e.x-=i.x,e.y-=i.y,n.x-=i.x,n.y-=i.y,r.x-=i.x,r.y-=i.y},e.prototype.safeHCoordinateIntersection=function(t,n,r,i){var o=null;try{o=Vu.intersection(t,n,r,i)}catch(s){if(!(s instanceof Uu))throw s;o=e.nearestEndpoint(t,n,r,i)}return o},e.prototype.intersection=function(t,n,r,i){var o=this.intersectionWithNormalization(t,n,r,i);return this.isInSegmentEnvelopes(o)||(o=new Nu(e.nearestEndpoint(t,n,r,i))),null!==this._precisionModel&&this._precisionModel.makePrecise(o),o},e.prototype.smallestInAbsValue=function(t,e,n,r){var i=t,o=Math.abs(i);return Math.abs(e)1e-4&&Yu.out.println("Distance = "+i.distance(o))},e.prototype.intersectionWithNormalization=function(t,e,n,r){var i=new Nu(t),o=new Nu(e),s=new Nu(n),a=new Nu(r),u=new Nu;this.normalizeToEnvCentre(i,o,s,a,u);var c=this.safeHCoordinateIntersection(i,o,s,a);return c.x+=u.x,c.y+=u.y,c},e.prototype.computeCollinearIntersection=function(e,n,r,i){var o=Hu.intersects(e,n,r),s=Hu.intersects(e,n,i),a=Hu.intersects(r,i,e),u=Hu.intersects(r,i,n);return o&&s?(this._intPt[0]=r,this._intPt[1]=i,t.COLLINEAR_INTERSECTION):a&&u?(this._intPt[0]=e,this._intPt[1]=n,t.COLLINEAR_INTERSECTION):o&&a?(this._intPt[0]=r,this._intPt[1]=e,!r.equals(e)||s||u?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):o&&u?(this._intPt[0]=r,this._intPt[1]=n,!r.equals(n)||s||a?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):s&&a?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||o||u?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):s&&u?(this._intPt[0]=i,this._intPt[1]=n,!i.equals(n)||o||a?t.COLLINEAR_INTERSECTION:t.POINT_INTERSECTION):t.NO_INTERSECTION},e.prototype.normalizeToEnvCentre=function(t,e,n,r,i){var o=t.xe.x?t.x:e.x,u=t.y>e.y?t.y:e.y,c=n.xr.x?n.x:r.x,p=n.y>r.y?n.y:r.y,f=((o>c?o:c)+(ah?s:h)+(u0&&s>0||o<0&&s<0)return t.NO_INTERSECTION;var a=uc.orientationIndex(r,i,e),u=uc.orientationIndex(r,i,n);if(a>0&&u>0||a<0&&u<0)return t.NO_INTERSECTION;return 0===o&&0===s&&0===a&&0===u?this.computeCollinearIntersection(e,n,r,i):(0===o||0===s||0===a||0===u?(this._isProper=!1,e.equals2D(r)||e.equals2D(i)?this._intPt[0]=e:n.equals2D(r)||n.equals2D(i)?this._intPt[0]=n:0===o?this._intPt[0]=new Nu(r):0===s?this._intPt[0]=new Nu(i):0===a?this._intPt[0]=new Nu(e):0===u&&(this._intPt[0]=new Nu(n))):(this._isProper=!0,this._intPt[0]=this.intersection(e,n,r,i)),t.POINT_INTERSECTION)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.nearestEndpoint=function(t,e,n,r){var i=t,o=uc.distancePointLine(t,n,r),s=uc.distancePointLine(e,n,r);return s0?n>0?-i:i:n>0?i:-i;if(0===e||0===n)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))return i;if(!(t<=n))return i}else{if(n>0)return-i;if(!(t>=n))return-i;i=-i,t=-t,n=-n}for(;;){if(s=Math.floor(n/t),n-=s*t,(r-=s*e)<0)return-i;if(r>e)return i;if(t>n+n){if(er+r)return-i;n=t-n,r=e-r,i=-i}if(0===r)return 0===n?0:-i;if(0===n)return i;if(s=Math.floor(t/n),t-=s*n,(e-=s*r)<0)return i;if(e>r)return-i;if(n>t+t){if(re+e)return i;t=n-t,e=r-e,i=-i}if(0===e)return 0===t?0:i;if(0===t)return-i}};var ac=function(){this._p=null,this._crossingCount=0,this._isPointOnSegment=!1;var t=arguments[0];this._p=t};ac.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=sc.signOfDet2x2(i,o,s,a);if(0===u)return this._isPointOnSegment=!0,null;a0&&this._crossingCount++}},ac.prototype.isPointInPolygon=function(){return this.getLocation()!==Lu.EXTERIOR},ac.prototype.getLocation=function(){return this._isPointOnSegment?Lu.BOUNDARY:this._crossingCount%2==1?Lu.INTERIOR:Lu.EXTERIOR},ac.prototype.isOnSegment=function(){return this._isPointOnSegment},ac.prototype.interfaces_=function(){return[]},ac.prototype.getClass=function(){return ac},ac.locatePointInRing=function(){if(arguments[0]instanceof Nu&&Ou(arguments[1],zu)){for(var t=arguments[0],e=arguments[1],n=new ac(t),r=new Nu,i=new Nu,o=1;o1||a<0||a>1)&&(i=!0)}}else i=!0;return i?Ru.min(uc.distancePointLine(t,n,r),uc.distancePointLine(e,n,r),uc.distancePointLine(n,t,e),uc.distancePointLine(r,t,e)):0},uc.isPointInRing=function(t,e){return uc.locatePointInRing(t,e)!==Lu.EXTERIOR},uc.computeLength=function(t){var e=t.size();if(e<=1)return 0;var n=0,r=new Nu;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],c=t[a];if(u.equals2D(n)||c.equals2D(n)||u.equals2D(c))return!1;var h=uc.computeOrientation(u,n,c),l=!1;return l=0===h?u.x>c.x:h>0,l},uc.locatePointInRing=function(t,e){return ac.locatePointInRing(t,e)},uc.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)},uc.computeOrientation=function(t,e,n){return uc.orientationIndex(t,e,n)},uc.distancePointLine=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];if(0===e.length)throw new vu("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)}},uc.isOnLine=function(t,e){for(var n=new oc,r=1;r0},mc.prototype.interfaces_=function(){return[dc]},mc.prototype.getClass=function(){return mc};var vc=function(){};vc.prototype.isInBoundary=function(t){return t>1},vc.prototype.interfaces_=function(){return[dc]},vc.prototype.getClass=function(){return vc};var xc=function(){};xc.prototype.isInBoundary=function(t){return 1===t},xc.prototype.interfaces_=function(){return[dc]},xc.prototype.getClass=function(){return xc};var Ec=function(){};Ec.prototype.add=function(){},Ec.prototype.addAll=function(){},Ec.prototype.isEmpty=function(){},Ec.prototype.iterator=function(){},Ec.prototype.size=function(){},Ec.prototype.toArray=function(){},Ec.prototype.remove=function(){};var wc=function(t){function e(e){t.call(this),this.message=e||""}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={name:{configurable:!0}};return n.name.get=function(){return"IndexOutOfBoundsException"},Object.defineProperties(e,n),e}(Error),bc=function(){};bc.prototype.hasNext=function(){},bc.prototype.next=function(){},bc.prototype.remove=function(){};var Ic=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}(Ec);(Li.prototype=new Error).name="NoSuchElementException";var Nc=function(t){function e(){t.call(this),this.array_=[],arguments[0]instanceof Ec&&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,Ec]},e.prototype.add=function(t){return 1===arguments.length?this.array_.push(t):this.array_.splice(arguments[0],arguments[1]),!0},e.prototype.clear=function(){this.array_=[]},e.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next());return!0},e.prototype.set=function(t,e){var n=this.array_[t];return this.array_[t]=e,n},e.prototype.iterator=function(){return new Cc(this)},e.prototype.get=function(t){if(t<0||t>=this.size())throw new wc;return this.array_[t]},e.prototype.isEmpty=function(){return 0===this.array_.length},e.prototype.size=function(){return this.array_.length},e.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e=1){if(this.get(this.size()-1).equals2D(i))return null}t.prototype.add.call(this,i)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var o=arguments[0],s=arguments[1];return this.add(o,s),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var a=arguments[0],u=arguments[1];if(arguments[2])for(var c=0;c=0;h--)this.add(a[h],u);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof Nu){var l=arguments[0],p=arguments[1];if(!arguments[2]){var f=this.size();if(f>0){if(l>0){if(this.get(l-1).equals2D(p))return null}if(l_&&(m=-1);for(var v=y;v!==_;v+=m)this.add(g[v],d);return!0}},e.prototype.closeRing=function(){this.size()>0&&this.add(new Nu(this.get(0)),!1)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},Object.defineProperties(e,n),e}(Nc),Mc=function(){},Lc={ForwardComparator:{configurable:!0},BidirectionalComparator:{configurable:!0},coordArrayType:{configurable:!0}};Lc.ForwardComparator.get=function(){return Pc},Lc.BidirectionalComparator.get=function(){return Oc},Lc.coordArrayType.get=function(){return new Array(0).fill(null)},Mc.prototype.interfaces_=function(){return[]},Mc.prototype.getClass=function(){return Mc},Mc.isRing=function(t){return!(t.length<4)&&!!t[0].equals2D(t[t.length-1])},Mc.ptNotInList=function(t,e){for(var n=0;n=t?e:[]},Mc.indexOf=function(t,e){for(var n=0;n0)&&(e=t[n]);return e},Mc.extract=function(t,e,n){e=Ru.clamp(e,0,t.length);var r=(n=Ru.clamp(n,-1,t.length))-e+1;n<0&&(r=0),e>=t.length&&(r=0),nr.length)return 1;if(0===n.length)return 0;var i=Mc.compare(n,r);return Mc.isEqualReversed(n,r)?0:i},Oc.prototype.OLDcompare=function(t,e){var n=t,r=e;if(n.lengthr.length)return 1;if(0===n.length)return 0;for(var i=Mc.increasingDirection(n),o=Mc.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},qi.prototype.put=function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:Fc,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(null!==i);var s={key:t,left:null,right:null,value:e,parent:n,color:Fc,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},qi.prototype.fixAfterInsertion=function(t){for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)if(Ti(t)===Di(Ti(Ti(t)))){var e=Fi(Ti(Ti(t)));1===Ri(e)?(Ai(Ti(t),Fc),Ai(e,Fc),Ai(Ti(Ti(t)),1),t=Ti(Ti(t))):(t===Fi(Ti(t))&&(t=Ti(t),this.rotateLeft(t)),Ai(Ti(t),Fc),Ai(Ti(Ti(t)),1),this.rotateRight(Ti(Ti(t))))}else{var n=Di(Ti(Ti(t)));1===Ri(n)?(Ai(Ti(t),Fc),Ai(n,Fc),Ai(Ti(Ti(t)),1),t=Ti(Ti(t))):(t===Di(Ti(t))&&(t=Ti(t),this.rotateRight(t)),Ai(Ti(t),Fc),Ai(Ti(Ti(t)),1),this.rotateLeft(Ti(Ti(t))))}this.root_.color=Fc},qi.prototype.values=function(){var t=new Nc,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=qi.successor(e));)t.add(e.value);return t},qi.prototype.entrySet=function(){var t=new Ac,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=qi.successor(e));)t.add(e);return t},qi.prototype.rotateLeft=function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}},qi.prototype.rotateRight=function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null===t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}},qi.prototype.getFirstEntry=function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t},qi.successor=function(t){if(null===t)return null;if(null!==t.right){for(var e=t.right;null!==e.left;)e=e.left;return e}for(var n=t.parent,r=t;null!==n&&r===n.right;)r=n,n=n.parent;return n},qi.prototype.size=function(){return this.size_};var qc=function(){};qc.prototype.interfaces_=function(){return[]},qc.prototype.getClass=function(){return qc},Gi.prototype=new Oi,(Bi.prototype=new Gi).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(Wc.toString(t.getOrdinate(i,o)))}return r.append(")"),r.toString()}},Zc.ensureValidRing=function(t,e){var n=e.size();if(0===n)return e;if(n<=3)return Zc.createClosedRing(t,e,4);return e.getOrdinate(0,zu.X)===e.getOrdinate(n-1,zu.X)&&e.getOrdinate(0,zu.Y)===e.getOrdinate(n-1,zu.Y)?e:Zc.createClosedRing(t,e,n+1)},Zc.createClosedRing=function(t,e,n){var r=t.create(n,e.getDimension()),i=e.size();Zc.copy(e,0,r,0,i);for(var o=i;o0&&Zc.reverse(this._points),null}},e.prototype.getCoordinate=function(){return this.isEmpty()?null:this._points.getCoordinate(0)},e.prototype.getBoundaryDimension=function(){return this.isClosed()?kc.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 uc.computeLength(this._points)},e.prototype.getNumPoints=function(){return this._points.size()},e.prototype.reverse=function(){var t=this._points.copy();Zc.reverse(t);return this.getFactory().createLineString(t)},e.prototype.compareToSameClass=function(){if(1===arguments.length){for(var t=arguments[0],e=0,n=0;e= 2)");this._points=t},e.prototype.isCoordinate=function(t){for(var e=0;e=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}(Kc),ih=function(t){function e(){t.apply(this,arguments)}t&&(e.__proto__=t),(e.prototype=Object.create(t&&t.prototype)).constructor=e;var n={serialVersionUID:{configurable:!0}};return e.prototype.getSortIndex=function(){return lc.SORTINDEX_MULTIPOLYGON},e.prototype.equalsExact=function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!this.isEquivalentClass(e)&&t.prototype.equalsExact.call(this,e,n)}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 t=this._geometries.length,e=new Array(t).fill(null),n=0;n0?e.createPoint(n[0]):e.createPoint():t},uh.prototype.interfaces_=function(){return[oh.GeometryEditorOperation]},uh.prototype.getClass=function(){return uh};var ch=function(){};ch.prototype.edit=function(t,e){return t instanceof rh?e.createLinearRing(this.edit(t.getCoordinateSequence(),t)):t instanceof Kc?e.createLineString(this.edit(t.getCoordinateSequence(),t)):t instanceof $c?e.createPoint(this.edit(t.getCoordinateSequence(),t)):t},ch.prototype.interfaces_=function(){return[oh.GeometryEditorOperation]},ch.prototype.getClass=function(){return ch};var hh=function(){if(this._dimension=3,this._coordinates=null,1===arguments.length){if(arguments[0]instanceof Array)this._coordinates=arguments[0],this._dimension=3;else if(Number.isInteger(arguments[0])){var t=arguments[0];this._coordinates=new Array(t).fill(null);for(var e=0;e0){var t=new Au(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e3&&(r=3),r<2?new hh(n):new hh(n,r)}},ph.prototype.interfaces_=function(){return[Mu,Mi]},ph.prototype.getClass=function(){return ph},ph.instance=function(){return ph.instanceObject},fh.serialVersionUID.get=function(){return-0x38e49fa6cf6f2e00},fh.instanceObject.get=function(){return new ph},Object.defineProperties(ph,fh);var gh=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(t){return this.map_.get(t)||null},e.prototype.put=function(t,e){return this.map_.set(t,e),e},e.prototype.values=function(){for(var t=new Nc,e=this.map_.values(),n=e.next();!n.done;)t.add(n.value),n=e.next();return t},e.prototype.entrySet=function(){var t=new Ac;return this.map_.entries().forEach(function(e){return t.add(e)}),t},e.prototype.size=function(){return this.map_.size()},e}(Rc),dh=function t(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=t.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof _h){var e=arguments[0];this._modelType=e,e===t.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){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}},yh={serialVersionUID:{configurable:!0},maximumPreciseValue:{configurable:!0}};dh.prototype.equals=function(t){if(!(t instanceof dh))return!1;var e=t;return this._modelType===e._modelType&&this._scale===e._scale},dh.prototype.compareTo=function(t){var e=t,n=this.getMaximumSignificantDigits(),r=e.getMaximumSignificantDigits();return new Du(n).compareTo(new Du(r))},dh.prototype.getScale=function(){return this._scale},dh.prototype.isFloating=function(){return this._modelType===dh.FLOATING||this._modelType===dh.FLOATING_SINGLE},dh.prototype.getType=function(){return this._modelType},dh.prototype.toString=function(){var t="UNKNOWN";return this._modelType===dh.FLOATING?t="Floating":this._modelType===dh.FLOATING_SINGLE?t="Floating-Single":this._modelType===dh.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t},dh.prototype.makePrecise=function(){if("number"==typeof arguments[0]){var t=arguments[0];if(xu.isNaN(t))return t;if(this._modelType===dh.FLOATING_SINGLE){return t}return this._modelType===dh.FIXED?Math.round(t*this._scale)/this._scale:t}if(arguments[0]instanceof Nu){var e=arguments[0];if(this._modelType===dh.FLOATING)return null;e.x=this.makePrecise(e.x),e.y=this.makePrecise(e.y)}},dh.prototype.getMaximumSignificantDigits=function(){var t=16;return this._modelType===dh.FLOATING?t=16:this._modelType===dh.FLOATING_SINGLE?t=6:this._modelType===dh.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t},dh.prototype.setScale=function(t){this._scale=Math.abs(t)},dh.prototype.interfaces_=function(){return[Mi,wu]},dh.prototype.getClass=function(){return dh},dh.mostPrecise=function(t,e){return t.compareTo(e)>=0?t:e},yh.serialVersionUID.get=function(){return 0x6bee6404e9a25c00},yh.maximumPreciseValue.get=function(){return 9007199254740992},Object.defineProperties(dh,yh);var _h=function t(e){this._name=e||null,t.nameToTypeMap.put(e,this)},mh={serialVersionUID:{configurable:!0},nameToTypeMap:{configurable:!0}};_h.prototype.readResolve=function(){return _h.nameToTypeMap.get(this._name)},_h.prototype.toString=function(){return this._name},_h.prototype.interfaces_=function(){return[Mi]},_h.prototype.getClass=function(){return _h},mh.serialVersionUID.get=function(){return-552860263173159e4},mh.nameToTypeMap.get=function(){return new gh},Object.defineProperties(_h,mh),dh.Type=_h,dh.FIXED=new _h("FIXED"),dh.FLOATING=new _h("FLOATING"),dh.FLOATING_SINGLE=new _h("FLOATING SINGLE");var vh=function t(){this._precisionModel=new dh,this._SRID=0,this._coordinateSequenceFactory=t.getDefaultCoordinateSequenceFactory(),0===arguments.length||(1===arguments.length?Ou(arguments[0],Mu)?this._coordinateSequenceFactory=arguments[0]:arguments[0]instanceof dh&&(this._precisionModel=arguments[0]):2===arguments.length?(this._precisionModel=arguments[0],this._SRID=arguments[1]):3===arguments.length&&(this._precisionModel=arguments[0],this._SRID=arguments[1],this._coordinateSequenceFactory=arguments[2]))},xh={serialVersionUID:{configurable:!0}};vh.prototype.toGeometry=function(t){return t.isNull()?this.createPoint(null):t.getMinX()===t.getMaxX()&&t.getMinY()===t.getMaxY()?this.createPoint(new Nu(t.getMinX(),t.getMinY())):t.getMinX()===t.getMaxX()||t.getMinY()===t.getMaxY()?this.createLineString([new Nu(t.getMinX(),t.getMinY()),new Nu(t.getMaxX(),t.getMaxY())]):this.createPolygon(this.createLinearRing([new Nu(t.getMinX(),t.getMinY()),new Nu(t.getMinX(),t.getMaxY()),new Nu(t.getMaxX(),t.getMaxY()),new Nu(t.getMaxX(),t.getMinY()),new Nu(t.getMinX(),t.getMinY())]),null)},vh.prototype.createLineString=function(t){return t?t instanceof Array?new Kc(this.getCoordinateSequenceFactory().create(t),this):Ou(t,zu)?new Kc(t,this):void 0:new Kc(this.getCoordinateSequenceFactory().create([]),this)},vh.prototype.createMultiLineString=function(){if(0===arguments.length)return new Yc(null,this);if(1===arguments.length){var t=arguments[0];return new Yc(t,this)}},vh.prototype.buildGeometry=function(t){for(var e=null,n=!1,r=!1,i=t.iterator();i.hasNext();){var o=i.next(),s=o.getClass();null===e&&(e=s),s!==e&&(n=!0),o.isGeometryCollectionOrDerived()&&(r=!0)}if(null===e)return this.createGeometryCollection();if(n||r)return this.createGeometryCollection(vh.toGeometryArray(t));var a=t.iterator().next();if(t.size()>1){if(a instanceof eh)return this.createMultiPolygon(vh.toPolygonArray(t));if(a instanceof Kc)return this.createMultiLineString(vh.toLineStringArray(t));if(a instanceof $c)return this.createMultiPoint(vh.toPointArray(t));nc.shouldNeverReachHere("Unhandled class: "+a.getClass().getName())}return a},vh.prototype.createMultiPointFromCoords=function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)},vh.prototype.createPoint=function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Nu){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(Ou(arguments[0],zu)){var e=arguments[0];return new $c(e,this)}}},vh.prototype.getCoordinateSequenceFactory=function(){return this._coordinateSequenceFactory},vh.prototype.createPolygon=function(){if(0===arguments.length)return new eh(null,null,this);if(1===arguments.length){if(Ou(arguments[0],zu)){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 rh){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];return new eh(r,i,this)}},vh.prototype.getSRID=function(){return this._SRID},vh.prototype.createGeometryCollection=function(){if(0===arguments.length)return new Uc(null,this);if(1===arguments.length){var t=arguments[0];return new Uc(t,this)}},vh.prototype.createGeometry=function(t){return new oh(this).edit(t,{edit:function(){if(2===arguments.length){var t=arguments[0];return this._coordinateSequenceFactory.create(t)}}})},vh.prototype.getPrecisionModel=function(){return this._precisionModel},vh.prototype.createLinearRing=function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(Ou(arguments[0],zu)){var e=arguments[0];return new rh(e,this)}}},vh.prototype.createMultiPolygon=function(){if(0===arguments.length)return new ih(null,this);if(1===arguments.length){var t=arguments[0];return new ih(t,this)}},vh.prototype.createMultiPoint=function(){if(0===arguments.length)return new nh(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return new nh(t,this)}if(arguments[0]instanceof Array){var e=arguments[0];return this.createMultiPoint(null!==e?this.getCoordinateSequenceFactory().create(e):null)}if(Ou(arguments[0],zu)){var n=arguments[0];if(null===n)return this.createMultiPoint(new Array(0).fill(null));for(var r=new Array(n.size()).fill(null),i=0;i=this.size())throw new Error;return this.array_[t]},ji.prototype.push=function(t){return this.array_.push(t),t},ji.prototype.pop=function(t){if(0===this.array_.length)throw new zi;return this.array_.pop()},ji.prototype.peek=function(){if(0===this.array_.length)throw new zi;return this.array_[this.array_.length-1]},ji.prototype.empty=function(){return 0===this.array_.length},ji.prototype.isEmpty=function(){return this.empty()},ji.prototype.search=function(t){return this.array_.indexOf(t)},ji.prototype.size=function(){return this.array_.length},ji.prototype.toArray=function(){for(var t=[],e=0,n=this.array_.length;e0&&this._minIndexthis._minCoord.y&&n.y>this._minCoord.y&&r===uc.CLOCKWISE&&(i=!0),i&&(this._minIndex=this._minIndex-1)},Lh.prototype.getRightmostSideOfSegment=function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var r=Sh.LEFT;return n[e].ythis._minCoord.x)&&(this._minDe=t,this._minIndex=n,this._minCoord=e[n])},Lh.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)},Lh.prototype.findEdge=function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}nc.isTrue(0!==this._minIndex||this._minCoord.equals(this._minDe.getCoordinate()),"inconsistency in rightmost processing"),0===this._minIndex?this.findRightmostEdgeAtNode():this.findRightmostEdgeAtVertex(),this._orientedDe=this._minDe;this.getRightmostSide(this._minDe,this._minIndex)===Sh.LEFT&&(this._orientedDe=this._minDe.getSym())},Lh.prototype.interfaces_=function(){return[]},Lh.prototype.getClass=function(){return Lh};var Ph=function(t){function e(n,r){t.call(this,e.msgWithCoord(n,r)),this.pt=r?new Nu(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(t,e){return e?t:t+" [ "+e+" ]"},e}(tc),Oh=function(){this.array_=[]};Oh.prototype.addLast=function(t){this.array_.push(t)},Oh.prototype.removeFirst=function(){return this.array_.shift()},Oh.prototype.isEmpty=function(){return 0===this.array_.length};var Rh=function(){this._finder=null,this._dirEdgeList=new Nc,this._nodes=new Nc,this._rightMostCoord=null,this._env=null,this._finder=new Lh};Rh.prototype.clearVisitedEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){t.next().setVisited(!1)}},Rh.prototype.getRightmostCoordinate=function(){return this._rightMostCoord},Rh.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(null===e)throw new Ph("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)}},Rh.prototype.computeDepth=function(t){this.clearVisitedEdges();var e=this._finder.getEdge();e.setEdgeDepths(Sh.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)},Rh.prototype.create=function(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()},Rh.prototype.findResultEdges=function(){for(var t=this._dirEdgeList.iterator();t.hasNext();){var e=t.next();e.getDepth(Sh.RIGHT)>=1&&e.getDepth(Sh.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}},Rh.prototype.computeDepths=function(t){var e=new Ac,n=new Oh,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))}}}},Rh.prototype.compareTo=function(t){var e=t;return this._rightMostCoord.xe._rightMostCoord.x?1:0},Rh.prototype.getEnvelope=function(){if(null===this._env){for(var t=new Hu,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[Sh.ON]=this.location[Sh.ON],e[Sh.LEFT]=Lu.NONE,e[Sh.RIGHT]=Lu.NONE,this.location=e}for(var n=0;n1&&t.append(Lu.toLocationSymbol(this.location[Sh.LEFT])),t.append(Lu.toLocationSymbol(this.location[Sh.ON])),this.location.length>1&&t.append(Lu.toLocationSymbol(this.location[Sh.RIGHT])),t.toString()},Th.prototype.setLocations=function(t,e,n){this.location[Sh.ON]=t,this.location[Sh.LEFT]=e,this.location[Sh.RIGHT]=n},Th.prototype.get=function(t){return t1},Th.prototype.isAnyNull=function(){for(var t=0;tthis._maxNodeDegree&&(this._maxNodeDegree=e),t=this.getNext(t)}while(t!==this._startDe);this._maxNodeDegree*=2},Dh.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])}},Dh.prototype.isHole=function(){return this._isHole},Dh.prototype.setInResult=function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)},Dh.prototype.containsPoint=function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!uc.isPointInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();){if(n.next().containsPoint(t))return!1}return!0},Dh.prototype.addHole=function(t){this._holes.add(t)},Dh.prototype.isShell=function(){return null===this._shell},Dh.prototype.getLabel=function(){return this._label},Dh.prototype.getEdges=function(){return this._edges},Dh.prototype.getMaxNodeDegree=function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree},Dh.prototype.getShell=function(){return this._shell},Dh.prototype.mergeLabel=function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],r=e.getLocation(n,Sh.RIGHT);if(r===Lu.NONE)return null;if(this._label.getLocation(n)===Lu.NONE)return this._label.setLocation(n,r),null}},Dh.prototype.setShell=function(t){this._shell=t,null!==t&&t.addHole(this)},Dh.prototype.toPolygon=function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n=2,"found partial label"),this.computeIM(t)},Gh.prototype.isInResult=function(){return this._isInResult},Gh.prototype.isVisited=function(){return this._isVisited},Gh.prototype.interfaces_=function(){return[]},Gh.prototype.getClass=function(){return Gh};var Bh=function(t){function e(){t.call(this),this._coord=null,this._edges=null;var e=arguments[0],n=arguments[1];this._coord=e,this._edges=n,this._label=new Ah(0,Lu.NONE)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.isIncidentEdgeInResult=function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();){if(t.next().getEdge().isInResult())return!0}return!1},e.prototype.isIsolated=function(){return 1===this._label.getGeometryCount()},e.prototype.getCoordinate=function(){return this._coord},e.prototype.print=function(t){t.println("node "+this._coord+" lbl: "+this._label)},e.prototype.computeIM=function(t){},e.prototype.computeMergedLocation=function(t,e){var n=Lu.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var r=t.getLocation(e);n!==Lu.BOUNDARY&&(n=r)}return n},e.prototype.setLabel=function(){if(2!==arguments.length)return t.prototype.setLabel.apply(this,arguments);var e=arguments[0],n=arguments[1];null===this._label?this._label=new Ah(e,n):this._label.setLocation(e,n)},e.prototype.getEdges=function(){return this._edges},e.prototype.mergeLabel=function(){if(arguments[0]instanceof e){var t=arguments[0];this.mergeLabel(t._label)}else if(arguments[0]instanceof Ah)for(var n=arguments[0],r=0;r<2;r++){var i=this.computeMergedLocation(n,r);this._label.getLocation(r)===Lu.NONE&&this._label.setLocation(r,i)}},e.prototype.add=function(t){this._edges.insert(t),t.setNode(this)},e.prototype.setLabelBoundary=function(t){if(null===this._label)return null;var e=Lu.NONE;null!==this._label&&(e=this._label.getLocation(t));var n=null;switch(e){case Lu.BOUNDARY:n=Lu.INTERIOR;break;case Lu.INTERIOR:default:n=Lu.BOUNDARY}this._label.setLocation(t,n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Gh),kh=function(){this.nodeMap=new qi,this.nodeFact=null;var t=arguments[0];this.nodeFact=t};kh.prototype.find=function(t){return this.nodeMap.get(t)},kh.prototype.addNode=function(){if(arguments[0]instanceof Nu){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof Bh){var n=arguments[0],r=this.nodeMap.get(n.getCoordinate());return null===r?(this.nodeMap.put(n.getCoordinate(),n),n):(r.mergeLabel(n),r)}},kh.prototype.print=function(t){for(var e=this.iterator();e.hasNext();){e.next().print(t)}},kh.prototype.iterator=function(){return this.nodeMap.values().iterator()},kh.prototype.values=function(){return this.nodeMap.values()},kh.prototype.getBoundaryNodes=function(t){for(var e=new Nc,n=this.iterator();n.hasNext();){var r=n.next();r.getLabel().getLocation(t)===Lu.BOUNDARY&&e.add(r)}return e},kh.prototype.add=function(t){var e=t.getCoordinate();this.addNode(e).add(t)},kh.prototype.interfaces_=function(){return[]},kh.prototype.getClass=function(){return kh};var zh=function(){},jh={NE:{configurable:!0},NW:{configurable:!0},SW:{configurable:!0},SE:{configurable:!0}};zh.prototype.interfaces_=function(){return[]},zh.prototype.getClass=function(){return zh},zh.isNorthern=function(t){return t===zh.NE||t===zh.NW},zh.isOpposite=function(t,e){if(t===e)return!1;return 2===(t-e+4)%4},zh.commonHalfPlane=function(t,e){if(t===e)return t;if(2===(t-e+4)%4)return-1;var n=te?t:e)?3:n},zh.isInHalfPlane=function(t,e){return e===zh.SE?t===zh.SE||t===zh.SW:t===e||t===e+1},zh.quadrant=function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new vu("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?zh.NE:zh.SE:e>=0?zh.NW:zh.SW}if(arguments[0]instanceof Nu&&arguments[1]instanceof Nu){var n=arguments[0],r=arguments[1];if(r.x===n.x&&r.y===n.y)throw new vu("Cannot compute the quadrant for two identical points "+n);return r.x>=n.x?r.y>=n.y?zh.NE:zh.SE:r.y>=n.y?zh.NW:zh.SW}},jh.NE.get=function(){return 0},jh.NW.get=function(){return 1},jh.SW.get=function(){return 2},jh.SE.get=function(){return 3},Object.defineProperties(zh,jh);var Xh=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,1===arguments.length){var t=arguments[0];this._edge=t}else if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2];this._edge=e,this.init(n,r),this._label=null}else if(4===arguments.length){var i=arguments[0],o=arguments[1],s=arguments[2],a=arguments[3];this._edge=i,this.init(o,s),this._label=a}};Xh.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);null!==a?(this.placePolygonHoles(a,s),e.add(a)):n.addAll(s)}else r.add(o)}return r},Hh.prototype.containsPoint=function(t){for(var e=this._shellList.iterator();e.hasNext();){if(e.next().containsPoint(t))return!0}return!1},Hh.prototype.buildMaximalEdgeRings=function(t){for(var e=new Nc,n=t.iterator();n.hasNext();){var r=n.next();if(r.isInResult()&&r.getLabel().isArea()&&null===r.getEdgeRing()){var i=new qh(r,this._geometryFactory);e.add(i),i.setInResult()}}return e},Hh.prototype.placePolygonHoles=function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next();r.isHole()&&r.setShell(t)}},Hh.prototype.getPolygons=function(){return this.computePolygons(this._shellList)},Hh.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(),c=u.getLinearRing(),h=c.getEnvelopeInternal();null!==o&&(s=o.getLinearRing().getEnvelopeInternal());var l=!1;h.contains(r)&&uc.isPointInRing(i,c.getCoordinates())&&(l=!0),l&&(null===o||s.contains(h))&&(o=u)}return o},Hh.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 nc.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n},Hh.prototype.add=function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0],n=arguments[1];Vh.linkResultDirectedEdges(n);var r=this.buildMaximalEdgeRings(e),i=new Nc,o=this.buildMinimalEdgeRings(r,this._shellList,i);this.sortShellsAndHoles(o,this._shellList,i),this.placeFreeHoles(this._shellList,i)}},Hh.prototype.interfaces_=function(){return[]},Hh.prototype.getClass=function(){return Hh};var Wh=function(){};Wh.prototype.getBounds=function(){},Wh.prototype.interfaces_=function(){return[]},Wh.prototype.getClass=function(){return Wh};var Jh=function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e};Jh.prototype.getItem=function(){return this._item},Jh.prototype.getBounds=function(){return this._bounds},Jh.prototype.interfaces_=function(){return[Wh,Mi]},Jh.prototype.getClass=function(){return Jh};var Zh=function(){this._size=null,this._items=null,this._size=0,this._items=new Nc,this._items.add(null)};Zh.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},Zh.prototype.size=function(){return this._size},Zh.prototype.reorder=function(t){for(var e=null,n=this._items.get(t);2*t<=this._size&&((e=2*t)!==this._size&&this._items.get(e+1).compareTo(this._items.get(e))<0&&e++,this._items.get(e).compareTo(n)<0);t=e)this._items.set(t,this._items.get(e));this._items.set(t,n)},Zh.prototype.clear=function(){this._size=0,this._items.clear()},Zh.prototype.isEmpty=function(){return 0===this._size},Zh.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)},Zh.prototype.interfaces_=function(){return[]},Zh.prototype.getClass=function(){return Zh};var Kh=function(){};Kh.prototype.visitItem=function(t){},Kh.prototype.interfaces_=function(){return[]},Kh.prototype.getClass=function(){return Kh};var Qh=function(){};Qh.prototype.insert=function(t,e){},Qh.prototype.remove=function(t,e){},Qh.prototype.query=function(){},Qh.prototype.interfaces_=function(){return[]},Qh.prototype.getClass=function(){return Qh};var $h=function(){if(this._childBoundables=new Nc,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t}},tl={serialVersionUID:{configurable:!0}};$h.prototype.getLevel=function(){return this._level},$h.prototype.size=function(){return this._childBoundables.size()},$h.prototype.getChildBoundables=function(){return this._childBoundables},$h.prototype.addChildBoundable=function(t){nc.isTrue(null===this._bounds),this._childBoundables.add(t)},$h.prototype.isEmpty=function(){return this._childBoundables.isEmpty()},$h.prototype.getBounds=function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds},$h.prototype.interfaces_=function(){return[Wh,Mi]},$h.prototype.getClass=function(){return $h},tl.serialVersionUID.get=function(){return 0x5a1e55ec41369800},Object.defineProperties($h,tl);var el=function(){};el.reverseOrder=function(){return{compare:function(t,e){return e.compareTo(t)}}},el.min=function(t){return el.sort(t),t.get(0)},el.sort=function(t,e){var n=t.toArray();e?Bc.sort(n,e):Bc.sort(n);for(var r=t.iterator(),i=0,o=n.length;inl.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 vu("neither boundable is composite")},nl.prototype.isLeaves=function(){return!(nl.isComposite(this._boundable1)||nl.isComposite(this._boundable2))},nl.prototype.compareTo=function(t){var e=t;return this._distancee._distance?1:0},nl.prototype.expand=function(t,e,n,r){for(var i=t.getChildBoundables().iterator();i.hasNext();){var o=i.next(),s=new nl(o,e,this._itemDistance);s.getDistance()1,"Node capacity must be greater than 1"),this._nodeCapacity=n}},il={IntersectsOp:{configurable:!0},serialVersionUID:{configurable:!0},DEFAULT_NODE_CAPACITY:{configurable:!0}};rl.prototype.getNodeCapacity=function(){return this._nodeCapacity},rl.prototype.lastNode=function(t){return t.get(t.size()-1)},rl.prototype.size=function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.size(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();n instanceof $h?t+=this.size(n):n instanceof Jh&&(t+=1)}return t}},rl.prototype.removeItem=function(t,e){for(var n=null,r=t.getChildBoundables().iterator();r.hasNext();){var i=r.next();i instanceof Jh&&i.getItem()===e&&(n=i)}return null!==n&&(t.getChildBoundables().remove(n),!0)},rl.prototype.itemsTree=function(){if(0===arguments.length){this.build();var t=this.itemsTree(this._root);return null===t?new Nc:t}if(1===arguments.length){for(var e=arguments[0],n=new Nc,r=e.getChildBoundables().iterator();r.hasNext();){var i=r.next();if(i instanceof $h){var o=this.itemsTree(i);null!==o&&n.add(o)}else i instanceof Jh?n.add(i.getItem()):nc.shouldNeverReachHere()}return n.size()<=0?null:n}},rl.prototype.insert=function(t,e){nc.isTrue(!this._built,"Cannot insert items into an STR packed R-tree after it has been built."),this._itemBoundables.add(new Jh(t,e))},rl.prototype.boundablesAtLevel=function(){if(1===arguments.length){var t=arguments[0],e=new Nc;return this.boundablesAtLevel(t,this._root,e),e}if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];if(nc.isTrue(n>-2),r.getLevel()===n)return i.add(r),null;for(var o=r.getChildBoundables().iterator();o.hasNext();){var s=o.next();s instanceof $h?this.boundablesAtLevel(n,s,i):(nc.isTrue(s instanceof Jh),-1===n&&i.add(s))}return null}},rl.prototype.query=function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new Nc;return this.isEmpty()?e:(this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.query(t,this._root,e),e)}if(2===arguments.length){var n=arguments[0],r=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),n)&&this.query(n,this._root,r)}else if(3===arguments.length)if(Ou(arguments[2],Kh)&&arguments[0]instanceof Object&&arguments[1]instanceof $h)for(var i=arguments[0],o=arguments[1],s=arguments[2],a=o.getChildBoundables(),u=0;ut&&(t=r)}}return t+1}},rl.prototype.createParentBoundables=function(t,e){nc.isTrue(!t.isEmpty());var n=new Nc;n.add(this.createNode(e));var r=new Nc(t);el.sort(r,this.getComparator());for(var i=r.iterator();i.hasNext();){var o=i.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(o)}return n},rl.prototype.isEmpty=function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()},rl.prototype.interfaces_=function(){return[Mi]},rl.prototype.getClass=function(){return rl},rl.compareDoubles=function(t,e){return t>e?1:t0);for(var n=new Nc,r=0;r0;){var l=h.poll(),p=l.getDistance();if(p>=u)break;l.isLeaves()?(u=p,c=l):l.expandToQueue(h,u)}return[c.getBoundable(0).getItem(),c.getBoundable(1).getItem()]}}else if(3===arguments.length){var f=arguments[0],g=arguments[1],d=arguments[2],y=new Jh(f,g),_=new nl(this.getRoot(),y,d);return this.nearestNeighbour(_)[0]}},e.prototype.interfaces_=function(){return[Qh,Mi]},e.prototype.getClass=function(){return e},e.centreX=function(t){return e.avg(t.getMinX(),t.getMaxX())},e.avg=function(t,e){return(t+e)/2},e.centreY=function(t){return e.avg(t.getMinY(),t.getMaxY())},n.STRtreeNode.get=function(){return ul},n.serialVersionUID.get=function(){return 0x39920f7d5f261e0},n.xComparator.get=function(){return{interfaces_:function(){return[Iu]},compare:function(n,r){return t.compareDoubles(e.centreX(n.getBounds()),e.centreX(r.getBounds()))}}},n.yComparator.get=function(){return{interfaces_:function(){return[Iu]},compare:function(n,r){return t.compareDoubles(e.centreY(n.getBounds()),e.centreY(r.getBounds()))}}},n.intersectsOp.get=function(){return{interfaces_:function(){return[t.IntersectsOp]},intersects:function(t,e){return t.intersects(e)}}},n.DEFAULT_NODE_CAPACITY.get=function(){return 10},Object.defineProperties(e,n),e}(rl),ul=function(t){function e(){var e=arguments[0];t.call(this,e)}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.computeBounds=function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new Hu(n.getBounds()):t.expandToInclude(n.getBounds())}return t},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}($h),cl=function(){};cl.prototype.interfaces_=function(){return[]},cl.prototype.getClass=function(){return cl},cl.relativeSign=function(t,e){return te?1:0},cl.compare=function(t,e,n){if(e.equals2D(n))return 0;var r=cl.relativeSign(e.x,n.x),i=cl.relativeSign(e.y,n.y);switch(t){case 0:return cl.compareValue(r,i);case 1:return cl.compareValue(i,r);case 2:return cl.compareValue(i,-r);case 3:return cl.compareValue(-r,i);case 4:return cl.compareValue(-r,-i);case 5:return cl.compareValue(-i,-r);case 6:return cl.compareValue(-i,r);case 7:return cl.compareValue(r,-i)}return nc.shouldNeverReachHere("invalid octant value"),0},cl.compareValue=function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0};var hl=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 Nu(e),this.segmentIndex=n,this._segmentOctant=r,this._isInterior=!e.equals2D(t.getCoordinate(n))};hl.prototype.getCoordinate=function(){return this.coord},hl.prototype.print=function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)},hl.prototype.compareTo=function(t){var e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:cl.compare(this._segmentOctant,this.coord,e.coord)},hl.prototype.isEndPoint=function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t},hl.prototype.isInterior=function(){return this._isInterior},hl.prototype.interfaces_=function(){return[wu]},hl.prototype.getClass=function(){return hl};var ll=function(){this._nodeMap=new qi,this._edge=null;var t=arguments[0];this._edge=t};ll.prototype.getSplitCoordinates=function(){var t=new Sc;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()},ll.prototype.addCollapsedNodes=function(){var t=new Nc;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)}},ll.prototype.print=function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();){e.next().print(t)}},ll.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 Nu&&arguments[1]instanceof Nu){var i=arguments[0],o=arguments[1],s=o.x-i.x,a=o.y-i.y;if(0===s&&0===a)throw new vu("Cannot compute the octant for two identical points "+i);return pl.octant(s,a)}};var fl=function(){};fl.prototype.getCoordinates=function(){},fl.prototype.size=function(){},fl.prototype.getCoordinate=function(t){},fl.prototype.isClosed=function(){},fl.prototype.setData=function(t){},fl.prototype.getData=function(){},fl.prototype.interfaces_=function(){return[]},fl.prototype.getClass=function(){return fl};var gl=function(){};gl.prototype.addIntersection=function(t,e){},gl.prototype.interfaces_=function(){return[fl]},gl.prototype.getClass=function(){return gl};var dl=function(){this._nodeList=new ll(this),this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};dl.prototype.getCoordinates=function(){return this._pts},dl.prototype.size=function(){return this._pts.length},dl.prototype.getCoordinate=function(t){return this._pts[t]},dl.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},dl.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))},dl.prototype.setData=function(t){this._data=t},dl.prototype.safeOctant=function(t,e){return t.equals2D(e)?0:pl.octant(t,e)},dl.prototype.getData=function(){return this._data},dl.prototype.addIntersection=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[3],o=new Nu(n.getIntersection(i));this.addIntersection(o,r)}},dl.prototype.toString=function(){return $u.toLineString(new hh(this._pts))},dl.prototype.getNodeList=function(){return this._nodeList},dl.prototype.addIntersectionNode=function(t,e){var n=e,r=n+1;if(r=0&&n>=0?Math.max(e,n):e<=0&&n<=0?Math.max(e,n):0}if(arguments[0]instanceof Nu){var r=arguments[0];return uc.orientationIndex(this.p0,this.p1,r)}},yl.prototype.toGeometry=function(t){return t.createLineString([this.p0,this.p1])},yl.prototype.isVertical=function(){return this.p0.x===this.p1.x},yl.prototype.equals=function(t){if(!(t instanceof yl))return!1;var e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1)},yl.prototype.intersection=function(t){var e=new oc;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null},yl.prototype.project=function(){if(arguments[0]instanceof Nu){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new Nu(t);var e=this.projectionFactor(t),n=new Nu;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 yl){var r=arguments[0],i=this.projectionFactor(r.p0),o=this.projectionFactor(r.p1);if(i>=1&&o>=1)return null;if(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 yl(s,a)}},yl.prototype.normalize=function(){this.p1.compareTo(this.p0)<0&&this.reverse()},yl.prototype.angle=function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)},yl.prototype.getCoordinate=function(t){return 0===t?this.p0:this.p1},yl.prototype.distancePerpendicular=function(t){return uc.distancePointLinePerpendicular(t,this.p0,this.p1)},yl.prototype.minY=function(){return Math.min(this.p0.y,this.p1.y)},yl.prototype.midPoint=function(){return yl.midPoint(this.p0,this.p1)},yl.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;if(r<=0)return xu.NaN;return((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/r},yl.prototype.closestPoints=function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),r=xu.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)return this.project(t);return this.p0.distance(t)1||xu.isNaN(e))&&(e=1),e},yl.prototype.toString=function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"},yl.prototype.isHorizontal=function(){return this.p0.y===this.p1.y},yl.prototype.distance=function(){if(arguments[0]instanceof yl){var t=arguments[0];return uc.distanceLineLine(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof Nu){var e=arguments[0];return uc.distancePointLine(e,this.p0,this.p1)}},yl.prototype.pointAlong=function(t){var e=new Nu;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},yl.prototype.hashCode=function(){var t=xu.doubleToLongBits(this.p0.x);t^=31*xu.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=xu.doubleToLongBits(this.p1.x);n^=31*xu.doubleToLongBits(this.p1.y);return e^(Math.trunc(n)^Math.trunc(n>>32))},yl.prototype.interfaces_=function(){return[wu,Mi]},yl.prototype.getClass=function(){return yl},yl.midPoint=function(t,e){return new Nu((t.x+e.x)/2,(t.y+e.y)/2)},_l.serialVersionUID.get=function(){return 0x2d2172135f411c00},Object.defineProperties(yl,_l);var ml=function(){this.tempEnv1=new Hu,this.tempEnv2=new Hu,this._overlapSeg1=new yl,this._overlapSeg2=new yl};ml.prototype.overlap=function(){if(2===arguments.length);else if(4===arguments.length){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)}},ml.prototype.interfaces_=function(){return[]},ml.prototype.getClass=function(){return ml};var vl=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};vl.prototype.getLineSegment=function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]},vl.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=zh.quadrant(t[n],t[n+1]),i=e+1;in.getId()&&(n.computeOverlaps(i,t),this._nOverlaps++),this._segInt.isDone())return null}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},n.SegmentOverlapAction.get=function(){return Il},Object.defineProperties(e,n),e}(wl),Il=function(t){function e(){t.call(this),this._si=null;var e=arguments[0];this._si=e}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.overlap=function(){if(4!==arguments.length)return t.prototype.overlap.apply(this,arguments);var e=arguments[0],n=arguments[1],r=arguments[2],i=arguments[3],o=e.getContext(),s=r.getContext();this._si.processIntersections(o,n,s,i)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(ml),Nl=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,0===arguments.length);else if(1===arguments.length){var e=arguments[0];this.setQuadrantSegments(e)}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(r)}else if(4===arguments.length){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)}},Cl={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}};Nl.prototype.getEndCapStyle=function(){return this._endCapStyle},Nl.prototype.isSingleSided=function(){return this._isSingleSided},Nl.prototype.setQuadrantSegments=function(t){this._quadrantSegments=t,0===this._quadrantSegments&&(this._joinStyle=Nl.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=Nl.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==Nl.JOIN_ROUND&&(this._quadrantSegments=Nl.DEFAULT_QUADRANT_SEGMENTS)},Nl.prototype.getJoinStyle=function(){return this._joinStyle},Nl.prototype.setJoinStyle=function(t){this._joinStyle=t},Nl.prototype.setSimplifyFactor=function(t){this._simplifyFactor=t<0?0:t},Nl.prototype.getSimplifyFactor=function(){return this._simplifyFactor},Nl.prototype.getQuadrantSegments=function(){return this._quadrantSegments},Nl.prototype.setEndCapStyle=function(t){this._endCapStyle=t},Nl.prototype.getMitreLimit=function(){return this._mitreLimit},Nl.prototype.setMitreLimit=function(t){this._mitreLimit=t},Nl.prototype.setSingleSided=function(t){this._isSingleSided=t},Nl.prototype.interfaces_=function(){return[]},Nl.prototype.getClass=function(){return Nl},Nl.bufferDistanceError=function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)},Cl.CAP_ROUND.get=function(){return 1},Cl.CAP_FLAT.get=function(){return 2},Cl.CAP_SQUARE.get=function(){return 3},Cl.JOIN_ROUND.get=function(){return 1},Cl.JOIN_MITRE.get=function(){return 2},Cl.JOIN_BEVEL.get=function(){return 3},Cl.DEFAULT_QUADRANT_SEGMENTS.get=function(){return 8},Cl.DEFAULT_MITRE_LIMIT.get=function(){return 5},Cl.DEFAULT_SIMPLIFY_FACTOR.get=function(){return.01},Object.defineProperties(Nl,Cl);var Sl=function(t){this._distanceTol=null,this._isDeleted=null,this._angleOrientation=uc.COUNTERCLOCKWISE,this._inputLine=t||null},Ml={INIT:{configurable:!0},DELETE:{configurable:!0},KEEP:{configurable:!0},NUM_PTS_TO_CHECK:{configurable:!0}};Sl.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))},Sl.prototype.deleteShallowConcavities=function(){for(var t=1,e=this.findNextNonDeletedIndex(t),n=this.findNextNonDeletedIndex(e),r=!1;n=0;r--)this.addPt(t[r])},Ll.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-=Ol.PI_TIMES_2;for(;t<=-Math.PI;)t+=Ol.PI_TIMES_2;return t},Ol.angle=function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],r=n.x-e.x,i=n.y-e.y;return Math.atan2(i,r)}},Ol.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},Ol.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},Ol.interiorAngle=function(t,e,n){var r=Ol.angle(e,t),i=Ol.angle(e,n);return Math.abs(i-r)},Ol.normalizePositive=function(t){if(t<0){for(;t<0;)t+=Ol.PI_TIMES_2;t>=Ol.PI_TIMES_2&&(t=0)}else{for(;t>=Ol.PI_TIMES_2;)t-=Ol.PI_TIMES_2;t<0&&(t=0)}return t},Ol.angleBetween=function(t,e,n){var r=Ol.angle(e,t),i=Ol.angle(e,n);return Ol.diff(r,i)},Ol.diff=function(t,e){var n=null;return(n=tMath.PI&&(n=2*Math.PI-n),n},Ol.toRadians=function(t){return t*Math.PI/180},Ol.getTurn=function(t,e){var n=Math.sin(e-t);return n>0?Ol.COUNTERCLOCKWISE:n<0?Ol.CLOCKWISE:Ol.NONE},Ol.angleBetweenOriented=function(t,e,n){var r=Ol.angle(e,t),i=Ol.angle(e,n)-r;return i<=-Math.PI?i+Ol.PI_TIMES_2:i>Math.PI?i-Ol.PI_TIMES_2:i},Rl.PI_TIMES_2.get=function(){return 2*Math.PI},Rl.PI_OVER_2.get=function(){return Math.PI/2},Rl.PI_OVER_4.get=function(){return Math.PI/4},Rl.COUNTERCLOCKWISE.get=function(){return uc.COUNTERCLOCKWISE},Rl.CLOCKWISE.get=function(){return uc.CLOCKWISE},Rl.NONE.get=function(){return uc.COLLINEAR},Object.defineProperties(Ol,Rl);var Tl=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 yl,this._seg1=new yl,this._offset0=new yl,this._offset1=new yl,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 oc,this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===Nl.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(r)},Al={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}};Tl.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=uc.computeOrientation(this._s0,this._s1,this._s2),r=n===uc.CLOCKWISE&&this._side===Sh.LEFT||n===uc.COUNTERCLOCKWISE&&this._side===Sh.RIGHT;0===n?this.addCollinear(e):r?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)},Tl.prototype.addLineEndCap=function(t,e){var n=new yl(t,e),r=new yl;this.computeOffsetSegment(n,Sh.LEFT,this._distance,r);var i=new yl;this.computeOffsetSegment(n,Sh.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 Nl.CAP_ROUND:this._segList.addPt(r.p1),this.addFilletArc(e,a+Math.PI/2,a-Math.PI/2,uc.CLOCKWISE,this._distance),this._segList.addPt(i.p1);break;case Nl.CAP_FLAT:this._segList.addPt(r.p1),this._segList.addPt(i.p1);break;case Nl.CAP_SQUARE:var u=new Nu;u.x=Math.abs(this._distance)*Math.cos(a),u.y=Math.abs(this._distance)*Math.sin(a);var c=new Nu(r.p1.x+u.x,r.p1.y+u.y),h=new Nu(i.p1.x+u.x,i.p1.y+u.y);this._segList.addPt(c),this._segList.addPt(h)}},Tl.prototype.getCoordinates=function(){return this._segList.getCoordinates()},Tl.prototype.addMitreJoin=function(t,e,n,r){var i=!0,o=null;try{o=Vu.intersection(e.p0,e.p1,n.p0,n.p1);(r<=0?1:o.distance(t)/Math.abs(r))>this._bufParams.getMitreLimit()&&(i=!1)}catch(t){if(!(t instanceof Uu))throw t;o=new Nu(0,0),i=!1}i?this._segList.addPt(o):this.addLimitedMitreJoin(e,n,r,this._bufParams.getMitreLimit())},Tl.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,c=n.y-t.y,h=Math.atan2(c,u);r===uc.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)},Tl.prototype.addOutsideTurn=function(t,e){if(this._offset0.p1.distance(this._offset1.p0)0){var n=new Nu((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 Nu((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)}},Tl.prototype.createCircle=function(t){var e=new Nu(t.x+this._distance,t.y);this._segList.addPt(e),this.addFilletArc(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()},Tl.prototype.addBevelJoin=function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)},Tl.prototype.init=function(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new Ll,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*Tl.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)},Tl.prototype.addCollinear=function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2);this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===Nl.JOIN_BEVEL||this._bufParams.getJoinStyle()===Nl.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,uc.CLOCKWISE,this._distance))},Tl.prototype.closeRing=function(){this._segList.closeRing()},Tl.prototype.hasNarrowConcaveAngle=function(){return this._hasNarrowConcaveAngle},Tl.prototype.interfaces_=function(){return[]},Tl.prototype.getClass=function(){return Tl},Al.OFFSET_SEGMENT_SEPARATION_FACTOR.get=function(){return.001},Al.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return.001},Al.CURVE_VERTEX_SNAP_DISTANCE_FACTOR.get=function(){return 1e-6},Al.MAX_CLOSING_SEG_LEN_FACTOR.get=function(){return 80},Object.defineProperties(Tl,Al);var Dl=function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e};Dl.prototype.getOffsetCurve=function(t,e){if(this._distance=e,0===e)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&&Mc.reverse(o),o},Dl.prototype.computeSingleSidedBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var i=Sl.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],Sh.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(i[s],!0)}else{n.addSegments(t,!1);var a=Sl.simplify(t,r),u=a.length-1;n.initSideSegments(a[0],a[1],Sh.LEFT),n.addFirstSegment();for(var c=2;c<=u;c++)n.addNextSegment(a[c],!0)}n.addLastSegment(),n.closeRing()},Dl.prototype.computeRingBufferCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);e===Sh.RIGHT&&(r=-r);var i=Sl.simplify(t,r),o=i.length-1;n.initSideSegments(i[o-1],i[0],e);for(var s=1;s<=o;s++){var a=1!==s;n.addNextSegment(i[s],a)}n.closeRing()},Dl.prototype.computeLineBufferCurve=function(t,e){var n=this.simplifyTolerance(this._distance),r=Sl.simplify(t,n),i=r.length-1;e.initSideSegments(r[0],r[1],Sh.LEFT);for(var o=2;o<=i;o++)e.addNextSegment(r[o],!0);e.addLastSegment(),e.addLineEndCap(r[i-1],r[i]);var s=Sl.simplify(t,-n),a=s.length-1;e.initSideSegments(s[a],s[a-1],Sh.LEFT);for(var u=a-2;u>=0;u--)e.addNextSegment(s[u],!0);e.addLastSegment(),e.addLineEndCap(s[1],s[0]),e.closeRing()},Dl.prototype.computePointCurve=function(t,e){switch(this._bufParams.getEndCapStyle()){case Nl.CAP_ROUND:e.createCircle(t);break;case Nl.CAP_SQUARE:e.createSquare(t)}},Dl.prototype.getLineCurve=function(t,e){if(this._distance=e,e<0&&!this._bufParams.isSingleSided())return null;if(0===e)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()},Dl.prototype.getBufferParameters=function(){return this._bufParams},Dl.prototype.simplifyTolerance=function(t){return t*this._bufParams.getSimplifyFactor()},Dl.prototype.getRingCurve=function(t,e,n){if(this._distance=n,t.length<=2)return this.getLineCurve(t,n);if(0===n)return Dl.copyCoordinates(t);var r=this.getSegGen(n);return this.computeRingBufferCurve(t,e,r),r.getCoordinates()},Dl.prototype.computeOffsetCurve=function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){var i=Sl.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],Sh.LEFT),n.addFirstSegment();for(var s=o-2;s>=0;s--)n.addNextSegment(i[s],!0)}else{var a=Sl.simplify(t,r),u=a.length-1;n.initSideSegments(a[0],a[1],Sh.LEFT),n.addFirstSegment();for(var c=2;c<=u;c++)n.addNextSegment(a[c],!0)}n.addLastSegment()},Dl.prototype.getSegGen=function(t){return new Tl(this._precisionModel,this._bufParams,t)},Dl.prototype.interfaces_=function(){return[]},Dl.prototype.getClass=function(){return Dl},Dl.copyCoordinates=function(t){for(var e=new Array(t.length).fill(null),n=0;ni.getMaxY()||this.findStabbedSegments(t,r.getDirectedEdges(),e)}return e}if(3===arguments.length)if(Ou(arguments[2],Ic)&&arguments[0]instanceof Nu&&arguments[1]instanceof Uh)for(var o=arguments[0],s=arguments[1],a=arguments[2],u=s.getEdge().getCoordinates(),c=0;cthis._seg.p1.y&&this._seg.reverse();if(!(Math.max(this._seg.p0.x,this._seg.p1.x)this._seg.p1.y||uc.computeOrientation(this._seg.p0,this._seg.p1,o)===uc.RIGHT)){var h=s.getDepth(Sh.LEFT);this._seg.p0.equals(u[c])||(h=s.getDepth(Sh.RIGHT));var l=new Gl(this._seg,h);a.add(l)}}else if(Ou(arguments[2],Ic)&&arguments[0]instanceof Nu&&Ou(arguments[1],Ic))for(var p=arguments[0],f=arguments[1],g=arguments[2],d=f.iterator();d.hasNext();){var y=d.next();y.isForward()&&this.findStabbedSegments(p,y,g)}},Fl.prototype.getDepth=function(t){var e=this.findStabbedSegments(t);if(0===e.size())return 0;return el.min(e)._leftDepth},Fl.prototype.interfaces_=function(){return[]},Fl.prototype.getClass=function(){return Fl},ql.DepthSegment.get=function(){return Gl},Object.defineProperties(Fl,ql);var Gl=function(){this._upwardSeg=null,this._leftDepth=null;var t=arguments[0],e=arguments[1];this._upwardSeg=new yl(t),this._leftDepth=e};Gl.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 0!==n?n:0!=(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?n:this._upwardSeg.compareTo(e._upwardSeg)},Gl.prototype.compareX=function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1)},Gl.prototype.toString=function(){return this._upwardSeg.toString()},Gl.prototype.interfaces_=function(){return[wu]},Gl.prototype.getClass=function(){return Gl};var Bl=function(t,e,n){this.p0=t||null,this.p1=e||null,this.p2=n||null};Bl.prototype.area=function(){return Bl.area(this.p0,this.p1,this.p2)},Bl.prototype.signedArea=function(){return Bl.signedArea(this.p0,this.p1,this.p2)},Bl.prototype.interpolateZ=function(t){if(null===t)throw new vu("Supplied point is null.");return Bl.interpolateZ(t,this.p0,this.p1,this.p2)},Bl.prototype.longestSideLength=function(){return Bl.longestSideLength(this.p0,this.p1,this.p2)},Bl.prototype.isAcute=function(){return Bl.isAcute(this.p0,this.p1,this.p2)},Bl.prototype.circumcentre=function(){return Bl.circumcentre(this.p0,this.p1,this.p2)},Bl.prototype.area3D=function(){return Bl.area3D(this.p0,this.p1,this.p2)},Bl.prototype.centroid=function(){return Bl.centroid(this.p0,this.p1,this.p2)},Bl.prototype.inCentre=function(){return Bl.inCentre(this.p0,this.p1,this.p2)},Bl.prototype.interfaces_=function(){return[]},Bl.prototype.getClass=function(){return Bl},Bl.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)},Bl.signedArea=function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2},Bl.det=function(t,e,n,r){return t*r-e*n},Bl.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,c=r.y-o,h=s*c-a*u,l=t.x-i,p=t.y-o,f=(c*l-a*p)/h,g=(-u*l+s*p)/h;return e.z+f*(n.z-e.z)+g*(r.z-e.z)},Bl.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},Bl.isAcute=function(t,e,n){return!!Ol.isAcute(t,e,n)&&(!!Ol.isAcute(e,n,t)&&!!Ol.isAcute(n,t,e))},Bl.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,c=2*Bl.det(o,s,a,u),h=Bl.det(s,o*o+s*s,u,a*a+u*u),l=Bl.det(o,o*o+s*s,a,a*a+u*u);return new Nu(r-h/c,i+l/c)},Bl.perpendicularBisector=function(t,e){var n=e.x-t.x,r=e.y-t.y,i=new Vu(t.x+n/2,t.y+r/2,1),o=new Vu(t.x-r+n/2,t.y+n+r/2,1);return new Vu(i,o)},Bl.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 Nu(t.x+i*o,t.y+i*s)},Bl.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,c=i*u-o*a,h=o*s-r*u,l=r*a-i*s,p=c*c+h*h+l*l,f=Math.sqrt(p)/2;return f},Bl.centroid=function(t,e,n){var r=(t.x+e.x+n.x)/3,i=(t.y+e.y+n.y)/3;return new Nu(r,i)},Bl.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 Nu(a,u)};var kl=function(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new Nc;var t=arguments[0],e=arguments[1],n=arguments[2];this._inputGeom=t,this._distance=e,this._curveBuilder=n};kl.prototype.addPoint=function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,Lu.EXTERIOR,Lu.INTERIOR)},kl.prototype.addPolygon=function(t){var e=this._distance,n=Sh.LEFT;this._distance<0&&(e=-this._distance,n=Sh.RIGHT);var r=t.getExteriorRing(),i=Mc.removeRepeatedPoints(r.getCoordinates());if(this._distance<0&&this.isErodedCompletely(r,this._distance))return null;if(this._distance<=0&&i.length<3)return null;this.addPolygonRing(i,e,n,Lu.EXTERIOR,Lu.INTERIOR);for(var o=0;o0&&this.isErodedCompletely(s,-this._distance)||this.addPolygonRing(a,e,Sh.opposite(n),Lu.INTERIOR,Lu.EXTERIOR)}},kl.prototype.isTriangleErodedCompletely=function(t,e){var n=new Bl(t[0],t[1],t[2]),r=n.inCentre();return uc.distancePointLine(r,n.p0,n.p1)=rh.MINIMUM_VALID_SIZE&&uc.isCCW(t)&&(o=i,s=r,n=Sh.opposite(n));var a=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(a,o,s)},kl.prototype.add=function(t){if(t.isEmpty())return null;t instanceof eh?this.addPolygon(t):t instanceof Kc?this.addLineString(t):t instanceof $c?this.addPoint(t):t instanceof nh?this.addCollection(t):t instanceof Yc?this.addCollection(t):t instanceof ih?this.addCollection(t):t instanceof Uc&&this.addCollection(t)},kl.prototype.isErodedCompletely=function(t,e){var n=t.getCoordinates();if(n.length<4)return e<0;if(4===n.length)return this.isTriangleErodedCompletely(n,e);var r=t.getEnvelopeInternal(),i=Math.min(r.getHeight(),r.getWidth());return e<0&&2*Math.abs(e)>i},kl.prototype.addCollection=function(t){for(var e=0;e=this._max)throw new Li;var t=this._parent.getGeometryN(this._index++);return t instanceof Uc?(this._subcollectionIterator=new jl(t),this._subcollectionIterator.next()):t},jl.prototype.remove=function(){throw new Error(this.getClass().getName())},jl.prototype.hasNext=function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)},jl.prototype.interfaces_=function(){return[bc]},jl.prototype.getClass=function(){return jl},jl.isAtomic=function(t){return!(t instanceof Uc)};var Xl=function(){this._geom=null;var t=arguments[0];this._geom=t};Xl.prototype.locate=function(t){return Xl.locate(t,this._geom)},Xl.prototype.interfaces_=function(){return[zl]},Xl.prototype.getClass=function(){return Xl},Xl.isPointInRing=function(t,e){return!!e.getEnvelopeInternal().intersects(t)&&uc.isPointInRing(t,e.getCoordinates())},Xl.containsPointInPolygon=function(t,e){if(e.isEmpty())return!1;var n=e.getExteriorRing();if(!Xl.isPointInRing(t,n))return!1;for(var r=0;r=0;n--){var r=this._edgeList.get(n),i=r.getSym();null===e&&(e=i),null!==t&&i.setNext(t),t=r}e.setNext(t)},e.prototype.computeDepths=function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth(Sh.LEFT),r=t.getDepth(Sh.RIGHT),i=this.computeDepths(e+1,this._edgeList.size(),n);if(this.computeDepths(0,e,i)!==r)throw new Ph("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[0],s=arguments[1],a=arguments[2],u=o;u=0;i--){var o=this._resultAreaEdgeList.get(i),s=o.getSym();switch(null===e&&o.getEdgeRing()===t&&(e=o),r){case this._SCANNING_FOR_INCOMING:if(s.getEdgeRing()!==t)continue;n=s,r=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(o.getEdgeRing()!==t)continue;n.setNextMin(o),r=this._SCANNING_FOR_INCOMING}}r===this._LINKING_TO_OUTGOING&&(nc.isTrue(null!==e,"found null for first outgoing dirEdge"),nc.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(e))},e.prototype.getOutgoingDegree=function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();){e.next().isInResult()&&t++}return t}if(1===arguments.length){for(var n=arguments[0],r=0,i=this.iterator();i.hasNext();){i.next().getEdgeRing()===n&&r++}return r}},e.prototype.getLabel=function(){return this._label},e.prototype.findCoveredLineEdges=function(){for(var t=Lu.NONE,e=this.iterator();e.hasNext();){var n=e.next(),r=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=Lu.INTERIOR;break}if(r.isInResult()){t=Lu.EXTERIOR;break}}}if(t===Lu.NONE)return null;for(var i=t,o=this.iterator();o.hasNext();){var s=o.next(),a=s.getSym();s.isLineEdge()?s.getEdge().setCovered(i===Lu.INTERIOR):(s.isInResult()&&(i=Lu.EXTERIOR),a.isInResult()&&(i=Lu.INTERIOR))}},e.prototype.computeLabelling=function(e){t.prototype.computeLabelling.call(this,e),this._label=new Ah(Lu.NONE);for(var n=this.iterator();n.hasNext();)for(var r=n.next().getEdge().getLabel(),i=0;i<2;i++){var o=r.getLocation(i);o!==Lu.INTERIOR&&o!==Lu.BOUNDARY||this._label.setLocation(i,Lu.INTERIOR)}},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Ul),Vl=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(t){return new Bh(t,new Yl)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Yh),Hl=function t(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e)};Hl.prototype.compareTo=function(t){var e=t;return Hl.compareOriented(this._pts,this._orientation,e._pts,e._orientation)},Hl.prototype.interfaces_=function(){return[wu]},Hl.prototype.getClass=function(){return Hl},Hl.orientation=function(t){return 1===Mc.increasingDirection(t)},Hl.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,c=r?0:n.length-1;;){var h=t[u].compareTo(n[c]);if(0!==h)return h;var l=(u+=i)===s,p=(c+=o)===a;if(l&&!p)return-1;if(!l&&p)return 1;if(l&&p)return 0}};var Wl=function(){this._edges=new Nc,this._ocaMap=new qi};Wl.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(") ")},Wl.prototype.addAll=function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())},Wl.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 Nu(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 rp(o,new Ah(this.edge._label))},Ql.prototype.add=function(t,e,n){var r=new Kl(t,e,n),i=this._nodeMap.get(r);return null!==i?i:(this._nodeMap.put(r,r),r)},Ql.prototype.isIntersection=function(t){for(var e=this.iterator();e.hasNext();){if(e.next().coord.equals(t))return!0}return!1},Ql.prototype.interfaces_=function(){return[]},Ql.prototype.getClass=function(){return Ql};var $l=function(){};$l.prototype.getChainStartIndices=function(t){var e=0,n=new Nc;n.add(new Du(e));do{var r=this.findChainEnd(t,e);n.add(new Du(r)),e=r}while(en?e:n},tp.prototype.getMinX=function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return ee&&(r=1),this._depth[t][n]=r}}},ep.prototype.getDelta=function(t){return this._depth[t][Sh.RIGHT]-this._depth[t][Sh.LEFT]},ep.prototype.getLocation=function(t,e){return this._depth[t][e]<=0?Lu.EXTERIOR:Lu.INTERIOR},ep.prototype.toString=function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]},ep.prototype.add=function(){if(1===arguments.length)for(var t=arguments[0],e=0;e<2;e++)for(var n=1;n<3;n++){var r=t.getLocation(e,n);r!==Lu.EXTERIOR&&r!==Lu.INTERIOR||(this.isNull(e,n)?this._depth[e][n]=ep.depthAtLocation(r):this._depth[e][n]+=ep.depthAtLocation(r))}else if(3===arguments.length){var i=arguments[0],o=arguments[1];arguments[2]===Lu.INTERIOR&&this._depth[i][o]++}},ep.prototype.interfaces_=function(){return[]},ep.prototype.getClass=function(){return ep},ep.depthAtLocation=function(t){return t===Lu.EXTERIOR?0:t===Lu.INTERIOR?1:ep.NULL_VALUE},np.NULL_VALUE.get=function(){return-1},Object.defineProperties(ep,np);var rp=function(t){function e(){if(t.call(this),this.pts=null,this._env=null,this.eiList=new Ql(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new ep,this._depthDelta=0,1===arguments.length){var n=arguments[0];e.call(this,n,null)}else if(2===arguments.length){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 t=new Array(2).fill(null);t[0]=this.pts[0],t[1]=this.pts[1];return new e(t,Ah.toLineLabel(this._label))},e.prototype.isIsolated=function(){return this._isIsolated},e.prototype.getCoordinates=function(){return this.pts},e.prototype.setIsolated=function(t){this._isIsolated=t},e.prototype.setName=function(t){this._name=t},e.prototype.equals=function(t){if(!(t instanceof e))return!1;var n=t;if(this.pts.length!==n.pts.length)return!1;for(var r=!0,i=!0,o=this.pts.length,s=0;s0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}},e.prototype.print=function(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(var e=0;e0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this._label+" "+this._depthDelta)},e.prototype.computeIM=function(t){e.updateIM(this._label,t)},e.prototype.isCollapsed=function(){return!!this._label.isArea()&&(3===this.pts.length&&!!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(t){t.print("edge "+this._name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")},e.prototype.getMonotoneChainEdge=function(){return null===this._mce&&(this._mce=new tp(this)),this._mce},e.prototype.getEnvelope=function(){if(null===this._env){this._env=new Hu;for(var t=0;t0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this._label+" "+this._depthDelta),t.toString()},e.prototype.isPointwiseEqual=function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;er||this._maxyo;if(s)return!1;var a=this.intersectsToleranceSquare(t,e);return nc.isTrue(!(s&&a),"Found bad envelope test"),a},up.prototype.initCorners=function(t){this._minx=t.x-.5,this._maxx=t.x+.5,this._miny=t.y-.5,this._maxy=t.y+.5,this._corner[0]=new Nu(this._maxx,this._maxy),this._corner[1]=new Nu(this._minx,this._maxy),this._corner[2]=new Nu(this._minx,this._miny),this._corner[3]=new Nu(this._maxx,this._miny)},up.prototype.intersects=function(t,e){return 1===this._scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))},up.prototype.scale=function(t){return Math.round(t*this._scaleFactor)},up.prototype.getCoordinate=function(){return this._originalPt},up.prototype.copyScaled=function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)},up.prototype.getSafeEnvelope=function(){if(null===this._safeEnv){var t=up.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new Hu(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}return this._safeEnv},up.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())))},up.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))))))},up.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)},up.prototype.interfaces_=function(){return[]},up.prototype.getClass=function(){return up},cp.SAFE_ENV_EXPANSION_FACTOR.get=function(){return.75},Object.defineProperties(up,cp);var hp=function(){this.tempEnv1=new Hu,this.selectedSegment=new yl};hp.prototype.select=function(){if(1===arguments.length);else if(2===arguments.length){var t=arguments[0],e=arguments[1];t.getLineSegment(e,this.selectedSegment),this.select(this.selectedSegment)}},hp.prototype.interfaces_=function(){return[]},hp.prototype.getClass=function(){return hp};var lp=function(){this._index=null;var t=arguments[0];this._index=t},pp={HotPixelSnapAction:{configurable:!0}};lp.prototype.snap=function(){if(1===arguments.length){var t=arguments[0];return this.snap(t,null,-1)}if(3===arguments.length){var e=arguments[0],n=arguments[1],r=arguments[2],i=e.getSafeEnvelope(),o=new fp(e,n,r);return this._index.query(i,{interfaces_:function(){return[Kh]},visitItem:function(t){t.select(i,o)}}),o.isNodeAdded()}},lp.prototype.interfaces_=function(){return[]},lp.prototype.getClass=function(){return lp},pp.HotPixelSnapAction.get=function(){return fp},Object.defineProperties(lp,pp);var fp=function(t){function e(){t.call(this),this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var e=arguments[0],n=arguments[1],r=arguments[2];this._hotPixel=e,this._parentEdge=n,this._hotPixelVertexIndex=r}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(2!==arguments.length)return t.prototype.select.apply(this,arguments);var e=arguments[0],n=arguments[1],r=e.getContext();if(null!==this._parentEdge&&r===this._parentEdge&&n===this._hotPixelVertexIndex)return null;this._isNodeAdded=this._hotPixel.addSnappedNode(r,n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(hp),gp=function(){this._li=null,this._interiorIntersections=null;var t=arguments[0];this._li=t,this._interiorIntersections=new Nc};gp.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(e){if(!(e instanceof Ph))throw e;t._saveException=e}if(null!==t._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var n=arguments[0],r=yp.precisionScaleFactor(this._argGeom,this._distance,n),i=new dh(r);this.bufferFixedPrecision(i)}},yp.prototype.computeGeometry=function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===dh.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()},yp.prototype.setQuadrantSegments=function(t){this._bufParams.setQuadrantSegments(t)},yp.prototype.bufferOriginalPrecision=function(){try{var t=new ip(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(t){if(!(t instanceof tc))throw t;this._saveException=t}},yp.prototype.getResultGeometry=function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry},yp.prototype.setEndCapStyle=function(t){this._bufParams.setEndCapStyle(t)},yp.prototype.interfaces_=function(){return[]},yp.prototype.getClass=function(){return yp},yp.bufferOp=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return new yp(t).getResultGeometry(e)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof lc&&"number"==typeof arguments[1]){var n=arguments[0],r=arguments[1],i=arguments[2],o=new yp(n);o.setQuadrantSegments(i);return o.getResultGeometry(r)}if(arguments[2]instanceof Nl&&arguments[0]instanceof lc&&"number"==typeof arguments[1]){var s=arguments[0],a=arguments[1],u=arguments[2];return new yp(s,u).getResultGeometry(a)}}else if(4===arguments.length){var c=arguments[0],h=arguments[1],l=arguments[2],p=arguments[3],f=new yp(c);f.setQuadrantSegments(l),f.setEndCapStyle(p);return f.getResultGeometry(h)}},yp.precisionScaleFactor=function(t,e,n){var r=t.getEnvelopeInternal(),i=Ru.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)},_p.CAP_ROUND.get=function(){return Nl.CAP_ROUND},_p.CAP_BUTT.get=function(){return Nl.CAP_FLAT},_p.CAP_FLAT.get=function(){return Nl.CAP_FLAT},_p.CAP_SQUARE.get=function(){return Nl.CAP_SQUARE},_p.MAX_PRECISION_DIGITS.get=function(){return 12},Object.defineProperties(yp,_p);var mp=function(){this._pt=[new Nu,new Nu],this._distance=xu.NaN,this._isNull=!0};mp.prototype.getCoordinates=function(){return this._pt},mp.prototype.getCoordinate=function(t){return this._pt[t]},mp.prototype.setMinimum=function(){if(1===arguments.length){var t=arguments[0];this.setMinimum(t._pt[0],t._pt[1])}else if(2===arguments.length){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)}},mp.prototype.interfaces_=function(){return[]},mp.prototype.getClass=function(){return mp};var vp=function(){};vp.prototype.interfaces_=function(){return[]},vp.prototype.getClass=function(){return vp},vp.computeDistance=function(){if(arguments[2]instanceof mp&&arguments[0]instanceof Kc&&arguments[1]instanceof Nu)for(var t=arguments[0],e=arguments[1],n=arguments[2],r=t.getCoordinates(),i=new yl,o=0;o0||this._isIn?Lu.INTERIOR:Lu.EXTERIOR)},Cp.prototype.interfaces_=function(){return[]},Cp.prototype.getClass=function(){return Cp};var Sp=function t(){if(this._component=null,this._segIndex=null,this._pt=null,2===arguments.length){var e=arguments[0],n=arguments[1];t.call(this,e,t.INSIDE_AREA,n)}else if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];this._component=r,this._segIndex=i,this._pt=o}},Mp={INSIDE_AREA:{configurable:!0}};Sp.prototype.isInsideArea=function(){return this._segIndex===Sp.INSIDE_AREA},Sp.prototype.getCoordinate=function(){return this._pt},Sp.prototype.getGeometryComponent=function(){return this._component},Sp.prototype.getSegmentIndex=function(){return this._segIndex},Sp.prototype.interfaces_=function(){return[]},Sp.prototype.getClass=function(){return Sp},Mp.INSIDE_AREA.get=function(){return-1},Object.defineProperties(Sp,Mp);var Lp=function(t){this._pts=t||null};Lp.prototype.filter=function(t){t instanceof $c&&this._pts.add(t)},Lp.prototype.interfaces_=function(){return[jc]},Lp.prototype.getClass=function(){return Lp},Lp.getPoints=function(){if(1===arguments.length){var t=arguments[0];return t instanceof $c?el.singletonList(t):Lp.getPoints(t,new Nc)}if(2===arguments.length){var e=arguments[0],n=arguments[1];return e instanceof $c?n.add(e):e instanceof Uc&&e.apply(new Lp(n)),n}};var Pp=function(){this._locations=null;var t=arguments[0];this._locations=t};Pp.prototype.filter=function(t){(t instanceof $c||t instanceof Kc||t instanceof eh)&&this._locations.add(new Sp(t,0,t.getCoordinate()))},Pp.prototype.interfaces_=function(){return[jc]},Pp.prototype.getClass=function(){return Pp},Pp.getLocations=function(t){var e=new Nc;return t.apply(new Pp(e)),e};var Op=function(){if(this._geom=null,this._terminateDistance=0,this._ptLocator=new Cp,this._minDistanceLocation=null,this._minDistance=xu.MAX_VALUE,2===arguments.length){var t=arguments[0],e=arguments[1];this._geom=[t,e],this._terminateDistance=0}else if(3===arguments.length){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}};Op.prototype.computeContainmentDistance=function(){if(0===arguments.length){var t=new Array(2).fill(null);if(this.computeContainmentDistance(0,t),this._minDistance<=this._terminateDistance)return null;this.computeContainmentDistance(1,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],r=1-e,i=Ip.getPolygons(this._geom[e]);if(i.size()>0){var o=Pp.getLocations(this._geom[r]);if(this.computeContainmentDistance(o,i,n),this._minDistance<=this._terminateDistance)return this._minDistanceLocation[r]=n[0],this._minDistanceLocation[e]=n[1],null}}else if(3===arguments.length)if(arguments[2]instanceof Array&&Ou(arguments[0],Ic)&&Ou(arguments[1],Ic)){for(var s=arguments[0],a=arguments[1],u=arguments[2],c=0;cthis._minDistance)return null;for(var r=t.getCoordinates(),i=e.getCoordinate(),o=0;othis._minDistance)return null;for(var l=u.getCoordinates(),p=c.getCoordinates(),f=0;fthis._distance&&this.initialize(e,n,r)}},Rp.prototype.interfaces_=function(){return[]},Rp.prototype.getClass=function(){return Rp};var Tp=function(){};Tp.prototype.interfaces_=function(){return[]},Tp.prototype.getClass=function(){return Tp},Tp.computeDistance=function(){if(arguments[2]instanceof Rp&&arguments[0]instanceof Kc&&arguments[1]instanceof Nu)for(var t=arguments[0],e=arguments[1],n=arguments[2],r=new yl,i=t.getCoordinates(),o=0;o1||t<=0)throw new vu("Fraction is not in range (0.0 - 1.0]");this._densifyFrac=t},Ap.prototype.compute=function(t,e){this.computeOrientedDistance(t,e,this._ptDist),this.computeOrientedDistance(e,t,this._ptDist)},Ap.prototype.distance=function(){return this.compute(this._g0,this._g1),this._ptDist.getDistance()},Ap.prototype.computeOrientedDistance=function(t,e,n){var r=new Fp(e);if(t.apply(r),n.setMaximum(r.getMaxPointDistance()),this._densifyFrac>0){var i=new qp(e,this._densifyFrac);t.apply(i),n.setMaximum(i.getMaxPointDistance())}},Ap.prototype.orientedDistance=function(){return this.computeOrientedDistance(this._g0,this._g1,this._ptDist),this._ptDist.getDistance()},Ap.prototype.interfaces_=function(){return[]},Ap.prototype.getClass=function(){return Ap},Ap.distance=function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];return new Ap(t,e).distance()}if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2],o=new Ap(n,r);return o.setDensifyFraction(i),o.distance()}},Dp.MaxPointDistanceFilter.get=function(){return Fp},Dp.MaxDensifiedByFractionDistanceFilter.get=function(){return qp},Object.defineProperties(Ap,Dp);var Fp=function(){this._maxPtDist=new Rp,this._minPtDist=new Rp,this._euclideanDist=new Tp,this._geom=null;var t=arguments[0];this._geom=t};Fp.prototype.filter=function(t){this._minPtDist.initialize(),Tp.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)},Fp.prototype.getMaxPointDistance=function(){return this._maxPtDist},Fp.prototype.interfaces_=function(){return[gc]},Fp.prototype.getClass=function(){return Fp};var qp=function(){this._maxPtDist=new Rp,this._minPtDist=new Rp,this._geom=null,this._numSubSegs=0;var t=arguments[0],e=arguments[1];this._geom=t,this._numSubSegs=Math.trunc(Math.round(1/e))};qp.prototype.filter=function(t,e){if(0===e)return null;for(var n=t.getCoordinate(e-1),r=t.getCoordinate(e),i=(r.x-n.x)/this._numSubSegs,o=(r.y-n.y)/this._numSubSegs,s=0;sn){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 "+$u.toLineString(i[0],i[1])+")"}},Gp.prototype.isValid=function(){var t=Math.abs(this._bufDistance),e=Gp.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(),Gp.VERBOSE&&Yu.out.println("Min Dist= "+this._minDistanceFound+" err= "+(1-this._minDistanceFound/this._bufDistance)+" Max Dist= "+this._maxDistanceFound+" err= "+(this._maxDistanceFound/this._bufDistance-1)),this._isValid)},Gp.prototype.checkNegativeValid=function(){if(!(this._input instanceof eh||this._input instanceof ih||this._input instanceof Uc))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)},Gp.prototype.getErrorIndicator=function(){return this._errorIndicator},Gp.prototype.checkMinimumDistance=function(t,e,n){var r=new Op(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?null:this._distance>0?null:(this._result.isEmpty()||(this._isValid=!1,this._errorMsg="Result is non-empty",this._errorIndicator=this._result),void this.report("ExpectedEmpty"))},kp.prototype.report=function(t){if(!kp.VERBOSE)return null;Yu.out.println("Check "+t+": "+(this._isValid?"passed":"FAILED"))},kp.prototype.getErrorMessage=function(){return this._errorMsg},kp.prototype.interfaces_=function(){return[]},kp.prototype.getClass=function(){return kp},kp.isValidMsg=function(t,e,n){var r=new kp(t,e,n);return r.isValid()?null:r.getErrorMessage()},kp.isValid=function(t,e,n){return!!new kp(t,e,n).isValid()},zp.VERBOSE.get=function(){return!1},zp.MAX_ENV_DIFF_FRAC.get=function(){return.012},Object.defineProperties(kp,zp);var jp=function(){this._pts=null,this._data=null;var t=arguments[0],e=arguments[1];this._pts=t,this._data=e};jp.prototype.getCoordinates=function(){return this._pts},jp.prototype.size=function(){return this._pts.length},jp.prototype.getCoordinate=function(t){return this._pts[t]},jp.prototype.isClosed=function(){return this._pts[0].equals(this._pts[this._pts.length-1])},jp.prototype.getSegmentOctant=function(t){return t===this._pts.length-1?-1:pl.octant(this.getCoordinate(t),this.getCoordinate(t+1))},jp.prototype.setData=function(t){this._data=t},jp.prototype.getData=function(){return this._data},jp.prototype.toString=function(){return $u.toLineString(new hh(this._pts))},jp.prototype.interfaces_=function(){return[fl]},jp.prototype.getClass=function(){return jp};var Xp=function(){this._findAllIntersections=!1,this._isCheckEndSegmentsOnly=!1,this._li=null,this._interiorIntersection=null,this._intSegments=null,this._intersections=new Nc,this._intersectionCount=0,this._keepIntersections=!0;var t=arguments[0];this._li=t,this._interiorIntersection=null};Xp.prototype.getInteriorIntersection=function(){return this._interiorIntersection},Xp.prototype.setCheckEndSegmentsOnly=function(t){this._isCheckEndSegmentsOnly=t},Xp.prototype.getIntersectionSegments=function(){return this._intSegments},Xp.prototype.count=function(){return this._intersectionCount},Xp.prototype.getIntersections=function(){return this._intersections},Xp.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},Xp.prototype.setKeepIntersections=function(t){this._keepIntersections=t},Xp.prototype.processIntersections=function(t,e,n,r){if(!this._findAllIntersections&&this.hasIntersection())return null;if(t===n&&e===r)return null;if(this._isCheckEndSegmentsOnly){if(!(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++)},Xp.prototype.isEndSegment=function(t,e){return 0===e||e>=t.size()-2},Xp.prototype.hasIntersection=function(){return null!==this._interiorIntersection},Xp.prototype.isDone=function(){return!this._findAllIntersections&&null!==this._interiorIntersection},Xp.prototype.interfaces_=function(){return[Jl]},Xp.prototype.getClass=function(){return Xp},Xp.createAllIntersectionsFinder=function(t){var e=new Xp(t);return e.setFindAllIntersections(!0),e},Xp.createAnyIntersectionFinder=function(t){return new Xp(t)},Xp.createIntersectionCounter=function(t){var e=new Xp(t);return e.setFindAllIntersections(!0),e.setKeepIntersections(!1),e};var Up=function(){this._li=new oc,this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0;var t=arguments[0];this._segStrings=t};Up.prototype.execute=function(){if(null!==this._segInt)return null;this.checkInteriorIntersections()},Up.prototype.getIntersections=function(){return this._segInt.getIntersections()},Up.prototype.isValid=function(){return this.execute(),this._isValid},Up.prototype.setFindAllIntersections=function(t){this._findAllIntersections=t},Up.prototype.checkInteriorIntersections=function(){this._isValid=!0,this._segInt=new Xp(this._li),this._segInt.setFindAllIntersections(this._findAllIntersections);var t=new bl;if(t.setSegmentIntersector(this._segInt),t.computeNodes(this._segStrings),this._segInt.hasIntersection())return this._isValid=!1,null},Up.prototype.checkValid=function(){if(this.execute(),!this._isValid)throw new Ph(this.getErrorMessage(),this._segInt.getInteriorIntersection())},Up.prototype.getErrorMessage=function(){if(this._isValid)return"no intersections found";var t=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+$u.toLineString(t[0],t[1])+" and "+$u.toLineString(t[2],t[3])},Up.prototype.interfaces_=function(){return[]},Up.prototype.getClass=function(){return Up},Up.computeIntersections=function(t){var e=new Up(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()};var Yp=function t(){this._nv=null;var e=arguments[0];this._nv=new Up(t.toSegmentStrings(e))};Yp.prototype.checkValid=function(){this._nv.checkValid()},Yp.prototype.interfaces_=function(){return[]},Yp.prototype.getClass=function(){return Yp},Yp.toSegmentStrings=function(t){for(var e=new Nc,n=t.iterator();n.hasNext();){var r=n.next();e.add(new jp(r.getCoordinates(),r))}return e},Yp.checkValid=function(t){new Yp(t).checkValid()};var Vp=function(t){this._mapOp=t};Vp.prototype.map=function(t){for(var e=new Nc,n=0;n0&&r<4&&!this._preserveType?this._factory.createLineString(n):this._factory.createLinearRing(n)},Jp.prototype.interfaces_=function(){return[]},Jp.prototype.getClass=function(){return Jp};var Zp=function t(){if(this._snapTolerance=0,this._srcPts=null,this._seg=new yl,this._allowSnappingToSourceVertices=!1,this._isClosed=!1,arguments[0]instanceof Kc&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1];t.call(this,e.getCoordinates(),n)}else if(arguments[0]instanceof Array&&"number"==typeof arguments[1]){var r=arguments[0],i=arguments[1];this._srcPts=r,this._isClosed=t.isClosed(r),this._snapTolerance=i}};Zp.prototype.snapVertices=function(t,e){for(var n=this._isClosed?t.size()-1:t.size(),r=0;r=0&&t.add(o+1,new Nu(i),!1)}},Zp.prototype.findSegmentIndexToSnap=function(t,e){for(var n=xu.MAX_VALUE,r=-1,i=0;ie&&(e=r)}return e}if(2===arguments.length){var i=arguments[0],o=arguments[1];return Math.min(Kp.computeOverlaySnapTolerance(i),Kp.computeOverlaySnapTolerance(o))}},Kp.computeSizeBasedSnapTolerance=function(t){var e=t.getEnvelopeInternal();return Math.min(e.getHeight(),e.getWidth())*Kp.SNAP_PRECISION_FACTOR},Kp.snapToSelf=function(t,e,n){return new Kp(t).snapToSelf(e,n)},Qp.SNAP_PRECISION_FACTOR.get=function(){return 1e-9},Object.defineProperties(Kp,Qp);var $p=function(t){function e(e,n,r){t.call(this),this._snapTolerance=e||null,this._snapPts=n||null,this._isSelfSnap=void 0!==r&&r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.snapLine=function(t,e){var n=new Zp(t,this._snapTolerance);return n.setAllowSnappingToSourceVertices(this._isSelfSnap),n.snapTo(e)},e.prototype.transformCoordinates=function(t,e){var n=t.toCoordinateArray(),r=this.snapLine(n,this._snapPts);return this._factory.getCoordinateSequenceFactory().create(r)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(Jp),tf=function(){this._isFirst=!0,this._commonMantissaBitsCount=53,this._commonBits=0,this._commonSignExp=null};tf.prototype.getCommon=function(){return xu.longBitsToDouble(this._commonBits)},tf.prototype.add=function(t){var e=xu.doubleToLongBits(t);if(this._isFirst)return this._commonBits=e,this._commonSignExp=tf.signExpBits(this._commonBits),this._isFirst=!1,null;if(tf.signExpBits(e)!==this._commonSignExp)return this._commonBits=0,null;this._commonMantissaBitsCount=tf.numCommonMostSigMantissaBits(this._commonBits,e),this._commonBits=tf.zeroLowerBits(this._commonBits,64-(12+this._commonMantissaBitsCount))},tf.prototype.toString=function(){if(1===arguments.length){var t=arguments[0],e=xu.longBitsToDouble(t),n="0000000000000000000000000000000000000000000000000000000000000000"+xu.toBinaryString(t),r=n.substring(n.length-64);return r.substring(0,1)+" "+r.substring(1,12)+"(exp) "+r.substring(12)+" [ "+e+" ]"}},tf.prototype.interfaces_=function(){return[]},tf.prototype.getClass=function(){return tf},tf.getBit=function(t,e){return 0!=(t&1<>52},tf.zeroLowerBits=function(t,e){return t&~((1<=0;r--){if(tf.getBit(t,r)!==tf.getBit(e,r))return n;n++}return 52};var ef=function(){this._commonCoord=null,this._ccFilter=new rf},nf={CommonCoordinateFilter:{configurable:!0},Translater:{configurable:!0}};ef.prototype.addCommonBits=function(t){var e=new of(this._commonCoord);t.apply(e),t.geometryChanged()},ef.prototype.removeCommonBits=function(t){if(0===this._commonCoord.x&&0===this._commonCoord.y)return t;var e=new Nu(this._commonCoord);e.x=-e.x,e.y=-e.y;var n=new of(e);return t.apply(n),t.geometryChanged(),t},ef.prototype.getCommonCoordinate=function(){return this._commonCoord},ef.prototype.add=function(t){t.apply(this._ccFilter),this._commonCoord=this._ccFilter.getCommonCoordinate()},ef.prototype.interfaces_=function(){return[]},ef.prototype.getClass=function(){return ef},nf.CommonCoordinateFilter.get=function(){return rf},nf.Translater.get=function(){return of},Object.defineProperties(ef,nf);var rf=function(){this._commonBitsX=new tf,this._commonBitsY=new tf};rf.prototype.filter=function(t){this._commonBitsX.add(t.x),this._commonBitsY.add(t.y)},rf.prototype.getCommonCoordinate=function(){return new Nu(this._commonBitsX.getCommon(),this._commonBitsY.getCommon())},rf.prototype.interfaces_=function(){return[gc]},rf.prototype.getClass=function(){return rf};var of=function(){this.trans=null;var t=arguments[0];this.trans=t};of.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)},of.prototype.isDone=function(){return!1},of.prototype.isGeometryChanged=function(){return!0},of.prototype.interfaces_=function(){return[Xc]},of.prototype.getClass=function(){return of};var sf=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()};sf.prototype.selfSnap=function(t){return new Kp(t).snapTo(t,this._snapTolerance)},sf.prototype.removeCommonBits=function(t){this._cbr=new ef,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},sf.prototype.prepareResult=function(t){return this._cbr.addCommonBits(t),t},sf.prototype.getResultGeometry=function(t){var e=this.snap(this._geom),n=Mf.overlayOp(e[0],e[1],t);return this.prepareResult(n)},sf.prototype.checkValid=function(t){t.isValid()||Yu.out.println("Snapped geometry is invalid")},sf.prototype.computeSnapTolerance=function(){this._snapTolerance=Kp.computeOverlaySnapTolerance(this._geom[0],this._geom[1])},sf.prototype.snap=function(t){var e=this.removeCommonBits(t);return Kp.snap(e[0],e[1],this._snapTolerance)},sf.prototype.interfaces_=function(){return[]},sf.prototype.getClass=function(){return sf},sf.overlayOp=function(t,e,n){return new sf(t,e).getResultGeometry(n)},sf.union=function(t,e){return sf.overlayOp(t,e,Mf.UNION)},sf.intersection=function(t,e){return sf.overlayOp(t,e,Mf.INTERSECTION)},sf.symDifference=function(t,e){return sf.overlayOp(t,e,Mf.SYMDIFFERENCE)},sf.difference=function(t,e){return sf.overlayOp(t,e,Mf.DIFFERENCE)};var af=function(t,e){this._geom=new Array(2).fill(null),this._geom[0]=t,this._geom[1]=e};af.prototype.getResultGeometry=function(t){var e=null,n=!1,r=null;try{e=Mf.overlayOp(this._geom[0],this._geom[1],t);n=!0}catch(t){if(!(t instanceof tc))throw t;r=t}if(!n)try{e=sf.overlayOp(this._geom[0],this._geom[1],t)}catch(t){throw t instanceof tc?r:t}return e},af.prototype.interfaces_=function(){return[]},af.prototype.getClass=function(){return af},af.overlayOp=function(t,e,n){return new af(t,e).getResultGeometry(n)},af.union=function(t,e){return af.overlayOp(t,e,Mf.UNION)},af.intersection=function(t,e){return af.overlayOp(t,e,Mf.INTERSECTION)},af.symDifference=function(t,e){return af.overlayOp(t,e,Mf.SYMDIFFERENCE)},af.difference=function(t,e){return af.overlayOp(t,e,Mf.DIFFERENCE)};var uf=function(){this.mce=null,this.chainIndex=null;var t=arguments[0],e=arguments[1];this.mce=t,this.chainIndex=e};uf.prototype.computeIntersections=function(t,e){this.mce.computeIntersectsForChain(this.chainIndex,t.mce,t.chainIndex,e)},uf.prototype.interfaces_=function(){return[]},uf.prototype.getClass=function(){return uf};var cf=function t(){if(this._label=null,this._xValue=null,this._eventType=null,this._insertEvent=null,this._deleteEventIndex=null,this._obj=null,2===arguments.length){var e=arguments[0],n=arguments[1];this._eventType=t.DELETE,this._xValue=e,this._insertEvent=n}else if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];this._eventType=t.INSERT,this._label=r,this._xValue=i,this._obj=o}},hf={INSERT:{configurable:!0},DELETE:{configurable:!0}};cf.prototype.isDelete=function(){return this._eventType===cf.DELETE},cf.prototype.setDeleteEventIndex=function(t){this._deleteEventIndex=t},cf.prototype.getObject=function(){return this._obj},cf.prototype.compareTo=function(t){var e=t;return this._xValuee._xValue?1:this._eventTypee._eventType?1:0},cf.prototype.getInsertEvent=function(){return this._insertEvent},cf.prototype.isInsert=function(){return this._eventType===cf.INSERT},cf.prototype.isSameLabel=function(t){return null!==this._label&&this._label===t._label},cf.prototype.getDeleteEventIndex=function(){return this._deleteEventIndex},cf.prototype.interfaces_=function(){return[wu]},cf.prototype.getClass=function(){return cf},hf.INSERT.get=function(){return 1},hf.DELETE.get=function(){return 2},Object.defineProperties(cf,hf);var lf=function(){};lf.prototype.interfaces_=function(){return[]},lf.prototype.getClass=function(){return lf};var pf=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};pf.prototype.isTrivialIntersection=function(t,e,n,r){if(t===n&&1===this._li.getIntersectionNum()){if(pf.isAdjacentSegments(e,r))return!0;if(t.isClosed()){var i=t.getNumPoints()-1;if(0===e&&r===i||0===r&&e===i)return!0}}return!1},pf.prototype.getProperIntersectionPoint=function(){return this._properIntersectionPoint},pf.prototype.setIsDoneIfProperInt=function(t){this._isDoneWhenProperInt=t},pf.prototype.hasProperInteriorIntersection=function(){return this._hasProperInterior},pf.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},pf.prototype.hasProperIntersection=function(){return this._hasProper},pf.prototype.hasIntersection=function(){return this._hasIntersection},pf.prototype.isDone=function(){return this._isDone},pf.prototype.isBoundaryPoint=function(t,e){return null!==e&&(!!this.isBoundaryPointInternal(t,e[0])||!!this.isBoundaryPointInternal(t,e[1]))},pf.prototype.setBoundaryNodes=function(t,e){this._bdyNodes=new Array(2).fill(null),this._bdyNodes[0]=t,this._bdyNodes[1]=e},pf.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))))},pf.prototype.interfaces_=function(){return[]},pf.prototype.getClass=function(){return pf},pf.isAdjacentSegments=function(t,e){return 1===Math.abs(t-e)};var ff=function(t){function e(){t.call(this),this.events=new Nc,this.nOverlaps=null}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.prepareEvents=function(){el.sort(this.events);for(var t=0;te||this._maxo?1:0},yf.prototype.interfaces_=function(){return[Iu]},yf.prototype.getClass=function(){return yf};var _f=function(t){function e(){t.call(this),this._item=null;var e=arguments[0],n=arguments[1],r=arguments[2];this._min=e,this._max=n,this._item=r}return t&&(e.__proto__=t),e.prototype=Object.create(t&&t.prototype),e.prototype.constructor=e,e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;n.visitItem(this._item)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(gf),mf=function(t){function e(){t.call(this),this._node1=null,this._node2=null;var e=arguments[0],n=arguments[1];this._node1=e,this._node2=n,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(t,e){this._min=Math.min(t._min,e._min),this._max=Math.max(t._max,e._max)},e.prototype.query=function(t,e,n){if(!this.intersects(t,e))return null;null!==this._node1&&this._node1.query(t,e,n),null!==this._node2&&this._node2.query(t,e,n)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e}(gf),vf=function(){this._leaves=new Nc,this._root=null,this._level=0};vf.prototype.buildTree=function(){el.sort(this._leaves,new gf.NodeComparator);for(var t=this._leaves,e=null,n=new Nc;;){if(this.buildLevel(t,n),1===n.size())return n.get(0);e=t,t=n,n=e}},vf.prototype.insert=function(t,e,n){if(null!==this._root)throw new Error("Index cannot be added to once it has been queried");this._leaves.add(new _f(t,e,n))},vf.prototype.query=function(t,e,n){this.init(),this._root.query(t,e,n)},vf.prototype.buildRoot=function(){if(null!==this._root)return null;this._root=this.buildTree()},vf.prototype.printNode=function(t){Yu.out.println($u.toLineString(new Nu(t._min,this._level),new Nu(t._max,this._level)))},vf.prototype.init=function(){if(null!==this._root)return null;this.buildRoot()},vf.prototype.buildLevel=function(t,e){this._level++,e.clear();for(var n=0;n=2,"found LineString with single point"),this.insertBoundaryPoint(this._argIndex,e[0]),this.insertBoundaryPoint(this._argIndex,e[e.length-1])},e.prototype.getInvalidPoint=function(){return this._invalidPoint},e.prototype.getBoundaryPoints=function(){for(var t=this.getBoundaryNodes(),e=new Array(t.size()).fill(null),n=0,r=t.iterator();r.hasNext();){var i=r.next();e[n++]=i.getCoordinate().copy()}return e},e.prototype.getBoundaryNodes=function(){return null===this._boundaryNodes&&(this._boundaryNodes=this._nodes.getBoundaryNodes(this._argIndex)),this._boundaryNodes},e.prototype.addSelfIntersectionNode=function(t,e,n){if(this.isBoundaryNode(t,e))return null;n===Lu.BOUNDARY&&this._useBoundaryDeterminationRule?this.insertBoundaryPoint(t,e):this.insertPoint(t,e,n)},e.prototype.addPolygonRing=function(t,e,n){if(t.isEmpty())return null;var r=Mc.removeRepeatedPoints(t.getCoordinates());if(r.length<4)return this._hasTooFewPoints=!0,this._invalidPoint=r[0],null;var i=e,o=n;uc.isCCW(r)&&(i=n,o=e);var s=new rp(r,new Ah(this._argIndex,Lu.BOUNDARY,i,o));this._lineEdgeMap.put(t,s),this.insertEdge(s),this.insertPoint(this._argIndex,r[0],Lu.BOUNDARY)},e.prototype.insertPoint=function(t,e,n){var r=this._nodes.addNode(e),i=r.getLabel();null===i?r._label=new Ah(t,n):i.setLocation(t,n)},e.prototype.createEdgeSetIntersector=function(){return new ff},e.prototype.addSelfIntersectionNodes=function(t){for(var e=this._edges.iterator();e.hasNext();)for(var n=e.next(),r=n.getLabel().getLocation(t),i=n.eiList.iterator();i.hasNext();){var o=i.next();this.addSelfIntersectionNode(t,o.coord,r)}},e.prototype.add=function(){if(1!==arguments.length)return t.prototype.add.apply(this,arguments);var e=arguments[0];if(e.isEmpty())return null;if(e instanceof ih&&(this._useBoundaryDeterminationRule=!1),e instanceof eh)this.addPolygon(e);else if(e instanceof Kc)this.addLineString(e);else if(e instanceof $c)this.addPoint(e);else if(e instanceof nh)this.addCollection(e);else if(e instanceof Yc)this.addCollection(e);else if(e instanceof ih)this.addCollection(e);else{if(!(e instanceof Uc))throw new Error(e.getClass().getName());this.addCollection(e)}},e.prototype.addCollection=function(t){for(var e=0;e50?(null===this._areaPtLocator&&(this._areaPtLocator=new Ef(this._parentGeom)),this._areaPtLocator.locate(t)):this._ptLocator.locate(t,this._parentGeom)},e.prototype.findEdge=function(){if(1===arguments.length){var e=arguments[0];return this._lineEdgeMap.get(e)}return t.prototype.findEdge.apply(this,arguments)},e.prototype.interfaces_=function(){return[]},e.prototype.getClass=function(){return e},e.determineBoundary=function(t,e){return t.isInBoundary(e)?Lu.BOUNDARY:Lu.INTERIOR},e}(Vh),Cf=function(){if(this._li=new oc,this._resultPrecisionModel=null,this._arg=null,1===arguments.length){var t=arguments[0];this.setComputationPrecision(t.getPrecisionModel()),this._arg=new Array(1).fill(null),this._arg[0]=new Nf(0,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1],r=dc.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 Nf(0,e,r),this._arg[1]=new Nf(1,n,r)}else if(3===arguments.length){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 Nf(0,i,s),this._arg[1]=new Nf(1,o,s)}};Cf.prototype.getArgGeometry=function(t){return this._arg[t].getGeometry()},Cf.prototype.setComputationPrecision=function(t){this._resultPrecisionModel=t,this._li.setPrecisionModel(this._resultPrecisionModel)},Cf.prototype.interfaces_=function(){return[]},Cf.prototype.getClass=function(){return Cf};var Sf=function(){};Sf.prototype.interfaces_=function(){return[]},Sf.prototype.getClass=function(){return Sf},Sf.map=function(){if(arguments[0]instanceof lc&&Ou(arguments[1],Sf.MapOp)){for(var t=arguments[0],e=arguments[1],n=new Nc,r=0;r=t.size()?null:t.get(e)},Df.union=function(t){return new Df(t).union()},Ff.STRTREE_NODE_CAPACITY.get=function(){return 4},Object.defineProperties(Df,Ff);var qf=function(){};qf.prototype.interfaces_=function(){return[]},qf.prototype.getClass=function(){return qf},qf.union=function(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return Mf.createEmptyResult(Mf.UNION,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}return t.checkNotGeometryCollection(t),t.checkNotGeometryCollection(e),af.overlayOp(t,e,Mf.UNION)};var Gf=function(){return new Ui};Ui.prototype={constructor:Ui,reset:function(){this.s=this.t=0},add:function(t){Yi(Bf,t,this.t),Yi(this,Bf.s,this.s),this.s?this.t+=Bf.t:this.s=Bf.t},valueOf:function(){return this.s}};var Bf=new Ui,kf=1e-6,zf=Math.PI,jf=zf/2,Xf=zf/4,Uf=2*zf,Yf=180/zf,Vf=zf/180,Hf=Math.abs,Wf=Math.atan,Jf=Math.atan2,Zf=Math.cos,Kf=Math.exp,Qf=Math.log,$f=Math.sin,tg=Math.sqrt,eg=Math.tan,ng={Feature:function(t,e){Ji(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++r2?t[2]*Vf:0),e.invert=function(e){return e=t.invert(e[0]*Vf,e[1]*Vf),e[0]*=Yf,e[1]*=Yf,e},e},ag=function(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:Wi,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}},ug=function(t,e,n,r,i,o){var s,a=t[0],u=t[1],c=0,h=1,l=e[0]-a,p=e[1]-u;if(s=n-a,l||!(s>0)){if(s/=l,l<0){if(s0){if(s>h)return;s>c&&(c=s)}if(s=i-a,l||!(s<0)){if(s/=l,l<0){if(s>h)return;s>c&&(c=s)}else if(l>0){if(s0)){if(s/=p,p<0){if(s0){if(s>h)return;s>c&&(c=s)}if(s=o-u,p||!(s<0)){if(s/=p,p<0){if(s>h)return;s>c&&(c=s)}else if(p>0){if(s0&&(t[0]=a+c*l,t[1]=u+c*p),h<1&&(e[0]=a+h*l,e[1]=u+h*p),!0}}}}},cg=function(t,e){return Hf(t[0]-e[0])=0;--o)i.point((h=c[o])[0],h[1]);else r(p.x,p.p.x,-1,i);p=p.p}c=(p=p.o).z,f=!f}while(!p.v);i.lineEnd()}}},lg=function(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},pg=1e9,fg=-pg,gg=Gf(),dg=(Gf(),function(t){return t}),yg=(Gf(),Gf(),1/0),_g=yg,mg=-yg,vg=mg,xg={point:function(t,e){tmg&&(mg=t),e<_g&&(_g=e),e>vg&&(vg=e)},lineStart:Wi,lineEnd:Wi,polygonStart:Wi,polygonEnd:Wi,result:function(){var t=[[yg,_g],[mg,vg]];return mg=vg=-(_g=yg=1/0),t}},Eg=(Gf(),function(t,e,n,r){return function(i,o){function s(e,n){var r=i(e,n);t(e=r[0],n=r[1])&&o.point(e,n)}function a(t,e){var n=i(t,e);y.point(n[0],n[1])}function u(){E.point=a,y.lineStart()}function c(){E.point=s,y.lineEnd()}function h(t,e){d.push([t,e]);var n=i(t,e);v.point(n[0],n[1])}function l(){v.lineStart(),d=[]}function p(){h(d[0][0],d[0][1]),v.lineEnd();var t,e,n,r,i=v.clean(),s=m.result(),a=s.length;if(d.pop(),f.push(d),d=null,a)if(1&i){if(n=s[0],(e=n.length-1)>0){for(x||(o.polygonStart(),x=!0),o.lineStart(),t=0;t1&&2&i&&s.push(s.pop().concat(s.shift())),g.push(s.filter(go))}var f,g,d,y=e(o),_=i.invert(r[0],r[1]),m=ag(),v=e(m),x=!1,E={point:s,lineStart:u,lineEnd:c,polygonStart:function(){E.point=h,E.lineStart=l,E.lineEnd=p,g=[],f=[]},polygonEnd:function(){E.point=s,E.lineStart=u,E.lineEnd=c,g=lg(g);var t=function(t,e){var n=e[0],r=e[1],i=[$f(n),-Zf(n),0],o=0,s=0;gg.reset();for(var a=0,u=t.length;a=0?1:-1,I=b*w,N=I>zf,C=g*x;if(gg.add(Jf(C*b*$f(I),d*E+C*Zf(I))),o+=N?w+b*Uf:w,N^p>=n^m>=n){var S=eo($i(l),$i(_));io(S);var M=eo(i,S);io(M);var L=(N^w>=0?-1:1)*Hi(M[2]);(r>L||r===L&&(S[0]||S[1]))&&(s+=N^w>=0?1:-1)}}return(o<-kf||o0?zf:-zf,u=Hf(o-n);Hf(u-zf)0?jf:-jf),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(a,r),t.point(o,r),e=0):i!==a&&u>=zf&&(Hf(n-i)kf?Wf(($f(e)*(o=Zf(r))*$f(n)-$f(r)*(i=Zf(e))*$f(t))/(i*o*s)):(e+r)/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(null==t)i=n*jf,r.point(-zf,i),r.point(0,i),r.point(zf,i),r.point(zf,0),r.point(zf,-i),r.point(0,-i),r.point(-zf,-i),r.point(-zf,0),r.point(-zf,i);else if(Hf(t[0]-e[0])>kf){var o=t[0]o}function r(t,e,n){var r=[1,0,0],i=eo($i(t),$i(e)),s=to(i,i),a=i[0],u=s-a*a;if(!u)return!n&&t;var c=o*s/u,h=-o*a/u,l=eo(r,i),p=ro(r,c);no(p,ro(i,h));var f=l,g=to(p,f),d=to(f,f),y=g*g-d*(to(p,p)-1);if(!(y<0)){var _=tg(y),m=ro(f,(-g-_)/d);if(no(m,p),m=Qi(m),!n)return m;var v,x=t[0],E=e[0],w=t[1],b=e[1];E0^m[1]<(Hf(m[0]-x)zf^(x<=m[0]&&m[0]<=E)){var C=ro(f,(-g+_)/d);return no(C,p),[m,Qi(C)]}}}function i(e,n){var r=s?t:zf-t,i=0;return e<-r?i|=1:e>r&&(i|=2),n<-r?i|=4:n>r&&(i|=8),i}var o=Zf(t),s=o>0,a=Hf(o)>kf;return Eg(n,function(t){var e,o,u,c,h;return{lineStart:function(){c=u=!1,h=1},point:function(l,p){var f,g=[l,p],d=n(l,p),y=s?d?0:i(l,p):d?i(l+(l<0?zf:-zf),p):0;if(!e&&(c=u=d)&&t.lineStart(),d!==u&&(!(f=r(e,g))||cg(e,f)||cg(g,f))&&(g[0]+=kf,g[1]+=kf,d=n(g[0],g[1])),d!==u)h=0,d?(t.lineStart(),f=r(g,e),t.point(f[0],f[1])):(f=r(e,g),t.point(f[0],f[1]),t.lineEnd()),e=f;else if(a&&e&&s^d){var _;y&o||!(_=r(g,e,!0))||(h=0,s?(t.lineStart(),t.point(_[0][0],_[0][1]),t.point(_[1][0],_[1][1]),t.lineEnd()):(t.point(_[1][0],_[1][1]),t.lineEnd(),t.lineStart(),t.point(_[0][0],_[0][1])))}!d||e&&cg(e,g)||t.point(g[0],g[1]),e=g,u=d,o=y},lineEnd:function(){u&&t.lineEnd(),e=null},clean:function(){return h|(c&&u)<<1}}},function(n,r,i,o){!function(t,e,n,r,i,o){if(n){var s=Zf(e),a=$f(e),u=r*n;null==i?(i=e+r*Uf,o=e-u/2):(i=ho(s,i),o=ho(s,o),(r>0?io)&&(i+=r*Uf));for(var c,h=i;r>0?h>o:h4*e&&d--){var x=s+p,E=a+f,w=u+g,b=tg(x*x+E*E+w*w),I=Hi(w/=b),N=Hf(Hf(w)-1)e||Hf((_*L+m*P)/v-.5)>.3||s*p+a*f+u*g2?t[2]+90:90]):(t=n(),[t[0],t[1],t[2]-90])},n([0,0,90]).scale(159.155)};t.projection=Ms,t.random=yu,t.clusters=_u,t.helpers=jo,t.invariant=Uo,t.meta=Xo,t.isolines=function(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.zProperty||"elevation",i=n.commonProperties||{},o=n.breaksProperties||[];if(W(t,"Point","Input must contain Points"),!e)throw new Error("breaks is required");if(!Array.isArray(e))throw new Error("breaks must be an Array");if(!I(i))throw new Error("commonProperties must be an Object");if(!Array.isArray(o))throw new Error("breaksProperties must be an Array");var s=rt(t,{zProperty:r,flip:!0});return c(function(t,e,n){var r=j(n),i=r[2]-r[0],o=r[3]-r[1],s=r[0],a=r[1],u=e[0].length-1,c=e.length-1,h=i/u,l=o/c,p=function(t){t[0]=t[0]*h+s,t[1]=t[1]*l+a};return t.forEach(function(t){S(t,p)}),t}(function(t,e,n,r,i){for(var o=[],s=1;ss;)r=Math.floor((o+1)*Math.random()),n=i[r],i[r]=i[o],i[o]=n;return i.slice(s)}(t.features,e))},t.envelope=he,t.square=le,t.circle=fe,t.midpoint=function(t,e){return pe(t,qt(t,e)/2,ge(t,e))},t.center=de,t.centerOfMass=_e,t.centroid=ye,t.combine=function(t){function n(t,e,n){n?r[e].coordinates=r[e].coordinates.concat(t.geometry.coordinates):r[e].coordinates.push(t.geometry.coordinates),r[e].properties.push(t.properties)}var r={MultiPoint:{coordinates:[],properties:[]},MultiLineString:{coordinates:[],properties:[]},MultiPolygon:{coordinates:[],properties:[]}},i=Object.keys(r).reduce(function(t,e){return t[e.replace("Multi","")]=e,t},{});return O(t,function(t){t.geometry&&(r[t.geometry.type]?n(t,t.geometry.type,!0):i[t.geometry.type]&&n(t,i[t.geometry.type],!1))}),c(Object.keys(r).filter(function(t){return r[t].coordinates.length}).sort().map(function(t){return e({type:t,coordinates:r[t].coordinates},{collectedProperties:r[t].properties})}))},t.distance=qt,t.explode=me,t.bbox=j,t.tesselate=function(t){if(!t.geometry||"Polygon"!==t.geometry.type&&"MultiPolygon"!==t.geometry.type)throw new Error("input must be a Polygon or MultiPolygon");var e={type:"FeatureCollection",features:[]};return"Polygon"===t.geometry.type?e.features=De(t.geometry.coordinates):t.geometry.coordinates.forEach(function(t){e.features=e.features.concat(De(t))}),e},t.bboxPolygon=ce,t.booleanPointInPolygon=Pt,t.nearestPoint=Fe,t.nearestPointOnLine=on,t.nearestPointToLine=function(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.units,i=n.properties||{};if(!t)throw new Error("points is required");if(!(t=function(t){var e=[];switch(t.geometry?t.geometry.type:t.type){case"GeometryCollection":return A(t,function(t){"Point"===t.type&&e.push({type:"Feature",properties:{},geometry:t})}),{type:"FeatureCollection",features:e};case"FeatureCollection":return t.features=t.features.filter(function(t){return"Point"===t.geometry.type}),t;default:throw new Error("points must be a Point Collection")}}(t)).features.length)throw new Error("points must contain features");if(!e)throw new Error("line is required");if("LineString"!==K(e))throw new Error("line must be a LineString");var o=1/0,s=null;return O(t,function(t){var n=gn(t,e,{units:r});n=0&&c<=1&&(f.onLine1=!0),h>=0&&h<=1&&(f.onLine2=!0),!(!f.onLine1||!f.onLine2)&&[f.x,f.y])}(t[n][0],t[n][1],t[n+1][0],t[n+1][1],e[o][0],e[o][1],e[o+1][0],e[o+1][1]);s&&i.features.push(r([s[0],s[1]]))}})}),i},t.pointOnFeature=yn,t.area=mn,t.along=function(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var i;if("Feature"===t.type)i=t.geometry.coordinates;else{if("LineString"!==t.type)throw new Error("input must be a LineString Feature or Geometry");i=t.coordinates}if(!b(e))throw new Error("distance must be a number");for(var o=0,s=0;s=o&&s===i.length-1);s++){if(o>=e){var a=e-o;if(a){var u=ge(i[s],i[s-1])-180;return pe(i[s],a,u,n)}return r(i[s])}o+=qt(i[s],i[s+1],n)}return r(i[i.length-1])},t.length=bn,t.lineSlice=function(t,e,n){var r=U(n);if("LineString"!==K(n))throw new Error("line must be a LineString");for(var i,o=on(n,t),s=on(n,e),u=[(i=o.properties.index<=s.properties.index?[o,s]:[s,o])[0].geometry.coordinates],c=i[0].properties.index+1;c is required");if("boolean"!=typeof n)throw new Error(" must be a boolean");if("boolean"!=typeof r)throw new Error(" must be a boolean");!1===r&&(t=Gt(t));var i=[];switch(t.type){case"GeometryCollection":return A(t,function(t){sr(t,n)}),t;case"FeatureCollection":return O(t,function(t){O(sr(t,n),function(t){i.push(t)})}),c(i)}return sr(t,n)},t.isobands=function(t,e,n){if(n=n||{},!I(n))throw new Error("options is invalid");var r=n.zProperty||"elevation",i=n.commonProperties||{},s=n.breaksProperties||[];if(W(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(!I(i))throw new Error("commonProperties is not an Object");if(!Array.isArray(s))throw new Error("breaksProperties is not an Array");var a=cr(t,{zProperty:r,flip:!0}),u=function(t,e,n){for(var r=[],i=1;i0}(t,e);case"Polygon":return!br(e,t)}break;case"Polygon":switch(e.type){case"Point":return!Pt(e,t);case"LineString":return!br(t,e);case"Polygon":return!function(t,e){for(var n=0;n0)for(var n=0;n0))throw new Error("Invalid maxDistance");if(!(void 0===r||null===r||Math.sign(r)>0))throw new Error("Invalid minPoints");t=Gt(t),r=r||3;var o=new Ja.DBSCAN,s=-1;return o.run(T(t),E(e,i),r,qt).forEach(function(e){s++,e.forEach(function(e){var n=t.features[e];n.properties||(n.properties={}),n.properties.cluster=s,n.properties.dbscan="core"})}),o.noise.forEach(function(e){var n=t.features[e];n.properties||(n.properties={}),n.properties.cluster?n.properties.dbscan="edge":n.properties.dbscan="noise"}),t},t.clustersKmeans=function(t,e){if("object"!=typeof(e=e||{}))throw new Error("options is invalid");var n=e.numberOfClusters,r=e.mutate;W(t,"Point","Input must contain Points");var i=t.features.length;(n=n||Math.round(Math.sqrt(i/2)))>i&&(n=i),!1!==r&&void 0!==r||(t=Gt(t));var o=T(t),s=o.slice(0,n),a=ru(o,n,s),u={};return a.centroids.forEach(function(t,e){u[e]=t}),O(t,function(t,e){var n=a.idxs[e];t.properties.cluster=n,t.properties.centroid=u[n]}),t},t.pointToLineDistance=gn,t.booleanParallel=function(t,e){if(!t)throw new Error("line1 is required");if(!e)throw new Error("line2 is required");if("LineString"!==Ar(t,"line1"))throw new Error("line1 must be a LineString");if("LineString"!==Ar(e,"line2"))throw new Error("line2 must be a LineString");for(var n=en(te(t)).features,r=en(te(e)).features,i=0;i=d;){for(var T=[],A=[],D=g+w,F=0;D<=y;){var q=r([D,O]),G=function(t,e){for(var n=0;n0&&0!==e)if(e>o[o.length-1])e-=o.length;else{var r=Ro(e,o);0!==r&&(e-=r)}if(e!==+u){var l=i[e];l&&c&&(void 0!==n&&l.properties[n]!==c.properties[n]||Rr(c,l)&&function(t,e){var n=a(T(t)),r=a(T(e));return nn(n,r).features.length>0}(c,l)&&(i[u]=Po(c,l),o.push(t.properties.origIndexPosition),o.sort(function(t,e){return t-e}),s.remove(t),i.splice(e,1),c.properties.origIndexPosition=u,s.remove(c,function(t,e){return t.properties.origIndexPosition===e.properties.origIndexPosition}),h=!0))}}),h){if(!c)continue;c.properties.origIndexPosition=u,s.insert(c),u--}}return i.forEach(function(t){delete t.properties.origIndexPosition,delete t.bbox}),r},t.hexGrid=To,t.mask=function(t,e){var n=function(t){return o(t&&t.geometry.coordinates||[[[180,90],[-180,90],[-180,-90],[180,-90],[180,90]]])}(e),r=function(t){var e=[],n=[];return F(t,function(t){var r=t.geometry.coordinates,i=r[0],s=r.slice(1);e.push(o([i])),s.forEach(function(t){n.push(o([t]))})}),[c(e),c(n)]}(t),i=r[0],s=r[1];return function(t,e,n){var r=[];return r.push(t.geometry.coordinates[0]),F(e,function(t){r.push(t.geometry.coordinates[0])}),F(n,function(t){r.push(t.geometry.coordinates[0])}),o(r)}(n,i=Ao(i),s=Ao(s))},t.squareGrid=Fo,t.triangleGrid=qo,t.interpolate=function(t,e,n){if("object"!=typeof(n=n||{}))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(W(t,"Point","input must contain Points"),!e)throw new Error("cellSize is required");if(void 0!==o&&"number"!=typeof o)throw new Error("weight must be a number");i=i||"elevation",r=r||"square",o=o||1;var s,a=j(t);switch(r){case"point":case"points":s=Ln(a,e,n);break;case"square":case"squares":s=Fo(a,e,n);break;case"hex":case"hexes":s=To(a,e,n);break;case"triangle":case"triangles":s=qo(a,e,n);break;default:throw new Error("invalid gridType")}var u=[];return O(s,function(e){var s=0,a=0;O(t,function(t){var u,c=qt("point"===r?e:ye(e),t,n);if(void 0!==i&&(u=t.properties[i]),void 0===u&&(u=t.geometry.coordinates[2]),void 0===u)throw new Error("zValue is missing");0===c&&(s=u);var h=1/Math.pow(c,o);a+=h,s+=h*u});var c=Gt(e);c.properties[i]=s/a,u.push(c)}),c(u)},t.pointOnSurface=yn,t.polygonToLineString=kn,t.lineStringToPolygon=jn,t.inside=Pt,t.within=Rt,t.bezier=ue,t.nearest=Fe,t.pointOnLine=on,t.lineDistance=bn,t.radians2degrees=v,t.degrees2radians=x,t.distanceToDegrees=_,t.distanceToRadians=y,t.radiansToDistance=d,t.bearingToAngle=m,t.convertDistance=E,t.toMercator=cn,t.toWgs84=hn,t.randomPosition=yi,t.randomPoint=_i,t.randomPolygon=mi,t.randomLineString=vi,t.getCluster=Ei,t.clusterEach=wi,t.clusterReduce=bi,t.createBins=Ii,t.applyFilter=Ni,t.propertiesContainsFilter=Ci,t.filterProperties=Si,t.earthRadius=Go,t.factors=Bo,t.unitsFactors=ko,t.areaFactors=zo,t.feature=e,t.geometry=n,t.point=r,t.points=i,t.polygon=o,t.polygons=s,t.lineString=a,t.lineStrings=u,t.featureCollection=c,t.multiLineString=h,t.multiPoint=l,t.multiPolygon=p,t.geometryCollection=f,t.round=g,t.radiansToLength=d,t.lengthToRadians=y,t.lengthToDegrees=_,t.bearingToAzimuth=m,t.radiansToDegrees=v,t.degreesToRadians=x,t.convertLength=E,t.convertArea=w,t.isNumber=b,t.isObject=I,t.validateBBox=N,t.validateId=C,t.getCoord=X,t.getCoords=U,t.containsNumber=Y,t.geojsonType=V,t.featureOf=H,t.collectionOf=W,t.getGeom=J,t.getGeomType=Z,t.getType=K,t.coordEach=S,t.coordReduce=M,t.propEach=L,t.propReduce=P,t.featureEach=O,t.featureReduce=R,t.coordAll=T,t.geomEach=A,t.geomReduce=D,t.flattenEach=F,t.flattenReduce=q,t.segmentEach=G,t.segmentReduce=B,t.lineEach=k,t.lineReduce=z,Object.defineProperty(t,"__esModule",{value:!0})});