/** * JSTS. See https://github.com/bjornharrtell/jsts * https://github.com/bjornharrtell/jsts/blob/master/LICENSE_EDLv1.txt * https://github.com/bjornharrtell/jsts/blob/master/LICENSE_EPLv1.txt * @license */ class t{static equalsWithTolerance(t,e,s){return Math.abs(t-e)<=s}}class e extends Error{constructor(t){super(t),this.name=Object.keys({Exception:e})[0]}toString(){return this.message}}class s extends e{constructor(t){super(t),this.name=Object.keys({IllegalArgumentException:s})[0]}}class n{constructor(t,e){this.low=e||0,this.high=t||0}static toBinaryString(t){let e,s="";for(e=2147483648;e>0;e>>>=1)s+=(t.high&e)===e?"1":"0";for(e=2147483648;e>0;e>>>=1)s+=(t.low&e)===e?"1":"0";return s}}function i(){}function r(){}function o(){}function l(){}function a(){}i.NaN=NaN,i.isNaN=t=>Number.isNaN(t),i.isInfinite=t=>!Number.isFinite(t),i.MAX_VALUE=Number.MAX_VALUE,i.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,i.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?function(){const t=2146435072,e=new Float64Array(1),s=new Int32Array(e.buffer);i.doubleToLongBits=function(i){e[0]=i;let r=0|s[0],o=0|s[1];return(o&t)===t&&0!=(1048575&o)&&0!==r&&(r=0,o=2146959360),new n(o,r)},i.longBitsToDouble=function(t){return s[0]=t.low,s[1]=t.high,e[0]}}():function(){const t=1023,e=Math.log2,s=Math.floor,r=Math.pow,o=function(){for(let t=53;t>0;t--){const n=r(2,t)-1;if(s(e(n))+1===t)return n}return 0}();i.doubleToLongBits=function(i){let l,a,c,h,u,g,d,_,p;if(i<0||1/i===Number.NEGATIVE_INFINITY?(g=1<<31,i=-i):g=0,0===i)return p=0,_=g,new n(_,p);if(i===1/0)return p=0,_=2146435072|g,new n(_,p);if(i!=i)return p=0,_=2146959360,new n(_,p);if(h=0,p=0,l=s(i),l>1)if(l<=o)h=s(e(l)),h<=20?(p=0,_=l<<20-h&1048575):(c=h-20,a=r(2,c),p=l%a<<32-c,_=l/a&1048575);else for(c=l,p=0;a=c/2,c=s(a),0!==c;)h++,p>>>=1,p|=(1&_)<<31,_>>>=1,a!==c&&(_|=524288);if(d=h+t,u=0===l,l=i-l,h<52&&0!==l)for(c=0;;){if(a=2*l,a>=1?(l=a-1,u?(d--,u=!1):(c<<=1,c|=1,h++)):(l=a,u?0==--d&&(h++,u=!1):(c<<=1,h++)),20===h)_|=c,c=0;else if(52===h){p|=c;break}if(1===a){h<20?_|=c<<20-h:h<52&&(p|=c<<52-h);break}}return _|=d<<20,_|=g,new n(_,p)},i.longBitsToDouble=function(e){let s,n,i,o;const l=e.high,a=e.low,c=l&1<<31?-1:1;for(i=((2146435072&l)>>20)-t,o=0,n=1<<19,s=1;s<=20;s++)l&n&&(o+=r(2,-s)),n>>>=1;for(n=1<<31,s=21;s<=52;s++)a&n&&(o+=r(2,-s)),n>>>=1;if(-1023===i){if(0===o)return 0*c;i=-1022}else{if(1024===i)return 0===o?c/0:NaN;o+=1}return c*o*r(2,i)}}();class c extends e{constructor(t){super(t),this.name=Object.keys({RuntimeException:c})[0]}}class h extends c{constructor(){super(),h.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)c.constructor_.call(this);else if(1===arguments.length){const t=arguments[0];c.constructor_.call(this,t)}}}class u{static shouldNeverReachHere(){if(0===arguments.length)u.shouldNeverReachHere(null);else if(1===arguments.length){const t=arguments[0];throw new h("Should never reach here"+(null!==t?": "+t:""))}}static isTrue(){if(1===arguments.length){const t=arguments[0];u.isTrue(t,null)}else if(2===arguments.length){const t=arguments[1];if(!arguments[0])throw null===t?new h:new h(t)}}static equals(){if(2===arguments.length){const t=arguments[0],e=arguments[1];u.equals(t,e,null)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];if(!e.equals(t))throw new h("Expected "+t+" but encountered "+e+(null!==s?": "+s:""))}}}const g=new ArrayBuffer(8),d=new Float64Array(g),_=new Int32Array(g);class p{constructor(){p.constructor_.apply(this,arguments)}static constructor_(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)p.constructor_.call(this,0,0);else if(1===arguments.length){const t=arguments[0];p.constructor_.call(this,t.x,t.y,t.getZ())}else if(2===arguments.length){const t=arguments[0],e=arguments[1];p.constructor_.call(this,t,e,p.NULL_ORDINATE)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this.x=t,this.y=e,this.z=s}}static hashCode(t){return d[0]=t,_[0]^_[1]}getM(){return i.NaN}setOrdinate(t,e){switch(t){case p.X:this.x=e;break;case p.Y:this.y=e;break;case p.Z:this.setZ(e);break;default:throw new s("Invalid ordinate index: "+t)}}equals2D(){if(1===arguments.length){const t=arguments[0];return this.x===t.x&&this.y===t.y}if(2===arguments.length){const e=arguments[0],s=arguments[1];return!!t.equalsWithTolerance(this.x,e.x,s)&&!!t.equalsWithTolerance(this.y,e.y,s)}}setM(t){throw new s("Invalid ordinate index: "+p.M)}getZ(){return this.z}getOrdinate(t){switch(t){case p.X:return this.x;case p.Y:return this.y;case p.Z:return this.getZ()}throw new s("Invalid ordinate index: "+t)}equals3D(t){return this.x===t.x&&this.y===t.y&&(this.getZ()===t.getZ()||i.isNaN(this.getZ())&&i.isNaN(t.getZ()))}equals(t){return t instanceof p&&this.equals2D(t)}equalInZ(e,s){return t.equalsWithTolerance(this.getZ(),e.getZ(),s)}setX(t){this.x=t}compareTo(t){const e=t;return this.xe.x?1:this.ye.y?1:0}getX(){return this.x}setZ(t){this.z=t}clone(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return u.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}}copy(){return new p(this)}toString(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}distance3D(t){const e=this.x-t.x,s=this.y-t.y,n=this.getZ()-t.getZ();return Math.sqrt(e*e+s*s+n*n)}getY(){return this.y}setY(t){this.y=t}distance(t){const e=this.x-t.x,s=this.y-t.y;return Math.sqrt(e*e+s*s)}hashCode(){let t=17;return t=37*t+p.hashCode(this.x),t=37*t+p.hashCode(this.y),t}setCoordinate(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}get interfaces_(){return[r,o,a]}}class m{constructor(){m.constructor_.apply(this,arguments)}static constructor_(){if(this._dimensionsToTest=2,0===arguments.length)m.constructor_.call(this,2);else if(1===arguments.length){const t=arguments[0];if(2!==t&&3!==t)throw new s("only 2 or 3 dimensions may be specified");this._dimensionsToTest=t}}static compare(t,e){return te?1:i.isNaN(t)?i.isNaN(e)?0:-1:i.isNaN(e)?1:0}compare(t,e){const s=m.compare(t.x,e.x);if(0!==s)return s;const n=m.compare(t.y,e.y);if(0!==n)return n;if(this._dimensionsToTest<=2)return 0;return m.compare(t.getZ(),e.getZ())}get interfaces_(){return[l]}}p.DimensionalComparator=m,p.NULL_ORDINATE=i.NaN,p.X=0,p.Y=1,p.Z=2,p.M=3;class f extends p{constructor(){super(),f.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)p.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof f){const t=arguments[0];p.constructor_.call(this,t.x,t.y)}else if(arguments[0]instanceof p){const t=arguments[0];p.constructor_.call(this,t.x,t.y)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];p.constructor_.call(this,t,e,p.NULL_ORDINATE)}}setOrdinate(t,e){switch(t){case f.X:this.x=e;break;case f.Y:this.y=e;break;default:throw new s("Invalid ordinate index: "+t)}}getZ(){return p.NULL_ORDINATE}getOrdinate(t){switch(t){case f.X:return this.x;case f.Y:return this.y}throw new s("Invalid ordinate index: "+t)}setZ(t){throw new s("CoordinateXY dimension 2 does not support z-ordinate")}copy(){return new f(this)}toString(){return"("+this.x+", "+this.y+")"}setCoordinate(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}}f.X=0,f.Y=1,f.Z=-1,f.M=-1;class y extends p{constructor(){super(),y.constructor_.apply(this,arguments)}static constructor_(){if(this._m=null,0===arguments.length)p.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof y){const t=arguments[0];p.constructor_.call(this,t.x,t.y),this._m=t._m}else if(arguments[0]instanceof p){const t=arguments[0];p.constructor_.call(this,t.x,t.y),this._m=this.getM()}}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];p.constructor_.call(this,t,e,p.NULL_ORDINATE),this._m=s}}getM(){return this._m}setOrdinate(t,e){switch(t){case y.X:this.x=e;break;case y.Y:this.y=e;break;case y.M:this._m=e;break;default:throw new s("Invalid ordinate index: "+t)}}setM(t){this._m=t}getZ(){return p.NULL_ORDINATE}getOrdinate(t){switch(t){case y.X:return this.x;case y.Y:return this.y;case y.M:return this._m}throw new s("Invalid ordinate index: "+t)}setZ(t){throw new s("CoordinateXY dimension 2 does not support z-ordinate")}copy(){return new y(this)}toString(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}setCoordinate(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}y.X=0,y.Y=1,y.Z=-1,y.M=2;class x extends p{constructor(){super(),x.constructor_.apply(this,arguments)}static constructor_(){if(this._m=null,0===arguments.length)p.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof x){const t=arguments[0];p.constructor_.call(this,t),this._m=t._m}else if(arguments[0]instanceof p){const t=arguments[0];p.constructor_.call(this,t),this._m=this.getM()}}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];p.constructor_.call(this,t,e,s),this._m=n}}getM(){return this._m}setOrdinate(t,e){switch(t){case p.X:this.x=e;break;case p.Y:this.y=e;break;case p.Z:this.z=e;break;case p.M:this._m=e;break;default:throw new s("Invalid ordinate index: "+t)}}setM(t){this._m=t}getOrdinate(t){switch(t){case p.X:return this.x;case p.Y:return this.y;case p.Z:return this.getZ();case p.M:return this.getM()}throw new s("Invalid ordinate index: "+t)}copy(){return new x(this)}toString(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}setCoordinate(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}function E(t,e){return t.interfaces_&&t.interfaces_.indexOf(e)>-1}class I{add(){}addAll(){}isEmpty(){}iterator(){}size(){}toArray(){}remove(){}}class N extends e{constructor(t){super(t),this.name=Object.keys({IndexOutOfBoundsException:N})[0]}}class C extends I{get(){}set(){}isEmpty(){}}class w extends e{constructor(t){super(t),this.name=Object.keys({NoSuchElementException:w})[0]}}class S extends C{constructor(t){super(),this.array=[],t instanceof I&&this.addAll(t)}get interfaces_(){return[C,I]}ensureCapacity(){}add(t){return 1===arguments.length?this.array.push(t):this.array.splice(arguments[0],0,arguments[1]),!0}clear(){this.array=[]}addAll(t){for(const e of t)this.array.push(e)}set(t,e){const s=this.array[t];return this.array[t]=e,s}iterator(){return new L(this)}get(t){if(t<0||t>=this.size())throw new N;return this.array[t]}isEmpty(){return 0===this.array.length}sort(t){t?this.array.sort(((e,s)=>t.compare(e,s))):this.array.sort()}size(){return this.array.length}toArray(){return this.array.slice()}remove(t){for(let e=0,s=this.array.length;e=1){if(this.get(this.size()-1).equals2D(t))return null}super.add.call(this,t)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){const t=arguments[0],e=arguments[1];return this.add(t,e),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){const t=arguments[0],e=arguments[1];if(arguments[2])for(let s=0;s=0;s--)this.add(t[s],e);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof p){const t=arguments[0],e=arguments[1];if(!arguments[2]){const s=this.size();if(s>0){if(t>0){if(this.get(t-1).equals2D(e))return null}if(tn&&(i=-1);for(let r=s;r!==n;r+=i)this.add(t[r],e);return!0}}closeRing(){if(this.size()>0){const t=this.get(0).copy();this.add(t,!1)}}}T.coordArrayType=new Array(0).fill(null);class R{filter(t,e){}isDone(){}isGeometryChanged(){}}class P{constructor(){P.constructor_.apply(this,arguments)}static constructor_(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof p){const t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof P){const t=arguments[0];this.init(t)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.init(t.x,e.x,t.y,e.y)}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];this.init(t,e,s,n)}}static intersects(){if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];return s.x>=(t.xe.x?t.x:e.x)&&s.y>=(t.ye.y?t.y:e.y)}if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];let i=Math.min(s.x,n.x),r=Math.max(s.x,n.x),o=Math.min(t.x,e.x),l=Math.max(t.x,e.x);return!(o>r)&&(!(lr)&&!(lt._minx?this._minx:t._minx,s=this._miny>t._miny?this._miny:t._miny,n=this._maxx=this._minx&&t.getMaxX()<=this._maxx&&t.getMinY()>=this._miny&&t.getMaxY()<=this._maxy)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];return!this.isNull()&&(t>=this._minx&&t<=this._maxx&&e>=this._miny&&e<=this._maxy)}}intersects(){if(1===arguments.length){if(arguments[0]instanceof P){const t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxxthis._maxy||t._maxythis._maxx)return!1;if((t.x>e.x?t.x:e.x)this._maxy)return!1;return!((t.y>e.y?t.y:e.y)this._maxx||tthis._maxy||ethis._maxx&&(this._maxx=t._maxx),t._minythis._maxy&&(this._maxy=t._maxy))}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.isNull()?(this._minx=t,this._maxx=t,this._miny=e,this._maxy=e):(tthis._maxx&&(this._maxx=t),ethis._maxy&&(this._maxy=e))}}minExtent(){if(this.isNull())return 0;const t=this.getWidth(),e=this.getHeight();return te._minx?1:this._minye._miny?1:this._maxxe._maxx?1:this._maxye._maxy?1:0}translate(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)}copy(){return new P(this)}toString(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}setToNull(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}disjoint(t){return!(!this.isNull()&&!t.isNull())||(t._minx>this._maxx||t._maxxthis._maxy||t._maxye?t:e}expandBy(){if(1===arguments.length){const t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){const t=arguments[0],e=arguments[1];if(this.isNull())return null;this._minx-=t,this._maxx+=t,this._miny-=e,this._maxy+=e,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}contains(){if(1===arguments.length){if(arguments[0]instanceof P){const t=arguments[0];return this.covers(t)}if(arguments[0]instanceof p){const t=arguments[0];return this.covers(t)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];return this.covers(t,e)}}centre(){return this.isNull()?null:new p((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}init(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof p){const t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof P){const t=arguments[0];this._minx=t._minx,this._maxx=t._maxx,this._miny=t._miny,this._maxy=t._maxy}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.init(t.x,e.x,t.y,e.y)}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];tt._maxx&&(e=this._minx-t._maxx);let s=0;return this._maxyt._maxy&&(s=this._miny-t._maxy),0===e?s:0===s?e:Math.sqrt(e*e+s*s)}hashCode(){let t=17;return t=37*t+p.hashCode(this._minx),t=37*t+p.hashCode(this._maxx),t=37*t+p.hashCode(this._miny),t=37*t+p.hashCode(this._maxy),t}get interfaces_(){return[r,a]}}class O{constructor(t){this.str=t}append(t){this.str+=t}setCharAt(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}toString(){return this.str}}class v{constructor(t){this.value=t}intValue(){return this.value}compareTo(t){return this.valuet?1:0}static compare(t,e){return te?1:0}static isNan(t){return Number.isNaN(t)}static valueOf(t){return new v(t)}}class M{static isWhitespace(t){return t<=32&&t>=0||127===t}static toUpperCase(t){return t.toUpperCase()}}class b{constructor(){b.constructor_.apply(this,arguments)}static constructor_(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){const t=arguments[0];this.init(t)}else if(arguments[0]instanceof b){const t=arguments[0];this.init(t)}else if("string"==typeof arguments[0]){const t=arguments[0];b.constructor_.call(this,b.parse(t))}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.init(t,e)}}static determinant(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];return b.determinant(b.valueOf(t),b.valueOf(e),b.valueOf(s),b.valueOf(n))}if(arguments[3]instanceof b&&arguments[2]instanceof b&&arguments[0]instanceof b&&arguments[1]instanceof b){const t=arguments[1],e=arguments[2],s=arguments[3];return arguments[0].multiply(s).selfSubtract(t.multiply(e))}}static sqr(t){return b.valueOf(t).selfMultiply(t)}static valueOf(){if("string"==typeof arguments[0]){const t=arguments[0];return b.parse(t)}if("number"==typeof arguments[0]){return new b(arguments[0])}}static sqrt(t){return b.valueOf(t).sqrt()}static parse(t){let e=0;const s=t.length;for(;M.isWhitespace(t.charAt(e));)e++;let n=!1;if(e=s);){const s=t.charAt(e);if(e++,M.isDigit(s)){const t=s-"0";i.selfMultiply(b.TEN),i.selfAdd(t),r++}else{if("."!==s){if("e"===s||"E"===s){const s=t.substring(e);try{l=v.parseInt(s)}catch(e){throw e instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+s+" in string "+t):e}break}throw new NumberFormatException("Unexpected character '"+s+"' at position "+e+" in string "+t)}o=r,a=!0}}let c=i;a||(o=r);const h=r-o-l;if(0===h)c=i;else if(h>0){const t=b.TEN.pow(h);c=i.divide(t)}else if(h<0){const t=b.TEN.pow(-h);c=i.multiply(t)}return n?c.negate():c}static createNaN(){return new b(i.NaN,i.NaN)}static copy(t){return new b(t)}static magnitude(t){const e=Math.abs(t),s=Math.log(e)/Math.log(10);let n=Math.trunc(Math.floor(s));return 10*Math.pow(10,n)<=e&&(n+=1),n}static stringOfChar(t,e){const s=new O;for(let n=0;n9?(i=!0,a="9"):a="0"+n,o.append(a),s=s.subtract(b.valueOf(n)).multiply(b.TEN),i&&s.selfAdd(b.TEN);let c=!0;const h=b.magnitude(s._hi);if(h<0&&Math.abs(h)>=l-e&&(c=!1),!c)break}return e[0]=n,o.toString()}sqr(){return this.multiply(this)}doubleValue(){return this._hi+this._lo}subtract(){if(arguments[0]instanceof b){const t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){const t=arguments[0];return this.add(-t)}}equals(){if(1===arguments.length&&arguments[0]instanceof b){const t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}}isZero(){return 0===this._hi&&0===this._lo}selfSubtract(){if(arguments[0]instanceof b){const t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo)}if("number"==typeof arguments[0]){const t=arguments[0];return this.isNaN()?this:this.selfAdd(-t,0)}}getSpecialNumberString(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}min(t){return this.le(t)?this:t}selfDivide(){if(1===arguments.length){if(arguments[0]instanceof b){const t=arguments[0];return this.selfDivide(t._hi,t._lo)}if("number"==typeof arguments[0]){const t=arguments[0];return this.selfDivide(t,0)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];let s=null,n=null,i=null,r=null,o=null,l=null,a=null,c=null;return o=this._hi/t,l=b.SPLIT*o,s=l-o,c=b.SPLIT*t,s=l-s,n=o-s,i=c-t,a=o*t,i=c-i,r=t-i,c=s*i-a+s*r+n*i+n*r,l=(this._hi-a-c+this._lo-o*e)/t,c=o+l,this._hi=c,this._lo=o-c+l,this}}dump(){return"DD<"+this._hi+", "+this._lo+">"}divide(){if(arguments[0]instanceof b){const t=arguments[0];let e=null,s=null,n=null,i=null,r=null,o=null,l=null,a=null;r=this._hi/t._hi,o=b.SPLIT*r,e=o-r,a=b.SPLIT*t._hi,e=o-e,s=r-e,n=a-t._hi,l=r*t._hi,n=a-n,i=t._hi-n,a=e*n-l+e*i+s*n+s*i,o=(this._hi-l-a+this._lo-r*t._lo)/t._hi,a=r+o;return new b(a,r-a+o)}if("number"==typeof arguments[0]){const t=arguments[0];return i.isNaN(t)?b.createNaN():b.copy(this).selfDivide(t,0)}}ge(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>=t._lo}pow(t){if(0===t)return b.valueOf(1);let e=new b(this),s=b.valueOf(1),n=Math.abs(t);if(n>1)for(;n>0;)n%2==1&&s.selfMultiply(e),n/=2,n>0&&(e=e.sqr());else s=e;return t<0?s.reciprocal():s}ceil(){if(this.isNaN())return b.NaN;const t=Math.ceil(this._hi);let e=0;return t===this._hi&&(e=Math.ceil(this._lo)),new b(t,e)}compareTo(t){const e=t;return this._hie._hi?1:this._loe._lo?1:0}rint(){if(this.isNaN())return this;return this.add(.5).floor()}setValue(){if(arguments[0]instanceof b){const t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){const t=arguments[0];return this.init(t),this}}max(t){return this.ge(t)?this:t}sqrt(){if(this.isZero())return b.valueOf(0);if(this.isNegative())return b.NaN;const t=1/Math.sqrt(this._hi),e=this._hi*t,s=b.valueOf(e),n=this.subtract(s.sqr())._hi*(.5*t);return s.add(n)}selfAdd(){if(1===arguments.length){if(arguments[0]instanceof b){const t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){const t=arguments[0];let e=null,s=null,n=null,i=null,r=null,o=null;return n=this._hi+t,r=n-this._hi,i=n-r,i=t-r+(this._hi-i),o=i+this._lo,e=n+o,s=o+(n-e),this._hi=e+s,this._lo=s+(e-this._hi),this}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];let s=null,n=null,i=null,r=null,o=null,l=null,a=null,c=null;o=this._hi+t,i=this._lo+e,a=o-this._hi,c=i-this._lo,l=o-a,r=i-c,l=t-a+(this._hi-l),r=e-c+(this._lo-r),a=l+i,s=o+a,n=a+(o-s),a=r+n;const h=s+a,u=a+(s-h);return this._hi=h,this._lo=u,this}}selfMultiply(){if(1===arguments.length){if(arguments[0]instanceof b){const t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if("number"==typeof arguments[0]){const t=arguments[0];return this.selfMultiply(t,0)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];let s=null,n=null,i=null,r=null,o=null,l=null;o=b.SPLIT*this._hi,s=o-this._hi,l=b.SPLIT*t,s=o-s,n=this._hi-s,i=l-t,o=this._hi*t,i=l-i,r=t-i,l=s*i-o+s*r+n*i+n*r+(this._hi*e+this._lo*t);const a=o+l;s=o-a;const c=l+s;return this._hi=a,this._lo=c,this}}selfSqr(){return this.selfMultiply(this)}floor(){if(this.isNaN())return b.NaN;const t=Math.floor(this._hi);let e=0;return t===this._hi&&(e=Math.floor(this._lo)),new b(t,e)}negate(){return this.isNaN()?this:new b(-this._hi,-this._lo)}clone(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return null;throw t}}multiply(){if(arguments[0]instanceof b){const t=arguments[0];return t.isNaN()?b.createNaN():b.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){const t=arguments[0];return i.isNaN(t)?b.createNaN():b.copy(this).selfMultiply(t,0)}}isNaN(){return i.isNaN(this._hi)}intValue(){return Math.trunc(this._hi)}toString(){const t=b.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()}toStandardNotation(){const t=this.getSpecialNumberString();if(null!==t)return t;const e=new Array(1).fill(null),s=this.extractSignificantDigits(!0,e),n=e[0]+1;let i=s;if("."===s.charAt(0))i="0"+s;else if(n<0)i="0."+b.stringOfChar("0",-n)+s;else if(-1===s.indexOf(".")){const t=n-s.length;i=s+b.stringOfChar("0",t)+".0"}return this.isNegative()?"-"+i:i}reciprocal(){let t=null,e=null,s=null,n=null,i=null,r=null,o=null,l=null;i=1/this._hi,r=b.SPLIT*i,t=r-i,l=b.SPLIT*this._hi,t=r-t,e=i-t,s=l-this._hi,o=i*this._hi,s=l-s,n=this._hi-s,l=t*s-o+t*n+e*s+e*n,r=(1-o-l-i*this._lo)/this._hi;const a=i+r;return new b(a,i-a+r)}toSciNotation(){if(this.isZero())return b.SCI_NOT_ZERO;const t=this.getSpecialNumberString();if(null!==t)return t;const e=new Array(1).fill(null),s=this.extractSignificantDigits(!1,e),n=b.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===s.charAt(0))throw new IllegalStateException("Found leading zero: "+s);let i="";s.length>1&&(i=s.substring(1));const r=s.charAt(0)+"."+i;return this.isNegative()?"-"+r+n:r+n}abs(){return this.isNaN()?b.NaN:this.isNegative()?this.negate():new b(this)}isPositive(){return this._hi>0||0===this._hi&&this._lo>0}lt(t){return this._hit._hi||this._hi===t._hi&&this._lo>t._lo}isNegative(){return this._hi<0||0===this._hi&&this._lo<0}trunc(){return this.isNaN()?b.NaN:this.isPositive()?this.floor():this.ceil()}signum(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}get interfaces_(){return[a,r,o]}}b.PI=new b(3.141592653589793,12246467991473532e-32),b.TWO_PI=new b(6.283185307179586,24492935982947064e-32),b.PI_2=new b(1.5707963267948966,6123233995736766e-32),b.E=new b(2.718281828459045,14456468917292502e-32),b.NaN=new b(i.NaN,i.NaN),b.EPS=123259516440783e-46,b.SPLIT=134217729,b.MAX_PRINT_DIGITS=32,b.TEN=b.valueOf(10),b.ONE=b.valueOf(1),b.SCI_NOT_EXPONENT_CHAR="E",b.SCI_NOT_ZERO="0.0E0";class D{static orientationIndex(t,e,s){const n=D.orientationIndexFilter(t,e,s);if(n<=1)return n;const i=b.valueOf(e.x).selfAdd(-t.x),r=b.valueOf(e.y).selfAdd(-t.y),o=b.valueOf(s.x).selfAdd(-e.x),l=b.valueOf(s.y).selfAdd(-e.y);return i.selfMultiply(l).selfSubtract(r.selfMultiply(o)).signum()}static signOfDet2x2(){if(arguments[3]instanceof b&&arguments[2]instanceof b&&arguments[0]instanceof b&&arguments[1]instanceof b){const t=arguments[1],e=arguments[2],s=arguments[3];return arguments[0].multiply(s).selfSubtract(t.multiply(e)).signum()}if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=b.valueOf(t),r=b.valueOf(e),o=b.valueOf(s),l=b.valueOf(n);return i.multiply(l).selfSubtract(r.multiply(o)).signum()}}static intersection(t,e,s,n){const r=new b(t.y).selfSubtract(e.y),o=new b(e.x).selfSubtract(t.x),l=new b(t.x).selfMultiply(e.y).selfSubtract(new b(e.x).selfMultiply(t.y)),a=new b(s.y).selfSubtract(n.y),c=new b(n.x).selfSubtract(s.x),h=new b(s.x).selfMultiply(n.y).selfSubtract(new b(n.x).selfMultiply(s.y)),u=o.multiply(h).selfSubtract(c.multiply(l)),g=a.multiply(l).selfSubtract(r.multiply(h)),d=r.multiply(c).selfSubtract(a.multiply(o)),_=u.selfDivide(d).doubleValue(),m=g.selfDivide(d).doubleValue();return i.isNaN(_)||i.isInfinite(_)||i.isNaN(m)||i.isInfinite(m)?null:new p(_,m)}static orientationIndexFilter(t,e,s){let n=null;const i=(t.x-s.x)*(e.y-s.y),r=(t.y-s.y)*(e.x-s.x),o=i-r;if(i>0){if(r<=0)return D.signum(o);n=i+r}else{if(!(i<0))return D.signum(o);if(r>=0)return D.signum(o);n=-i-r}const l=D.DP_SAFE_EPSILON*n;return o>=l||-o>=l?D.signum(o):2}static signum(t){return t>0?1:t<0?-1:0}}D.DP_SAFE_EPSILON=1e-15;class A{getM(t){if(this.hasM()){const e=this.getDimension()-this.getMeasures();return this.getOrdinate(t,e)}return i.NaN}setOrdinate(t,e,s){}getZ(t){return this.hasZ()?this.getOrdinate(t,2):i.NaN}size(){}getOrdinate(t,e){}getCoordinate(){}getCoordinateCopy(t){}createCoordinate(){}getDimension(){}hasM(){return this.getMeasures()>0}getX(t){}hasZ(){return this.getDimension()-this.getMeasures()>2}getMeasures(){return 0}expandEnvelope(t){}copy(){}getY(t){}toCoordinateArray(){}get interfaces_(){return[o]}}A.X=0,A.Y=1,A.Z=2,A.M=3;class F{static index(t,e,s){return D.orientationIndex(t,e,s)}static isCCW(){if(arguments[0]instanceof Array){const t=arguments[0],e=t.length-1;if(e<3)throw new s("Ring has fewer than 4 points, so orientation cannot be determined");let n=t[0],i=0;for(let s=1;s<=e;s++){const e=t[s];e.y>n.y&&(n=e,i=s)}let r=i;do{r-=1,r<0&&(r=e)}while(t[r].equals2D(n)&&r!==i);let o=i;do{o=(o+1)%e}while(t[o].equals2D(n)&&o!==i);const l=t[r],a=t[o];if(l.equals2D(n)||a.equals2D(n)||l.equals2D(a))return!1;const c=F.index(l,n,a);let h=null;return h=0===c?l.x>a.x:c>0,h}if(E(arguments[0],A)){const t=arguments[0],e=t.size()-1;if(e<3)throw new s("Ring has fewer than 4 points, so orientation cannot be determined");let n=t.getCoordinate(0),i=0;for(let s=1;s<=e;s++){const e=t.getCoordinate(s);e.y>n.y&&(n=e,i=s)}let r=null,o=i;do{o-=1,o<0&&(o=e),r=t.getCoordinate(o)}while(r.equals2D(n)&&o!==i);let l=null,a=i;do{a=(a+1)%e,l=t.getCoordinate(a)}while(l.equals2D(n)&&a!==i);if(r.equals2D(n)||l.equals2D(n)||r.equals2D(l))return!1;const c=F.index(r,n,l);let h=null;return h=0===c?r.x>l.x:c>0,h}}}F.CLOCKWISE=-1,F.RIGHT=F.CLOCKWISE,F.COUNTERCLOCKWISE=1,F.LEFT=F.COUNTERCLOCKWISE,F.COLLINEAR=0,F.STRAIGHT=F.COLLINEAR;class G{static intersection(t,e,s,n){const r=t.xe.x?t.x:e.x,a=t.y>e.y?t.y:e.y,c=s.xn.x?s.x:n.x,g=s.y>n.y?s.y:n.y,d=((r>c?r:c)+(lh?o:h)+(as?s:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){const t=arguments[0],e=arguments[1],s=arguments[2];return ts?s:t}}static wrap(t,e){return t<0?e- -t%e:t%e}static max(){if(3===arguments.length){const t=arguments[1],e=arguments[2];let s=arguments[0];return t>s&&(s=t),e>s&&(s=e),s}if(4===arguments.length){const t=arguments[1],e=arguments[2],s=arguments[3];let n=arguments[0];return t>n&&(n=t),e>n&&(n=e),s>n&&(n=s),n}}static average(t,e){return(t+e)/2}}B.LOG_10=Math.log(10);class Y{static segmentToSegment(t,e,s,n){if(t.equals(e))return Y.pointToSegment(t,s,n);if(s.equals(n))return Y.pointToSegment(n,t,e);let i=!1;if(P.intersects(t,e,s,n)){const r=(e.x-t.x)*(n.y-s.y)-(e.y-t.y)*(n.x-s.x);if(0===r)i=!0;else{const o=(t.y-s.y)*(n.x-s.x)-(t.x-s.x)*(n.y-s.y),l=((t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y))/r,a=o/r;(a<0||a>1||l<0||l>1)&&(i=!0)}}else i=!0;return i?B.min(Y.pointToSegment(t,s,n),Y.pointToSegment(e,s,n),Y.pointToSegment(s,t,e),Y.pointToSegment(n,t,e)):0}static pointToSegment(t,e,s){if(e.x===s.x&&e.y===s.y)return t.distance(e);const n=(s.x-e.x)*(s.x-e.x)+(s.y-e.y)*(s.y-e.y),i=((t.x-e.x)*(s.x-e.x)+(t.y-e.y)*(s.y-e.y))/n;if(i<=0)return t.distance(e);if(i>=1)return t.distance(s);const r=((e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y))/n;return Math.abs(r)*Math.sqrt(n)}static pointToLinePerpendicular(t,e,s){const n=(s.x-e.x)*(s.x-e.x)+(s.y-e.y)*(s.y-e.y),i=((e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y))/n;return Math.abs(i)*Math.sqrt(n)}static pointToSegmentString(t,e){if(0===e.length)throw new s("Line array must contain at least one vertex");let n=t.distance(e[0]);for(let s=0;s0)&&(n=e,s=i)}return s}}static extend(t,e,s){const n=t.create(s,e.getDimension()),i=e.size();if(W.copy(e,0,n,0,i),i>0)for(let t=i;t0)&&(e=n)}return e}}class Z extends e{constructor(t){super(t),this.name=Object.keys({UnsupportedOperationException:Z})[0]}}class j{static toDimensionSymbol(t){switch(t){case j.FALSE:return j.SYM_FALSE;case j.TRUE:return j.SYM_TRUE;case j.DONTCARE:return j.SYM_DONTCARE;case j.P:return j.SYM_P;case j.L:return j.SYM_L;case j.A:return j.SYM_A}throw new s("Unknown dimension value: "+t)}static toDimensionValue(t){switch(M.toUpperCase(t)){case j.SYM_FALSE:return j.FALSE;case j.SYM_TRUE:return j.TRUE;case j.SYM_DONTCARE:return j.DONTCARE;case j.SYM_P:return j.P;case j.SYM_L:return j.L;case j.SYM_A:return j.A}throw new s("Unknown dimension symbol: "+t)}}j.P=0,j.L=1,j.A=2,j.FALSE=-1,j.TRUE=-2,j.DONTCARE=-3,j.SYM_FALSE="F",j.SYM_TRUE="T",j.SYM_DONTCARE="*",j.SYM_P="0",j.SYM_L="1",j.SYM_A="2";class K{filter(t){}}class Q extends X{constructor(){super(),Q.constructor_.apply(this,arguments)}static constructor_(){if(this._points=null,0===arguments.length);else if(2===arguments.length){const t=arguments[0],e=arguments[1];X.constructor_.call(this,e),this.init(t)}}computeEnvelopeInternal(){return this.isEmpty()?new P:this._points.expandEnvelope(new P)}isRing(){return this.isClosed()&&this.isSimple()}getCoordinates(){return this._points.toCoordinateArray()}copyInternal(){return new Q(this._points.copy(),this._factory)}equalsExact(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof X){const t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;const s=t;if(this._points.size()!==s._points.size())return!1;for(let t=0;t0){const t=this._points.copy();W.reverse(t),this._points=t}return null}}}getCoordinate(){return this.isEmpty()?null:this._points.getCoordinate(0)}getBoundaryDimension(){return this.isClosed()?j.FALSE:0}isClosed(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}reverseInternal(){const t=this._points.copy();return W.reverse(t),this.getFactory().createLineString(t)}getEndPoint(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}getTypeCode(){return X.TYPECODE_LINESTRING}getDimension(){return 1}getLength(){return U.ofLine(this._points)}getNumPoints(){return this._points.size()}compareToSameClass(){if(1===arguments.length){const t=arguments[0];let e=0,s=0;for(;e= 2)");this._points=t}isCoordinate(t){for(let e=0;et.compareTo(e)));else if(2===arguments.length)t.sort(((t,e)=>arguments[1].compare(t,e)));else if(3===arguments.length){const e=t.slice(arguments[1],arguments[2]);e.sort();const s=t.slice(0,arguments[1]).concat(e,t.slice(arguments[2],t.length));t.splice(0,t.length);for(const e of s)t.push(e)}else if(4===arguments.length){const e=t.slice(arguments[1],arguments[2]);e.sort(((t,e)=>arguments[3].compare(t,e)));const s=t.slice(0,arguments[1]).concat(e,t.slice(arguments[2],t.length));t.splice(0,t.length);for(const e of s)t.push(e)}}static asList(t){const e=new S;for(const s of t)e.add(s);return e}static copyOf(t,e){return t.slice(0,e)}}class st{}class nt extends X{constructor(){super(),nt.constructor_.apply(this,arguments)}static constructor_(){this._shell=null,this._holes=null;let t=arguments[0],e=arguments[1],n=arguments[2];if(X.constructor_.call(this,n),null===t&&(t=this.getFactory().createLinearRing()),null===e&&(e=[]),X.hasNullElements(e))throw new s("holes must not contain null elements");if(t.isEmpty()&&X.hasNonEmptyElements(e))throw new s("shell is empty but holes are not");this._shell=t,this._holes=e}computeEnvelopeInternal(){return this._shell.getEnvelopeInternal()}getCoordinates(){if(this.isEmpty())return[];const t=new Array(this.getNumPoints()).fill(null);let e=-1;const s=this._shell.getCoordinates();for(let n=0;n=1&&this.getCoordinateSequence().size()= 4)")}getGeometryType(){return X.TYPENAME_LINEARRING}}ht.MINIMUM_VALID_SIZE=4;class ut{static measures(t){return t instanceof f?0:t instanceof y||t instanceof x?1:0}static dimension(t){return t instanceof f?2:t instanceof y?3:t instanceof x?4:3}static create(){if(1===arguments.length){const t=arguments[0];return ut.create(t,0)}if(2===arguments.length){const t=arguments[0],e=arguments[1];return 2===t?new f:3===t&&0===e?new p:3===t&&1===e?new y:4===t&&1===e?new x:new p}}}class gt{static isRing(t){return!(t.length<4)&&!!t[0].equals2D(t[t.length-1])}static ptNotInList(t,e){for(let s=0;s=t?e:[]}static indexOf(t,e){for(let s=0;s0)&&(e=t[s]);return e}static extract(t,e,s){e=B.clamp(e,0,t.length);let n=(s=B.clamp(s,-1,t.length))-e+1;s<0&&(n=0),e>=t.length&&(n=0),sn.length)return 1;if(0===s.length)return 0;const i=gt.compare(s,n);return gt.isEqualReversed(s,n)?0:i}OLDcompare(t,e){const s=t,n=e;if(s.lengthn.length)return 1;if(0===s.length)return 0;const i=gt.increasingDirection(s),r=gt.increasingDirection(n);let o=i>0?0:s.length-1,l=r>0?0:s.length-1;for(let t=0;t0){const t=new dt(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(let e=1;e3&&(t=3),t<2&&(t=2),new _t(arguments[0],t)}if(3===arguments.length){let t=arguments[2],e=arguments[1]-t;return t>1&&(t=1),e>3&&(e=3),e<2&&(e=2),new _t(arguments[0],e+t,t)}}}get interfaces_(){return[V,a]}}pt.instanceObject=new pt;class mt extends at{constructor(){super(),mt.constructor_.apply(this,arguments)}static constructor_(){const t=arguments[0],e=arguments[1];at.constructor_.call(this,t,e)}copyInternal(){const t=new Array(this._geometries.length).fill(null);for(let e=0;et.add(e))),t}size(){return this.map.size()}}class It{constructor(){It.constructor_.apply(this,arguments)}static constructor_(){if(this._modelType=null,this._scale=null,0===arguments.length)this._modelType=It.FLOATING;else if(1===arguments.length)if(arguments[0]instanceof Nt){const t=arguments[0];this._modelType=t,t===It.FIXED&&this.setScale(1)}else if("number"==typeof arguments[0]){const t=arguments[0];this._modelType=It.FIXED,this.setScale(t)}else if(arguments[0]instanceof It){const t=arguments[0];this._modelType=t._modelType,this._scale=t._scale}}static mostPrecise(t,e){return t.compareTo(e)>=0?t:e}equals(t){if(!(t instanceof It))return!1;const e=t;return this._modelType===e._modelType&&this._scale===e._scale}compareTo(t){const e=t,s=this.getMaximumSignificantDigits(),n=e.getMaximumSignificantDigits();return v.compare(s,n)}getScale(){return this._scale}isFloating(){return this._modelType===It.FLOATING||this._modelType===It.FLOATING_SINGLE}getType(){return this._modelType}toString(){let t="UNKNOWN";return this._modelType===It.FLOATING?t="Floating":this._modelType===It.FLOATING_SINGLE?t="Floating-Single":this._modelType===It.FIXED&&(t="Fixed (Scale="+this.getScale()+")"),t}makePrecise(){if("number"==typeof arguments[0]){const t=arguments[0];if(i.isNaN(t))return t;if(this._modelType===It.FLOATING_SINGLE){return t}return this._modelType===It.FIXED?Math.round(t*this._scale)/this._scale:t}if(arguments[0]instanceof p){const t=arguments[0];if(this._modelType===It.FLOATING)return null;t.x=this.makePrecise(t.x),t.y=this.makePrecise(t.y)}}getMaximumSignificantDigits(){let t=16;return this._modelType===It.FLOATING?t=16:this._modelType===It.FLOATING_SINGLE?t=6:this._modelType===It.FIXED&&(t=1+Math.trunc(Math.ceil(Math.log(this.getScale())/Math.log(10)))),t}setScale(t){this._scale=Math.abs(t)}get interfaces_(){return[a,r]}}class Nt{constructor(){Nt.constructor_.apply(this,arguments)}static constructor_(){this._name=null;const t=arguments[0];this._name=t,Nt.nameToTypeMap.put(t,this)}readResolve(){return Nt.nameToTypeMap.get(this._name)}toString(){return this._name}get interfaces_(){return[a]}}Nt.nameToTypeMap=new Et,It.Type=Nt,It.FIXED=new Nt("FIXED"),It.FLOATING=new Nt("FLOATING"),It.FLOATING_SINGLE=new Nt("FLOATING SINGLE"),It.maximumPreciseValue=9007199254740992;class Ct extends at{constructor(){super(),Ct.constructor_.apply(this,arguments)}static constructor_(){const t=arguments[0],e=arguments[1];at.constructor_.call(this,t,e)}copyInternal(){const t=new Array(this._geometries.length).fill(null);for(let e=0;e1){if(i instanceof nt)return this.createMultiPolygon(wt.toPolygonArray(t));if(i instanceof Q)return this.createMultiLineString(wt.toLineStringArray(t));if(i instanceof $)return this.createMultiPoint(wt.toPointArray(t));u.shouldNeverReachHere("Unhandled geometry type: "+i.getGeometryType())}return i}createMultiPointFromCoords(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}createPoint(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof p){const t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(E(arguments[0],A)){return new $(arguments[0],this)}}}getCoordinateSequenceFactory(){return this._coordinateSequenceFactory}createPolygon(){if(0===arguments.length)return this.createPolygon(null,null);if(1===arguments.length){if(E(arguments[0],A)){const t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){const t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof ht){const t=arguments[0];return this.createPolygon(t,null)}}else if(2===arguments.length){return new nt(arguments[0],arguments[1],this)}}getSRID(){return this._SRID}createGeometryCollection(){if(0===arguments.length)return new at(null,this);if(1===arguments.length){return new at(arguments[0],this)}}getPrecisionModel(){return this._precisionModel}createLinearRing(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){const t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(E(arguments[0],A)){return new ht(arguments[0],this)}}}createMultiPolygon(){if(0===arguments.length)return new mt(null,this);if(1===arguments.length){return new mt(arguments[0],this)}}createMultiPoint(){if(0===arguments.length)return new ct(null,this);if(1===arguments.length){if(arguments[0]instanceof Array){return new ct(arguments[0],this)}if(E(arguments[0],A)){const t=arguments[0];if(null===t)return this.createMultiPoint(new Array(0).fill(null));const e=new Array(t.size()).fill(null);for(let s=0;s="a"&&t<="z"||t>="A"&&t<="Z"}isNumeric_(t,e){return t>="0"&&t<="9"||"."==t&&!(void 0!==e&&e)}isWhiteSpace_(t){return" "==t||"\t"==t||"\r"==t||"\n"==t}nextChar_(){return this.wkt.charAt(++this.index_)}nextToken(){const t=this.nextChar_(),e=this.index_;let s,n=t;if("("==t)s=vt;else if(","==t)s=Dt;else if(")"==t)s=Mt;else if(this.isNumeric_(t)||"-"==t)s=bt,n=this.readNumber_();else if(this.isAlpha_(t))s=Ot,n=this.readText_();else{if(this.isWhiteSpace_(t))return this.nextToken();if(""!==t)throw new Error("Unexpected character: "+t);s=At}return{position:e,value:n,type:s}}readNumber_(){let t;const e=this.index_;let s=!1,n=!1;do{"."==t?s=!0:"e"!=t&&"E"!=t||(n=!0),t=this.nextChar_()}while(this.isNumeric_(t,s)||!n&&("e"==t||"E"==t)||n&&("-"==t||"+"==t));return parseFloat(this.wkt.substring(e,this.index_--))}readText_(){let t;const e=this.index_;do{t=this.nextChar_()}while(this.isAlpha_(t));return this.wkt.substring(e,this.index_--).toUpperCase()}}class qt{constructor(t,e){this.lexer_=t,this.token_,this.layout_=St,this.factory=e}consume_(){this.token_=this.lexer_.nextToken()}isTokenType(t){return this.token_.type==t}match(t){const e=this.isTokenType(t);return e&&this.consume_(),e}parse(){this.consume_();return this.parseGeometry_()}parseGeometryLayout_(){let t=St;const e=this.token_;if(this.isTokenType(Ot)){const s=e.value;"Z"===s?t=Lt:"M"===s?t=Tt:"ZM"===s&&(t=Rt),t!==St&&this.consume_()}return t}parseGeometryCollectionText_(){if(this.match(vt)){const t=[];do{t.push(this.parseGeometry_())}while(this.match(Dt));if(this.match(Mt))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parsePointText_(){if(this.match(vt)){const t=this.parsePoint_();if(this.match(Mt))return t}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}parseLineStringText_(){if(this.match(vt)){const t=this.parsePointList_();if(this.match(Mt))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parsePolygonText_(){if(this.match(vt)){const t=this.parseLineStringTextList_();if(this.match(Mt))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parseMultiPointText_(){if(this.match(vt)){let t;if(t=this.token_.type==vt?this.parsePointTextList_():this.parsePointList_(),this.match(Mt))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parseMultiLineStringText_(){if(this.match(vt)){const t=this.parseLineStringTextList_();if(this.match(Mt))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parseMultiPolygonText_(){if(this.match(vt)){const t=this.parsePolygonTextList_();if(this.match(Mt))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}parsePoint_(){const t=[],e=this.layout_.length;for(let s=0;snew p(...t),s=s=>{const n=s.map((s=>t.createLinearRing(s.map(e))));return n.length>1?t.createPolygon(n[0],n.slice(1)):t.createPolygon(n[0])},n=this.token_;if(this.match(Ot)){const i=n.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==i){const e=this.parseGeometryCollectionText_();return t.createGeometryCollection(e)}switch(i){case"POINT":{const e=this.parsePointText_();return e?t.createPoint(new p(...e)):t.createPoint()}case"LINESTRING":{const s=this.parseLineStringText_().map(e);return t.createLineString(s)}case"LINEARRING":{const s=this.parseLineStringText_().map(e);return t.createLinearRing(s)}case"POLYGON":{const e=this.parsePolygonText_();return e&&0!==e.length?s(e):t.createPolygon()}case"MULTIPOINT":{const s=this.parseMultiPointText_();if(!s||0===s.length)return t.createMultiPoint();const n=s.map(e).map((e=>t.createPoint(e)));return t.createMultiPoint(n)}case"MULTILINESTRING":{const s=this.parseMultiLineStringText_().map((s=>t.createLineString(s.map(e))));return t.createMultiLineString(s)}case"MULTIPOLYGON":{const e=this.parseMultiPolygonText_();if(!e||0===e.length)return t.createMultiPolygon();const n=e.map(s);return t.createMultiPolygon(n)}default:throw new Error("Invalid geometry type: "+i)}}throw new Error(this.formatErrorMessage_())}}function Bt(t){if(t.isEmpty())return"";const e=t.getCoordinate(),s=[e.x,e.y];return void 0===e.z||Number.isNaN(e.z)||s.push(e.z),void 0===e.m||Number.isNaN(e.m)||s.push(e.m),s.join(" ")}function Yt(t){const e=t.getCoordinates().map((t=>{const e=[t.x,t.y];return void 0===t.z||Number.isNaN(t.z)||e.push(t.z),void 0===t.m||Number.isNaN(t.m)||e.push(t.m),e})),s=[];for(let t=0,n=e.length;t0&&(e+=" "+n),t.isEmpty())return e+" EMPTY";return e+" ("+s(t)+")"}class kt{constructor(t){this.geometryFactory=t||new wt,this.precisionModel=this.geometryFactory.getPrecisionModel()}read(t){const e=new Gt(t);return new qt(e,this.geometryFactory).parse()}write(t){return Xt(t)}}class Ut{constructor(t){this.parser=new kt(t)}write(t){return this.parser.write(t)}static toLineString(t,e){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+t.x+" "+t.y+", "+e.x+" "+e.y+" )"}}class Ht{constructor(){Ht.constructor_.apply(this,arguments)}static constructor_(){this._result=null,this._inputLines=Array(2).fill().map((()=>Array(2))),this._intPt=new Array(2).fill(null),this._intLineIndex=null,this._isProper=null,this._pa=null,this._pb=null,this._precisionModel=null,this._intPt[0]=new p,this._intPt[1]=new p,this._pa=this._intPt[0],this._pb=this._intPt[1],this._result=0}static computeEdgeDistance(t,e,s){const n=Math.abs(s.x-e.x),i=Math.abs(s.y-e.y);let r=-1;if(t.equals(e))r=0;else if(t.equals(s))r=n>i?n:i;else{const s=Math.abs(t.x-e.x),o=Math.abs(t.y-e.y);r=n>i?s:o,0!==r||t.equals(e)||(r=Math.max(s,o))}return u.isTrue(!(0===r&&!t.equals(e)),"Bad distance calculation"),r}static nonRobustComputeEdgeDistance(t,e,s){const n=t.x-e.x,i=t.y-e.y,r=Math.sqrt(n*n+i*i);return u.isTrue(!(0===r&&!t.equals(e)),"Invalid distance calculation"),r}getIndexAlongSegment(t,e){return this.computeIntLineIndex(),this._intLineIndex[t][e]}getTopologySummary(){const t=new dt;return this.isEndPoint()&&t.append(" endpoint"),this._isProper&&t.append(" proper"),this.isCollinear()&&t.append(" collinear"),t.toString()}computeIntersection(t,e,s,n){this._inputLines[0][0]=t,this._inputLines[0][1]=e,this._inputLines[1][0]=s,this._inputLines[1][1]=n,this._result=this.computeIntersect(t,e,s,n)}getIntersectionNum(){return this._result}computeIntLineIndex(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map((()=>Array(2))),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){const t=arguments[0];this.getEdgeDistance(t,0)>this.getEdgeDistance(t,1)?(this._intLineIndex[t][0]=0,this._intLineIndex[t][1]=1):(this._intLineIndex[t][0]=1,this._intLineIndex[t][1]=0)}}isProper(){return this.hasIntersection()&&this._isProper}setPrecisionModel(t){this._precisionModel=t}isInteriorIntersection(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){const t=arguments[0];for(let e=0;e1e-4&&q.out.println("Distance = "+i.distance(r))}intersectionSafe(t,e,s,n){let i=G.intersection(t,e,s,n);return null===i&&(i=Wt.nearestEndpoint(t,e,s,n)),i}computeCollinearIntersection(t,e,s,n){const i=P.intersects(t,e,s),r=P.intersects(t,e,n),o=P.intersects(s,n,t),l=P.intersects(s,n,e);return i&&r?(this._intPt[0]=s,this._intPt[1]=n,Ht.COLLINEAR_INTERSECTION):o&&l?(this._intPt[0]=t,this._intPt[1]=e,Ht.COLLINEAR_INTERSECTION):i&&o?(this._intPt[0]=s,this._intPt[1]=t,!s.equals(t)||r||l?Ht.COLLINEAR_INTERSECTION:Ht.POINT_INTERSECTION):i&&l?(this._intPt[0]=s,this._intPt[1]=e,!s.equals(e)||r||o?Ht.COLLINEAR_INTERSECTION:Ht.POINT_INTERSECTION):r&&o?(this._intPt[0]=n,this._intPt[1]=t,!n.equals(t)||i||l?Ht.COLLINEAR_INTERSECTION:Ht.POINT_INTERSECTION):r&&l?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||i||o?Ht.COLLINEAR_INTERSECTION:Ht.POINT_INTERSECTION):Ht.NO_INTERSECTION}computeIntersect(t,e,s,n){if(this._isProper=!1,!P.intersects(t,e,s,n))return Ht.NO_INTERSECTION;const i=F.index(t,e,s),r=F.index(t,e,n);if(i>0&&r>0||i<0&&r<0)return Ht.NO_INTERSECTION;const o=F.index(s,n,t),l=F.index(s,n,e);if(o>0&&l>0||o<0&&l<0)return Ht.NO_INTERSECTION;return 0===i&&0===r&&0===o&&0===l?this.computeCollinearIntersection(t,e,s,n):(0===i||0===r||0===o||0===l?(this._isProper=!1,t.equals2D(s)||t.equals2D(n)?this._intPt[0]=t:e.equals2D(s)||e.equals2D(n)?this._intPt[0]=e:0===i?this._intPt[0]=new p(s):0===r?this._intPt[0]=new p(n):0===o?this._intPt[0]=new p(t):0===l&&(this._intPt[0]=new p(e))):(this._isProper=!0,this._intPt[0]=this.intersection(t,e,s,n)),Ht.POINT_INTERSECTION)}}class Zt{constructor(){Zt.constructor_.apply(this,arguments)}static constructor_(){if(this.p0=null,this.p1=null,0===arguments.length)Zt.constructor_.call(this,new p,new p);else if(1===arguments.length){const t=arguments[0];Zt.constructor_.call(this,t.p0,t.p1)}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.p0=t,this.p1=e}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];Zt.constructor_.call(this,new p(t,e),new p(s,n))}}static midPoint(t,e){return new p((t.x+e.x)/2,(t.y+e.y)/2)}minX(){return Math.min(this.p0.x,this.p1.x)}orientationIndex(){if(arguments[0]instanceof Zt){const t=arguments[0],e=F.index(this.p0,this.p1,t.p0),s=F.index(this.p0,this.p1,t.p1);return e>=0&&s>=0||e<=0&&s<=0?Math.max(e,s):0}if(arguments[0]instanceof p){const t=arguments[0];return F.index(this.p0,this.p1,t)}}toGeometry(t){return t.createLineString([this.p0,this.p1])}isVertical(){return this.p0.x===this.p1.x}equals(t){if(!(t instanceof Zt))return!1;const e=t;return this.p0.equals(e.p0)&&this.p1.equals(e.p1)}intersection(t){const e=new Wt;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null}project(){if(arguments[0]instanceof p){const t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new p(t);const e=this.projectionFactor(t),s=new p;return s.x=this.p0.x+e*(this.p1.x-this.p0.x),s.y=this.p0.y+e*(this.p1.y-this.p0.y),s}if(arguments[0]instanceof Zt){const t=arguments[0],e=this.projectionFactor(t.p0),s=this.projectionFactor(t.p1);if(e>=1&&s>=1)return null;if(e<=0&&s<=0)return null;let n=this.project(t.p0);e<0&&(n=this.p0),e>1&&(n=this.p1);let i=this.project(t.p1);return s<0&&(i=this.p0),s>1&&(i=this.p1),new Zt(n,i)}}normalize(){this.p1.compareTo(this.p0)<0&&this.reverse()}angle(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}getCoordinate(t){return 0===t?this.p0:this.p1}distancePerpendicular(t){return Y.pointToLinePerpendicular(t,this.p0,this.p1)}minY(){return Math.min(this.p0.y,this.p1.y)}midPoint(){return Zt.midPoint(this.p0,this.p1)}projectionFactor(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;const e=this.p1.x-this.p0.x,s=this.p1.y-this.p0.y,n=e*e+s*s;if(n<=0)return i.NaN;return((t.x-this.p0.x)*e+(t.y-this.p0.y)*s)/n}closestPoints(t){const e=this.intersection(t);if(null!==e)return[e,e];const s=new Array(2).fill(null);let n=i.MAX_VALUE,r=null;const o=this.closestPoint(t.p0);n=o.distance(t.p0),s[0]=o,s[1]=t.p0;const l=this.closestPoint(t.p1);r=l.distance(t.p1),r0&&e<1)return this.project(t);return this.p0.distance(t)1||i.isNaN(e))&&(e=1),e}toString(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}isHorizontal(){return this.p0.y===this.p1.y}reflect(t){const e=this.p1.getY()-this.p0.getY(),s=this.p0.getX()-this.p1.getX(),n=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),i=e*e+s*s,r=e*e-s*s,o=t.getX(),l=t.getY();return new p((-r*o-2*e*s*l-2*e*n)/i,(r*l-2*e*s*o-2*s*n)/i)}distance(){if(arguments[0]instanceof Zt){const t=arguments[0];return Y.segmentToSegment(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof p){const t=arguments[0];return Y.pointToSegment(t,this.p0,this.p1)}}pointAlong(t){const e=new p;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}hashCode(){let t=i.doubleToLongBits(this.p0.x);t^=31*i.doubleToLongBits(this.p0.y);const e=Math.trunc(t)^Math.trunc(t>>32);let s=i.doubleToLongBits(this.p1.x);s^=31*i.doubleToLongBits(this.p1.y);return e^(Math.trunc(s)^Math.trunc(s>>32))}get interfaces_(){return[r,a]}}class jt{static toLocationSymbol(t){switch(t){case jt.EXTERIOR:return"e";case jt.BOUNDARY:return"b";case jt.INTERIOR:return"i";case jt.NONE:return"-"}throw new s("Unknown location value: "+t)}}jt.INTERIOR=0,jt.BOUNDARY=1,jt.EXTERIOR=2,jt.NONE=-1;class Kt{constructor(){Kt.constructor_.apply(this,arguments)}static constructor_(){if(this._matrix=null,0===arguments.length)this._matrix=Array(3).fill().map((()=>Array(3))),this.setAll(j.FALSE);else if(1===arguments.length)if("string"==typeof arguments[0]){const t=arguments[0];Kt.constructor_.call(this),this.set(t)}else if(arguments[0]instanceof Kt){const t=arguments[0];Kt.constructor_.call(this),this._matrix[jt.INTERIOR][jt.INTERIOR]=t._matrix[jt.INTERIOR][jt.INTERIOR],this._matrix[jt.INTERIOR][jt.BOUNDARY]=t._matrix[jt.INTERIOR][jt.BOUNDARY],this._matrix[jt.INTERIOR][jt.EXTERIOR]=t._matrix[jt.INTERIOR][jt.EXTERIOR],this._matrix[jt.BOUNDARY][jt.INTERIOR]=t._matrix[jt.BOUNDARY][jt.INTERIOR],this._matrix[jt.BOUNDARY][jt.BOUNDARY]=t._matrix[jt.BOUNDARY][jt.BOUNDARY],this._matrix[jt.BOUNDARY][jt.EXTERIOR]=t._matrix[jt.BOUNDARY][jt.EXTERIOR],this._matrix[jt.EXTERIOR][jt.INTERIOR]=t._matrix[jt.EXTERIOR][jt.INTERIOR],this._matrix[jt.EXTERIOR][jt.BOUNDARY]=t._matrix[jt.EXTERIOR][jt.BOUNDARY],this._matrix[jt.EXTERIOR][jt.EXTERIOR]=t._matrix[jt.EXTERIOR][jt.EXTERIOR]}}static matches(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){const t=arguments[0],e=arguments[1];return e===j.SYM_DONTCARE||(e===j.SYM_TRUE&&(t>=0||t===j.TRUE)||(e===j.SYM_FALSE&&t===j.FALSE||(e===j.SYM_P&&t===j.P||(e===j.SYM_L&&t===j.L||e===j.SYM_A&&t===j.A))))}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){const t=arguments[1];return new Kt(arguments[0]).matches(t)}}static isTrue(t){return t>=0||t===j.TRUE}isIntersects(){return!this.isDisjoint()}isCovers(){return(Kt.isTrue(this._matrix[jt.INTERIOR][jt.INTERIOR])||Kt.isTrue(this._matrix[jt.INTERIOR][jt.BOUNDARY])||Kt.isTrue(this._matrix[jt.BOUNDARY][jt.INTERIOR])||Kt.isTrue(this._matrix[jt.BOUNDARY][jt.BOUNDARY]))&&this._matrix[jt.EXTERIOR][jt.INTERIOR]===j.FALSE&&this._matrix[jt.EXTERIOR][jt.BOUNDARY]===j.FALSE}isCoveredBy(){return(Kt.isTrue(this._matrix[jt.INTERIOR][jt.INTERIOR])||Kt.isTrue(this._matrix[jt.INTERIOR][jt.BOUNDARY])||Kt.isTrue(this._matrix[jt.BOUNDARY][jt.INTERIOR])||Kt.isTrue(this._matrix[jt.BOUNDARY][jt.BOUNDARY]))&&this._matrix[jt.INTERIOR][jt.EXTERIOR]===j.FALSE&&this._matrix[jt.BOUNDARY][jt.EXTERIOR]===j.FALSE}set(){if(1===arguments.length){const t=arguments[0];for(let e=0;e=0&&e>=0&&this.setAtLeast(t,e,s)}isWithin(){return Kt.isTrue(this._matrix[jt.INTERIOR][jt.INTERIOR])&&this._matrix[jt.INTERIOR][jt.EXTERIOR]===j.FALSE&&this._matrix[jt.BOUNDARY][jt.EXTERIOR]===j.FALSE}isTouches(t,e){return t>e?this.isTouches(e,t):(t===j.A&&e===j.A||t===j.L&&e===j.L||t===j.L&&e===j.A||t===j.P&&e===j.A||t===j.P&&e===j.L)&&(this._matrix[jt.INTERIOR][jt.INTERIOR]===j.FALSE&&(Kt.isTrue(this._matrix[jt.INTERIOR][jt.BOUNDARY])||Kt.isTrue(this._matrix[jt.BOUNDARY][jt.INTERIOR])||Kt.isTrue(this._matrix[jt.BOUNDARY][jt.BOUNDARY])))}isOverlaps(t,e){return t===j.P&&e===j.P||t===j.A&&e===j.A?Kt.isTrue(this._matrix[jt.INTERIOR][jt.INTERIOR])&&Kt.isTrue(this._matrix[jt.INTERIOR][jt.EXTERIOR])&&Kt.isTrue(this._matrix[jt.EXTERIOR][jt.INTERIOR]):t===j.L&&e===j.L&&(1===this._matrix[jt.INTERIOR][jt.INTERIOR]&&Kt.isTrue(this._matrix[jt.INTERIOR][jt.EXTERIOR])&&Kt.isTrue(this._matrix[jt.EXTERIOR][jt.INTERIOR]))}isEquals(t,e){return t===e&&(Kt.isTrue(this._matrix[jt.INTERIOR][jt.INTERIOR])&&this._matrix[jt.INTERIOR][jt.EXTERIOR]===j.FALSE&&this._matrix[jt.BOUNDARY][jt.EXTERIOR]===j.FALSE&&this._matrix[jt.EXTERIOR][jt.INTERIOR]===j.FALSE&&this._matrix[jt.EXTERIOR][jt.BOUNDARY]===j.FALSE)}toString(){const t=new dt("123456789");for(let e=0;e<3;e++)for(let s=0;s<3;s++)t.setCharAt(3*e+s,j.toDimensionSymbol(this._matrix[e][s]));return t.toString()}setAll(t){for(let e=0;e<3;e++)for(let s=0;s<3;s++)this._matrix[e][s]=t}get(t,e){return this._matrix[t][e]}transpose(){let t=this._matrix[1][0];return this._matrix[1][0]=this._matrix[0][1],this._matrix[0][1]=t,t=this._matrix[2][0],this._matrix[2][0]=this._matrix[0][2],this._matrix[0][2]=t,t=this._matrix[2][1],this._matrix[2][1]=this._matrix[1][2],this._matrix[1][2]=t,this}matches(t){if(9!==t.length)throw new s("Should be length 9: "+t);for(let e=0;e<3;e++)for(let s=0;s<3;s++)if(!Kt.matches(this._matrix[e][s],t.charAt(3*e+s)))return!1;return!0}add(t){for(let e=0;e<3;e++)for(let s=0;s<3;s++)this.setAtLeast(e,s,t.get(e,s))}isDisjoint(){return this._matrix[jt.INTERIOR][jt.INTERIOR]===j.FALSE&&this._matrix[jt.INTERIOR][jt.BOUNDARY]===j.FALSE&&this._matrix[jt.BOUNDARY][jt.INTERIOR]===j.FALSE&&this._matrix[jt.BOUNDARY][jt.BOUNDARY]===j.FALSE}isCrosses(t,e){return t===j.P&&e===j.L||t===j.P&&e===j.A||t===j.L&&e===j.A?Kt.isTrue(this._matrix[jt.INTERIOR][jt.INTERIOR])&&Kt.isTrue(this._matrix[jt.INTERIOR][jt.EXTERIOR]):t===j.L&&e===j.P||t===j.A&&e===j.P||t===j.A&&e===j.L?Kt.isTrue(this._matrix[jt.INTERIOR][jt.INTERIOR])&&Kt.isTrue(this._matrix[jt.EXTERIOR][jt.INTERIOR]):t===j.L&&e===j.L&&0===this._matrix[jt.INTERIOR][jt.INTERIOR]}get interfaces_(){return[o]}}class Qt{static toDegrees(t){return 180*t/Math.PI}static normalize(t){for(;t>Math.PI;)t-=Qt.PI_TIMES_2;for(;t<=-Math.PI;)t+=Qt.PI_TIMES_2;return t}static angle(){if(1===arguments.length){const t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){const t=arguments[0],e=arguments[1],s=e.x-t.x,n=e.y-t.y;return Math.atan2(n,s)}}static isAcute(t,e,s){const n=t.x-e.x,i=t.y-e.y;return n*(s.x-e.x)+i*(s.y-e.y)>0}static isObtuse(t,e,s){const n=t.x-e.x,i=t.y-e.y;return n*(s.x-e.x)+i*(s.y-e.y)<0}static interiorAngle(t,e,s){const n=Qt.angle(e,t),i=Qt.angle(e,s);return Math.abs(i-n)}static normalizePositive(t){if(t<0){for(;t<0;)t+=Qt.PI_TIMES_2;t>=Qt.PI_TIMES_2&&(t=0)}else{for(;t>=Qt.PI_TIMES_2;)t-=Qt.PI_TIMES_2;t<0&&(t=0)}return t}static angleBetween(t,e,s){const n=Qt.angle(e,t),i=Qt.angle(e,s);return Qt.diff(n,i)}static diff(t,e){let s=null;return s=tMath.PI&&(s=2*Math.PI-s),s}static toRadians(t){return t*Math.PI/180}static getTurn(t,e){const s=Math.sin(e-t);return s>0?Qt.COUNTERCLOCKWISE:s<0?Qt.CLOCKWISE:Qt.NONE}static angleBetweenOriented(t,e,s){const n=Qt.angle(e,t),i=Qt.angle(e,s)-n;return i<=-Math.PI?i+Qt.PI_TIMES_2:i>Math.PI?i-Qt.PI_TIMES_2:i}}Qt.PI_TIMES_2=2*Math.PI,Qt.PI_OVER_2=Math.PI/2,Qt.PI_OVER_4=Math.PI/4,Qt.COUNTERCLOCKWISE=F.COUNTERCLOCKWISE,Qt.CLOCKWISE=F.CLOCKWISE,Qt.NONE=F.COLLINEAR;class Jt extends e{constructor(){super(),Jt.constructor_.apply(this,arguments)}static constructor_(){e.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}class $t{constructor(){$t.constructor_.apply(this,arguments)}static constructor_(){if(this.x=null,this.y=null,this.w=null,0===arguments.length)this.x=0,this.y=0,this.w=1;else if(1===arguments.length){const t=arguments[0];this.x=t.x,this.y=t.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){const t=arguments[0],e=arguments[1];this.x=t,this.y=e,this.w=1}else if(arguments[0]instanceof $t&&arguments[1]instanceof $t){const t=arguments[0],e=arguments[1];this.x=t.y*e.w-e.y*t.w,this.y=e.x*t.w-t.x*e.w,this.w=t.x*e.y-e.x*t.y}else if(arguments[0]instanceof p&&arguments[1]instanceof p){const t=arguments[0],e=arguments[1];this.x=t.y-e.y,this.y=e.x-t.x,this.w=t.x*e.y-e.x*t.y}}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this.x=t,this.y=e,this.w=s}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=t.y-e.y,r=e.x-t.x,o=t.x*e.y-e.x*t.y,l=s.y-n.y,a=n.x-s.x,c=s.x*n.y-n.x*s.y;this.x=r*c-a*o,this.y=l*o-i*c,this.w=i*a-l*r}}getY(){const t=this.y/this.w;if(i.isNaN(t)||i.isInfinite(t))throw new Jt;return t}getX(){const t=this.x/this.w;if(i.isNaN(t)||i.isInfinite(t))throw new Jt;return t}getCoordinate(){const t=new p;return t.x=this.getX(),t.y=this.getY(),t}}class te{constructor(){te.constructor_.apply(this,arguments)}static constructor_(){this.p0=null,this.p1=null,this.p2=null;const t=arguments[0],e=arguments[1],s=arguments[2];this.p0=t,this.p1=e,this.p2=s}static area(t,e,s){return Math.abs(((s.x-t.x)*(e.y-t.y)-(e.x-t.x)*(s.y-t.y))/2)}static signedArea(t,e,s){return((s.x-t.x)*(e.y-t.y)-(e.x-t.x)*(s.y-t.y))/2}static det(t,e,s,n){return t*n-e*s}static interpolateZ(t,e,s,n){const i=e.x,r=e.y,o=s.x-i,l=n.x-i,a=s.y-r,c=n.y-r,h=o*c-l*a,u=t.x-i,g=t.y-r,d=(c*u-l*g)/h,_=(-a*u+o*g)/h;return e.getZ()+d*(s.getZ()-e.getZ())+_*(n.getZ()-e.getZ())}static longestSideLength(t,e,s){const n=t.distance(e),i=e.distance(s),r=s.distance(t);let o=n;return i>o&&(o=i),r>o&&(o=r),o}static circumcentreDD(t,e,s){const n=b.valueOf(t.x).subtract(s.x),i=b.valueOf(t.y).subtract(s.y),r=b.valueOf(e.x).subtract(s.x),o=b.valueOf(e.y).subtract(s.y),l=b.determinant(n,i,r,o).multiply(2),a=n.sqr().add(i.sqr()),c=r.sqr().add(o.sqr()),h=b.determinant(i,a,o,c),u=b.determinant(n,a,r,c),g=b.valueOf(s.x).subtract(h.divide(l)).doubleValue(),d=b.valueOf(s.y).add(u.divide(l)).doubleValue();return new p(g,d)}static isAcute(t,e,s){return!!Qt.isAcute(t,e,s)&&(!!Qt.isAcute(e,s,t)&&!!Qt.isAcute(s,t,e))}static circumcentre(t,e,s){const n=s.x,i=s.y,r=t.x-n,o=t.y-i,l=e.x-n,a=e.y-i,c=2*te.det(r,o,l,a),h=te.det(o,r*r+o*o,a,l*l+a*a),u=te.det(r,r*r+o*o,l,l*l+a*a);return new p(n-h/c,i+u/c)}static perpendicularBisector(t,e){const s=e.x-t.x,n=e.y-t.y,i=new $t(t.x+s/2,t.y+n/2,1),r=new $t(t.x-n+s/2,t.y+s+n/2,1);return new $t(i,r)}static angleBisector(t,e,s){const n=e.distance(t),i=n/(n+e.distance(s)),r=s.x-t.x,o=s.y-t.y;return new p(t.x+i*r,t.y+i*o)}static area3D(t,e,s){const n=e.x-t.x,i=e.y-t.y,r=e.getZ()-t.getZ(),o=s.x-t.x,l=s.y-t.y,a=s.getZ()-t.getZ(),c=i*a-r*l,h=r*o-n*a,u=n*l-i*o,g=c*c+h*h+u*u;return Math.sqrt(g)/2}static centroid(t,e,s){const n=(t.x+e.x+s.x)/3,i=(t.y+e.y+s.y)/3;return new p(n,i)}static inCentre(t,e,s){const n=e.distance(s),i=t.distance(s),r=t.distance(e),o=n+i+r,l=(n*t.x+i*e.x+r*s.x)/o,a=(n*t.y+i*e.y+r*s.y)/o;return new p(l,a)}area(){return te.area(this.p0,this.p1,this.p2)}signedArea(){return te.signedArea(this.p0,this.p1,this.p2)}interpolateZ(t){if(null===t)throw new s("Supplied point is null.");return te.interpolateZ(t,this.p0,this.p1,this.p2)}longestSideLength(){return te.longestSideLength(this.p0,this.p1,this.p2)}isAcute(){return te.isAcute(this.p0,this.p1,this.p2)}circumcentre(){return te.circumcentre(this.p0,this.p1,this.p2)}area3D(){return te.area3D(this.p0,this.p1,this.p2)}centroid(){return te.centroid(this.p0,this.p1,this.p2)}inCentre(){return te.inCentre(this.p0,this.p1,this.p2)}}class ee extends e{constructor(){super(),ee.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)e.constructor_.call(this);else if(1===arguments.length){const t=arguments[0];e.constructor_.call(this,t)}}}class se{constructor(){se.constructor_.apply(this,arguments)}static constructor_(){if(this._m00=null,this._m01=null,this._m02=null,this._m10=null,this._m11=null,this._m12=null,0===arguments.length)this.setToIdentity();else if(1===arguments.length){if(arguments[0]instanceof Array){const t=arguments[0];this._m00=t[0],this._m01=t[1],this._m02=t[2],this._m10=t[3],this._m11=t[4],this._m12=t[5]}else if(arguments[0]instanceof se){const t=arguments[0];this.setTransformation(t)}}else if(6===arguments.length&&"number"==typeof arguments[5]&&"number"==typeof arguments[4]&&"number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=arguments[4],r=arguments[5];this.setTransformation(t,e,s,n,i,r)}}static translationInstance(t,e){const s=new se;return s.setToTranslation(t,e),s}static shearInstance(t,e){const s=new se;return s.setToShear(t,e),s}static reflectionInstance(){if(2===arguments.length){const t=arguments[0],e=arguments[1],s=new se;return s.setToReflection(t,e),s}if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=new se;return i.setToReflection(t,e,s,n),i}}static rotationInstance(){if(1===arguments.length){const t=arguments[0];return se.rotationInstance(Math.sin(t),Math.cos(t))}if(2===arguments.length){const t=arguments[0],e=arguments[1],s=new se;return s.setToRotation(t,e),s}if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];return se.rotationInstance(Math.sin(t),Math.cos(t),e,s)}if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=new se;return i.setToRotation(t,e,s,n),i}}static scaleInstance(){if(2===arguments.length){const t=arguments[0],e=arguments[1],s=new se;return s.setToScale(t,e),s}if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=new se;return i.translate(-s,-n),i.scale(t,e),i.translate(s,n),i}}setToReflectionBasic(t,e,n,i){if(t===n&&e===i)throw new s("Reflection line points must be distinct");const r=n-t,o=i-e,l=Math.sqrt(r*r+o*o),a=o/l,c=r/l,h=2*a*c,u=c*c-a*a;return this._m00=u,this._m01=h,this._m02=0,this._m10=h,this._m11=-u,this._m12=0,this}getInverse(){const t=this.getDeterminant();if(0===t)throw new ee("Transformation is non-invertible");const e=this._m11/t,s=-this._m10/t,n=-this._m01/t,i=this._m00/t,r=(this._m01*this._m12-this._m02*this._m11)/t,o=(-this._m00*this._m12+this._m10*this._m02)/t;return new se(e,n,r,s,i,o)}compose(t){const e=t._m00*this._m00+t._m01*this._m10,s=t._m00*this._m01+t._m01*this._m11,n=t._m00*this._m02+t._m01*this._m12+t._m02,i=t._m10*this._m00+t._m11*this._m10,r=t._m10*this._m01+t._m11*this._m11,o=t._m10*this._m02+t._m11*this._m12+t._m12;return this._m00=e,this._m01=s,this._m02=n,this._m10=i,this._m11=r,this._m12=o,this}equals(t){if(null===t)return!1;if(!(t instanceof se))return!1;const e=t;return this._m00===e._m00&&this._m01===e._m01&&this._m02===e._m02&&this._m10===e._m10&&this._m11===e._m11&&this._m12===e._m12}setToScale(t,e){return this._m00=t,this._m01=0,this._m02=0,this._m10=0,this._m11=e,this._m12=0,this}isIdentity(){return 1===this._m00&&0===this._m01&&0===this._m02&&0===this._m10&&1===this._m11&&0===this._m12}scale(t,e){return this.compose(se.scaleInstance(t,e)),this}setToIdentity(){return this._m00=1,this._m01=0,this._m02=0,this._m10=0,this._m11=1,this._m12=0,this}isGeometryChanged(){return!0}setTransformation(){if(1===arguments.length){const t=arguments[0];return this._m00=t._m00,this._m01=t._m01,this._m02=t._m02,this._m10=t._m10,this._m11=t._m11,this._m12=t._m12,this}if(6===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=arguments[4],r=arguments[5];return this._m00=t,this._m01=e,this._m02=s,this._m10=n,this._m11=i,this._m12=r,this}}setToRotation(){if(1===arguments.length){const t=arguments[0];return this.setToRotation(Math.sin(t),Math.cos(t)),this}if(2===arguments.length){const t=arguments[0],e=arguments[1];return this._m00=e,this._m01=-t,this._m02=0,this._m10=t,this._m11=e,this._m12=0,this}if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];return this.setToRotation(Math.sin(t),Math.cos(t),e,s),this}if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];return this._m00=e,this._m01=-t,this._m02=s-s*e+n*t,this._m10=t,this._m11=e,this._m12=n-s*t-n*e,this}}getMatrixEntries(){return[this._m00,this._m01,this._m02,this._m10,this._m11,this._m12]}filter(t,e){this.transform(t,e)}rotate(){if(1===arguments.length){const t=arguments[0];return this.compose(se.rotationInstance(t)),this}if(2===arguments.length){const t=arguments[0],e=arguments[1];return this.compose(se.rotationInstance(t,e)),this}if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];return this.compose(se.rotationInstance(t,e,s)),this}if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];return this.compose(se.rotationInstance(t,e,s,n)),this}}getDeterminant(){return this._m00*this._m11-this._m01*this._m10}composeBefore(t){const e=this._m00*t._m00+this._m01*t._m10,s=this._m00*t._m01+this._m01*t._m11,n=this._m00*t._m02+this._m01*t._m12+this._m02,i=this._m10*t._m00+this._m11*t._m10,r=this._m10*t._m01+this._m11*t._m11,o=this._m10*t._m02+this._m11*t._m12+this._m12;return this._m00=e,this._m01=s,this._m02=n,this._m10=i,this._m11=r,this._m12=o,this}setToShear(t,e){return this._m00=1,this._m01=t,this._m02=0,this._m10=e,this._m11=1,this._m12=0,this}isDone(){return!1}clone(){try{return null}catch(t){if(!(t instanceof e))throw t;u.shouldNeverReachHere()}return null}translate(t,e){return this.compose(se.translationInstance(t,e)),this}setToReflection(){if(2===arguments.length){const t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new s("Reflection vector must be non-zero");if(t===e)return this._m00=0,this._m01=1,this._m02=0,this._m10=1,this._m11=0,this._m12=0,this;const n=Math.sqrt(t*t+e*e),i=e/n,r=t/n;return this.rotate(-i,r),this.scale(1,-1),this.rotate(i,r),this}if(4===arguments.length){const t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];if(t===n&&e===i)throw new s("Reflection line points must be distinct");this.setToTranslation(-t,-e);const r=n-t,o=i-e,l=Math.sqrt(r*r+o*o),a=o/l,c=r/l;return this.rotate(-a,c),this.scale(1,-1),this.rotate(a,c),this.translate(t,e),this}}toString(){return"AffineTransformation[["+this._m00+", "+this._m01+", "+this._m02+"], ["+this._m10+", "+this._m11+", "+this._m12+"]]"}setToTranslation(t,e){return this._m00=1,this._m01=0,this._m02=t,this._m10=0,this._m11=1,this._m12=e,this}shear(t,e){return this.compose(se.shearInstance(t,e)),this}transform(){if(1===arguments.length){const t=arguments[0].copy();return t.apply(this),t}if(2===arguments.length){if(arguments[0]instanceof p&&arguments[1]instanceof p){const t=arguments[0],e=arguments[1],s=this._m00*t.x+this._m01*t.y+this._m02,n=this._m10*t.x+this._m11*t.y+this._m12;return e.x=s,e.y=n,e}if(E(arguments[0],A)&&Number.isInteger(arguments[1])){const t=arguments[0],e=arguments[1],s=this._m00*t.getOrdinate(e,0)+this._m01*t.getOrdinate(e,1)+this._m02,n=this._m10*t.getOrdinate(e,0)+this._m11*t.getOrdinate(e,1)+this._m12;t.setOrdinate(e,0,s),t.setOrdinate(e,1,n)}}}reflect(){if(2===arguments.length){const t=arguments[0],e=arguments[1];return this.compose(se.reflectionInstance(t,e)),this}if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];return this.compose(se.reflectionInstance(t,e,s,n)),this}}get interfaces_(){return[o,R]}}class ne{static solve(t,e){const n=e.length;if(t.length!==n||t[0].length!==n)throw new s("Matrix A is incorrectly sized");for(let s=0;sMath.abs(t[i][s])&&(i=e);if(0===t[i][s])return null;ne.swapRows(t,s,i),ne.swapRows(e,s,i);for(let i=s+1;i=s;e--)t[i][e]-=t[s][e]*r;e[i]-=e[s]*r}}const i=new Array(n).fill(null);for(let s=n-1;s>=0;s--){let r=0;for(let e=s+1;e3)throw new s("Too many control points");return 1===t.length?re.createFromControlVectors(t[0],e[0]):2===t.length?re.createFromControlVectors(t[0],t[1],e[0],e[1]):re.createFromControlVectors(t[0],t[1],t[2],e[0],e[1],e[2])}}else{if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=new p(n.x-s.x,n.y-s.y),r=Qt.angleBetweenOriented(e,t,i),o=e.distance(t),l=n.distance(s);if(0===o)return null;const a=l/o,c=se.translationInstance(-t.x,-t.y);return c.rotate(r),c.scale(a,a),c.translate(s.x,s.y),c}if(6===arguments.length){return new ie(arguments[0],arguments[1],arguments[2],arguments[3],arguments[4],arguments[5]).getTransformation()}}}}class oe{constructor(){oe.constructor_.apply(this,arguments)}static constructor_(){this._coords=null;const t=arguments[0];this._coords=t}static getCoordinates(t){const e=new S;return t.apply(new oe(e)),e}filter(t){(t instanceof Q||t instanceof $)&&this._coords.add(t.getCoordinate())}get interfaces_(){return[z]}}class le{constructor(){le.constructor_.apply(this,arguments)}static constructor_(){this._mapOp=null;const t=arguments[0];this._mapOp=t}static map(t,e){return new le(e).map(t)}map(t){const e=new S;for(let s=0;s0&&n<4&&!this._preserveType?this._factory.createLineString(s):this._factory.createLinearRing(s)}}class pe{constructor(){pe.constructor_.apply(this,arguments)}static constructor_(){this._comps=null;const t=arguments[0];this._comps=t}static getGeometry(t){return t.getFactory().buildGeometry(pe.getLines(t))}static getLines(){if(1===arguments.length){const t=arguments[0];return pe.getLines(t,new S)}if(2===arguments.length){const t=arguments[0],e=arguments[1];return t instanceof Q?e.add(t):t instanceof at&&t.apply(new pe(e)),e}}filter(t){t instanceof Q&&this._comps.add(t)}get interfaces_(){return[K]}}class me{constructor(){me.constructor_.apply(this,arguments)}static constructor_(){if(this._lines=null,this._isForcedToLineString=!1,1===arguments.length){const t=arguments[0];this._lines=t}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this._lines=t,this._isForcedToLineString=e}}static getGeometry(){if(1===arguments.length){const t=arguments[0];return t.getFactory().buildGeometry(me.getLines(t))}if(2===arguments.length){const t=arguments[0],e=arguments[1];return t.getFactory().buildGeometry(me.getLines(t,e))}}static getLines(){if(1===arguments.length){const t=arguments[0];return me.getLines(t,!1)}if(2===arguments.length){if(E(arguments[0],I)&&E(arguments[1],I)){const t=arguments[1];for(let e=arguments[0].iterator();e.hasNext();){const s=e.next();me.getLines(s,t)}return t}if(arguments[0]instanceof X&&"boolean"==typeof arguments[1]){const t=arguments[0],e=arguments[1],s=new S;return t.apply(new me(s,e)),s}if(arguments[0]instanceof X&&E(arguments[1],I)){const t=arguments[0],e=arguments[1];return t instanceof Q?e.add(t):t.apply(new me(e)),e}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&E(arguments[0],I)&&E(arguments[1],I)){const t=arguments[1],e=arguments[2];for(let s=arguments[0].iterator();s.hasNext();){const n=s.next();me.getLines(n,t,e)}return t}if("boolean"==typeof arguments[2]&&arguments[0]instanceof X&&E(arguments[1],I)){const t=arguments[1],e=arguments[2];return arguments[0].apply(new me(t,e)),t}}}filter(t){if(this._isForcedToLineString&&t instanceof ht){const e=t.getFactory().createLineString(t.getCoordinateSequence());return this._lines.add(e),null}t instanceof Q&&this._lines.add(t)}setForceToLineString(t){this._isForcedToLineString=t}get interfaces_(){return[z]}}const fe={reverseOrder:function(){return{compare:(t,e)=>e.compareTo(t)}},min:function(t){return fe.sort(t),t.get(0)},sort:function(t,e){const s=t.toArray();e?et.sort(s,e):et.sort(s);const n=t.iterator();for(let t=0,e=s.length;t2*Math.PI)&&(l=2*Math.PI);const a=l/(this._nPts-1),c=new Array(this._nPts).fill(null);let h=0;for(let e=0;e2*Math.PI)&&(l=2*Math.PI);const a=l/(this._nPts-1),c=new Array(this._nPts+2).fill(null);let h=0;c[h++]=this.coord(r,o);for(let e=0;e1&&(s=1);const n=s*e,i=(1-s)*e,r=t.getMinX()+e,o=t.getMinY()+e,l=new Array(this._nPts+1).fill(null);let a=0;for(let t=0;tthis._distance&&this.initialize(t,e,s)}}}class Te{static computeDistance(){if(arguments[2]instanceof Le&&arguments[0]instanceof Q&&arguments[1]instanceof p){const t=arguments[0],e=arguments[1],s=arguments[2],n=new Zt,i=t.getCoordinates();for(let t=0;t1||t<=0)throw new s("Fraction is not in range (0.0 - 1.0]");this._densifyFrac=t}compute(t,e){this.computeOrientedDistance(t,e,this._ptDist),this.computeOrientedDistance(e,t,this._ptDist)}distance(){return this.compute(this._g0,this._g1),this._ptDist.getDistance()}computeOrientedDistance(t,e,s){const n=new Pe(e);if(t.apply(n),s.setMaximum(n.getMaxPointDistance()),this._densifyFrac>0){const n=new Oe(e,this._densifyFrac);t.apply(n),s.setMaximum(n.getMaxPointDistance())}}orientedDistance(){return this.computeOrientedDistance(this._g0,this._g1,this._ptDist),this._ptDist.getDistance()}}class Pe{constructor(){Pe.constructor_.apply(this,arguments)}static constructor_(){this._maxPtDist=new Le,this._minPtDist=new Le,this._euclideanDist=new Te,this._geom=null;const t=arguments[0];this._geom=t}filter(t){this._minPtDist.initialize(),Te.computeDistance(this._geom,t,this._minPtDist),this._maxPtDist.setMaximum(this._minPtDist)}getMaxPointDistance(){return this._maxPtDist}get interfaces_(){return[k]}}class Oe{constructor(){Oe.constructor_.apply(this,arguments)}static constructor_(){this._maxPtDist=new Le,this._minPtDist=new Le,this._geom=null,this._numSubSegs=0;const t=arguments[0],e=arguments[1];this._geom=t,this._numSubSegs=Math.trunc(Math.round(1/e))}filter(t,e){if(0===e)return null;const s=t.getCoordinate(e-1),n=t.getCoordinate(e),i=(n.x-s.x)/this._numSubSegs,r=(n.y-s.y)/this._numSubSegs;for(let t=0;te||this._maxr?1:0}get interfaces_(){return[l]}};class Ae extends De{constructor(){super(),Ae.constructor_.apply(this,arguments)}static constructor_(){this._item=null;const t=arguments[0],e=arguments[1],s=arguments[2];this._min=t,this._max=e,this._item=s}query(t,e,s){if(!this.intersects(t,e))return null;s.visitItem(this._item)}}class Fe extends De{constructor(){super(),Fe.constructor_.apply(this,arguments)}static constructor_(){this._node1=null,this._node2=null;const t=arguments[0],e=arguments[1];this._node1=t,this._node2=e,this.buildExtent(this._node1,this._node2)}buildExtent(t,e){this._min=Math.min(t._min,e._min),this._max=Math.max(t._max,e._max)}query(t,e,s){if(!this.intersects(t,e))return null;null!==this._node1&&this._node1.query(t,e,s),null!==this._node2&&this._node2.query(t,e,s)}}class Ge{constructor(){Ge.constructor_.apply(this,arguments)}static constructor_(){this._leaves=new S,this._root=null,this._level=0}buildTree(){fe.sort(this._leaves,new De.NodeComparator);let t=this._leaves,e=null,s=new S;for(;;){if(this.buildLevel(t,s),1===s.size())return s.get(0);e=t,t=s,s=e}}insert(t,e,s){if(null!==this._root)throw new IllegalStateException("Index cannot be added to once it has been queried");this._leaves.add(new Ae(t,e,s))}query(t,e,s){if(this.init(),null===this._root)return null;this._root.query(t,e,s)}buildRoot(){if(null!==this._root)return null;this._root=this.buildTree()}printNode(t){q.out.println(Ut.toLineString(new p(t._min,this._level),new p(t._max,this._level)))}init(){return null!==this._root||0===this._leaves.size()?null:void this.buildRoot()}buildLevel(t,e){this._level++,e.clear();for(let s=0;sn&&(s=e.x,n=t.x),this._p.x>=s&&this._p.x<=n&&(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){let s=F.index(t,e,this._p);if(s===F.COLLINEAR)return this._isPointOnSegment=!0,null;e.y=this._max)throw new w;const t=this._parent.getGeometryN(this._index++);return t instanceof at?(this._subcollectionIterator=new Ue(t),this._subcollectionIterator.next()):t}remove(){throw new Z(this.getClass().getName())}hasNext(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}get interfaces_(){return[ke]}}class He{constructor(){He.constructor_.apply(this,arguments)}static constructor_(){this._geom=null;const t=arguments[0];this._geom=t}static locatePointInPolygon(t,e){if(e.isEmpty())return jt.EXTERIOR;const s=e.getExteriorRing(),n=He.locatePointInRing(t,s);if(n!==jt.INTERIOR)return n;for(let s=0;s0&&this.addPoint(t[0])}addHole(t){const e=F.isCCW(t);for(let s=0;s0)t.x=this._cg3.x/3/this._areasum2,t.y=this._cg3.y/3/this._areasum2;else if(this._totalLength>0)t.x=this._lineCentSum.x/this._totalLength,t.y=this._lineCentSum.y/this._totalLength;else{if(!(this._ptCount>0))return null;t.x=this._ptCentSum.x/this._ptCount,t.y=this._ptCentSum.y/this._ptCount}return t}addShell(t){t.length>0&&this.setAreaBasePoint(t[0]);const e=!F.isCCW(t);for(let s=0;s=this.size())throw new N;return this.array[t]}push(t){return this.array.push(t),t}pop(){if(0===this.array.length)throw new Je;return this.array.pop()}peek(){if(0===this.array.length)throw new Je;return this.array[this.array.length-1]}empty(){return 0===this.array.length}isEmpty(){return this.empty()}search(t){return this.array.indexOf(t)}size(){return this.array.length}toArray(){return this.array.slice()}}class ts{constructor(){ts.constructor_.apply(this,arguments)}static constructor_(){this._coordSet=new yt,this._list=new S}static filterCoordinates(t){const e=new ts;for(let s=0;s50&&(t=this.reduce(this._inputPts));const e=this.preSort(t),s=this.grahamScan(e),n=this.toCoordinateArray(s);return this.lineOrPolygon(n)}padArray3(t){const e=new Array(3).fill(null);for(let s=0;se[2].y&&(e[2]=t[s]),t[s].x+t[s].y>e[3].x+e[3].y&&(e[3]=t[s]),t[s].x>e[4].x&&(e[4]=t[s]),t[s].x-t[s].y>e[5].x-e[5].y&&(e[5]=t[s]),t[s].y0;)e=s.pop();s.push(e),s.push(t[n])}return s.push(t[0]),s}}class ss{constructor(){ss.constructor_.apply(this,arguments)}static constructor_(){this._origin=null;const t=arguments[0];this._origin=t}static polarCompare(t,e,s){const n=e.x-t.x,i=e.y-t.y,r=s.x-t.x,o=s.y-t.y,l=F.index(t,e,s);if(l===F.COUNTERCLOCKWISE)return 1;if(l===F.CLOCKWISE)return-1;const a=n*n+i*i,c=r*r+o*o;return ac?1:0}compare(t,e){const s=t,n=e;return ss.polarCompare(this._origin,s,n)}get interfaces_(){return[l]}}es.RadialComparator=ss;class ns{constructor(){ns.constructor_.apply(this,arguments)}static constructor_(){this._interiorPoint=null,this._maxWidth=-1;const t=arguments[0];this.process(t)}static getInteriorPoint(t){return new ns(t).getInteriorPoint()}static avg(t,e){return(t+e)/2}getInteriorPoint(){return this._interiorPoint}process(t){if(t.isEmpty())return null;if(t instanceof nt)this.processPolygon(t);else if(t instanceof at){const e=t;for(let t=0;tthis._maxWidth&&(this._maxWidth=s,this._interiorPoint=e.getInteriorPoint())}}class is{constructor(){is.constructor_.apply(this,arguments)}static constructor_(){this._polygon=null,this._interiorPointY=null,this._interiorSectionWidth=0,this._interiorPoint=null;const t=arguments[0];this._polygon=t,this._interiorPointY=os.getScanLineY(t)}static isEdgeCrossingCounted(t,e,s){const n=t.getY(),i=e.getY();return n!==i&&(!(n===s&&it.getMaxY())}if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];return!(t.getY()>s&&e.getY()>s)&&!(t.getY()this._interiorSectionWidth){this._interiorSectionWidth=i;const t=ns.avg(s,n);this._interiorPoint=new p(t,this._interiorPointY)}}}process(){if(this._polygon.isEmpty())return null;this._interiorPoint=new p(this._polygon.getCoordinate());const t=new S;this.scanRing(this._polygon.getExteriorRing(),t);for(let e=0;ee?1:0}get interfaces_(){return[l]}}is.DoubleComparator=rs;class os{constructor(){os.constructor_.apply(this,arguments)}static constructor_(){this._poly=null,this._centreY=null,this._hiY=i.MAX_VALUE,this._loY=-i.MAX_VALUE;const t=arguments[0];this._poly=t,this._hiY=t.getEnvelopeInternal().getMaxY(),this._loY=t.getEnvelopeInternal().getMinY(),this._centreY=ns.avg(this._loY,this._hiY)}static getScanLineY(t){return new os(t).getScanLineY()}updateInterval(t){t<=this._centreY?t>this._loY&&(this._loY=t):t>this._centreY&&t0}get interfaces_(){return[cs]}}class gs{isInBoundary(t){return t>1}get interfaces_(){return[cs]}}class ds{isInBoundary(t){return 1===t}get interfaces_(){return[cs]}}cs.Mod2BoundaryNodeRule=hs,cs.EndPointBoundaryNodeRule=us,cs.MultiValentEndPointBoundaryNodeRule=gs,cs.MonoValentEndPointBoundaryNodeRule=ds,cs.MOD2_BOUNDARY_RULE=new hs,cs.ENDPOINT_BOUNDARY_RULE=new us,cs.MULTIVALENT_ENDPOINT_BOUNDARY_RULE=new gs,cs.MONOVALENT_ENDPOINT_BOUNDARY_RULE=new ds,cs.OGC_SFS_BOUNDARY_RULE=cs.MOD2_BOUNDARY_RULE;class _s{constructor(){_s.constructor_.apply(this,arguments)}static constructor_(){if(this._boundaryRule=cs.OGC_SFS_BOUNDARY_RULE,this._isIn=null,this._numBoundaries=null,0===arguments.length);else if(1===arguments.length){const t=arguments[0];if(null===t)throw new s("Rule must be non-null");this._boundaryRule=t}}locateInPolygonRing(t,e){return e.getEnvelopeInternal().intersects(t)?Xe.locateInRing(t,e.getCoordinates()):jt.EXTERIOR}intersects(t,e){return this.locate(t,e)!==jt.EXTERIOR}updateLocationInfo(t){t===jt.INTERIOR&&(this._isIn=!0),t===jt.BOUNDARY&&this._numBoundaries++}computeLocation(t,e){if(e instanceof $&&this.updateLocationInfo(this.locateOnPoint(t,e)),e instanceof Q)this.updateLocationInfo(this.locateOnLineString(t,e));else if(e instanceof nt)this.updateLocationInfo(this.locateInPolygon(t,e));else if(e instanceof Ct){const s=e;for(let e=0;e0||this._isIn?jt.INTERIOR:jt.EXTERIOR)}}class ps{constructor(){ps.constructor_.apply(this,arguments)}static constructor_(){this._input=null,this._extremalPts=null,this._centre=null,this._radius=0;const t=arguments[0];this._input=t}static farthestPoints(t){const e=t[0].distance(t[1]),s=t[1].distance(t[2]),n=t[2].distance(t[0]);return e>=s&&e>=n?[t[0],t[1]]:s>=e&&s>=n?[t[1],t[2]]:[t[2],t[0]]}static pointWitMinAngleWithX(t,e){let s=i.MAX_VALUE,n=null;for(let i=0;i=t.length&&(e=0),e}static computeC(t,e,s){return t*s.y-e*s.x}static getMinimumDiameter(t){return new ms(t).getDiameter()}static getMinimumRectangle(t){return new ms(t).getMinimumRectangle()}static computeSegmentForLine(t,e,s){let n=null,i=null;return Math.abs(e)>Math.abs(t)?(n=new p(0,s/e),i=new p(1,s/e-t/e)):(n=new p(s/t,0),i=new p(s/t-e/t,1)),new Zt(n,i)}getWidthCoordinate(){return this.computeMinimumDiameter(),this._minWidthPt}getSupportingSegment(){return this.computeMinimumDiameter(),this._inputGeom.getFactory().createLineString([this._minBaseSeg.p0,this._minBaseSeg.p1])}getDiameter(){if(this.computeMinimumDiameter(),null===this._minWidthPt)return this._inputGeom.getFactory().createLineString();const t=this._minBaseSeg.project(this._minWidthPt);return this._inputGeom.getFactory().createLineString([t,this._minWidthPt])}computeWidthConvex(t){this._convexHullPts=t instanceof nt?t.getExteriorRing().getCoordinates():t.getCoordinates(),0===this._convexHullPts.length?(this._minWidth=0,this._minWidthPt=null,this._minBaseSeg=null):1===this._convexHullPts.length?(this._minWidth=0,this._minWidthPt=this._convexHullPts[0],this._minBaseSeg.p0=this._convexHullPts[0],this._minBaseSeg.p1=this._convexHullPts[0]):2===this._convexHullPts.length||3===this._convexHullPts.length?(this._minWidth=0,this._minWidthPt=this._convexHullPts[0],this._minBaseSeg.p0=this._convexHullPts[0],this._minBaseSeg.p1=this._convexHullPts[1]):this.computeConvexRingMinDiameter(this._convexHullPts)}computeConvexRingMinDiameter(t){this._minWidth=i.MAX_VALUE;let e=1;const s=new Zt;for(let n=0;n=n;)n=i,r=o,o=ms.nextIndex(t,r),i=e.distancePerpendicular(t[o]);return nn&&(n=l),lo&&(o=a),a1){const t=o/l;for(let e=1;ee?t:e)?3:s}static isInHalfPlane(t,e){return e===Is.SE?t===Is.SE||t===Is.SW:t===e||t===e+1}static quadrant(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){const t=arguments[0],e=arguments[1];if(0===t&&0===e)throw new s("Cannot compute the quadrant for point ( "+t+", "+e+" )");return t>=0?e>=0?Is.NE:Is.SE:e>=0?Is.NW:Is.SW}if(arguments[0]instanceof p&&arguments[1]instanceof p){const t=arguments[0],e=arguments[1];if(e.x===t.x&&e.y===t.y)throw new s("Cannot compute the quadrant for two identical points "+t);return e.x>=t.x?e.y>=t.y?Is.NE:Is.SE:e.y>=t.y?Is.NW:Is.SW}}}Is.NE=0,Is.NW=1,Is.SW=2,Is.SE=3;class Ns{constructor(){Ns.constructor_.apply(this,arguments)}static constructor_(){this._orig=null,this._sym=null,this._next=null;const t=arguments[0];this._orig=t}static create(t,e){const s=new Ns(t),n=new Ns(e);return s.link(n),s}find(t){let e=this;do{if(null===e)return null;if(e.dest().equals2D(t))return e;e=e.oNext()}while(e!==this);return null}dest(){return this._sym._orig}isEdgesSorted(){const t=this.findLowest();let e=t;do{const s=e.oNext();if(s===t)break;if(!(s.compareTo(e)>0))return!1;e=s}while(e!==t);return!0}oNext(){return this._sym._next}directionY(){return this.directionPt().getY()-this._orig.getY()}insert(t){if(this.oNext()===this)return this.insertAfter(t),null;this.insertionEdge(t).insertAfter(t)}insertAfter(t){u.equals(this._orig,t.orig());const e=this.oNext();this._sym.setNext(t),t.sym().setNext(e)}degree(){let t=0,e=this;do{t++,e=e.oNext()}while(e!==this);return t}equals(){if(2===arguments.length&&arguments[1]instanceof p&&arguments[0]instanceof p){const t=arguments[0],e=arguments[1];return this._orig.equals2D(t)&&this._sym._orig.equals(e)}}findLowest(){let t=this,e=this.oNext();do{e.compareTo(t)<0&&(t=e),e=e.oNext()}while(e!==this);return t}directionPt(){return this.dest()}sym(){return this._sym}prev(){return this._sym.next()._sym}compareAngularDirection(t){const e=this.directionX(),s=this.directionY(),n=t.directionX(),i=t.directionY();if(e===n&&s===i)return 0;const r=Is.quadrant(e,s),o=Is.quadrant(n,i);if(r>o)return 1;if(r0&&t.compareTo(e)>=0&&t.compareTo(s)<=0)return e;if(s.compareTo(e)<=0&&(t.compareTo(s)<=0||t.compareTo(e)>=0))return e;e=s}while(e!==this);return u.shouldNeverReachHere(),null}compareTo(t){const e=t;return this.compareAngularDirection(e)}toStringNode(){const t=this.orig();this.dest();const e=new dt;e.append("Node( "+Ut.format(t)+" )\n");let s=this;do{e.append(" -> "+s),e.append("\n"),s=s.oNext()}while(s!==this);return e.toString()}link(t){this.setSym(t),t.setSym(this),this.setNext(t),t.setNext(this)}next(){return this._next}setSym(t){this._sym=t}orig(){return this._orig}toString(){return"HE("+this._orig.x+" "+this._orig.y+", "+this._sym._orig.x+" "+this._sym._orig.y+")"}toStringNodeEdge(){return" -> ("+Ut.format(this.dest())}setNext(t){this._next=t}}class Cs extends Ns{constructor(){super(),Cs.constructor_.apply(this,arguments)}static constructor_(){this._isMarked=!1;const t=arguments[0];Ns.constructor_.call(this,t)}static setMarkBoth(t,e){t.setMark(e),t.sym().setMark(e)}static isMarked(t){return t.isMarked()}static setMark(t,e){t.setMark(e)}static markBoth(t){t.mark(),t.sym().mark()}static mark(t){t.mark()}mark(){this._isMarked=!0}setMark(t){this._isMarked=t}isMarked(){return this._isMarked}}class ws{constructor(){ws.constructor_.apply(this,arguments)}static constructor_(){this._vertexMap=new Et}static isValidEdge(t,e){return 0!==e.compareTo(t)}insert(t,e,s){const n=this.create(t,e);null!==s?s.insert(n):this._vertexMap.put(t,n);const i=this._vertexMap.get(e);return null!==i?i.insert(n.sym()):this._vertexMap.put(e,n.sym()),n}create(t,e){const s=this.createEdge(t),n=this.createEdge(e);return s.link(n),s}createEdge(t){return new Ns(t)}addEdge(t,e){if(!ws.isValidEdge(t,e))return null;const s=this._vertexMap.get(t);let n=null;if(null!==s&&(n=s.find(e)),null!==n)return n;return this.insert(t,e,s)}getVertexEdges(){return this._vertexMap.values()}findEdge(t,e){const s=this._vertexMap.get(t);return null===s?null:s.find(e)}}class Ss extends Cs{constructor(){super(),Ss.constructor_.apply(this,arguments)}static constructor_(){this._isStart=!1;const t=arguments[0];Cs.constructor_.call(this,t)}setStart(){this._isStart=!0}isStart(){return this._isStart}}class Ls extends ws{constructor(){super()}createEdge(t){return new Ss(t)}}class Ts{constructor(){Ts.constructor_.apply(this,arguments)}static constructor_(){this._result=null,this._factory=null,this._graph=null,this._lines=new S,this._nodeEdgeStack=new $e,this._ringStartEdge=null,this._graph=new Ls}static dissolve(t){const e=new Ts;return e.add(t),e.getResult()}addLine(t){this._lines.add(this._factory.createLineString(t.toCoordinateArray()))}updateRingStartEdge(t){return t.isStart()||(t=t.sym()).isStart()?null===this._ringStartEdge?(this._ringStartEdge=t,null):void(t.orig().compareTo(this._ringStartEdge.orig())<0&&(this._ringStartEdge=t)):null}getResult(){return null===this._result&&this.computeResult(),this._result}process(t){let e=t.prevNode();null===e&&(e=t),this.stackEdges(e),this.buildLines()}buildRing(t){const e=new T;let s=t;for(e.add(s.orig().copy(),!1);2===s.sym().degree();){const n=s.next();if(n===t)break;e.add(n.orig().copy(),!1),s=n}e.add(s.dest().copy(),!1),this.addLine(e)}buildLine(t){const e=new T;let s=t;for(this._ringStartEdge=null,Cs.markBoth(s),e.add(s.orig().copy(),!1);2===s.sym().degree();){this.updateRingStartEdge(s);const n=s.next();if(n===t)return this.buildRing(this._ringStartEdge),null;e.add(n.orig().copy(),!1),s=n,Cs.markBoth(s)}e.add(s.dest().clone(),!1),this.stackEdges(s.sym()),this.addLine(e)}stackEdges(t){let e=t;do{Cs.isMarked(e)||this._nodeEdgeStack.add(e),e=e.oNext()}while(e!==t)}computeResult(){for(let t=this._graph.getVertexEdges().iterator();t.hasNext();){const e=t.next();Cs.isMarked(e)||this.process(e)}this._result=this._factory.buildGeometry(this._lines)}buildLines(){for(;!this._nodeEdgeStack.empty();){const t=this._nodeEdgeStack.pop();Cs.isMarked(t)||this.buildLine(t)}}add(){if(arguments[0]instanceof X){arguments[0].apply(new class{get interfaces_(){return[z]}filter(t){t instanceof Q&&this.add(t)}})}else if(E(arguments[0],I)){for(let t=arguments[0].iterator();t.hasNext();){const e=t.next();this.add(e)}}else if(arguments[0]instanceof Q){const t=arguments[0];null===this._factory&&(this._factory=t.getFactory());const e=t.getCoordinateSequence();let s=!1;for(let t=1;te._xValue?1:this._eventTypee._eventType?1:0}getInsertEvent(){return this._insertEvent}isInsert(){return this._eventType===vs.INSERT}isSameLabel(t){return null!==this._label&&this._label===t._label}getDeleteEventIndex(){return this._deleteEventIndex}get interfaces_(){return[r]}}vs.INSERT=1,vs.DELETE=2;class Ms{constructor(){Ms.constructor_.apply(this,arguments)}static constructor_(){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;const t=arguments[0],e=arguments[1],s=arguments[2];this._li=t,this._includeProper=e,this._recordIsolated=s}static isAdjacentSegments(t,e){return 1===Math.abs(t-e)}isTrivialIntersection(t,e,s,n){if(t===s&&1===this._li.getIntersectionNum()){if(Ms.isAdjacentSegments(e,n))return!0;if(t.isClosed()){const s=t.getNumPoints()-1;if(0===e&&n===s||0===n&&e===s)return!0}}return!1}getProperIntersectionPoint(){return this._properIntersectionPoint}setIsDoneIfProperInt(t){this._isDoneWhenProperInt=t}hasProperInteriorIntersection(){return this._hasProperInterior}isBoundaryPointInternal(t,e){for(let s=e.iterator();s.hasNext();){const e=s.next().getCoordinate();if(t.isIntersection(e))return!0}return!1}hasProperIntersection(){return this._hasProper}hasIntersection(){return this._hasIntersection}isDone(){return this._isDone}isBoundaryPoint(t,e){return null!==e&&(!!this.isBoundaryPointInternal(t,e[0])||!!this.isBoundaryPointInternal(t,e[1]))}setBoundaryNodes(t,e){this._bdyNodes=new Array(2).fill(null),this._bdyNodes[0]=t,this._bdyNodes[1]=e}addIntersections(t,e,s,n){if(t===s&&e===n)return null;this.numTests++;const i=t.getCoordinates()[e],r=t.getCoordinates()[e+1],o=s.getCoordinates()[n],l=s.getCoordinates()[n+1];this._li.computeIntersection(i,r,o,l),this._li.hasIntersection()&&(this._recordIsolated&&(t.setIsolated(!1),s.setIsolated(!1)),this._numIntersections++,this.isTrivialIntersection(t,e,s,n)||(this._hasIntersection=!0,!this._includeProper&&this._li.isProper()||(t.addIntersections(this._li,e,0),s.addIntersections(this._li,n,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))))}}class bs extends class{}{constructor(){super(),bs.constructor_.apply(this,arguments)}static constructor_(){this.events=new S,this.nOverlaps=null}prepareEvents(){fe.sort(this.events);for(let t=0;tthis.location.length){const t=new Array(3).fill(null);t[Ps.ON]=this.location[Ps.ON],t[Ps.LEFT]=jt.NONE,t[Ps.RIGHT]=jt.NONE,this.location=t}for(let e=0;e1&&t.append(jt.toLocationSymbol(this.location[Ps.LEFT])),t.append(jt.toLocationSymbol(this.location[Ps.ON])),this.location.length>1&&t.append(jt.toLocationSymbol(this.location[Ps.RIGHT])),t.toString()}setLocations(t,e,s){this.location[Ps.ON]=t,this.location[Ps.LEFT]=e,this.location[Ps.RIGHT]=s}get(t){return t1}isAnyNull(){for(let t=0;t0||!e.coord.equals2D(n);i||s--;const r=new Array(s).fill(null);let o=0;r[o++]=new p(t.coord);for(let s=t.segmentIndex+1;s<=e.segmentIndex;s++)r[o++]=this.edge.pts[s];return i&&(r[o]=e.coord),new Ks(r,new As(this.edge._label))}add(t,e,s){const n=new Fs(t,e,s),i=this._nodeMap.get(n);return null!==i?i:(this._nodeMap.put(n,n),n)}isIntersection(t){for(let e=this.iterator();e.hasNext();){if(e.next().coord.equals(t))return!0}return!1}}class Us{constructor(){Us.constructor_.apply(this,arguments)}static constructor_(){if(this._data=null,this._size=0,0===arguments.length)Us.constructor_.call(this,10);else if(1===arguments.length){const t=arguments[0];this._data=new Array(t).fill(null)}}size(){return this._size}addAll(t){return null===t||0===t.length?null:(this.ensureCapacity(this._size+t.length),q.arraycopy(t,0,this._data,this._size,t.length),void(this._size+=t.length))}ensureCapacity(t){if(t<=this._data.length)return null;const e=Math.max(t,2*this._data.length);this._data=et.copyOf(this._data,e)}toArray(){const t=new Array(this._size).fill(null);return q.arraycopy(this._data,0,t,0,this._size),t}add(t){this.ensureCapacity(this._size+1),this._data[this._size]=t,++this._size}}class Hs{static toIntArray(t){const e=new Array(t.size()).fill(null);for(let s=0;ss?e:s}getMinX(t){const e=this.pts[this.startIndex[t]].x,s=this.pts[this.startIndex[t+1]].x;return eArray(3)));for(let t=0;t<2;t++)for(let e=0;e<3;e++)this._depth[t][e]=Zs.NULL_VALUE}static depthAtLocation(t){return t===jt.EXTERIOR?0:t===jt.INTERIOR?1:Zs.NULL_VALUE}getDepth(t,e){return this._depth[t][e]}setDepth(t,e,s){this._depth[t][e]=s}isNull(){if(0===arguments.length){for(let t=0;t<2;t++)for(let e=0;e<3;e++)if(this._depth[t][e]!==Zs.NULL_VALUE)return!1;return!0}if(1===arguments.length){const t=arguments[0];return this._depth[t][1]===Zs.NULL_VALUE}if(2===arguments.length){const t=arguments[0],e=arguments[1];return this._depth[t][e]===Zs.NULL_VALUE}}normalize(){for(let t=0;t<2;t++)if(!this.isNull(t)){let e=this._depth[t][1];this._depth[t][2]e&&(n=1),this._depth[t][s]=n}}}getDelta(t){return this._depth[t][Ps.RIGHT]-this._depth[t][Ps.LEFT]}getLocation(t,e){return this._depth[t][e]<=0?jt.EXTERIOR:jt.INTERIOR}toString(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]}add(){if(1===arguments.length){const t=arguments[0];for(let e=0;e<2;e++)for(let s=1;s<3;s++){const n=t.getLocation(e,s);n!==jt.EXTERIOR&&n!==jt.INTERIOR||(this.isNull(e,s)?this._depth[e][s]=Zs.depthAtLocation(n):this._depth[e][s]+=Zs.depthAtLocation(n))}}else if(3===arguments.length){const t=arguments[0],e=arguments[1];arguments[2]===jt.INTERIOR&&this._depth[t][e]++}}}Zs.NULL_VALUE=-1;class js{constructor(){js.constructor_.apply(this,arguments)}static constructor_(){if(this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,0===arguments.length);else if(1===arguments.length){const t=arguments[0];this._label=t}}setVisited(t){this._isVisited=t}setInResult(t){this._isInResult=t}isCovered(){return this._isCovered}isCoveredSet(){return this._isCoveredSet}setLabel(t){this._label=t}getLabel(){return this._label}setCovered(t){this._isCovered=t,this._isCoveredSet=!0}updateIM(t){u.isTrue(this._label.getGeometryCount()>=2,"found partial label"),this.computeIM(t)}isInResult(){return this._isInResult}isVisited(){return this._isVisited}}class Ks extends js{constructor(){super(),Ks.constructor_.apply(this,arguments)}static constructor_(){if(this.pts=null,this._env=null,this.eiList=new ks(this),this._name=null,this._mce=null,this._isIsolated=!0,this._depth=new Zs,this._depthDelta=0,1===arguments.length){const t=arguments[0];Ks.constructor_.call(this,t,null)}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.pts=t,this._label=e}}static updateIM(){if(!(2===arguments.length&&arguments[1]instanceof Kt&&arguments[0]instanceof As))return super.updateIM.apply(this,arguments);{const t=arguments[0],e=arguments[1];e.setAtLeastIfValid(t.getLocation(0,Ps.ON),t.getLocation(1,Ps.ON),1),t.isArea()&&(e.setAtLeastIfValid(t.getLocation(0,Ps.LEFT),t.getLocation(1,Ps.LEFT),2),e.setAtLeastIfValid(t.getLocation(0,Ps.RIGHT),t.getLocation(1,Ps.RIGHT),2))}}getDepth(){return this._depth}getCollapsedEdge(){const t=new Array(2).fill(null);t[0]=this.pts[0],t[1]=this.pts[1];return new Ks(t,As.toLineLabel(this._label))}isIsolated(){return this._isIsolated}getCoordinates(){return this.pts}setIsolated(t){this._isIsolated=t}setName(t){this._name=t}equals(t){if(!(t instanceof Ks))return!1;const e=t;if(this.pts.length!==e.pts.length)return!1;let s=!0,n=!0,i=this.pts.length;for(let t=0;t0?this.pts[0]:null;if(1===arguments.length){const t=arguments[0];return this.pts[t]}}print(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(let e=0;e0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this._label+" "+this._depthDelta)}computeIM(t){Ks.updateIM(this._label,t)}isCollapsed(){return!!this._label.isArea()&&(3===this.pts.length&&!!this.pts[0].equals(this.pts[2]))}isClosed(){return this.pts[0].equals(this.pts[this.pts.length-1])}getMaximumSegmentIndex(){return this.pts.length-1}getDepthDelta(){return this._depthDelta}getNumPoints(){return this.pts.length}printReverse(t){t.print("edge "+this._name+": ");for(let e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")}getMonotoneChainEdge(){return null===this._mce&&(this._mce=new Ws(this)),this._mce}getEnvelope(){if(null===this._env){this._env=new P;for(let t=0;t0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this._label+" "+this._depthDelta),t.toString()}isPointwiseEqual(t){if(this.pts.length!==t.pts.length)return!1;for(let e=0;et._quadrant?1:this._quadrant=2,"found LineString with single point"),this.insertBoundaryPoint(this._argIndex,e[0]),this.insertBoundaryPoint(this._argIndex,e[e.length-1])}getInvalidPoint(){return this._invalidPoint}getBoundaryPoints(){const t=this.getBoundaryNodes(),e=new Array(t.size()).fill(null);let s=0;for(let n=t.iterator();n.hasNext();){const t=n.next();e[s++]=t.getCoordinate().copy()}return e}getBoundaryNodes(){return null===this._boundaryNodes&&(this._boundaryNodes=this._nodes.getBoundaryNodes(this._argIndex)),this._boundaryNodes}addSelfIntersectionNode(t,e,s){if(this.isBoundaryNode(t,e))return null;s===jt.BOUNDARY&&this._useBoundaryDeterminationRule?this.insertBoundaryPoint(t,e):this.insertPoint(t,e,s)}addPolygonRing(t,e,s){if(t.isEmpty())return null;const n=gt.removeRepeatedPoints(t.getCoordinates());if(n.length<4)return this._hasTooFewPoints=!0,this._invalidPoint=n[0],null;let i=e,r=s;F.isCCW(n)&&(i=s,r=e);const o=new Ks(n,new As(this._argIndex,jt.BOUNDARY,i,r));this._lineEdgeMap.put(t,o),this.insertEdge(o),this.insertPoint(this._argIndex,n[0],jt.BOUNDARY)}insertPoint(t,e,s){const n=this._nodes.addNode(e),i=n.getLabel();null===i?n._label=new As(t,s):i.setLocation(t,s)}createEdgeSetIntersector(){return new bs}addSelfIntersectionNodes(t){for(let e=this._edges.iterator();e.hasNext();){const s=e.next(),n=s.getLabel().getLocation(t);for(let e=s.eiList.iterator();e.hasNext();){const s=e.next();this.addSelfIntersectionNode(t,s.coord,n)}}}add(){if(!(1===arguments.length&&arguments[0]instanceof X))return super.add.apply(this,arguments);{const t=arguments[0];if(t.isEmpty())return null;if(t instanceof mt&&(this._useBoundaryDeterminationRule=!1),t instanceof nt)this.addPolygon(t);else if(t instanceof Q)this.addLineString(t);else if(t instanceof $)this.addPoint(t);else if(t instanceof ct)this.addCollection(t);else if(t instanceof Ct)this.addCollection(t);else if(t instanceof mt)this.addCollection(t);else{if(!(t instanceof at))throw new Z(t.getGeometryType());this.addCollection(t)}}}addCollection(t){for(let e=0;e50?(null===this._areaPtLocator&&(this._areaPtLocator=new Ye(this._parentGeom)),this._areaPtLocator.locate(t)):this._ptLocator.locate(t,this._parentGeom)}findEdge(){if(1===arguments.length&&arguments[0]instanceof Q){const t=arguments[0];return this._lineEdgeMap.get(t)}return super.findEdge.apply(this,arguments)}}var on=Object.freeze({__proto__:null,GeometryGraph:rn});class ln{visit(t){}}class an{constructor(){an.constructor_.apply(this,arguments)}static constructor_(){if(this._p=null,this._data=null,this._left=null,this._right=null,this._count=null,2===arguments.length){const t=arguments[0],e=arguments[1];this._p=new p(t),this._left=null,this._right=null,this._count=1,this._data=e}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this._p=new p(t,e),this._left=null,this._right=null,this._count=1,this._data=s}}isRepeated(){return this._count>1}getRight(){return this._right}getCoordinate(){return this._p}setLeft(t){this._left=t}getX(){return this._p.x}getData(){return this._data}getCount(){return this._count}getLeft(){return this._left}getY(){return this._p.y}increment(){this._count=this._count+1}setRight(t){this._right=t}}class cn{constructor(){cn.constructor_.apply(this,arguments)}static constructor_(){if(this._root=null,this._numberOfNodes=null,this._tolerance=null,0===arguments.length)cn.constructor_.call(this,0);else if(1===arguments.length){const t=arguments[0];this._tolerance=t}}static toCoordinates(){if(1===arguments.length){const t=arguments[0];return cn.toCoordinates(t,!1)}if(2===arguments.length){const t=arguments[0],e=arguments[1],s=new T;for(let n=t.iterator();n.hasNext();){const t=n.next(),i=e?t.getCount():1;for(let e=0;e0){const e=this.findBestMatchNode(t);if(null!==e)return e.increment(),e}return this.insertExact(t,e)}}query(){if(1===arguments.length){const t=arguments[0],e=new S;return this.query(t,e),e}if(2===arguments.length)if(arguments[0]instanceof P&&E(arguments[1],C)){const t=arguments[0],e=arguments[1];this.queryNode(this._root,t,!0,new class{get interfaces_(){return[ln]}visit(t){e.add(t)}})}else if(arguments[0]instanceof P&&E(arguments[1],ln)){const t=arguments[0],e=arguments[1];this.queryNode(this._root,t,!0,e)}}queryNode(t,e,s,n){if(null===t)return null;let i=null,r=null,o=null;s?(i=e.getMinX(),r=e.getMaxX(),o=t.getX()):(i=e.getMinY(),r=e.getMaxY(),o=t.getY());const l=o<=r;i=e&&(t.getMinY()>=s&&(n=3),t.getMaxY()<=s&&(n=1)),t.getMaxX()<=e&&(t.getMinY()>=s&&(n=2),t.getMaxY()<=s&&(n=0)),n}hasChildren(){for(let t=0;t<4;t++)if(null!==this._subnode[t])return!0;return!1}isPrunable(){return!(this.hasChildren()||this.hasItems())}addAllItems(t){t.addAll(this._items);for(let e=0;e<4;e++)null!==this._subnode[e]&&this._subnode[e].addAllItems(t);return t}getNodeCount(){let t=0;for(let e=0;e<4;e++)null!==this._subnode[e]&&(t+=this._subnode[e].size());return t+1}size(){let t=0;for(let e=0;e<4;e++)null!==this._subnode[e]&&(t+=this._subnode[e].size());return t+this._items.size()}addAllItemsFromOverlapping(t,e){if(!this.isSearchMatch(t))return null;e.addAll(this._items);for(let s=0;s<4;s++)null!==this._subnode[s]&&this._subnode[s].addAllItemsFromOverlapping(t,e)}visitItems(t,e){for(let t=this._items.iterator();t.hasNext();)e.visitItem(t.next())}hasItems(){return!this._items.isEmpty()}remove(t,e){if(!this.isSearchMatch(t))return!1;let s=!1;for(let n=0;n<4;n++)if(null!==this._subnode[n]&&(s=this._subnode[n].remove(t,e),s)){this._subnode[n].isPrunable()&&(this._subnode[n]=null);break}return s||(s=this._items.remove(e),s)}visit(t,e){if(!this.isSearchMatch(t))return null;this.visitItems(t,e);for(let s=0;s<4;s++)null!==this._subnode[s]&&this._subnode[s].visit(t,e)}getItems(){return this._items}depth(){let t=0;for(let e=0;e<4;e++)if(null!==this._subnode[e]){const s=this._subnode[e].depth();s>t&&(t=s)}return t+1}isEmpty(){let t=!0;if(this._items.isEmpty()){for(let e=0;e<4;e++)if(null!==this._subnode[e]&&!this._subnode[e].isEmpty()){t=!1;break}}else t=!1;return t}add(t){this._items.add(t)}get interfaces_(){return[a]}}function dn(){}dn.exponent=function(t){return function(t,e){let s,n,i,r;const o={32:{d:127,c:128,b:0,a:0},64:{d:32752,c:0,b:0,a:0}},l={32:8,64:11}[t];r||(s=e<0||1/e<0,isFinite(e)||(r=o[t],s&&(r.d+=1<=2;)n++,i/=2;for(;i<1&&n>0;)n--,i*=2;n<=0&&(i/=2),32===t&&n>254&&(r={d:s?255:127,c:128,b:0,a:0},n=Math.pow(2,l)-1,i=0)}return n}(64,t)-1023},dn.powerOf2=function(t){return Math.pow(2,t)};class _n{constructor(){_n.constructor_.apply(this,arguments)}static constructor_(){this._pt=new p,this._level=0,this._env=null;const t=arguments[0];this.computeKey(t)}static computeQuadLevel(t){const e=t.getWidth(),s=t.getHeight(),n=e>s?e:s;return dn.exponent(n)+1}getLevel(){return this._level}computeKey(){if(1===arguments.length){const t=arguments[0];for(this._level=_n.computeQuadLevel(t),this._env=new P,this.computeKey(this._level,t);!this._env.contains(t);)this._level+=1,this.computeKey(this._level,t)}else if(2===arguments.length){const t=arguments[0],e=arguments[1],s=dn.powerOf2(t);this._pt.x=Math.floor(e.getMinX()/s)*s,this._pt.y=Math.floor(e.getMinY()/s)*s,this._env.init(this._pt.x,this._pt.x+s,this._pt.y,this._pt.y+s)}}getEnvelope(){return this._env}getCentre(){return new p((this._env.getMinX()+this._env.getMaxX())/2,(this._env.getMinY()+this._env.getMaxY())/2)}getPoint(){return this._pt}}class pn extends gn{constructor(){super(),pn.constructor_.apply(this,arguments)}static constructor_(){this._env=null,this._centrex=null,this._centrey=null,this._level=null;const t=arguments[0],e=arguments[1];this._env=t,this._level=e,this._centrex=(t.getMinX()+t.getMaxX())/2,this._centrey=(t.getMinY()+t.getMaxY())/2}static createNode(t){const e=new _n(t);return new pn(e.getEnvelope(),e.getLevel())}static createExpanded(t,e){const s=new P(e);null!==t&&s.expandToInclude(t._env);const n=pn.createNode(s);return null!==t&&n.insertNode(t),n}find(t){const e=gn.getSubnodeIndex(t,this._centrex,this._centrey);if(-1===e)return this;if(null!==this._subnode[e]){return this._subnode[e].find(t)}return this}isSearchMatch(t){return null!==t&&this._env.intersects(t)}getSubnode(t){return null===this._subnode[t]&&(this._subnode[t]=this.createSubnode(t)),this._subnode[t]}getEnvelope(){return this._env}getNode(t){const e=gn.getSubnodeIndex(t,this._centrex,this._centrey);if(-1!==e){return this.getSubnode(e).getNode(t)}return this}createSubnode(t){let e=0,s=0,n=0,i=0;switch(t){case 0:e=this._env.getMinX(),s=this._centrex,n=this._env.getMinY(),i=this._centrey;break;case 1:e=this._centrex,s=this._env.getMaxX(),n=this._env.getMinY(),i=this._centrey;break;case 2:e=this._env.getMinX(),s=this._centrex,n=this._centrey,i=this._env.getMaxY();break;case 3:e=this._centrex,s=this._env.getMaxX(),n=this._centrey,i=this._env.getMaxY()}const r=new P(e,s,n,i);return new pn(r,this._level-1)}insertNode(t){u.isTrue(null===this._env||this._env.contains(t._env));const e=gn.getSubnodeIndex(t._env,this._centrex,this._centrey);if(t._level===this._level-1)this._subnode[e]=t;else{const s=this.createSubnode(e);s.insertNode(t),this._subnode[e]=s}}}class mn{static isZeroWidth(t,e){const s=e-t;if(0===s)return!0;const n=s/Math.max(Math.abs(t),Math.abs(e));return dn.exponent(n)<=mn.MIN_BINARY_EXPONENT}}mn.MIN_BINARY_EXPONENT=-50;class fn extends gn{constructor(){super()}insert(t,e){const s=gn.getSubnodeIndex(t,fn.origin.x,fn.origin.y);if(-1===s)return this.add(e),null;const n=this._subnode[s];if(null===n||!n.getEnvelope().contains(t)){const e=pn.createExpanded(n,t);this._subnode[s]=e}this.insertContained(this._subnode[s],t,e)}isSearchMatch(t){return!0}insertContained(t,e,s){u.isTrue(t.getEnvelope().contains(e));const n=mn.isZeroWidth(e.getMinX(),e.getMaxX()),i=mn.isZeroWidth(e.getMinY(),e.getMaxY());let r=null;r=n||i?t.find(e):t.getNode(e),r.add(s)}}fn.origin=new p(0,0);class yn{insert(t,e){}remove(t,e){}query(){}}class xn{constructor(){xn.constructor_.apply(this,arguments)}static constructor_(){this._root=null,this._minExtent=1,this._root=new fn}static ensureExtent(t,e){let s=t.getMinX(),n=t.getMaxX(),i=t.getMinY(),r=t.getMaxY();return s!==n&&i!==r?t:(s===n&&(s-=e/2,n+=e/2),i===r&&(i-=e/2,r+=e/2),new P(s,n,i,r))}size(){return null!==this._root?this._root.size():0}insert(t,e){this.collectStats(t);const s=xn.ensureExtent(t,this._minExtent);this._root.insert(s,e)}query(){if(1===arguments.length){const t=arguments[0],e=new qe;return this.query(t,e),e.getItems()}if(2===arguments.length){const t=arguments[0],e=arguments[1];this._root.visit(t,e)}}queryAll(){const t=new S;return this._root.addAllItems(t),t}remove(t,e){const s=xn.ensureExtent(t,this._minExtent);return this._root.remove(s,e)}collectStats(t){const e=t.getWidth();e0&&(this._minExtent=e);const s=t.getHeight();s0&&(this._minExtent=s)}depth(){return null!==this._root?this._root.depth():0}isEmpty(){return null===this._root||this._root.isEmpty()}get interfaces_(){return[yn,a]}}var En=Object.freeze({__proto__:null,Quadtree:xn});class In{getBounds(){}}class Nn{constructor(){Nn.constructor_.apply(this,arguments)}static constructor_(){this._bounds=null,this._item=null;const t=arguments[0],e=arguments[1];this._bounds=t,this._item=e}getItem(){return this._item}getBounds(){return this._bounds}get interfaces_(){return[In,a]}}class Cn{constructor(){Cn.constructor_.apply(this,arguments)}static constructor_(){this._size=null,this._items=null,this._size=0,this._items=new S,this._items.add(null)}poll(){if(this.isEmpty())return null;const t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t}size(){return this._size}reorder(t){let e=null;const s=this._items.get(t);for(;2*t<=this._size&&(e=2*t,e!==this._size&&this._items.get(e+1).compareTo(this._items.get(e))<0&&e++,this._items.get(e).compareTo(s)<0);t=e)this._items.set(t,this._items.get(e));this._items.set(t,s)}clear(){this._size=0,this._items.clear()}peek(){if(this.isEmpty())return null;return this._items.get(1)}isEmpty(){return 0===this._size}add(t){this._items.add(null),this._size+=1;let 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)}}class wn{constructor(){wn.constructor_.apply(this,arguments)}static constructor_(){if(this._childBoundables=new S,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){const t=arguments[0];this._level=t}}getLevel(){return this._level}size(){return this._childBoundables.size()}getChildBoundables(){return this._childBoundables}addChildBoundable(t){u.isTrue(null===this._bounds),this._childBoundables.add(t)}isEmpty(){return this._childBoundables.isEmpty()}getBounds(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds}get interfaces_(){return[In,a]}}class Sn{static maxDistance(t,e,s,n,i,r,o,l){let a=Sn.distance(t,e,i,r);return a=Math.max(a,Sn.distance(t,e,o,l)),a=Math.max(a,Sn.distance(s,n,i,r)),a=Math.max(a,Sn.distance(s,n,o,l)),a}static distance(t,e,s,n){const i=s-t,r=n-e;return Math.sqrt(i*i+r*r)}static maximumDistance(t,e){const s=Math.min(t.getMinX(),e.getMinX()),n=Math.min(t.getMinY(),e.getMinY()),i=Math.max(t.getMaxX(),e.getMaxX()),r=Math.max(t.getMaxY(),e.getMaxY());return Sn.distance(s,n,i,r)}static minMaxDistance(t,e){const s=t.getMinX(),n=t.getMinY(),i=t.getMaxX(),r=t.getMaxY(),o=e.getMinX(),l=e.getMinY(),a=e.getMaxX(),c=e.getMaxY();let h=Sn.maxDistance(s,n,s,r,o,l,o,c);return h=Math.min(h,Sn.maxDistance(s,n,s,r,o,l,a,l)),h=Math.min(h,Sn.maxDistance(s,n,s,r,a,c,o,c)),h=Math.min(h,Sn.maxDistance(s,n,s,r,a,c,a,l)),h=Math.min(h,Sn.maxDistance(s,n,i,n,o,l,o,c)),h=Math.min(h,Sn.maxDistance(s,n,i,n,o,l,a,l)),h=Math.min(h,Sn.maxDistance(s,n,i,n,a,c,o,c)),h=Math.min(h,Sn.maxDistance(s,n,i,n,a,c,a,l)),h=Math.min(h,Sn.maxDistance(i,r,s,r,o,l,o,c)),h=Math.min(h,Sn.maxDistance(i,r,s,r,o,l,a,l)),h=Math.min(h,Sn.maxDistance(i,r,s,r,a,c,o,c)),h=Math.min(h,Sn.maxDistance(i,r,s,r,a,c,a,l)),h=Math.min(h,Sn.maxDistance(i,r,i,n,o,l,o,c)),h=Math.min(h,Sn.maxDistance(i,r,i,n,o,l,a,l)),h=Math.min(h,Sn.maxDistance(i,r,i,n,a,c,o,c)),h=Math.min(h,Sn.maxDistance(i,r,i,n,a,c,a,l)),h}}class Ln{constructor(){Ln.constructor_.apply(this,arguments)}static constructor_(){this._boundable1=null,this._boundable2=null,this._distance=null,this._itemDistance=null;const t=arguments[0],e=arguments[1],s=arguments[2];this._boundable1=t,this._boundable2=e,this._itemDistance=s,this._distance=this.distance()}static area(t){return t.getBounds().getArea()}static isComposite(t){return t instanceof wn}maximumDistance(){return Sn.maximumDistance(this._boundable1.getBounds(),this._boundable2.getBounds())}expandToQueue(t,e){const n=Ln.isComposite(this._boundable1),i=Ln.isComposite(this._boundable2);if(n&&i)return Ln.area(this._boundable1)>Ln.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,t,e),null):(this.expand(this._boundable2,this._boundable1,!0,t,e),null);if(n)return this.expand(this._boundable1,this._boundable2,!1,t,e),null;if(i)return this.expand(this._boundable2,this._boundable1,!0,t,e),null;throw new s("neither boundable is composite")}isLeaves(){return!(Ln.isComposite(this._boundable1)||Ln.isComposite(this._boundable2))}compareTo(t){const e=t;return this._distancee._distance?1:0}expand(t,e,s,n,i){for(let r=t.getChildBoundables().iterator();r.hasNext();){const t=r.next();let o=null;o=s?new Ln(e,t,this._itemDistance):new Ln(t,e,this._itemDistance),o.getDistance()1,"Node capacity must be greater than 1"),this._nodeCapacity=t}}static compareDoubles(t,e){return t>e?1:t-2),e.getLevel()===t)return s.add(e),null;for(let n=e.getChildBoundables().iterator();n.hasNext();){const e=n.next();e instanceof wn?this.boundablesAtLevel(t,e,s):(u.isTrue(e instanceof Nn),-1===t&&s.add(e))}return null}}query(){if(1===arguments.length){const t=arguments[0];this.build();const e=new S;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.queryInternal(t,this._root,e),e}if(2===arguments.length){const t=arguments[0],e=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.queryInternal(t,this._root,e)}}build(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}getRoot(){return this.build(),this._root}remove(){if(2===arguments.length){const t=arguments[0],e=arguments[1];return this.build(),!!this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.remove(t,this._root,e)}if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];let n=this.removeItem(e,s);if(n)return!0;let i=null;for(let r=e.getChildBoundables().iterator();r.hasNext();){const e=r.next();if(this.getIntersectsOp().intersects(e.getBounds(),t)&&(e instanceof wn&&(n=this.remove(t,e,s),n))){i=e;break}}return null!==i&&i.getChildBoundables().isEmpty()&&e.getChildBoundables().remove(i),n}}createHigherLevels(t,e){u.isTrue(!t.isEmpty());const s=this.createParentBoundables(t,e+1);return 1===s.size()?s.get(0):this.createHigherLevels(s,e+1)}depth(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){let t=0;for(let e=arguments[0].getChildBoundables().iterator();e.hasNext();){const s=e.next();if(s instanceof wn){const e=this.depth(s);e>t&&(t=e)}}return t+1}}createParentBoundables(t,e){u.isTrue(!t.isEmpty());const s=new S;s.add(this.createNode(e));const n=new S(t);fe.sort(n,this.getComparator());for(let t=n.iterator();t.hasNext();){const n=t.next();this.lastNode(s).getChildBoundables().size()===this.getNodeCapacity()&&s.add(this.createNode(e)),this.lastNode(s).addChildBoundable(n)}return s}isEmpty(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}get interfaces_(){return[a]}}Tn.IntersectsOp=function(){},Tn.DEFAULT_NODE_CAPACITY=10;class Rn{distance(t,e){}}class Pn extends Tn{constructor(){super(),Pn.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)Pn.constructor_.call(this,Pn.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){const t=arguments[0];Tn.constructor_.call(this,t)}}static centreX(t){return Pn.avg(t.getMinX(),t.getMaxX())}static avg(t,e){return(t+e)/2}static getItems(t){const e=new Array(t.size()).fill(null);let s=0;for(;!t.isEmpty();){const n=t.poll();e[s]=n.getBoundable(0).getItem(),s++}return e}static centreY(t){return Pn.avg(t.getMinY(),t.getMaxY())}createParentBoundablesFromVerticalSlices(t,e){u.isTrue(t.length>0);const s=new S;for(let n=0;n=0;){const t=n.poll(),r=t.getDistance();if(r>=s)break;if(t.isLeaves())if(i.size()r&&(i.poll(),i.add(t));s=i.peek().getDistance()}else t.expandToQueue(n,s)}return Pn.getItems(i)}}createNode(t){return new On(t)}size(){return 0===arguments.length?super.size.call(this):super.size.apply(this,arguments)}insert(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof P))return super.insert.apply(this,arguments);{const t=arguments[0],e=arguments[1];if(t.isNull())return null;super.insert.call(this,t,e)}}getIntersectsOp(){return Pn.intersectsOp}verticalSlices(t,e){const s=Math.trunc(Math.ceil(t.size()/e)),n=new Array(e).fill(null),i=t.iterator();for(let t=0;t0;){const t=n.poll(),i=t.getDistance();if(i>=e)break;t.isLeaves()?(e=i,s=t):t.expandToQueue(n,e)}return null===s?null:[s.getBoundable(0).getItem(),s.getBoundable(1).getItem()]}}else{if(2===arguments.length){const t=arguments[0],e=arguments[1];if(this.isEmpty()||t.isEmpty())return null;const s=new Ln(this.getRoot(),t.getRoot(),e);return this.nearestNeighbour(s)}if(3===arguments.length){const t=arguments[2],e=new Nn(arguments[0],arguments[1]),s=new Ln(this.getRoot(),e,t);return this.nearestNeighbour(s)[0]}if(4===arguments.length){const t=arguments[2],e=arguments[3],s=new Nn(arguments[0],arguments[1]),n=new Ln(this.getRoot(),s,t);return this.nearestNeighbourK(n,e)}}}isWithinDistance(){if(2===arguments.length){const t=arguments[0],e=arguments[1];let s=i.POSITIVE_INFINITY;const n=new Cn;for(n.add(t);!n.isEmpty();){const t=n.poll(),i=t.getDistance();if(i>e)return!1;if(t.maximumDistance()<=e)return!0;if(t.isLeaves()){if(s=i,s<=e)return!0}else t.expandToQueue(n,s)}return!1}if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=new Ln(this.getRoot(),t.getRoot(),e);return this.isWithinDistance(n,s)}}get interfaces_(){return[yn,a]}}class On extends wn{constructor(){super(),On.constructor_.apply(this,arguments)}static constructor_(){const t=arguments[0];wn.constructor_.call(this,t)}computeBounds(){let t=null;for(let e=this.getChildBoundables().iterator();e.hasNext();){const s=e.next();null===t?t=new P(s.getBounds()):t.expandToInclude(s.getBounds())}return t}}Pn.STRtreeNode=On,Pn.xComparator=new class{get interfaces_(){return[l]}compare(t,e){return Tn.compareDoubles(Pn.centreX(t.getBounds()),Pn.centreX(e.getBounds()))}},Pn.yComparator=new class{get interfaces_(){return[l]}compare(t,e){return Tn.compareDoubles(Pn.centreY(t.getBounds()),Pn.centreY(e.getBounds()))}},Pn.intersectsOp=new class{get interfaces_(){return[IntersectsOp]}intersects(t,e){return t.intersects(e)}},Pn.DEFAULT_NODE_CAPACITY=10;var vn=Object.freeze({__proto__:null,STRtree:Pn}),Mn=Object.freeze({__proto__:null,kdtree:un,quadtree:En,strtree:vn});const bn=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"];class Dn{constructor(t){this.geometryFactory=t||new wt}read(t){let e;e="string"==typeof t?JSON.parse(t):t;const s=e.type;if(!An[s])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==bn.indexOf(s)?An[s].call(this,e.coordinates):"GeometryCollection"===s?An[s].call(this,e.geometries):An[s].call(this,e)}write(t){const e=t.getGeometryType();if(!Fn[e])throw new Error("Geometry is not supported");return Fn[e].call(this,t)}}const An={Feature:function(t){const e={};for(const s in t)e[s]=t[s];if(t.geometry){const s=t.geometry.type;if(!An[s])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=An.bbox.call(this,t.bbox)),e},FeatureCollection:function(t){const e={};if(t.features){e.features=[];for(let s=0;se?1:0}static compare(t,e,s){if(e.equals2D(s))return 0;const n=Bn.relativeSign(e.x,s.x),i=Bn.relativeSign(e.y,s.y);switch(t){case 0:return Bn.compareValue(n,i);case 1:return Bn.compareValue(i,n);case 2:return Bn.compareValue(i,-n);case 3:return Bn.compareValue(-n,i);case 4:return Bn.compareValue(-n,-i);case 5:return Bn.compareValue(-i,-n);case 6:return Bn.compareValue(-i,n);case 7:return Bn.compareValue(n,-i)}return u.shouldNeverReachHere("invalid octant value"),0}static compareValue(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0}}class Yn{constructor(){Yn.constructor_.apply(this,arguments)}static constructor_(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];this._segString=t,this.coord=new p(e),this.segmentIndex=s,this._segmentOctant=n,this._isInterior=!e.equals2D(t.getCoordinate(s))}getCoordinate(){return this.coord}print(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)}compareTo(t){const e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:this._isInterior?e._isInterior?Bn.compare(this._segmentOctant,this.coord,e.coord):1:-1}isEndPoint(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t}toString(){return this.segmentIndex+":"+this.coord.toString()}isInterior(){return this._isInterior}get interfaces_(){return[r]}}class Vn{constructor(){Vn.constructor_.apply(this,arguments)}static constructor_(){this._nodeMap=new Xs,this._edge=null;const t=arguments[0];this._edge=t}getSplitCoordinates(){const t=new T;this.addEndpoints();const e=this.iterator();let s=e.next();for(;e.hasNext();){const n=e.next();this.addEdgeCoordinates(s,n,t),s=n}return t.toCoordinateArray()}addCollapsedNodes(){const t=new S;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(let e=t.iterator();e.hasNext();){const t=e.next().intValue();this.add(this._edge.getCoordinate(t),t)}}createSplitEdgePts(t,e){let s=e.segmentIndex-t.segmentIndex+2;if(2===s)return[new p(t.coord),new p(e.coord)];const n=this._edge.getCoordinate(e.segmentIndex),i=e.isInterior()||!e.coord.equals2D(n);i||s--;const r=new Array(s).fill(null);let o=0;r[o++]=new p(t.coord);for(let s=t.segmentIndex+1;s<=e.segmentIndex;s++)r[o++]=this._edge.getCoordinate(s);return i&&(r[o]=new p(e.coord)),r}print(t){t.println("Intersections:");for(let e=this.iterator();e.hasNext();){e.next().print(t)}}findCollapsesFromExistingVertices(t){for(let e=0;e=0?e>=0?n>=i?0:1:n>=i?7:6:e>=0?n>=i?3:2:n>=i?4:5}if(arguments[0]instanceof p&&arguments[1]instanceof p){const t=arguments[0],e=arguments[1],n=e.x-t.x,i=e.y-t.y;if(0===n&&0===i)throw new s("Cannot compute the octant for two identical points "+t);return zn.octant(n,i)}}}class Xn{getCoordinates(){}size(){}getCoordinate(t){}isClosed(){}setData(t){}getData(){}}class kn{addIntersection(t,e){}get interfaces_(){return[Xn]}}class Un{constructor(){Un.constructor_.apply(this,arguments)}static constructor_(){this._nodeList=new Vn(this),this._pts=null,this._data=null;const t=arguments[0],e=arguments[1];this._pts=t,this._data=e}static getNodedSubstrings(){if(1===arguments.length){const t=arguments[0],e=new S;return Un.getNodedSubstrings(t,e),e}if(2===arguments.length){const t=arguments[1];for(let e=arguments[0].iterator();e.hasNext();){e.next().getNodeList().addSplitEdges(t)}}}getCoordinates(){return this._pts}size(){return this._pts.length}getCoordinate(t){return this._pts[t]}isClosed(){return this._pts[0].equals(this._pts[this._pts.length-1])}getSegmentOctant(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))}setData(t){this._data=t}safeOctant(t,e){return t.equals2D(e)?0:zn.octant(t,e)}getData(){return this._data}addIntersection(){if(2===arguments.length){const t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){const t=arguments[1],e=arguments[3],s=new p(arguments[0].getIntersection(e));this.addIntersection(s,t)}}toString(){return Ut.toLineString(new _t(this._pts))}getNodeList(){return this._nodeList}addIntersectionNode(t,e){let s=e;const n=s+1;if(n=t.length-1)return t.length-1;const n=Is.quadrant(t[s],t[s+1]);let i=e+1;for(;is.getId()&&(s.computeOverlaps(n,t),this._nOverlaps++),this._segInt.isDone())return null}}}}class Jn extends Hn{constructor(){super(),Jn.constructor_.apply(this,arguments)}static constructor_(){this._si=null;const t=arguments[0];this._si=t}overlap(){if(4!==arguments.length)return super.overlap.apply(this,arguments);{const t=arguments[1],e=arguments[2],s=arguments[3],n=arguments[0].getContext(),i=e.getContext();this._si.processIntersections(n,t,i,s)}}}Qn.SegmentOverlapAction=Jn;class $n{constructor(){$n.constructor_.apply(this,arguments)}static constructor_(){if(this._noder=null,this._scaleFactor=null,this._offsetX=null,this._offsetY=null,this._isScaled=!1,2===arguments.length){const t=arguments[0],e=arguments[1];$n.constructor_.call(this,t,e,0,0)}else if(4===arguments.length){const t=arguments[0],e=arguments[1];this._noder=t,this._scaleFactor=e,this._isScaled=!this.isIntegerPrecision()}}rescale(){if(E(arguments[0],I)){for(let t=arguments[0].iterator();t.hasNext();){const e=t.next();this.rescale(e.getCoordinates())}}else if(arguments[0]instanceof Array){const t=arguments[0];for(let e=0;e0&&this._minIndexthis._minCoord.y&&s.y>this._minCoord.y&&n===F.CLOCKWISE)&&(i=!0),i&&(this._minIndex=this._minIndex-1)}getRightmostSideOfSegment(t,e){const s=t.getEdge().getCoordinates();if(e<0||e+1>=s.length)return-1;if(s[e].y===s[e+1].y)return-1;let n=Ps.LEFT;return s[e].ythis._minCoord.x)&&(this._minDe=t,this._minIndex=s,this._minCoord=e[s])}findRightmostEdgeAtNode(){const 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)}findEdge(t){for(let e=t.iterator();e.hasNext();){const t=e.next();t.isForward()&&this.checkForRightmostCoordinate(t)}u.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)===Ps.LEFT&&(this._orientedDe=this._minDe.getSym())}}class li{constructor(){this.array=[]}addLast(t){this.array.push(t)}removeFirst(){return this.array.shift()}isEmpty(){return 0===this.array.length}}class ai{constructor(){ai.constructor_.apply(this,arguments)}static constructor_(){this._finder=null,this._dirEdgeList=new S,this._nodes=new S,this._rightMostCoord=null,this._env=null,this._finder=new oi}clearVisitedEdges(){for(let t=this._dirEdgeList.iterator();t.hasNext();){t.next().setVisited(!1)}}getRightmostCoordinate(){return this._rightMostCoord}computeNodeDepth(t){let e=null;for(let s=t.getEdges().iterator();s.hasNext();){const t=s.next();if(t.isVisited()||t.getSym().isVisited()){e=t;break}}if(null===e)throw new tn("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(let e=t.getEdges().iterator();e.hasNext();){const t=e.next();t.setVisited(!0),this.copySymDepths(t)}}computeDepth(t){this.clearVisitedEdges();const e=this._finder.getEdge();e.getNode(),e.getLabel(),e.setEdgeDepths(Ps.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)}create(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()}findResultEdges(){for(let t=this._dirEdgeList.iterator();t.hasNext();){const e=t.next();e.getDepth(Ps.RIGHT)>=1&&e.getDepth(Ps.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}}computeDepths(t){const e=new yt,s=new li,n=t.getNode();for(s.addLast(n),e.add(n),t.setVisited(!0);!s.isEmpty();){const t=s.removeFirst();e.add(t),this.computeNodeDepth(t);for(let n=t.getEdges().iterator();n.hasNext();){const t=n.next().getSym();if(t.isVisited())continue;const i=t.getNode();e.contains(i)||(s.addLast(i),e.add(i))}}}compareTo(t){const e=t;return this._rightMostCoord.xe._rightMostCoord.x?1:0}getEnvelope(){if(null===this._env){const t=new P;for(let e=this._dirEdgeList.iterator();e.hasNext();){const s=e.next().getEdge().getCoordinates();for(let e=0;ethis._maxNodeDegree&&(this._maxNodeDegree=e),t=this.getNext(t)}while(t!==this._startDe);this._maxNodeDegree*=2}addPoints(t,e,s){const n=t.getCoordinates();if(e){let t=1;s&&(t=0);for(let e=t;e=0;e--)this._pts.add(n[e])}}isHole(){return this._isHole}setInResult(){let t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)}containsPoint(t){const e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!Xe.isInRing(t,e.getCoordinates()))return!1;for(let e=this._holes.iterator();e.hasNext();){if(e.next().containsPoint(t))return!1}return!0}addHole(t){this._holes.add(t)}isShell(){return null===this._shell}getLabel(){return this._label}getEdges(){return this._edges}getMaxNodeDegree(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}getShell(){return this._shell}mergeLabel(){if(1===arguments.length){const t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){const t=arguments[1],e=arguments[0].getLocation(t,Ps.RIGHT);if(e===jt.NONE)return null;if(this._label.getLocation(t)===jt.NONE)return this._label.setLocation(t,e),null}}setShell(t){this._shell=t,null!==t&&t.addHole(this)}toPolygon(t){const e=new Array(this._holes.size()).fill(null);for(let t=0;t2){t.linkDirectedEdgesForMinimalEdgeRings();const n=t.buildMinimalRings(),i=this.findShell(n);null!==i?(this.placePolygonHoles(i,n),e.add(i)):s.addAll(n)}else n.add(t)}return n}buildMaximalEdgeRings(t){const e=new S;for(let s=t.iterator();s.hasNext();){const t=s.next();if(t.isInResult()&&t.getLabel().isArea()&&null===t.getEdgeRing()){const s=new ui(t,this._geometryFactory);e.add(s),s.setInResult()}}return e}placePolygonHoles(t,e){for(let s=e.iterator();s.hasNext();){const e=s.next();e.isHole()&&e.setShell(t)}}getPolygons(){return this.computePolygons(this._shellList)}findShell(t){let e=0,s=null;for(let n=t.iterator();n.hasNext();){const t=n.next();t.isHole()||(s=t,e++)}return u.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),s}add(){if(1===arguments.length){const t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){const t=arguments[0],e=arguments[1];nn.linkResultDirectedEdges(e);const s=this.buildMaximalEdgeRings(t),n=new S,i=this.buildMinimalEdgeRings(s,this._shellList,n);this.sortShellsAndHoles(i,this._shellList,n),this.placeFreeHoles(this._shellList,n)}}}class di{constructor(){di.constructor_.apply(this,arguments)}static constructor_(){this._inputLine=null,this._distanceTol=null,this._isDeleted=null,this._angleOrientation=F.COUNTERCLOCKWISE;const t=arguments[0];this._inputLine=t}static simplify(t,e){return new di(t).simplify(e)}isDeletable(t,e,s,n){const i=this._inputLine[t],r=this._inputLine[e],o=this._inputLine[s];return!!this.isConcave(i,r,o)&&(!!this.isShallow(i,r,o,n)&&this.isShallowSampled(i,r,t,s,n))}deleteShallowConcavities(){let t=1,e=this.findNextNonDeletedIndex(t),s=this.findNextNonDeletedIndex(e),n=!1;for(;s=0;e--)this.addPt(t[e])}isRedundant(t){if(this._ptList.size()<1)return!1;const e=this._ptList.get(this._ptList.size()-1);return t.distance(e)=8&&e.getJoinStyle()===ri.JOIN_ROUND&&(this._closingSegLengthFactor=pi.MAX_CLOSING_SEG_LEN_FACTOR),this.init(s)}addNextSegment(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;const s=F.index(this._s0,this._s1,this._s2),n=s===F.CLOCKWISE&&this._side===Ps.LEFT||s===F.COUNTERCLOCKWISE&&this._side===Ps.RIGHT;0===s?this.addCollinear(e):n?this.addOutsideTurn(s,e):this.addInsideTurn(s,e)}addLineEndCap(t,e){const s=new Zt(t,e),n=new Zt;this.computeOffsetSegment(s,Ps.LEFT,this._distance,n);const i=new Zt;this.computeOffsetSegment(s,Ps.RIGHT,this._distance,i);const r=e.x-t.x,o=e.y-t.y,l=Math.atan2(o,r);switch(this._bufParams.getEndCapStyle()){case ri.CAP_ROUND:this._segList.addPt(n.p1),this.addDirectedFillet(e,l+Math.PI/2,l-Math.PI/2,F.CLOCKWISE,this._distance),this._segList.addPt(i.p1);break;case ri.CAP_FLAT:this._segList.addPt(n.p1),this._segList.addPt(i.p1);break;case ri.CAP_SQUARE:const t=new p;t.x=Math.abs(this._distance)*Math.cos(l),t.y=Math.abs(this._distance)*Math.sin(l);const s=new p(n.p1.x+t.x,n.p1.y+t.y),r=new p(i.p1.x+t.x,i.p1.y+t.y);this._segList.addPt(s),this._segList.addPt(r)}}getCoordinates(){return this._segList.getCoordinates()}addMitreJoin(t,e,s,n){const i=G.intersection(e.p0,e.p1,s.p0,s.p1);if(null!==i){if((n<=0?1:i.distance(t)/Math.abs(n))<=this._bufParams.getMitreLimit())return this._segList.addPt(i),null}this.addLimitedMitreJoin(e,s,n,this._bufParams.getMitreLimit())}addOutsideTurn(t,e){if(this._offset0.p1.distance(this._offset1.p0)=h&&(l-=2*Math.PI),this._segList.addPt(e),this.addDirectedFillet(t,l,h,n,i),this._segList.addPt(s)}addLastSegment(){this._segList.addPt(this._offset1.p1)}initSideSegments(t,e,s){this._s1=t,this._s2=e,this._side=s,this._seg1.setCoordinates(t,e),this.computeOffsetSegment(this._seg1,s,this._distance,this._offset1)}addLimitedMitreJoin(t,e,s,n){const i=this._seg0.p1,r=Qt.angle(i,this._seg0.p0),o=Qt.angleBetweenOriented(this._seg0.p0,i,this._seg1.p1)/2,l=Qt.normalize(r+o),a=Qt.normalize(l+Math.PI),c=n*s,h=s-c*Math.abs(Math.sin(o)),u=i.x+c*Math.cos(a),g=i.y+c*Math.sin(a),d=new p(u,g),_=new Zt(i,d),m=_.pointAlongOffset(1,h),f=_.pointAlongOffset(1,-h);this._side===Ps.LEFT?(this._segList.addPt(m),this._segList.addPt(f)):(this._segList.addPt(f),this._segList.addPt(m))}addDirectedFillet(t,e,s,n,i){const r=n===F.CLOCKWISE?-1:1,o=Math.abs(e-s),l=Math.trunc(o/this._filletAngleQuantum+.5);if(l<1)return null;const a=o/l,c=new p;for(let s=0;s0){const t=new p((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(t);const e=new p((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(e)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}createCircle(t){const e=new p(t.x+this._distance,t.y);this._segList.addPt(e),this.addDirectedFillet(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}addBevelJoin(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)}init(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new _i,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*pi.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}addCollinear(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2);this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===ri.JOIN_BEVEL||this._bufParams.getJoinStyle()===ri.JOIN_MITRE?(t&&this._segList.addPt(this._offset0.p1),this._segList.addPt(this._offset1.p0)):this.addCornerFillet(this._s1,this._offset0.p1,this._offset1.p0,F.CLOCKWISE,this._distance))}closeRing(){this._segList.closeRing()}hasNarrowConcaveAngle(){return this._hasNarrowConcaveAngle}}pi.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,pi.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,pi.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,pi.MAX_CLOSING_SEG_LEN_FACTOR=80;class mi{constructor(){mi.constructor_.apply(this,arguments)}static constructor_(){this._distance=0,this._precisionModel=null,this._bufParams=null;const t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e}static copyCoordinates(t){const e=new Array(t.length).fill(null);for(let s=0;s=0;t--)s.addNextSegment(e[t],!0)}else{s.addSegments(t,!1);const e=di.simplify(t,n),i=e.length-1;s.initSideSegments(e[0],e[1],Ps.LEFT),s.addFirstSegment();for(let t=2;t<=i;t++)s.addNextSegment(e[t],!0)}s.addLastSegment(),s.closeRing()}computeRingBufferCurve(t,e,s){let n=this.simplifyTolerance(this._distance);e===Ps.RIGHT&&(n=-n);const i=di.simplify(t,n),r=i.length-1;s.initSideSegments(i[r-1],i[0],e);for(let t=1;t<=r;t++){const e=1!==t;s.addNextSegment(i[t],e)}s.closeRing()}computeLineBufferCurve(t,e){const s=this.simplifyTolerance(this._distance),n=di.simplify(t,s),i=n.length-1;e.initSideSegments(n[0],n[1],Ps.LEFT);for(let t=2;t<=i;t++)e.addNextSegment(n[t],!0);e.addLastSegment(),e.addLineEndCap(n[i-1],n[i]);const r=di.simplify(t,-s),o=r.length-1;e.initSideSegments(r[o],r[o-1],Ps.LEFT);for(let t=o-2;t>=0;t--)e.addNextSegment(r[t],!0);e.addLastSegment(),e.addLineEndCap(r[1],r[0]),e.closeRing()}computePointCurve(t,e){switch(this._bufParams.getEndCapStyle()){case ri.CAP_ROUND:e.createCircle(t);break;case ri.CAP_SQUARE:e.createSquare(t)}}getLineCurve(t,e){if(this._distance=e,this.isLineOffsetEmpty(e))return null;const s=Math.abs(e),n=this.getSegGen(s);if(t.length<=1)this.computePointCurve(t[0],n);else if(this._bufParams.isSingleSided()){const s=e<0;this.computeSingleSidedBufferCurve(t,s,n)}else this.computeLineBufferCurve(t,n);return n.getCoordinates()}getBufferParameters(){return this._bufParams}simplifyTolerance(t){return t*this._bufParams.getSimplifyFactor()}getRingCurve(t,e,s){if(this._distance=s,t.length<=2)return this.getLineCurve(t,s);if(0===s)return mi.copyCoordinates(t);const n=this.getSegGen(s);return this.computeRingBufferCurve(t,e,n),n.getCoordinates()}computeOffsetCurve(t,e,s){const n=this.simplifyTolerance(this._distance);if(e){const e=di.simplify(t,-n),i=e.length-1;s.initSideSegments(e[i],e[i-1],Ps.LEFT),s.addFirstSegment();for(let t=i-2;t>=0;t--)s.addNextSegment(e[t],!0)}else{const e=di.simplify(t,n),i=e.length-1;s.initSideSegments(e[0],e[1],Ps.LEFT),s.addFirstSegment();for(let t=2;t<=i;t++)s.addNextSegment(e[t],!0)}s.addLastSegment()}isLineOffsetEmpty(t){return 0===t||t<0&&!this._bufParams.isSingleSided()}getSegGen(t){return new pi(this._precisionModel,this._bufParams,t)}}class fi{constructor(){fi.constructor_.apply(this,arguments)}static constructor_(){this._subgraphs=null,this._seg=new Zt;const t=arguments[0];this._subgraphs=t}findStabbedSegments(){if(1===arguments.length){const t=arguments[0],e=new S;for(let s=this._subgraphs.iterator();s.hasNext();){const n=s.next(),i=n.getEnvelope();t.yi.getMaxY()||this.findStabbedSegments(t,n.getDirectedEdges(),e)}return e}if(3===arguments.length)if(E(arguments[2],C)&&arguments[0]instanceof p&&arguments[1]instanceof en){const t=arguments[0],e=arguments[1],s=arguments[2],n=e.getEdge().getCoordinates();for(let i=0;ithis._seg.p1.y&&this._seg.reverse();if(Math.max(this._seg.p0.x,this._seg.p1.x)this._seg.p1.y)continue;if(F.index(this._seg.p0,this._seg.p1,t)===F.RIGHT)continue;let r=e.getDepth(Ps.LEFT);this._seg.p0.equals(n[i])||(r=e.getDepth(Ps.RIGHT));const o=new yi(this._seg,r);s.add(o)}}else if(E(arguments[2],C)&&arguments[0]instanceof p&&E(arguments[1],C)){const t=arguments[0],e=arguments[2];for(let s=arguments[1].iterator();s.hasNext();){const n=s.next();n.isForward()&&this.findStabbedSegments(t,n,e)}}}getDepth(t){const e=this.findStabbedSegments(t);if(0===e.size())return 0;return fe.min(e)._leftDepth}}class yi{constructor(){yi.constructor_.apply(this,arguments)}static constructor_(){this._upwardSeg=null,this._leftDepth=null;const t=arguments[0],e=arguments[1];this._upwardSeg=new Zt(t),this._leftDepth=e}compareTo(t){const e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;let s=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==s?s:(s=-1*e._upwardSeg.orientationIndex(this._upwardSeg),0!==s?s:this._upwardSeg.compareTo(e._upwardSeg))}compareX(t,e){const s=t.p0.compareTo(e.p0);return 0!==s?s:t.p1.compareTo(e.p1)}toString(){return this._upwardSeg.toString()}get interfaces_(){return[r]}}fi.DepthSegment=yi;class xi{constructor(){xi.constructor_.apply(this,arguments)}static constructor_(){this._inputGeom=null,this._distance=null,this._curveBuilder=null,this._curveList=new S;const t=arguments[0],e=arguments[1],s=arguments[2];this._inputGeom=t,this._distance=e,this._curveBuilder=s}addRingSide(t,e,s,n,i){if(0===e&&t.length=ht.MINIMUM_VALID_SIZE&&F.isCCW(t)&&(r=i,o=n,s=Ps.opposite(s));const l=this._curveBuilder.getRingCurve(t,s,e);this.addCurve(l,r,o)}addRingBothSides(t,e){this.addRingSide(t,e,Ps.LEFT,jt.EXTERIOR,jt.INTERIOR),this.addRingSide(t,e,Ps.RIGHT,jt.INTERIOR,jt.EXTERIOR)}addPoint(t){if(this._distance<=0)return null;const e=t.getCoordinates(),s=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(s,jt.EXTERIOR,jt.INTERIOR)}addPolygon(t){let e=this._distance,s=Ps.LEFT;this._distance<0&&(e=-this._distance,s=Ps.RIGHT);const n=t.getExteriorRing(),i=gt.removeRepeatedPoints(n.getCoordinates());if(this._distance<0&&this.isErodedCompletely(n,this._distance))return null;if(this._distance<=0&&i.length<3)return null;this.addRingSide(i,e,s,jt.EXTERIOR,jt.INTERIOR);for(let n=0;n0&&this.isErodedCompletely(i,-this._distance)||this.addRingSide(r,e,Ps.opposite(s),jt.INTERIOR,jt.EXTERIOR)}}isTriangleErodedCompletely(t,e){const s=new te(t[0],t[1],t[2]),n=s.inCentre();return Y.pointToSegment(n,s.p0,s.p1)i}addCollection(t){for(let e=0;e=0;s--){const n=this._edgeList.get(s),i=n.getSym();null===e&&(e=i),null!==t&&i.setNext(t),t=n}e.setNext(t)}computeDepths(){if(1===arguments.length){const t=arguments[0],e=this.findIndex(t),s=t.getDepth(Ps.LEFT),n=t.getDepth(Ps.RIGHT),i=this.computeDepths(e+1,this._edgeList.size(),s);if(this.computeDepths(0,e,i)!==n)throw new tn("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){const t=arguments[1];let e=arguments[2];for(let s=arguments[0];s=0;i--){const r=this._resultAreaEdgeList.get(i),o=r.getSym();switch(null===e&&r.getEdgeRing()===t&&(e=r),n){case this._SCANNING_FOR_INCOMING:if(o.getEdgeRing()!==t)continue;s=o,n=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(r.getEdgeRing()!==t)continue;s.setNextMin(r),n=this._SCANNING_FOR_INCOMING}}n===this._LINKING_TO_OUTGOING&&(u.isTrue(null!==e,"found null for first outgoing dirEdge"),u.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),s.setNextMin(e))}getOutgoingDegree(){if(0===arguments.length){let t=0;for(let e=this.iterator();e.hasNext();){e.next().isInResult()&&t++}return t}if(1===arguments.length){const t=arguments[0];let e=0;for(let s=this.iterator();s.hasNext();){s.next().getEdgeRing()===t&&e++}return e}}getLabel(){return this._label}findCoveredLineEdges(){let t=jt.NONE;for(let e=this.iterator();e.hasNext();){const s=e.next(),n=s.getSym();if(!s.isLineEdge()){if(s.isInResult()){t=jt.INTERIOR;break}if(n.isInResult()){t=jt.EXTERIOR;break}}}if(t===jt.NONE)return null;let e=t;for(let t=this.iterator();t.hasNext();){const s=t.next(),n=s.getSym();s.isLineEdge()?s.getEdge().setCovered(e===jt.INTERIOR):(s.isInResult()&&(e=jt.EXTERIOR),n.isInResult()&&(e=jt.INTERIOR))}}computeLabelling(t){super.computeLabelling.call(this,t),this._label=new As(jt.NONE);for(let t=this.iterator();t.hasNext();){const e=t.next().getEdge().getLabel();for(let t=0;t<2;t++){const s=e.getLocation(t);s!==jt.INTERIOR&&s!==jt.BOUNDARY||this._label.setLocation(t,jt.INTERIOR)}}}}class Ni extends sn{constructor(){super()}createNode(t){return new Qs(t,new Ii)}}class Ci{constructor(){Ci.constructor_.apply(this,arguments)}static constructor_(){this._pts=null,this._orientation=null;const t=arguments[0];this._pts=t,this._orientation=Ci.orientation(t)}static orientation(t){return 1===gt.increasingDirection(t)}static compareOriented(t,e,s,n){const i=e?1:-1,r=n?1:-1,o=e?t.length:-1,l=n?s.length:-1;let a=e?0:t.length-1,c=n?0:s.length-1;for(;;){const e=t[a].compareTo(s[c]);if(0!==e)return e;a+=i,c+=r;const n=a===o,h=c===l;if(n&&!h)return-1;if(!n&&h)return 1;if(n&&h)return 0}}compareTo(t){const e=t;return Ci.compareOriented(this._pts,this._orientation,e._pts,e._orientation)}get interfaces_(){return[r]}}class wi{constructor(){wi.constructor_.apply(this,arguments)}static constructor_(){this._edges=new S,this._ocaMap=new Xs}print(t){t.print("MULTILINESTRING ( ");for(let e=0;e0&&t.print(","),t.print("(");const n=s.getCoordinates();for(let e=0;e0&&t.print(","),t.print(n[e].x+" "+n[e].y);t.println(")")}t.print(") ")}addAll(t){for(let e=t.iterator();e.hasNext();)this.add(e.next())}findEdgeIndex(t){for(let e=0;en||this._maxyr;if(o)return!1;const l=this.intersectsToleranceSquare(t,e);return u.isTrue(!(o&&l),"Found bad envelope test"),l}initCorners(t){const e=.5;this._minx=t.x-e,this._maxx=t.x+e,this._miny=t.y-e,this._maxy=t.y+e,this._corner[0]=new p(this._maxx,this._maxy),this._corner[1]=new p(this._minx,this._maxy),this._corner[2]=new p(this._minx,this._miny),this._corner[3]=new p(this._maxx,this._miny)}intersects(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))}scale(t){return Math.round(t*this._scaleFactor)}getCoordinate(){return this._originalPt}copyScaled(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)}getSafeEnvelope(){if(null===this._safeEnv){const t=Pi.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new P(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}return this._safeEnv}intersectsPixelClosure(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())))}intersectsToleranceSquare(t,e){let s=!1,n=!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()&&(s=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),!!this._li.isProper()||(!(!s||!n)||(!!t.equals(this._pt)||!!e.equals(this._pt))))))}addSnappedNode(t,e){const s=t.getCoordinate(e),n=t.getCoordinate(e+1);return!!this.intersects(s,n)&&(t.addIntersection(this.getCoordinate(),e),!0)}}Pi.SAFE_ENV_EXPANSION_FACTOR=.75;class Oi{constructor(){Oi.constructor_.apply(this,arguments)}static constructor_(){this.selectedSegment=new Zt}select(){if(1===arguments.length);else if(2===arguments.length){const t=arguments[1];arguments[0].getLineSegment(t,this.selectedSegment),this.select(this.selectedSegment)}}}class vi{constructor(){vi.constructor_.apply(this,arguments)}static constructor_(){this._index=null;const t=arguments[0];this._index=t}snap(){if(1===arguments.length){const t=arguments[0];return this.snap(t,null,-1)}if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=t.getSafeEnvelope(),i=new Mi(t,e,s);return this._index.query(n,new class{get interfaces_(){return[Me]}visitItem(t){t.select(n,i)}}),i.isNodeAdded()}}}class Mi extends Oi{constructor(){super(),Mi.constructor_.apply(this,arguments)}static constructor_(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;const t=arguments[0],e=arguments[1],s=arguments[2];this._hotPixel=t,this._parentEdge=e,this._hotPixelVertexIndex=s}isNodeAdded(){return this._isNodeAdded}select(){if(!(2===arguments.length&&Number.isInteger(arguments[1])&&arguments[0]instanceof Wn))return super.select.apply(this,arguments);{const t=arguments[1],e=arguments[0].getContext();if(this._parentEdge===e&&(t===this._hotPixelVertexIndex||t+1===this._hotPixelVertexIndex))return null;this._isNodeAdded|=this._hotPixel.addSnappedNode(e,t)}}}vi.HotPixelSnapAction=Mi;class bi{constructor(){bi.constructor_.apply(this,arguments)}static constructor_(){this._li=null,this._interiorIntersections=null;const t=arguments[0];this._li=t,this._interiorIntersections=new S}processIntersections(t,e,s,n){if(t===s&&e===n)return null;const i=t.getCoordinates()[e],r=t.getCoordinates()[e+1],o=s.getCoordinates()[n],l=s.getCoordinates()[n+1];if(this._li.computeIntersection(i,r,o,l),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(let t=0;t0?e:0),r=s-Math.trunc(Math.log(i)/Math.log(10)+1);return Math.pow(10,r)}bufferFixedPrecision(t){const e=new $n(new Di(new It(1)),t.getScale()),s=new Ti(this._bufParams);s.setWorkingPrecisionModel(t),s.setNoder(e),this._resultGeometry=s.buffer(this._argGeom,this._distance)}bufferReducedPrecision(){if(0===arguments.length){for(let t=Ai.MAX_PRECISION_DIGITS;t>=0;t--){try{this.bufferReducedPrecision(t)}catch(t){if(!(t instanceof tn))throw t;this._saveException=t}if(null!==this._resultGeometry)return null}throw this._saveException}if(1===arguments.length){const t=arguments[0],e=Ai.precisionScaleFactor(this._argGeom,this._distance,t),s=new It(e);this.bufferFixedPrecision(s)}}computeGeometry(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;const t=this._argGeom.getFactory().getPrecisionModel();t.getType()===It.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()}setQuadrantSegments(t){this._bufParams.setQuadrantSegments(t)}bufferOriginalPrecision(){try{const t=new Ti(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(t){if(!(t instanceof c))throw t;this._saveException=t}}getResultGeometry(t){return this._distance=t,this.computeGeometry(),this._resultGeometry}setEndCapStyle(t){this._bufParams.setEndCapStyle(t)}}Ai.CAP_ROUND=ri.CAP_ROUND,Ai.CAP_BUTT=ri.CAP_FLAT,Ai.CAP_FLAT=ri.CAP_FLAT,Ai.CAP_SQUARE=ri.CAP_SQUARE,Ai.MAX_PRECISION_DIGITS=12;var Fi=Object.freeze({__proto__:null,BufferOp:Ai,BufferParameters:ri});class Gi{constructor(){Gi.constructor_.apply(this,arguments)}static constructor_(){if(this._component=null,this._segIndex=null,this._pt=null,2===arguments.length){const t=arguments[0],e=arguments[1];Gi.constructor_.call(this,t,Gi.INSIDE_AREA,e)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this._component=t,this._segIndex=e,this._pt=s}}getSegmentIndex(){return this._segIndex}getCoordinate(){return this._pt}isInsideArea(){return this._segIndex===Gi.INSIDE_AREA}toString(){return this._component.getGeometryType()+"["+this._segIndex+"]-"+Ut.toPoint(this._pt)}getGeometryComponent(){return this._component}}Gi.INSIDE_AREA=-1;class qi{constructor(){qi.constructor_.apply(this,arguments)}static constructor_(){this._locations=null;const t=arguments[0];this._locations=t}static getLocations(t){const e=new S;return t.apply(new qi(e)),e}filter(t){if(t.isEmpty())return null;(t instanceof $||t instanceof Q||t instanceof nt)&&this._locations.add(new Gi(t,0,t.getCoordinate()))}get interfaces_(){return[K]}}class Bi{constructor(){Bi.constructor_.apply(this,arguments)}static constructor_(){if(this._geom=null,this._terminateDistance=0,this._ptLocator=new _s,this._minDistanceLocation=null,this._minDistance=i.MAX_VALUE,2===arguments.length){const t=arguments[0],e=arguments[1];Bi.constructor_.call(this,t,e,0)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this._geom=new Array(2).fill(null),this._geom[0]=t,this._geom[1]=e,this._terminateDistance=s}}static distance(t,e){return new Bi(t,e).distance()}static isWithinDistance(t,e,s){if(t.getEnvelopeInternal().distance(e.getEnvelopeInternal())>s)return!1;return new Bi(t,e,s).distance()<=s}static nearestPoints(t,e){return new Bi(t,e).nearestPoints()}computeContainmentDistance(){if(0===arguments.length){const 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){const t=arguments[0],e=arguments[1],s=this._geom[t];if(s.getDimension()<2)return null;const n=1-t,i=xe.getPolygons(s);if(i.size()>0){const s=qi.getLocations(this._geom[n]);if(this.computeContainmentDistance(s,i,e),this._minDistance<=this._terminateDistance)return this._minDistanceLocation[n]=e[0],this._minDistanceLocation[t]=e[1],null}}else if(3===arguments.length)if(arguments[2]instanceof Array&&E(arguments[0],C)&&E(arguments[1],C)){const t=arguments[0],e=arguments[1],s=arguments[2];for(let n=0;nthis._minDistance)return null;const n=t.getCoordinates(),i=e.getCoordinate();for(let r=0;rthis._minDistance)return null;const n=t.getCoordinates(),i=e.getCoordinates();for(let r=0;rthis._minDistance))for(let l=0;lthis._minDistance)continue;const c=Y.segmentToSegment(n[r],n[r+1],i[l],i[l+1]);if(ct&>.reverse(this._coordinates)}return this._coordinates}toLineString(){return this._factory.createLineString(this.getCoordinates())}add(t){this._directedEdges.add(t)}}class zi{constructor(){zi.constructor_.apply(this,arguments)}static constructor_(){this._isMarked=!1,this._isVisited=!1,this._data=null}static getComponentWithVisitedState(t,e){for(;t.hasNext();){const s=t.next();if(s.isVisited()===e)return s}return null}static setVisited(t,e){for(;t.hasNext();){t.next().setVisited(e)}}static setMarked(t,e){for(;t.hasNext();){t.next().setMarked(e)}}setVisited(t){this._isVisited=t}isMarked(){return this._isMarked}setData(t){this._data=t}getData(){return this._data}setMarked(t){this._isMarked=t}getContext(){return this._data}isVisited(){return this._isVisited}setContext(t){this._data=t}}class Xi extends zi{constructor(){super(),Xi.constructor_.apply(this,arguments)}static constructor_(){if(this._parentEdge=null,this._from=null,this._to=null,this._p0=null,this._p1=null,this._sym=null,this._edgeDirection=null,this._quadrant=null,this._angle=null,0===arguments.length);else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];this._from=t,this._to=e,this._edgeDirection=n,this._p0=t.getCoordinate(),this._p1=s;const i=this._p1.x-this._p0.x,r=this._p1.y-this._p0.y;this._quadrant=Is.quadrant(i,r),this._angle=Math.atan2(r,i)}}static toEdges(t){const e=new S;for(let s=t.iterator();s.hasNext();)e.add(s.next()._parentEdge);return e}isRemoved(){return null===this._parentEdge}compareDirection(t){return this._quadrant>t._quadrant?1:this._quadrant=0&&t.add(i+1,new p(s),!1)}}findSegmentIndexToSnap(t,e){let s=i.MAX_VALUE,n=-1;for(let i=0;ie&&(e=t)}return e}if(2===arguments.length){const t=arguments[0],e=arguments[1];return Math.min(ir.computeOverlaySnapTolerance(t),ir.computeOverlaySnapTolerance(e))}}static computeSizeBasedSnapTolerance(t){const e=t.getEnvelopeInternal();return Math.min(e.getHeight(),e.getWidth())*ir.SNAP_PRECISION_FACTOR}static snapToSelf(t,e,s){return new ir(t).snapToSelf(e,s)}snapTo(t,e){const s=this.extractTargetCoordinates(t);return new rr(e,s).transform(this._srcGeom)}snapToSelf(t,e){const s=this.extractTargetCoordinates(this._srcGeom),n=new rr(t,s,!0).transform(this._srcGeom);let i=n;return e&&E(i,st)&&(i=n.buffer(0)),i}computeSnapTolerance(t){return this.computeMinimumSegmentLength(t)/10}extractTargetCoordinates(t){const e=new ot,s=t.getCoordinates();for(let t=0;t=t.size()-2}static createAnyIntersectionFinder(t){return new ar(t)}static createInteriorIntersectionsFinder(t){const e=new ar(t);return e.setFindAllIntersections(!0),e.setInteriorIntersectionsOnly(!0),e}setCheckEndSegmentsOnly(t){this._isCheckEndSegmentsOnly=t}getIntersectionSegments(){return this._intSegments}count(){return this._intersectionCount}getIntersections(){return this._intersections}setFindAllIntersections(t){this._findAllIntersections=t}setKeepIntersections(t){this._keepIntersections=t}getIntersection(){return this._interiorIntersection}processIntersections(t,e,s,n){if(!this._findAllIntersections&&this.hasIntersection())return null;const i=t===s;if(i&&e===n)return null;if(this._isCheckEndSegmentsOnly){if(!(ar.isEndSegment(t,e)||ar.isEndSegment(s,n)))return null}const r=t.getCoordinate(e),o=t.getCoordinate(e+1),l=s.getCoordinate(n),a=s.getCoordinate(n+1),c=0===e,h=e+2===t.size(),u=0===n,g=n+2===s.size();this._li.computeIntersection(r,o,l,a);const d=this._li.hasIntersection()&&this._li.isInteriorIntersection();let _=!1;if(!this._isInteriorIntersectionsOnly){_=!(i&&Math.abs(n-e)<=1)&&ar.isInteriorVertexIntersection(r,o,l,a,c,h,u,g)}(d||_)&&(this._intSegments=new Array(4).fill(null),this._intSegments[0]=r,this._intSegments[1]=o,this._intSegments[2]=l,this._intSegments[3]=a,this._interiorIntersection=this._li.getIntersection(0),this._keepIntersections&&this._intersections.add(this._interiorIntersection),this._intersectionCount++)}hasIntersection(){return null!==this._interiorIntersection}isDone(){return!this._findAllIntersections&&null!==this._interiorIntersection}setInteriorIntersectionsOnly(t){this._isInteriorIntersectionsOnly=t}get interfaces_(){return[Si]}}class cr{constructor(){cr.constructor_.apply(this,arguments)}static constructor_(){this._li=new Wt,this._segStrings=null,this._findAllIntersections=!1,this._segInt=null,this._isValid=!0;const t=arguments[0];this._segStrings=t}static computeIntersections(t){const e=new cr(t);return e.setFindAllIntersections(!0),e.isValid(),e.getIntersections()}execute(){if(null!==this._segInt)return null;this.checkInteriorIntersections()}getIntersections(){return this._segInt.getIntersections()}isValid(){return this.execute(),this._isValid}setFindAllIntersections(t){this._findAllIntersections=t}checkInteriorIntersections(){this._isValid=!0,this._segInt=new ar(this._li),this._segInt.setFindAllIntersections(this._findAllIntersections);const t=new Qn;if(t.setSegmentIntersector(this._segInt),t.computeNodes(this._segStrings),this._segInt.hasIntersection())return this._isValid=!1,null}checkValid(){if(this.execute(),!this._isValid)throw new tn(this.getErrorMessage(),this._segInt.getIntersection())}getErrorMessage(){if(this._isValid)return"no intersections found";const t=this._segInt.getIntersectionSegments();return"found non-noded intersection between "+Ut.toLineString(t[0],t[1])+" and "+Ut.toLineString(t[2],t[3])}}class hr{constructor(){hr.constructor_.apply(this,arguments)}static constructor_(){this._nv=null;const t=arguments[0];this._nv=new cr(hr.toSegmentStrings(t))}static toSegmentStrings(t){const e=new S;for(let s=t.iterator();s.hasNext();){const t=s.next();e.add(new lr(t.getCoordinates(),t))}return e}static checkValid(t){new hr(t).checkValid()}checkValid(){this._nv.checkValid()}}class ur{constructor(){ur.constructor_.apply(this,arguments)}static constructor_(){this._op=null,this._geometryFactory=null,this._ptLocator=null,this._lineEdgesList=new S,this._resultLineList=new S;const t=arguments[0],e=arguments[1],s=arguments[2];this._op=t,this._geometryFactory=e,this._ptLocator=s}collectLines(t){for(let e=this._op.getGraph().getEdgeEnds().iterator();e.hasNext();){const s=e.next();this.collectLineEdge(s,t,this._lineEdgesList),this.collectBoundaryTouchEdge(s,t,this._lineEdgesList)}}labelIsolatedLine(t,e){const s=this._ptLocator.locate(t.getCoordinate(),this._op.getArgGeometry(e));t.getLabel().setLocation(e,s)}build(t){return this.findCoveredLineEdges(),this.collectLines(t),this.buildLines(t),this._resultLineList}collectLineEdge(t,e,s){const n=t.getLabel(),i=t.getEdge();t.isLineEdge()&&(t.isVisited()||!Er.isResultOfOp(n,e)||i.isCovered()||(s.add(i),t.setVisitedEdge(!0)))}findCoveredLineEdges(){for(let t=this._op.getGraph().getNodes().iterator();t.hasNext();){t.next().getEdges().findCoveredLineEdges()}for(let t=this._op.getGraph().getEdgeEnds().iterator();t.hasNext();){const e=t.next(),s=e.getEdge();if(e.isLineEdge()&&!s.isCoveredSet()){const t=this._op.isCoveredByA(e.getCoordinate());s.setCovered(t)}}}labelIsolatedLines(t){for(let e=t.iterator();e.hasNext();){const t=e.next(),s=t.getLabel();t.isIsolated()&&(s.isNull(0)?this.labelIsolatedLine(t,0):this.labelIsolatedLine(t,1))}}buildLines(t){for(let t=this._lineEdgesList.iterator();t.hasNext();){const e=t.next(),s=this._geometryFactory.createLineString(e.getCoordinates());this._resultLineList.add(s),e.setInResult(!0)}}collectBoundaryTouchEdge(t,e,s){const n=t.getLabel();return t.isLineEdge()||t.isVisited()||t.isInteriorAreaEdge()||t.getEdge().isInResult()?null:(u.isTrue(!(t.isInResult()||t.getSym().isInResult())||!t.getEdge().isInResult()),void(Er.isResultOfOp(n,e)&&e===Er.INTERSECTION&&(s.add(t.getEdge()),t.setVisitedEdge(!0))))}}class gr{constructor(){gr.constructor_.apply(this,arguments)}static constructor_(){this._op=null,this._geometryFactory=null,this._resultPointList=new S;const t=arguments[0],e=arguments[1];this._op=t,this._geometryFactory=e}filterCoveredNodeToPoint(t){const e=t.getCoordinate();if(!this._op.isCoveredByLA(e)){const t=this._geometryFactory.createPoint(e);this._resultPointList.add(t)}}extractNonCoveredResultNodes(t){for(let e=this._op.getGraph().getNodes().iterator();e.hasNext();){const s=e.next();if(!s.isInResult()&&(!s.isIncidentEdgeInResult()&&(0===s.getEdges().getDegree()||t===Er.INTERSECTION))){const e=s.getLabel();Er.isResultOfOp(e,t)&&this.filterCoveredNodeToPoint(s)}}}build(t){return this.extractNonCoveredResultNodes(t),this._resultPointList}}class dr{constructor(){this._isFirst=!0,this._commonMantissaBitsCount=53,this._commonBits=new n,this._commonSignExp=null}getCommon(){return i.longBitsToDouble(this._commonBits)}add(t){const e=i.doubleToLongBits(t);if(this._isFirst)return this._commonBits=e,this._commonSignExp=dr.signExpBits(this._commonBits),this._isFirst=!1,null;if(dr.signExpBits(e)!==this._commonSignExp)return this._commonBits.high=0,this._commonBits.low=0,null;this._commonMantissaBitsCount=dr.numCommonMostSigMantissaBits(this._commonBits,e),this._commonBits=dr.zeroLowerBits(this._commonBits,64-(12+this._commonMantissaBitsCount))}toString(){if(1===arguments.length){const t=arguments[0],e=i.longBitsToDouble(t),s="0000000000000000000000000000000000000000000000000000000000000000"+n.toBinaryString(t),r=s.substring(s.length-64);return r.substring(0,1)+" "+r.substring(1,12)+"(exp) "+r.substring(12)+" [ "+e+" ]"}}getClass(){return dr}get interfaces_(){return[]}static getBit(t,e){const s=1<>>20}static zeroLowerBits(t,e){let s="low";if(e>32&&(t.low=0,e%=32,s="high"),e>0){const n=e<32?~((1<=0;n--){if(dr.getBit(t,n)!==dr.getBit(e,n))return s;s++}return 52}}class _r{constructor(){_r.constructor_.apply(this,arguments)}static constructor_(){this._commonCoord=null,this._ccFilter=new pr}addCommonBits(t){const e=new mr(this._commonCoord);t.apply(e),t.geometryChanged()}removeCommonBits(t){if(0===this._commonCoord.x&&0===this._commonCoord.y)return t;const e=new p(this._commonCoord);e.x=-e.x,e.y=-e.y;const s=new mr(e);return t.apply(s),t.geometryChanged(),t}getCommonCoordinate(){return this._commonCoord}add(t){t.apply(this._ccFilter),this._commonCoord=this._ccFilter.getCommonCoordinate()}}class pr{constructor(){pr.constructor_.apply(this,arguments)}static constructor_(){this._commonBitsX=new dr,this._commonBitsY=new dr}filter(t){this._commonBitsX.add(t.x),this._commonBitsY.add(t.y)}getCommonCoordinate(){return new p(this._commonBitsX.getCommon(),this._commonBitsY.getCommon())}get interfaces_(){return[k]}}class mr{constructor(){mr.constructor_.apply(this,arguments)}static constructor_(){this.trans=null;const t=arguments[0];this.trans=t}filter(t,e){const s=t.getOrdinate(e,0)+this.trans.x,n=t.getOrdinate(e,1)+this.trans.y;t.setOrdinate(e,0,s),t.setOrdinate(e,1,n)}isDone(){return!1}isGeometryChanged(){return!0}get interfaces_(){return[R]}}_r.CommonCoordinateFilter=pr,_r.Translater=mr;class fr{constructor(){fr.constructor_.apply(this,arguments)}static constructor_(){this._geom=new Array(2).fill(null),this._snapTolerance=null,this._cbr=null;const t=arguments[0],e=arguments[1];this._geom[0]=t,this._geom[1]=e,this.computeSnapTolerance()}static overlayOp(t,e,s){return new fr(t,e).getResultGeometry(s)}static union(t,e){return fr.overlayOp(t,e,Er.UNION)}static intersection(t,e){return fr.overlayOp(t,e,Er.INTERSECTION)}static symDifference(t,e){return fr.overlayOp(t,e,Er.SYMDIFFERENCE)}static difference(t,e){return fr.overlayOp(t,e,Er.DIFFERENCE)}selfSnap(t){return new ir(t).snapTo(t,this._snapTolerance)}removeCommonBits(t){this._cbr=new _r,this._cbr.add(t[0]),this._cbr.add(t[1]);const e=new Array(2).fill(null);return e[0]=this._cbr.removeCommonBits(t[0].copy()),e[1]=this._cbr.removeCommonBits(t[1].copy()),e}prepareResult(t){return this._cbr.addCommonBits(t),t}getResultGeometry(t){const e=this.snap(this._geom),s=Er.overlayOp(e[0],e[1],t);return this.prepareResult(s)}checkValid(t){t.isValid()||q.out.println("Snapped geometry is invalid")}computeSnapTolerance(){this._snapTolerance=ir.computeOverlaySnapTolerance(this._geom[0],this._geom[1])}snap(t){const e=this.removeCommonBits(t);return ir.snap(e[0],e[1],this._snapTolerance)}}class yr{constructor(){yr.constructor_.apply(this,arguments)}static constructor_(){this._geom=new Array(2).fill(null);const t=arguments[0],e=arguments[1];this._geom[0]=t,this._geom[1]=e}static overlayOp(t,e,s){return new yr(t,e).getResultGeometry(s)}static union(t,e){return yr.overlayOp(t,e,Er.UNION)}static intersection(t,e){return yr.overlayOp(t,e,Er.INTERSECTION)}static symDifference(t,e){return yr.overlayOp(t,e,Er.SYMDIFFERENCE)}static difference(t,e){return yr.overlayOp(t,e,Er.DIFFERENCE)}getResultGeometry(t){let e=null,s=!1,n=null;try{e=Er.overlayOp(this._geom[0],this._geom[1],t);!0&&(s=!0)}catch(t){if(!(t instanceof c))throw t;n=t}if(!s)try{e=fr.overlayOp(this._geom[0],this._geom[1],t)}catch(t){throw t instanceof c?n:t}return e}}class xr{constructor(){xr.constructor_.apply(this,arguments)}static constructor_(){if(this._li=new Wt,this._resultPrecisionModel=null,this._arg=null,1===arguments.length){const t=arguments[0];this.setComputationPrecision(t.getPrecisionModel()),this._arg=new Array(1).fill(null),this._arg[0]=new rn(0,t)}else if(2===arguments.length){const t=arguments[0],e=arguments[1];xr.constructor_.call(this,t,e,cs.OGC_SFS_BOUNDARY_RULE)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];t.getPrecisionModel().compareTo(e.getPrecisionModel())>=0?this.setComputationPrecision(t.getPrecisionModel()):this.setComputationPrecision(e.getPrecisionModel()),this._arg=new Array(2).fill(null),this._arg[0]=new rn(0,t,s),this._arg[1]=new rn(1,e,s)}}getArgGeometry(t){return this._arg[t].getGeometry()}setComputationPrecision(t){this._resultPrecisionModel=t,this._li.setPrecisionModel(this._resultPrecisionModel)}}class Er extends xr{constructor(){super(),Er.constructor_.apply(this,arguments)}static constructor_(){this._ptLocator=new _s,this._geomFact=null,this._resultGeom=null,this._graph=null,this._edgeList=new wi,this._resultPolyList=new S,this._resultLineList=new S,this._resultPointList=new S;const t=arguments[0],e=arguments[1];xr.constructor_.call(this,t,e),this._graph=new nn(new Ni),this._geomFact=t.getFactory()}static overlayOp(t,e,s){return new Er(t,e).getResultGeometry(s)}static union(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return Er.createEmptyResult(Er.UNION,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}if(t.isGeometryCollection()||e.isGeometryCollection())throw new s("This method does not support GeometryCollection arguments");return yr.overlayOp(t,e,Er.UNION)}static intersection(t,e){if(t.isEmpty()||e.isEmpty())return Er.createEmptyResult(Er.INTERSECTION,t,e,t.getFactory());if(t.isGeometryCollection()){const s=e;return le.map(t,new class{get interfaces_(){return[MapOp]}map(t){return Er.intersection(t,s)}})}return yr.overlayOp(t,e,Er.INTERSECTION)}static symDifference(t,e){if(t.isEmpty()||e.isEmpty()){if(t.isEmpty()&&e.isEmpty())return Er.createEmptyResult(Er.SYMDIFFERENCE,t,e,t.getFactory());if(t.isEmpty())return e.copy();if(e.isEmpty())return t.copy()}if(t.isGeometryCollection()||e.isGeometryCollection())throw new s("This method does not support GeometryCollection arguments");return yr.overlayOp(t,e,Er.SYMDIFFERENCE)}static resultDimension(t,e,s){const n=e.getDimension(),i=s.getDimension();let r=-1;switch(t){case Er.INTERSECTION:r=Math.min(n,i);break;case Er.UNION:r=Math.max(n,i);break;case Er.DIFFERENCE:r=n;break;case Er.SYMDIFFERENCE:r=Math.max(n,i)}return r}static createEmptyResult(t,e,s,n){const i=Er.resultDimension(t,e,s);return n.createEmpty(i)}static difference(t,e){if(t.isEmpty())return Er.createEmptyResult(Er.DIFFERENCE,t,e,t.getFactory());if(e.isEmpty())return t.copy();if(t.isGeometryCollection()||e.isGeometryCollection())throw new s("This method does not support GeometryCollection arguments");return yr.overlayOp(t,e,Er.DIFFERENCE)}static isResultOfOp(){if(2===arguments.length){const t=arguments[0],e=arguments[1],s=t.getLocation(0),n=t.getLocation(1);return Er.isResultOfOp(s,n,e)}if(3===arguments.length){let t=arguments[0],e=arguments[1],s=arguments[2];switch(t===jt.BOUNDARY&&(t=jt.INTERIOR),e===jt.BOUNDARY&&(e=jt.INTERIOR),s){case Er.INTERSECTION:return t===jt.INTERIOR&&e===jt.INTERIOR;case Er.UNION:return t===jt.INTERIOR||e===jt.INTERIOR;case Er.DIFFERENCE:return t===jt.INTERIOR&&e!==jt.INTERIOR;case Er.SYMDIFFERENCE:return t===jt.INTERIOR&&e!==jt.INTERIOR||t!==jt.INTERIOR&&e===jt.INTERIOR}return!1}}insertUniqueEdge(t){const e=this._edgeList.findEqualEdge(t);if(null!==e){const s=e.getLabel();let n=t.getLabel();e.isPointwiseEqual(t)||(n=new As(t.getLabel()),n.flip());const i=e.getDepth();i.isNull()&&i.add(s),i.add(n),s.merge(n)}else this._edgeList.add(t)}getGraph(){return this._graph}cancelDuplicateResultEdges(){for(let t=this._graph.getEdgeEnds().iterator();t.hasNext();){const e=t.next(),s=e.getSym();e.isInResult()&&s.isInResult()&&(e.setInResult(!1),s.setInResult(!1))}}isCoveredByLA(t){return!!this.isCovered(t,this._resultLineList)||!!this.isCovered(t,this._resultPolyList)}computeGeometry(t,e,s,n){const i=new S;return i.addAll(t),i.addAll(e),i.addAll(s),i.isEmpty()?Er.createEmptyResult(n,this._arg[0].getGeometry(),this._arg[1].getGeometry(),this._geomFact):this._geomFact.buildGeometry(i)}mergeSymLabels(){for(let t=this._graph.getNodes().iterator();t.hasNext();){t.next().getEdges().mergeSymLabels()}}isCovered(t,e){for(let s=e.iterator();s.hasNext();){const e=s.next();if(this._ptLocator.locate(t,e)!==jt.EXTERIOR)return!0}return!1}replaceCollapsedEdges(){const t=new S;for(let e=this._edgeList.iterator();e.hasNext();){const s=e.next();s.isCollapsed()&&(e.remove(),t.add(s.getCollapsedEdge()))}this._edgeList.addAll(t)}updateNodeLabelling(){for(let t=this._graph.getNodes().iterator();t.hasNext();){const e=t.next(),s=e.getEdges().getLabel();e.getLabel().merge(s)}}getResultGeometry(t){return this.computeOverlay(t),this._resultGeom}insertUniqueEdges(t){for(let e=t.iterator();e.hasNext();){const t=e.next();this.insertUniqueEdge(t)}}computeOverlay(t){this.copyPoints(0),this.copyPoints(1),this._arg[0].computeSelfNodes(this._li,!1),this._arg[1].computeSelfNodes(this._li,!1),this._arg[0].computeEdgeIntersections(this._arg[1],this._li,!0);const e=new S;this._arg[0].computeSplitEdges(e),this._arg[1].computeSplitEdges(e),this.insertUniqueEdges(e),this.computeLabelsFromDepths(),this.replaceCollapsedEdges(),hr.checkValid(this._edgeList.getEdges()),this._graph.addEdges(this._edgeList.getEdges()),this.computeLabelling(),this.labelIncompleteNodes(),this.findResultAreaEdges(t),this.cancelDuplicateResultEdges();const s=new gi(this._geomFact);s.add(this._graph),this._resultPolyList=s.getPolygons();const n=new ur(this,this._geomFact,this._ptLocator);this._resultLineList=n.build(t);const i=new gr(this,this._geomFact,this._ptLocator);this._resultPointList=i.build(t),this._resultGeom=this.computeGeometry(this._resultPointList,this._resultLineList,this._resultPolyList,t)}labelIncompleteNode(t,e){const s=this._ptLocator.locate(t.getCoordinate(),this._arg[e].getGeometry());t.getLabel().setLocation(e,s)}copyPoints(t){for(let e=this._arg[t].getNodeIterator();e.hasNext();){const s=e.next();this._graph.addNode(s.getCoordinate()).setLabel(t,s.getLabel().getLocation(t))}}findResultAreaEdges(t){for(let e=this._graph.getEdgeEnds().iterator();e.hasNext();){const s=e.next(),n=s.getLabel();n.isArea()&&!s.isInteriorAreaEdge()&&Er.isResultOfOp(n.getLocation(0,Ps.RIGHT),n.getLocation(1,Ps.RIGHT),t)&&s.setInResult(!0)}}computeLabelsFromDepths(){for(let t=this._edgeList.iterator();t.hasNext();){const e=t.next(),s=e.getLabel(),n=e.getDepth();if(!n.isNull()){n.normalize();for(let t=0;t<2;t++)s.isNull(t)||!s.isArea()||n.isNull(t)||(0===n.getDelta(t)?s.toLine(t):(u.isTrue(!n.isNull(t,Ps.LEFT),"depth of LEFT side has not been initialized"),s.setLocation(t,Ps.LEFT,n.getLocation(t,Ps.LEFT)),u.isTrue(!n.isNull(t,Ps.RIGHT),"depth of RIGHT side has not been initialized"),s.setLocation(t,Ps.RIGHT,n.getLocation(t,Ps.RIGHT))))}}}computeLabelling(){for(let t=this._graph.getNodes().iterator();t.hasNext();){t.next().getEdges().computeLabelling(this._arg)}this.mergeSymLabels(),this.updateNodeLabelling()}labelIncompleteNodes(){for(let t=this._graph.getNodes().iterator();t.hasNext();){const e=t.next(),s=e.getLabel();e.isIsolated()&&(s.isNull(0)?this.labelIncompleteNode(e,0):this.labelIncompleteNode(e,1)),e.getEdges().updateLabelling(s)}}isCoveredByA(t){return!!this.isCovered(t,this._resultPolyList)}}Er.INTERSECTION=1,Er.UNION=2,Er.DIFFERENCE=3,Er.SYMDIFFERENCE=4;var Ir=Object.freeze({__proto__:null,snap:or,OverlayOp:Er});class Nr extends Xi{constructor(){super(),Nr.constructor_.apply(this,arguments)}static constructor_(){this._edgeRing=null,this._next=null,this._label=-1;const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];Xi.constructor_.call(this,t,e,s,n)}getNext(){return this._next}isInRing(){return null!==this._edgeRing}setRing(t){this._edgeRing=t}setLabel(t){this._label=t}getLabel(){return this._label}setNext(t){this._next=t}getRing(){return this._edgeRing}}class Cr extends Ui{constructor(){super(),Cr.constructor_.apply(this,arguments)}static constructor_(){this._line=null;const t=arguments[0];this._line=t}getLine(){return this._line}}class wr{constructor(){wr.constructor_.apply(this,arguments)}static constructor_(){this._geometryFactory=new wt,this._geomGraph=null,this._disconnectedRingcoord=null;const t=arguments[0];this._geomGraph=t}static findDifferentPoint(t,e){for(let s=0;s=t.getNumPoints()&&null===n)return null;let r=t.getCoordinate(i);null!==n&&n.segmentIndex===s.segmentIndex&&(r=n.coord);const o=new $s(t,s.coord,r,new As(t.getLabel()));e.add(o)}createEdgeEndForPrev(t,e,s,n){let i=s.segmentIndex;if(0===s.dist){if(0===i)return null;i--}let r=t.getCoordinate(i);null!==n&&n.segmentIndex>=i&&(r=n.coord);const o=new As(t.getLabel());o.flip();const l=new $s(t,s.coord,r,o);e.add(l)}computeEdgeEnds(){if(1===arguments.length){const t=arguments[0],e=new S;for(let s=t;s.hasNext();){const t=s.next();this.computeEdgeEnds(t,e)}return e}if(2===arguments.length){const t=arguments[0],e=arguments[1],s=t.getEdgeIntersectionList();s.addEndpoints();const n=s.iterator();let i=null,r=null;if(!n.hasNext())return null;let o=n.next();do{i=r,r=o,o=null,n.hasNext()&&(o=n.next()),null!==r&&(this.createEdgeEndForPrev(t,e,r,i),this.createEdgeEndForNext(t,e,r,o))}while(null!==r)}}}class Lr extends $s{constructor(){super(),Lr.constructor_.apply(this,arguments)}static constructor_(){if(this._edgeEnds=new S,1===arguments.length){const t=arguments[0];Lr.constructor_.call(this,null,t)}else if(2===arguments.length){const t=arguments[1];$s.constructor_.call(this,t.getEdge(),t.getCoordinate(),t.getDirectedCoordinate(),new As(t.getLabel())),this.insert(t)}}insert(t){this._edgeEnds.add(t)}print(t){t.println("EdgeEndBundle--\x3e Label: "+this._label);for(let e=this.iterator();e.hasNext();){e.next().print(t),t.println()}}iterator(){return this._edgeEnds.iterator()}getEdgeEnds(){return this._edgeEnds}computeLabelOn(t,e){let s=0,n=!1;for(let e=this.iterator();e.hasNext();){const i=e.next().getLabel().getLocation(t);i===jt.BOUNDARY&&s++,i===jt.INTERIOR&&(n=!0)}let i=jt.NONE;n&&(i=jt.INTERIOR),s>0&&(i=rn.determineBoundary(e,s)),this._label.setLocation(t,i)}computeLabelSide(t,e){for(let s=this.iterator();s.hasNext();){const n=s.next();if(n.getLabel().isArea()){const s=n.getLabel().getLocation(t,e);if(s===jt.INTERIOR)return this._label.setLocation(t,e,jt.INTERIOR),null;s===jt.EXTERIOR&&this._label.setLocation(t,e,jt.EXTERIOR)}}}getLabel(){return this._label}computeLabelSides(t){this.computeLabelSide(t,Ps.LEFT),this.computeLabelSide(t,Ps.RIGHT)}updateIM(t){Ks.updateIM(this._label,t)}computeLabel(t){let e=!1;for(let t=this.iterator();t.hasNext();){t.next().getLabel().isArea()&&(e=!0)}this._label=e?new As(jt.NONE,jt.NONE,jt.NONE):new As(jt.NONE);for(let s=0;s<2;s++)this.computeLabelOn(s,t),e&&this.computeLabelSides(s)}}class Tr extends Ei{constructor(){super()}updateIM(t){for(let e=this.iterator();e.hasNext();){e.next().updateIM(t)}}insert(t){let e=this._edgeMap.get(t);null===e?(e=new Lr(t),this.insertEdgeEnd(t,e)):e.insert(t)}}class Rr extends Qs{constructor(){super(),Rr.constructor_.apply(this,arguments)}static constructor_(){const t=arguments[0],e=arguments[1];Qs.constructor_.call(this,t,e)}updateIMFromEdges(t){this._edges.updateIM(t)}computeIM(t){t.setAtLeastIfValid(this._label.getLocation(0),this._label.getLocation(1),0)}}class Pr extends sn{constructor(){super()}createNode(t){return new Rr(t,new Tr)}}class Or{constructor(){Or.constructor_.apply(this,arguments)}static constructor_(){this._nodes=new Js(new Pr)}insertEdgeEnds(t){for(let e=t.iterator();e.hasNext();){const t=e.next();this._nodes.add(t)}}getNodeIterator(){return this._nodes.iterator()}copyNodesAndLabels(t,e){for(let s=t.getNodeIterator();s.hasNext();){const t=s.next();this._nodes.addNode(t.getCoordinate()).setLabel(e,t.getLabel().getLocation(e))}}build(t){this.computeIntersectionNodes(t,0),this.copyNodesAndLabels(t,0);const e=(new Sr).computeEdgeEnds(t.getEdgeIterator());this.insertEdgeEnds(e)}computeIntersectionNodes(t,e){for(let s=t.getEdgeIterator();s.hasNext();){const t=s.next(),n=t.getLabel().getLocation(e);for(let s=t.getEdgeIntersectionList().iterator();s.hasNext();){const t=s.next(),i=this._nodes.addNode(t.coord);n===jt.BOUNDARY?i.setLabelBoundary(e):i.getLabel().isNull(e)&&i.setLabel(e,jt.INTERIOR)}}}}class vr{constructor(){vr.constructor_.apply(this,arguments)}static constructor_(){this._li=new Wt,this._geomGraph=null,this._nodeGraph=new Or,this._invalidPoint=null;const t=arguments[0];this._geomGraph=t}isNodeEdgeAreaLabelsConsistent(){for(let t=this._nodeGraph.getNodeIterator();t.hasNext();){const e=t.next();if(!e.getEdges().isAreaLabelsConsistent(this._geomGraph))return this._invalidPoint=e.getCoordinate().copy(),!1}return!0}getInvalidPoint(){return this._invalidPoint}hasDuplicateRings(){for(let t=this._nodeGraph.getNodeIterator();t.hasNext();){for(let e=t.next().getEdges().iterator();e.hasNext();){const t=e.next();if(t.getEdgeEnds().size()>1)return this._invalidPoint=t.getEdge().getCoordinate(0),!0}}return!1}isNodeConsistentArea(){const t=this._geomGraph.computeSelfNodes(this._li,!0,!0);return t.hasProperIntersection()?(this._invalidPoint=t.getProperIntersectionPoint(),!1):(this._nodeGraph.build(this._geomGraph),this.isNodeEdgeAreaLabelsConsistent())}}class Mr{constructor(){Mr.constructor_.apply(this,arguments)}static constructor_(){this._graph=null,this._rings=new S,this._totalEnv=new P,this._index=null,this._nestedPt=null;const t=arguments[0];this._graph=t}buildIndex(){this._index=new Pn;for(let t=0;t=1&&(e=t.getCoordinateN(0)),this._validErr=new br(br.RING_NOT_CLOSED,e)}}checkShellsNotNested(t,e){for(let s=0;s=0;e--)s.add(t[e],!1)}static findEdgeRingContaining(t,e){const s=t.getRing(),n=s.getEnvelopeInternal();let i=s.getCoordinateN(0),r=null,o=null;for(let t=e.iterator();t.hasNext();){const e=t.next(),l=e.getRing().getEnvelopeInternal();if(l.equals(n))continue;if(!l.contains(n))continue;i=gt.ptNotInList(s.getCoordinates(),e.getCoordinates());e.isInRing(i)&&(null===r||o.contains(l))&&(r=e,o=r.getRing().getEnvelopeInternal())}return r}isIncluded(){return this._isIncluded}getCoordinates(){if(null===this._ringPts){const t=new T;for(let e=this._deList.iterator();e.hasNext();){const s=e.next(),n=s.getEdge();Ar.addEdge(n.getLine().getCoordinates(),s.getEdgeDirection(),t)}this._ringPts=t.toCoordinateArray()}return this._ringPts}isIncludedSet(){return this._isIncludedSet}isValid(){return this.getCoordinates(),!(this._ringPts.length<=3)&&(this.getRing(),Dr.isValid(this._ring))}build(t){let e=t;do{this.add(e),e.setRing(this),e=e.getNext(),u.isTrue(null!==e,"found null DE in ring"),u.isTrue(e===t||!e.isInRing(),"found DE already in ring")}while(e!==t)}isInRing(t){return jt.EXTERIOR!==this.getLocator().locate(t)}isOuterHole(){return!!this._isHole&&!this.hasShell()}getPolygon(){let t=null;if(null!==this._holes){t=new Array(this._holes.size()).fill(null);for(let e=0;e=0)continue;e.add(t);const i=Ar.findDirEdgesInRing(t);Fr.label(i,s),s++}return e}static getDegreeNonDeleted(t){let e=0;for(let s=t.getOutEdges().getEdges().iterator();s.hasNext();){s.next().isMarked()||e++}return e}static deleteAllEdges(t){for(let e=t.getOutEdges().getEdges().iterator();e.hasNext();){const t=e.next();t.setMarked(!0);const s=t.getSym();null!==s&&s.setMarked(!0)}}static label(t,e){for(let s=t.iterator();s.hasNext();){s.next().setLabel(e)}}static computeNextCWEdges(t){let e=null,s=null;for(let n=t.getOutEdges().getEdges().iterator();n.hasNext();){const t=n.next();if(!t.isMarked()){if(null===e&&(e=t),null!==s){s.getSym().setNext(t)}s=t}}if(null!==s){s.getSym().setNext(e)}}static computeNextCCWEdges(t,e){let s=null,n=null;const i=t.getOutEdges().getEdges();for(let t=i.size()-1;t>=0;t--){const r=i.get(t),o=r.getSym();let l=null;r.getLabel()===e&&(l=r);let a=null;o.getLabel()===e&&(a=o),null===l&&null===a||(null!==a&&(n=a),null!==l&&(null!==n&&(n.setNext(l),n=null),null===s&&(s=l)))}null!==n&&(u.isTrue(null!==s),n.setNext(s))}static getDegree(t,e){let s=0;for(let n=t.getOutEdges().getEdges().iterator();n.hasNext();){n.next().getLabel()===e&&s++}return s}static findIntersectionNodes(t,e){let s=t,n=null;do{const i=s.getFromNode();Fr.getDegree(i,e)>1&&(null===n&&(n=new S),n.add(i)),s=s.getNext(),u.isTrue(null!==s,"found null DE in ring"),u.isTrue(s===t||!s.isInRing(),"found DE already in ring")}while(s!==t);return n}findEdgeRing(t){const e=new Ar(this._factory);return e.build(t),e}computeDepthParity(){if(0===arguments.length)for(;;)return null}computeNextCWEdges(){for(let t=this.nodeIterator();t.hasNext();){const e=t.next();Fr.computeNextCWEdges(e)}}addEdge(t){if(t.isEmpty())return null;const e=gt.removeRepeatedPoints(t.getCoordinates());if(e.length<2)return null;const s=e[0],n=e[e.length-1],i=this.getNode(s),r=this.getNode(n),o=new Nr(i,r,e[1],!0),l=new Nr(r,i,e[e.length-2],!1),a=new Cr(t);a.setDirectedEdges(o,l),this.add(a)}deleteCutEdges(){this.computeNextCWEdges(),Fr.findLabeledEdgeRings(this._dirEdges);const t=new S;for(let e=this._dirEdges.iterator();e.hasNext();){const s=e.next();if(s.isMarked())continue;const n=s.getSym();if(s.getLabel()===n.getLabel()){s.setMarked(!0),n.setMarked(!0);const e=s.getEdge();t.add(e.getLine())}}return t}getEdgeRings(){this.computeNextCWEdges(),Fr.label(this._dirEdges,-1);const t=Fr.findLabeledEdgeRings(this._dirEdges);this.convertMaximalToMinimalEdgeRings(t);const e=new S;for(let t=this._dirEdges.iterator();t.hasNext();){const s=t.next();if(s.isMarked())continue;if(s.isInRing())continue;const n=this.findEdgeRing(s);e.add(n)}return e}getNode(t){let e=this.findNode(t);return null===e&&(e=new Wi(t),this.add(e)),e}convertMaximalToMinimalEdgeRings(t){for(let e=t.iterator();e.hasNext();){const t=e.next(),s=t.getLabel(),n=Fr.findIntersectionNodes(t,s);if(null!==n)for(let t=n.iterator();t.hasNext();){const e=t.next();Fr.computeNextCCWEdges(e,s)}}}deleteDangles(){const t=this.findNodesOfDegree(1),e=new yt,s=new $e;for(let e=t.iterator();e.hasNext();)s.push(e.next());for(;!s.isEmpty();){const t=s.pop();Fr.deleteAllEdges(t);for(let n=t.getOutEdges().getEdges().iterator();n.hasNext();){const t=n.next();t.setMarked(!0);const i=t.getSym();null!==i&&i.setMarked(!0);const r=t.getEdge();e.add(r.getLine());const o=t.getToNode();1===Fr.getDegreeNonDeleted(o)&&s.push(o)}}return e}}class Gr{constructor(){Gr.constructor_.apply(this,arguments)}static constructor_(){this._shells=null,this._shellIndex=null;const t=arguments[0];this._shells=t,this.buildIndex()}static assignHolesToShells(t,e){new Gr(e).assignHolesToShells(t)}assignHolesToShells(t){for(let e=t.iterator();e.hasNext();){const t=e.next();this.assignHoleToShell(t)}}buildIndex(){this._shellIndex=new Pn;for(const t of this._shells)this._shellIndex.insert(t.getRing().getEnvelopeInternal(),t)}queryOverlappingShells(t){return this._shellIndex.query(t)}findShellContaining(t){const e=t.getRing().getEnvelopeInternal(),s=this.queryOverlappingShells(e);return Ar.findEdgeRingContaining(t,s)}assignHoleToShell(t){const e=this.findShellContaining(t);null!==e&&e.addHole(t)}}class qr{constructor(){qr.constructor_.apply(this,arguments)}static constructor_(){if(this._lineStringAdder=new Br(this),this._graph=null,this._dangles=new S,this._cutEdges=new S,this._invalidRingLines=new S,this._holeList=null,this._shellList=null,this._polyList=null,this._isCheckingRingsValid=!0,this._extractOnlyPolygonal=null,this._geomFactory=null,0===arguments.length)qr.constructor_.call(this,!1);else if(1===arguments.length){const t=arguments[0];this._extractOnlyPolygonal=t}}static extractPolygons(t,e){const s=new S;for(let n=t.iterator();n.hasNext();){const t=n.next();(e||t.isIncluded())&&s.add(t.getPolygon())}return s}static findOuterShells(t){for(let e=t.iterator();e.hasNext();){const t=e.next(),s=t.getOuterHole();null===s||s.isProcessed()||(t.setIncluded(!0),s.setProcessed(!0))}}static findDisjointShells(t){qr.findOuterShells(t);let e=null;do{e=!1;for(let s=t.iterator();s.hasNext();){const t=s.next();t.isIncludedSet()||(t.updateIncluded(),t.isIncludedSet()||(e=!0))}}while(e)}getGeometry(){return null===this._geomFactory&&(this._geomFactory=new wt),this.polygonize(),this._extractOnlyPolygonal?this._geomFactory.buildGeometry(this._polyList):this._geomFactory.createGeometryCollection(wt.toGeometryArray(this._polyList))}getInvalidRingLines(){return this.polygonize(),this._invalidRingLines}findValidRings(t,e,s){for(let n=t.iterator();n.hasNext();){const t=n.next();t.isValid()?e.add(t):s.add(t.getLineString())}}polygonize(){if(null!==this._polyList)return null;if(this._polyList=new S,null===this._graph)return null;this._dangles=this._graph.deleteDangles(),this._cutEdges=this._graph.deleteCutEdges();const t=this._graph.getEdgeRings();let e=new S;this._invalidRingLines=new S,this._isCheckingRingsValid?this.findValidRings(t,e,this._invalidRingLines):e=t,this.findShellsAndHoles(e),Gr.assignHolesToShells(this._holeList,this._shellList),fe.sort(this._shellList,new Ar.EnvelopeComparator);let s=!0;this._extractOnlyPolygonal&&(qr.findDisjointShells(this._shellList),s=!1),this._polyList=qr.extractPolygons(this._shellList,s)}getDangles(){return this.polygonize(),this._dangles}getCutEdges(){return this.polygonize(),this._cutEdges}getPolygons(){return this.polygonize(),this._polyList}add(){if(E(arguments[0],I)){for(let t=arguments[0].iterator();t.hasNext();){const e=t.next();this.add(e)}}else if(arguments[0]instanceof Q){const t=arguments[0];this._geomFactory=t.getFactory(),null===this._graph&&(this._graph=new Fr(this._geomFactory)),this._graph.addEdge(t)}else if(arguments[0]instanceof X){arguments[0].apply(this._lineStringAdder)}}setCheckRingsValid(t){this._isCheckingRingsValid=t}findShellsAndHoles(t){this._holeList=new S,this._shellList=new S;for(let e=t.iterator();e.hasNext();){const t=e.next();t.computeHole(),t.isHole()?this._holeList.add(t):this._shellList.add(t)}}}class Br{constructor(){Br.constructor_.apply(this,arguments)}static constructor_(){this.p=null;const t=arguments[0];this.p=t}filter(t){t instanceof Q&&this.p.add(t)}get interfaces_(){return[z]}}qr.LineStringAdder=Br;var Yr=Object.freeze({__proto__:null,Polygonizer:qr});class Vr{constructor(){Vr.constructor_.apply(this,arguments)}static constructor_(){this._li=new Wt,this._ptLocator=new _s,this._arg=null,this._nodes=new Js(new Pr),this._im=null,this._isolatedEdges=new S,this._invalidPoint=null;const t=arguments[0];this._arg=t}insertEdgeEnds(t){for(let e=t.iterator();e.hasNext();){const t=e.next();this._nodes.add(t)}}computeProperIntersectionIM(t,e){const s=this._arg[0].getGeometry().getDimension(),n=this._arg[1].getGeometry().getDimension(),i=t.hasProperIntersection(),r=t.hasProperInteriorIntersection();2===s&&2===n?i&&e.setAtLeast("212101212"):2===s&&1===n?(i&&e.setAtLeast("FFF0FFFF2"),r&&e.setAtLeast("1FFFFF1FF")):1===s&&2===n?(i&&e.setAtLeast("F0FFFFFF2"),r&&e.setAtLeast("1F1FFFFFF")):1===s&&1===n&&r&&e.setAtLeast("0FFFFFFFF")}labelIsolatedEdges(t,e){for(let s=this._arg[t].getEdgeIterator();s.hasNext();){const t=s.next();t.isIsolated()&&(this.labelIsolatedEdge(t,e,this._arg[e].getGeometry()),this._isolatedEdges.add(t))}}labelIsolatedEdge(t,e,s){if(s.getDimension()>0){const n=this._ptLocator.locate(t.getCoordinate(),s);t.getLabel().setAllLocations(e,n)}else t.getLabel().setAllLocations(e,jt.EXTERIOR)}computeIM(){const t=new Kt;if(t.set(jt.EXTERIOR,jt.EXTERIOR,2),!this._arg[0].getGeometry().getEnvelopeInternal().intersects(this._arg[1].getGeometry().getEnvelopeInternal()))return this.computeDisjointIM(t),t;this._arg[0].computeSelfNodes(this._li,!1),this._arg[1].computeSelfNodes(this._li,!1);const e=this._arg[0].computeEdgeIntersections(this._arg[1],this._li,!1);this.computeIntersectionNodes(0),this.computeIntersectionNodes(1),this.copyNodesAndLabels(0),this.copyNodesAndLabels(1),this.labelIsolatedNodes(),this.computeProperIntersectionIM(e,t);const s=new Sr,n=s.computeEdgeEnds(this._arg[0].getEdgeIterator());this.insertEdgeEnds(n);const i=s.computeEdgeEnds(this._arg[1].getEdgeIterator());return this.insertEdgeEnds(i),this.labelNodeEdges(),this.labelIsolatedEdges(0,1),this.labelIsolatedEdges(1,0),this.updateIM(t),t}labelNodeEdges(){for(let t=this._nodes.iterator();t.hasNext();){t.next().getEdges().computeLabelling(this._arg)}}copyNodesAndLabels(t){for(let e=this._arg[t].getNodeIterator();e.hasNext();){const s=e.next();this._nodes.addNode(s.getCoordinate()).setLabel(t,s.getLabel().getLocation(t))}}labelIntersectionNodes(t){for(let e=this._arg[t].getEdgeIterator();e.hasNext();){const s=e.next(),n=s.getLabel().getLocation(t);for(let e=s.getEdgeIntersectionList().iterator();e.hasNext();){const s=e.next(),i=this._nodes.find(s.coord);i.getLabel().isNull(t)&&(n===jt.BOUNDARY?i.setLabelBoundary(t):i.setLabel(t,jt.INTERIOR))}}}labelIsolatedNode(t,e){const s=this._ptLocator.locate(t.getCoordinate(),this._arg[e].getGeometry());t.getLabel().setAllLocations(e,s)}computeIntersectionNodes(t){for(let e=this._arg[t].getEdgeIterator();e.hasNext();){const s=e.next(),n=s.getLabel().getLocation(t);for(let e=s.getEdgeIntersectionList().iterator();e.hasNext();){const s=e.next(),i=this._nodes.addNode(s.coord);n===jt.BOUNDARY?i.setLabelBoundary(t):i.getLabel().isNull(t)&&i.setLabel(t,jt.INTERIOR)}}}labelIsolatedNodes(){for(let t=this._nodes.iterator();t.hasNext();){const e=t.next(),s=e.getLabel();u.isTrue(s.getGeometryCount()>0,"node with empty label found"),e.isIsolated()&&(s.isNull(0)?this.labelIsolatedNode(e,0):this.labelIsolatedNode(e,1))}}updateIM(t){for(let e=this._isolatedEdges.iterator();e.hasNext();){e.next().updateIM(t)}for(let e=this._nodes.iterator();e.hasNext();){const s=e.next();s.updateIM(t),s.updateIMFromEdges(t)}}computeDisjointIM(t){const e=this._arg[0].getGeometry();e.isEmpty()||(t.set(jt.INTERIOR,jt.EXTERIOR,e.getDimension()),t.set(jt.BOUNDARY,jt.EXTERIOR,e.getBoundaryDimension()));const s=this._arg[1].getGeometry();s.isEmpty()||(t.set(jt.EXTERIOR,jt.INTERIOR,s.getDimension()),t.set(jt.EXTERIOR,jt.BOUNDARY,s.getBoundaryDimension()))}}class zr{constructor(){zr.constructor_.apply(this,arguments)}static constructor_(){this._rectEnv=null;const t=arguments[0];this._rectEnv=t.getEnvelopeInternal()}static contains(t,e){return new zr(t).contains(e)}isContainedInBoundary(t){if(t instanceof nt)return!1;if(t instanceof $)return this.isPointContainedInBoundary(t);if(t instanceof Q)return this.isLineStringContainedInBoundary(t);for(let e=0;e0){const s=t;t=e,e=s}let n=!1;return e.y>t.y&&(n=!0),n?this._li.computeIntersection(t,e,this._diagDown0,this._diagDown1):this._li.computeIntersection(t,e,this._diagUp0,this._diagUp1),!!this._li.hasIntersection()}}class kr{constructor(){kr.constructor_.apply(this,arguments)}static constructor_(){this._rectangle=null,this._rectEnv=null;const t=arguments[0];this._rectangle=t,this._rectEnv=t.getEnvelopeInternal()}static intersects(t,e){return new kr(t).intersects(e)}intersects(t){if(!this._rectEnv.intersects(t.getEnvelopeInternal()))return!1;const e=new Ur(this._rectEnv);if(e.applyTo(t),e.intersects())return!0;const s=new Hr(this._rectangle);if(s.applyTo(t),s.containsPoint())return!0;const n=new Wr(this._rectangle);return n.applyTo(t),!!n.intersects()}}class Ur extends Ee{constructor(){super(),Ur.constructor_.apply(this,arguments)}static constructor_(){this._rectEnv=null,this._intersects=!1;const t=arguments[0];this._rectEnv=t}isDone(){return!0===this._intersects}visit(t){const e=t.getEnvelopeInternal();return this._rectEnv.intersects(e)?this._rectEnv.contains(e)||e.getMinX()>=this._rectEnv.getMinX()&&e.getMaxX()<=this._rectEnv.getMaxX()||e.getMinY()>=this._rectEnv.getMinY()&&e.getMaxY()<=this._rectEnv.getMaxY()?(this._intersects=!0,null):void 0:null}intersects(){return this._intersects}}class Hr extends Ee{constructor(){super(),Hr.constructor_.apply(this,arguments)}static constructor_(){this._rectSeq=null,this._rectEnv=null,this._containsPoint=!1;const t=arguments[0];this._rectSeq=t.getExteriorRing().getCoordinateSequence(),this._rectEnv=t.getEnvelopeInternal()}isDone(){return!0===this._containsPoint}visit(t){if(!(t instanceof nt))return null;const e=t.getEnvelopeInternal();if(!this._rectEnv.intersects(e))return null;const s=new p;for(let n=0;n<4;n++)if(this._rectSeq.getCoordinate(n,s),e.contains(s)&&He.containsPointInPolygon(s,t))return this._containsPoint=!0,null}containsPoint(){return this._containsPoint}}class Wr extends Ee{constructor(){super(),Wr.constructor_.apply(this,arguments)}static constructor_(){this._rectEnv=null,this._rectIntersector=null,this._hasIntersection=!1,this._p0=new p,this._p1=new p;const t=arguments[0];this._rectEnv=t.getEnvelopeInternal(),this._rectIntersector=new Xr(this._rectEnv)}intersects(){return this._hasIntersection}isDone(){return!0===this._hasIntersection}visit(t){const e=t.getEnvelopeInternal();if(!this._rectEnv.intersects(e))return null;const s=me.getLines(t);this.checkIntersectionWithLineStrings(s)}checkIntersectionWithLineStrings(t){for(let e=t.iterator();e.hasNext();){const t=e.next();if(this.checkIntersectionWithSegments(t),this._hasIntersection)return null}}checkIntersectionWithSegments(t){const e=t.getCoordinateSequence();for(let t=1;t0)&&(!!t.getEnvelopeInternal().covers(e.getEnvelopeInternal())&&(!!t.isRectangle()||new Zr(t,e).getIntersectionMatrix().isCovers())))}static intersects(t,e){if(!t.getEnvelopeInternal().intersects(e.getEnvelopeInternal()))return!1;if(t.isRectangle())return kr.intersects(t,e);if(e.isRectangle())return kr.intersects(e,t);if(t.isGeometryCollection()||e.isGeometryCollection()){for(let s=0;s0)&&(!!t.getEnvelopeInternal().contains(e.getEnvelopeInternal())&&(t.isRectangle()?zr.contains(t,e):new Zr(t,e).getIntersectionMatrix().isContains())))}getIntersectionMatrix(){return this._relate.computeIM()}}var jr=Object.freeze({__proto__:null,RelateOp:Zr});class Kr{constructor(){Kr.constructor_.apply(this,arguments)}static constructor_(){this._pointGeom=null,this._otherGeom=null,this._geomFact=null;const t=arguments[0],e=arguments[1];this._pointGeom=t,this._otherGeom=e,this._geomFact=e.getFactory()}static union(t,e){return new Kr(t,e).union()}union(){const t=new _s,e=new ot;for(let s=0;sthis._dimension&&(this._dimension=t)}getDimension(){return this._dimension}filter(t){return this.recordDimension(t.getDimension()),t instanceof at||t.isEmpty()?null:t instanceof nt?(this._polygons.add(t),null):t instanceof Q?(this._lines.add(t),null):t instanceof $?(this._points.add(t),null):void u.shouldNeverReachHere("Unhandled geometry type: "+t.getGeometryType())}getExtract(t){switch(t){case 0:return this._points;case 1:return this._lines;case 2:return this._polygons}return u.shouldNeverReachHere("Invalid dimension: "+t),null}isEmpty(){return this._polygons.isEmpty()&&this._lines.isEmpty()&&this._points.isEmpty()}add(){if(E(arguments[0],I)){const t=arguments[0];for(const e of t)this.add(e)}else if(arguments[0]instanceof X){const t=arguments[0];null===this._geomFactory&&(this._geomFactory=t.getFactory()),t.apply(this)}}get interfaces_(){return[K]}}class Jr{constructor(){Jr.constructor_.apply(this,arguments)}static constructor_(){this._geomFactory=null,this._g0=null,this._g1=null,this._isUnionSafe=null;const t=arguments[0],e=arguments[1];this._g0=t,this._g1=e,this._geomFactory=t.getFactory()}static containsProperly(){if(2===arguments.length){const t=arguments[0],e=arguments[1];return!t.isNull()&&(e.getX()>t.getMinX()&&e.getX()t.getMinY()&&e.getY()=t.size()?null:t.get(e)}static union(t){return new $r(t).union()}reduceToGeometries(t){const e=new S;for(let s=t.iterator();s.hasNext();){const t=s.next();let n=null;E(t,C)?n=this.unionTree(t):t instanceof X&&(n=t),e.add(n)}return e}union(){if(null===this._inputPolys)throw new IllegalStateException("union() method cannot be called twice");if(this._inputPolys.isEmpty())return null;this._geomFactory=this._inputPolys.iterator().next().getFactory();const t=new Pn($r.STRTREE_NODE_CAPACITY);for(let e=this._inputPolys.iterator();e.hasNext();){const s=e.next();t.insert(s.getEnvelopeInternal(),s)}this._inputPolys=null;const e=t.itemsTree();return this.unionTree(e)}binaryUnion(){if(1===arguments.length){const t=arguments[0];return this.binaryUnion(t,0,t.size())}if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];if(s-e<=1){const s=$r.getGeometry(t,e);return this.unionSafe(s,null)}if(s-e==2)return this.unionSafe($r.getGeometry(t,e),$r.getGeometry(t,e+1));{const n=Math.trunc((s+e)/2),i=this.binaryUnion(t,e,n),r=this.binaryUnion(t,n,s);return this.unionSafe(i,r)}}}repeatedUnion(t){let e=null;for(let s=t.iterator();s.hasNext();){const t=s.next();e=null===e?t.copy():e.union(t)}return e}unionSafe(t,e){return null===t&&null===e?null:null===t?e.copy():null===e?t.copy():this.unionActual(t,e)}unionActual(t,e){const s=Jr.union(t,e);return $r.restrictToPolygons(s)}unionTree(t){const e=this.reduceToGeometries(t);return this.binaryUnion(e)}bufferUnion(){if(1===arguments.length){const t=arguments[0];return t.get(0).getFactory().buildGeometry(t).buffer(0)}if(2===arguments.length){const t=arguments[0],e=arguments[1];return t.getFactory().createGeometryCollection([t,e]).buffer(0)}}}$r.STRTREE_NODE_CAPACITY=4;class to{constructor(){to.constructor_.apply(this,arguments)}static constructor_(){if(this._geomFact=null,this._extracter=null,1===arguments.length){if(E(arguments[0],I)){const t=arguments[0];this.extract(t)}else if(arguments[0]instanceof X){const t=arguments[0];this.extract(t)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this._geomFact=e,this.extract(t)}}static union(){if(1===arguments.length){if(E(arguments[0],I)){return new to(arguments[0]).union()}if(arguments[0]instanceof X){return new to(arguments[0]).union()}}else if(2===arguments.length){return new to(arguments[0],arguments[1]).union()}}unionNoOpt(t){const e=this._geomFact.createPoint();return yr.overlayOp(t,e,Er.UNION)}unionWithNull(t,e){return null===t&&null===e?null:null===e?t:null===t?e:t.union(e)}extract(){if(E(arguments[0],I)){const t=arguments[0];this._extracter=Qr.extract(t)}else if(arguments[0]instanceof X){const t=arguments[0];this._extracter=Qr.extract(t)}}union(){if(null===this._geomFact&&(this._geomFact=this._extracter.getFactory()),null===this._geomFact)return null;if(this._extracter.isEmpty())return this._geomFact.createEmpty(this._extracter.getDimension());const t=this._extracter.getExtract(0),e=this._extracter.getExtract(1),s=this._extracter.getExtract(2);let n=null;if(t.size()>0){const e=this._geomFact.buildGeometry(t);n=this.unionNoOpt(e)}let i=null;if(e.size()>0){const t=this._geomFact.buildGeometry(e);i=this.unionNoOpt(t)}let r=null;s.size()>0&&(r=$r.union(s));const o=this.unionWithNull(i,r);let l=null;return l=null===n?o:null===o?n:Kr.union(n,o),null===l?this._geomFact.createGeometryCollection():l}}var eo=Object.freeze({__proto__:null,UnaryUnionOp:to}),so=Object.freeze({__proto__:null,IsValidOp:Dr,ConsistentAreaTester:vr}),no=Object.freeze({__proto__:null,BoundaryOp:ei,IsSimpleOp:ni,buffer:Fi,distance:Yi,linemerge:sr,overlay:Ir,polygonize:Yr,relate:jr,union:eo,valid:so});class io{constructor(){io.constructor_.apply(this,arguments)}static constructor_(){if(this._returnToOriginalPrecision=!0,this._cbr=null,0===arguments.length)io.constructor_.call(this,!0);else if(1===arguments.length){const t=arguments[0];this._returnToOriginalPrecision=t}}computeResultPrecision(t){return this._returnToOriginalPrecision&&this._cbr.addCommonBits(t),t}union(t,e){const s=this.removeCommonBits(t,e);return this.computeResultPrecision(s[0].union(s[1]))}intersection(t,e){const s=this.removeCommonBits(t,e);return this.computeResultPrecision(s[0].intersection(s[1]))}removeCommonBits(){if(1===arguments.length){const t=arguments[0];this._cbr=new _r,this._cbr.add(t);return this._cbr.removeCommonBits(t.copy())}if(2===arguments.length){const t=arguments[0],e=arguments[1];this._cbr=new _r,this._cbr.add(t),this._cbr.add(e);const s=new Array(2).fill(null);return s[0]=this._cbr.removeCommonBits(t.copy()),s[1]=this._cbr.removeCommonBits(e.copy()),s}}buffer(t,e){const s=this.removeCommonBits(t);return this.computeResultPrecision(s.buffer(e))}symDifference(t,e){const s=this.removeCommonBits(t,e);return this.computeResultPrecision(s[0].symDifference(s[1]))}difference(t,e){const s=this.removeCommonBits(t,e);return this.computeResultPrecision(s[0].difference(s[1]))}}class ro extends ce.CoordinateOperation{constructor(){super(),ro.constructor_.apply(this,arguments)}static constructor_(){this._targetPM=null,this._removeCollapsed=!0;const t=arguments[0],e=arguments[1];this._targetPM=t,this._removeCollapsed=e}edit(){if(2===arguments.length&&arguments[1]instanceof X&&arguments[0]instanceof Array){const t=arguments[0],e=arguments[1];if(0===t.length)return null;const s=new Array(t.length).fill(null);for(let e=0;e=2&&(s=!0);return e.edit(t,new ro(this._targetPM,s))}changePM(t,e){return this.createEditor(t.getFactory(),e).edit(t,new ce.NoOpGeometryOperation)}setRemoveCollapsedComponents(t){this._removeCollapsed=t}createFactory(t,e){return new wt(e,t.getSRID(),t.getCoordinateSequenceFactory())}setChangePrecisionModel(t){this._changePrecisionModel=t}reduce(t){const e=this.reducePointwise(t);return this._isPointwise?e:E(e,st)?Dr.isValid(e)?e:this.fixPolygonalTopology(e):e}setPointwise(t){this._isPointwise=t}createEditor(t,e){if(t.getPrecisionModel()===e)return new ce;const s=this.createFactory(t,e);return new ce(s)}}class lo{constructor(){lo.constructor_.apply(this,arguments)}static constructor_(){if(this._geom=null,this._pts=null,this._start=null,this._end=null,2===arguments.length){const t=arguments[0],e=arguments[1];this._pts=t,this._start=e,this._end=e+1}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this._pts=t,this._start=e,this._end=s}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];this._geom=t,this._pts=e,this._start=s,this._end=n}}computeDistanceLineLine(t,e){let s=i.MAX_VALUE;for(let n=this._start;nthis._start&&t.append(", "),this._pts.getCoordinate(s,e),t.append(e.x+" "+e.y);return t.append(" )"),t.toString()}computeDistancePointLine(t,e,s){let n=i.MAX_VALUE;for(let i=e._start;i=i-1&&(r=i);const o=new lo(t,e,n,r);s.add(o),n+=ao.FACET_SEQUENCE_SIZE}}static computeFacetSequences(t){const e=new S;return t.apply(new class{get interfaces_(){return[z]}filter(t){let s=null;(t instanceof Q||t instanceof $)&&(s=t.getCoordinateSequence(),ao.addFacetSequences(t,s,e))}}),e}static build(t){const e=new Pn(ao.STR_TREE_NODE_CAPACITY);for(let s=ao.computeFacetSequences(t).iterator();s.hasNext();){const t=s.next();e.insert(t.getEnvelope(),t)}return e.build(),e}}ao.FACET_SEQUENCE_SIZE=6,ao.STR_TREE_NODE_CAPACITY=4;class co{constructor(){co.constructor_.apply(this,arguments)}static constructor_(){this._inputGeom=null,this._minClearance=null,this._minClearancePts=null;const t=arguments[0];this._inputGeom=t}static getLine(t){return new co(t).getLine()}static getDistance(t){return new co(t).getDistance()}getLine(){return this.compute(),null===this._minClearancePts||null===this._minClearancePts[0]?this._inputGeom.getFactory().createLineString():this._inputGeom.getFactory().createLineString(this._minClearancePts)}compute(){if(null!==this._minClearancePts)return null;if(this._minClearancePts=new Array(2).fill(null),this._minClearance=i.MAX_VALUE,this._inputGeom.isEmpty())return null;const t=ao.build(this._inputGeom).nearestNeighbour(new ho),e=new ho;this._minClearance=e.distance(t[0],t[1]),this._minClearancePts=e.getCoordinates()}getDistance(){return this.compute(),this._minClearance}}class ho{constructor(){ho.constructor_.apply(this,arguments)}static constructor_(){this._minDist=i.MAX_VALUE,this._minPts=new Array(2).fill(null)}vertexDistance(t,e){for(let s=0;s0&&this.smc.updateClearance(e,this._queryPt,t)}filter(t,e){this.checkVertexDistance(t.getCoordinate(e)),e>0&&this.checkSegmentDistance(t.getCoordinate(e-1),t.getCoordinate(e))}checkSegmentDistance(t,e){if(this._queryPt.equals2D(t)||this._queryPt.equals2D(e))return null;const s=Y.pointToSegment(this._queryPt,e,t);s>0&&this.smc.updateClearance(s,this._queryPt,e,t)}isDone(){return!1}get interfaces_(){return[R]}}uo.VertexCoordinateFilter=go,uo.ComputeMCCoordinateSequenceFilter=_o;var po=Object.freeze({__proto__:null,CommonBits:dr,CommonBitsOp:io,CommonBitsRemover:_r,EnhancedPrecisionOp:class{static union(t,e){let s=null;try{return t.union(e)}catch(t){if(!(t instanceof c))throw t;s=t}try{const n=new io(!0).union(t,e);if(!n.isValid())throw s;return n}catch(t){throw t instanceof c?s:t}}static intersection(t,e){let s=null;try{return t.intersection(e)}catch(t){if(!(t instanceof c))throw t;s=t}try{const n=new io(!0).intersection(t,e);if(!n.isValid())throw s;return n}catch(t){throw t instanceof c?s:t}}static buffer(t,e){let s=null;try{return t.buffer(e)}catch(t){if(!(t instanceof c))throw t;s=t}try{const n=new io(!0).buffer(t,e);if(!n.isValid())throw s;return n}catch(t){throw t instanceof c?s:t}}static symDifference(t,e){let s=null;try{return t.symDifference(e)}catch(t){if(!(t instanceof c))throw t;s=t}try{const n=new io(!0).symDifference(t,e);if(!n.isValid())throw s;return n}catch(t){throw t instanceof c?s:t}}static difference(t,e){let s=null;try{return t.difference(e)}catch(t){if(!(t instanceof c))throw t;s=t}try{const n=new io(!0).difference(t,e);if(!n.isValid())throw s;return n}catch(t){throw t instanceof c?s:t}}},GeometryPrecisionReducer:oo,MinimumClearance:co,SimpleMinimumClearance:uo});class mo{constructor(){mo.constructor_.apply(this,arguments)}static constructor_(){this._pts=null,this._usePt=null,this._distanceTolerance=null,this._seg=new Zt;const t=arguments[0];this._pts=t}static simplify(t,e){const s=new mo(t);return s.setDistanceTolerance(e),s.simplify()}simplifySection(t,e){if(t+1===e)return null;this._seg.p0=this._pts[t],this._seg.p1=this._pts[e];let s=-1,n=t;for(let i=t+1;is&&(s=t,n=i)}if(s<=this._distanceTolerance)for(let s=t+1;s=e[0]&&nthis._distanceTolerance&&(i=!1);const l=new Zt;if(l.p0=this._linePts[t],l.p1=this._linePts[e],n[0]=t,n[1]=e,this.hasBadIntersection(this._line,n,l)&&(i=!1),i){const s=this.flatten(t,e);return this._line.addToResult(s),null}this.simplifySection(t,o,s),this.simplifySection(o,e,s)}hasBadOutputIntersection(t){for(let e=this._outputIndex.query(t).iterator();e.hasNext();){const s=e.next();if(this.hasInteriorIntersection(s,t))return!0}return!1}findFurthestPoint(t,e,s,n){const i=new Zt;i.p0=t[e],i.p1=t[s];let r=-1,o=e;for(let n=e+1;nr&&(r=s,o=n)}return n[0]=r,o}simplify(t){this._line=t,this._linePts=t.getParentCoordinates(),this.simplifySection(0,this._linePts.length-1,0)}remove(t,e,s){for(let n=e;nn&&(o=n),i.setMinimumLength(o),i.splitAt(r),i.getSplitPoint()}get interfaces_(){return[Do]}}class Fo{static triArea(t,e,s){return(e.x-t.x)*(s.y-t.y)-(e.y-t.y)*(s.x-t.x)}static isInCircleDDNormalized(t,e,s,n){const i=b.valueOf(t.x).selfSubtract(n.x),r=b.valueOf(t.y).selfSubtract(n.y),o=b.valueOf(e.x).selfSubtract(n.x),l=b.valueOf(e.y).selfSubtract(n.y),a=b.valueOf(s.x).selfSubtract(n.x),c=b.valueOf(s.y).selfSubtract(n.y),h=i.multiply(l).selfSubtract(o.multiply(r)),u=o.multiply(c).selfSubtract(a.multiply(l)),g=a.multiply(r).selfSubtract(i.multiply(c)),d=i.multiply(i).selfAdd(r.multiply(r)),_=o.multiply(o).selfAdd(l.multiply(l)),p=a.multiply(a).selfAdd(c.multiply(c));return d.selfMultiply(u).selfAdd(_.selfMultiply(g)).selfAdd(p.selfMultiply(h)).doubleValue()>0}static checkRobustInCircle(t,e,s,n){const i=Fo.isInCircleNonRobust(t,e,s,n),r=Fo.isInCircleDDSlow(t,e,s,n),o=Fo.isInCircleCC(t,e,s,n),l=te.circumcentre(t,e,s);q.out.println("p radius diff a = "+Math.abs(n.distance(l)-t.distance(l))/t.distance(l)),i===r&&i===o||(q.out.println("inCircle robustness failure (double result = "+i+", DD result = "+r+", CC result = "+o+")"),q.out.println(Ut.toLineString(new _t([t,e,s,n]))),q.out.println("Circumcentre = "+Ut.toPoint(l)+" radius = "+t.distance(l)),q.out.println("p radius diff a = "+Math.abs(n.distance(l)/t.distance(l)-1)),q.out.println("p radius diff b = "+Math.abs(n.distance(l)/e.distance(l)-1)),q.out.println("p radius diff c = "+Math.abs(n.distance(l)/s.distance(l)-1)),q.out.println())}static isInCircleDDFast(t,e,s,n){const i=b.sqr(t.x).selfAdd(b.sqr(t.y)).selfMultiply(Fo.triAreaDDFast(e,s,n)),r=b.sqr(e.x).selfAdd(b.sqr(e.y)).selfMultiply(Fo.triAreaDDFast(t,s,n)),o=b.sqr(s.x).selfAdd(b.sqr(s.y)).selfMultiply(Fo.triAreaDDFast(t,e,n)),l=b.sqr(n.x).selfAdd(b.sqr(n.y)).selfMultiply(Fo.triAreaDDFast(t,e,s));return i.selfSubtract(r).selfAdd(o).selfSubtract(l).doubleValue()>0}static isInCircleCC(t,e,s,n){const i=te.circumcentre(t,e,s),r=t.distance(i);return n.distance(i)-r<=0}static isInCircleNormalized(t,e,s,n){const i=t.x-n.x,r=t.y-n.y,o=e.x-n.x,l=e.y-n.y,a=s.x-n.x,c=s.y-n.y;return(i*i+r*r)*(o*c-a*l)+(o*o+l*l)*(a*r-i*c)+(a*a+c*c)*(i*l-o*r)>0}static isInCircleDDSlow(t,e,s,n){const i=b.valueOf(n.x),r=b.valueOf(n.y),o=b.valueOf(t.x),l=b.valueOf(t.y),a=b.valueOf(e.x),c=b.valueOf(e.y),h=b.valueOf(s.x),u=b.valueOf(s.y),g=o.multiply(o).add(l.multiply(l)).multiply(Fo.triAreaDDSlow(a,c,h,u,i,r)),d=a.multiply(a).add(c.multiply(c)).multiply(Fo.triAreaDDSlow(o,l,h,u,i,r)),_=h.multiply(h).add(u.multiply(u)).multiply(Fo.triAreaDDSlow(o,l,a,c,i,r)),p=i.multiply(i).add(r.multiply(r)).multiply(Fo.triAreaDDSlow(o,l,a,c,h,u));return g.subtract(d).add(_).subtract(p).doubleValue()>0}static isInCircleNonRobust(t,e,s,n){return(t.x*t.x+t.y*t.y)*Fo.triArea(e,s,n)-(e.x*e.x+e.y*e.y)*Fo.triArea(t,s,n)+(s.x*s.x+s.y*s.y)*Fo.triArea(t,e,n)-(n.x*n.x+n.y*n.y)*Fo.triArea(t,e,s)>0}static isInCircleRobust(t,e,s,n){return Fo.isInCircleNormalized(t,e,s,n)}static triAreaDDSlow(t,e,s,n,i,r){return s.subtract(t).multiply(r.subtract(e)).subtract(n.subtract(e).multiply(i.subtract(t)))}static triAreaDDFast(t,e,s){const n=b.valueOf(e.x).selfSubtract(t.x).selfMultiply(b.valueOf(s.y).selfSubtract(t.y)),i=b.valueOf(e.y).selfSubtract(t.y).selfMultiply(b.valueOf(s.x).selfSubtract(t.x));return n.selfSubtract(i)}}class Go{constructor(){Go.constructor_.apply(this,arguments)}static constructor_(){if(this._p=null,1===arguments.length){const t=arguments[0];this._p=new p(t)}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this._p=new p(t,e)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this._p=new p(t,e,s)}}static interpolateZ(){if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=e.distance(s),i=t.distance(e),r=s.getZ()-e.getZ();return e.getZ()+r*(i/n)}if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=e.x,r=e.y,o=s.x-i,l=n.x-i,a=s.y-r,c=n.y-r,h=o*c-l*a,u=t.x-i,g=t.y-r,d=(c*u-l*g)/h,_=(-a*u+o*g)/h;return e.getZ()+d*(s.getZ()-e.getZ())+_*(n.getZ()-e.getZ())}}circleCenter(t,e){const s=new Go(this.getX(),this.getY()),n=this.bisector(s,t),i=this.bisector(t,e),r=new $t(n,i);let o=null;try{o=new Go(r.getX(),r.getY())}catch(n){if(!(n instanceof Jt))throw n;q.err.println("a: "+s+" b: "+t+" c: "+e),q.err.println(n)}return o}dot(t){return this._p.x*t.getX()+this._p.y*t.getY()}magn(){return Math.sqrt(this._p.x*this._p.x+this._p.y*this._p.y)}getZ(){return this._p.getZ()}bisector(t,e){const s=e.getX()-t.getX(),n=e.getY()-t.getY(),i=new $t(t.getX()+s/2,t.getY()+n/2,1),r=new $t(t.getX()-n+s/2,t.getY()+s+n/2,1);return new $t(i,r)}equals(){if(1===arguments.length){const t=arguments[0];return this._p.x===t.getX()&&this._p.y===t.getY()}if(2===arguments.length){const t=arguments[0],e=arguments[1];return this._p.distance(t.getCoordinate())0}getX(){return this._p.x}crossProduct(t){return this._p.x*t.getY()-this._p.y*t.getX()}setZ(t){this._p.setZ(t)}times(t){return new Go(t*this._p.x,t*this._p.y)}cross(){return new Go(this._p.y,-this._p.x)}leftOf(t){return this.isCCW(t.orig(),t.dest())}toString(){return"POINT ("+this._p.x+" "+this._p.y+")"}sub(t){return new Go(this._p.x-t.getX(),this._p.y-t.getY())}getY(){return this._p.y}classify(t,e){const s=this,n=e.sub(t),i=s.sub(t),r=n.crossProduct(i);return r>0?Go.LEFT:r<0?Go.RIGHT:n.getX()*i.getX()<0||n.getY()*i.getY()<0?Go.BEHIND:n.magn()0}insertSite(t){let e=this._subdiv.locate(t);if(this._subdiv.isVertexOfEdge(e,t))return e;this._subdiv.isOnEdge(e,t.getCoordinate())&&(e=e.oPrev(),this._subdiv.delete(e.oNext()));let s=this._subdiv.makeEdge(e.orig(),t);Bo.splice(s,e);const n=s;do{s=this._subdiv.connect(e,s.sym()),e=s.oPrev()}while(e.lNext()!==n);for(;;){const i=e.oPrev();if(i.dest().rightOf(e)&&t.isInCircle(e.orig(),i.dest(),e.dest()))Bo.swap(e),e=e.oPrev();else{if(e.oNext()===n)return s;e=e.oNext().lPrev()}}}insertSites(t){for(let e=t.iterator();e.hasNext();){const t=e.next();this.insertSite(t)}}}class Vo{locate(t){}}class zo{constructor(){zo.constructor_.apply(this,arguments)}static constructor_(){this._subdiv=null,this._lastEdge=null;const t=arguments[0];this._subdiv=t,this.init()}init(){this._lastEdge=this.findEdge()}locate(t){this._lastEdge.isLive()||this.init();const e=this._subdiv.locateFromEdge(t,this._lastEdge);return this._lastEdge=e,e}findEdge(){return this._subdiv.getEdges().iterator().next()}get interfaces_(){return[Vo]}}class Xo extends c{constructor(){super(),Xo.constructor_.apply(this,arguments)}static constructor_(){if(this._seg=null,1===arguments.length){if("string"==typeof arguments[0]){const t=arguments[0];c.constructor_.call(this,t)}else if(arguments[0]instanceof Zt){const t=arguments[0];c.constructor_.call(this,"Locate failed to converge (at edge: "+t+"). Possible causes include invalid Subdivision topology or very close sites"),this._seg=new Zt(t)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];c.constructor_.call(this,Xo.msgWithSpatial(t,e)),this._seg=new Zt(e)}}static msgWithSpatial(t,e){return null!==e?t+" [ "+e+" ]":t}getSegment(){return this._seg}}class ko{visit(t){}}class Uo{constructor(){Uo.constructor_.apply(this,arguments)}static constructor_(){this._visitedKey=0,this._quadEdges=new S,this._startingEdge=null,this._tolerance=null,this._edgeCoincidenceTolerance=null,this._frameVertex=new Array(3).fill(null),this._frameEnv=null,this._locator=null,this._seg=new Zt,this._triEdges=new Array(3).fill(null);const t=arguments[0],e=arguments[1];this._tolerance=e,this._edgeCoincidenceTolerance=e/Uo.EDGE_COINCIDENCE_TOL_FACTOR,this.createFrame(t),this._startingEdge=this.initSubdiv(),this._locator=new zo(this)}static getTriangleEdges(t,e){if(e[0]=t,e[1]=e[0].lNext(),e[2]=e[1].lNext(),e[2].lNext()!==e[0])throw new s("Edges do not form a triangle")}getTriangleVertices(t){const e=new Zo;return this.visitTriangles(e,t),e.getTriangleVertices()}isFrameVertex(t){return!!t.equals(this._frameVertex[0])||(!!t.equals(this._frameVertex[1])||!!t.equals(this._frameVertex[2]))}isVertexOfEdge(t,e){return!(!e.equals(t.orig(),this._tolerance)&&!e.equals(t.dest(),this._tolerance))}connect(t,e){const s=Bo.connect(t,e);return this._quadEdges.add(s),s}getVoronoiCellPolygon(t,e){const s=new S,n=t;do{const e=t.rot().orig().getCoordinate();s.add(e),t=t.oPrev()}while(t!==n);const i=new T;i.addAll(s,!1),i.closeRing(),i.size()<4&&(q.out.println(i),i.add(i.get(i.size()-1),!0));const r=i.toCoordinateArray(),o=e.createPolygon(e.createLinearRing(r)),l=n.orig();return o.setUserData(l.getCoordinate()),o}setLocator(t){this._locator=t}initSubdiv(){const t=this.makeEdge(this._frameVertex[0],this._frameVertex[1]),e=this.makeEdge(this._frameVertex[1],this._frameVertex[2]);Bo.splice(t.sym(),e);const s=this.makeEdge(this._frameVertex[2],this._frameVertex[0]);return Bo.splice(e.sym(),s),Bo.splice(s.sym(),t),t}isFrameBorderEdge(t){const e=new Array(3).fill(null);Uo.getTriangleEdges(t,e);const s=new Array(3).fill(null);Uo.getTriangleEdges(t.sym(),s);const n=t.lNext().dest();if(this.isFrameVertex(n))return!0;const i=t.sym().lNext().dest();return!!this.isFrameVertex(i)}makeEdge(t,e){const s=Bo.makeEdge(t,e);return this._quadEdges.add(s),s}visitTriangles(t,e){this._visitedKey++;const s=new $e;s.push(this._startingEdge);const n=new yt;for(;!s.empty();){const i=s.pop();if(!n.contains(i)){const r=this.fetchTriangleToVisit(i,s,e,n);null!==r&&t.visit(r)}}}isFrameEdge(t){return!(!this.isFrameVertex(t.orig())&&!this.isFrameVertex(t.dest()))}isOnEdge(t,e){this._seg.setCoordinates(t.orig().getCoordinate(),t.dest().getCoordinate());return this._seg.distance(e)s?10*e:10*s,this._frameVertex[0]=new Go((t.getMaxX()+t.getMinX())/2,t.getMaxY()+n),this._frameVertex[1]=new Go(t.getMinX()-n,t.getMinY()-n),this._frameVertex[2]=new Go(t.getMaxX()+n,t.getMinY()-n),this._frameEnv=new P(this._frameVertex[0].getCoordinate(),this._frameVertex[1].getCoordinate()),this._frameEnv.expandToInclude(this._frameVertex[2].getCoordinate())}getTriangleCoordinates(t){const e=new jo;return this.visitTriangles(e,t),e.getTriangles()}getVertices(t){const e=new yt;for(let s=this._quadEdges.iterator();s.hasNext();){const n=s.next(),i=n.orig();!t&&this.isFrameVertex(i)||e.add(i);const r=n.dest();!t&&this.isFrameVertex(r)||e.add(r)}return e}fetchTriangleToVisit(t,e,s,n){let i=t,r=0,o=!1;do{this._triEdges[r]=i,this.isFrameEdge(i)&&(o=!0);const t=i.sym();n.contains(t)||e.push(t),n.add(i),r++,i=i.lNext()}while(i!==t);return o&&!s?null:this._triEdges}getEdges(){if(0===arguments.length)return this._quadEdges;if(1===arguments.length){const t=arguments[0],e=this.getPrimaryEdges(!1),s=new Array(e.size()).fill(null);let n=0;for(let i=e.iterator();i.hasNext();){const e=i.next();s[n++]=t.createLineString([e.orig().getCoordinate(),e.dest().getCoordinate()])}return t.createMultiLineString(s)}}getVertexUniqueEdges(t){const e=new S,s=new yt;for(let n=this._quadEdges.iterator();n.hasNext();){const i=n.next(),r=i.orig();s.contains(r)||(s.add(r),!t&&this.isFrameVertex(r)||e.add(i));const o=i.sym(),l=o.orig();s.contains(l)||(s.add(l),!t&&this.isFrameVertex(l)||e.add(o))}return e}getTriangleEdges(t){const e=new Wo;return this.visitTriangles(e,t),e.getTriangleEdges()}getPrimaryEdges(t){this._visitedKey++;const e=new S,s=new $e;s.push(this._startingEdge);const n=new yt;for(;!s.empty();){const i=s.pop();if(!n.contains(i)){const r=i.getPrimary();!t&&this.isFrameEdge(r)||e.add(r),s.push(i.oNext()),s.push(i.sym().oNext()),n.add(i),n.add(i.sym())}}return e}delete(t){Bo.splice(t,t.oPrev()),Bo.splice(t.sym(),t.sym().oPrev());const e=t.sym(),s=t.rot(),n=t.rot().sym();this._quadEdges.remove(t),this._quadEdges.remove(e),this._quadEdges.remove(s),this._quadEdges.remove(n),t.delete(),e.delete(),s.delete(),n.delete()}locateFromEdge(t,e){let s=0;const n=this._quadEdges.size();let i=e;for(;;){if(s++,s>n)throw new Xo(i.toLineSegment());if(t.equals(i.orig())||t.equals(i.dest()))break;if(t.rightOf(i))i=i.sym();else if(t.rightOf(i.oNext())){if(t.rightOf(i.dPrev()))break;i=i.dPrev()}else i=i.oNext()}return i}getTolerance(){return this._tolerance}getVoronoiCellPolygons(t){this.visitTriangles(new Ho,!0);const e=new S;for(let s=this.getVertexUniqueEdges(!1).iterator();s.hasNext();){const n=s.next();e.add(this.getVoronoiCellPolygon(n,t))}return e}getVoronoiDiagram(t){const e=this.getVoronoiCellPolygons(t);return t.createGeometryCollection(wt.toGeometryArray(e))}getTriangles(t){const e=this.getTriangleCoordinates(!1),s=new Array(e.size()).fill(null);let n=0;for(let i=e.iterator();i.hasNext();){const e=i.next();s[n++]=t.createPolygon(t.createLinearRing(e))}return t.createGeometryCollection(s)}insertSite(t){let e=this.locate(t);if(t.equals(e.orig(),this._tolerance)||t.equals(e.dest(),this._tolerance))return e;let s=this.makeEdge(e.orig(),t);Bo.splice(s,e);const n=s;do{s=this.connect(e,s.sym()),e=s.oPrev()}while(e.lNext()!==n);return n}locate(){if(1===arguments.length){if(arguments[0]instanceof Go){const t=arguments[0];return this._locator.locate(t)}if(arguments[0]instanceof p){const t=arguments[0];return this._locator.locate(new Go(t))}}else if(2===arguments.length){const t=arguments[0],e=arguments[1],s=this._locator.locate(new Go(t));if(null===s)return null;let n=s;s.dest().getCoordinate().equals2D(t)&&(n=s.sym());let i=n;do{if(i.dest().getCoordinate().equals2D(e))return i;i=i.oNext()}while(i!==n);return null}}}class Ho{visit(t){const e=t[0].orig().getCoordinate(),s=t[1].orig().getCoordinate(),n=t[2].orig().getCoordinate(),i=te.circumcentreDD(e,s,n),r=new Go(i);for(let e=0;e<3;e++)t[e].rot().setOrig(r)}get interfaces_(){return[ko]}}class Wo{constructor(){Wo.constructor_.apply(this,arguments)}static constructor_(){this._triList=new S}getTriangleEdges(){return this._triList}visit(t){this._triList.add(t)}get interfaces_(){return[ko]}}class Zo{constructor(){Zo.constructor_.apply(this,arguments)}static constructor_(){this._triList=new S}visit(t){this._triList.add([t[0].orig(),t[1].orig(),t[2].orig()])}getTriangleVertices(){return this._triList}get interfaces_(){return[ko]}}class jo{constructor(){jo.constructor_.apply(this,arguments)}static constructor_(){this._coordList=new T,this._triCoords=new S}checkTriangleSize(t){t.length>=2?Ut.toLineString(t[0],t[1]):t.length>=1&&Ut.toPoint(t[0])}visit(t){this._coordList.clear();for(let e=0;e<3;e++){const s=t[e].orig();this._coordList.add(s.getCoordinate())}if(this._coordList.size()>0){this._coordList.closeRing();const t=this._coordList.toCoordinateArray();if(4!==t.length)return null;this._triCoords.add(t)}}getTriangles(){return this._triCoords}get interfaces_(){return[ko]}}Uo.TriangleCircumcentreVisitor=Ho,Uo.TriangleEdgesListVisitor=Wo,Uo.TriangleVertexListVisitor=Zo,Uo.TriangleCoordinatesVisitor=jo,Uo.EDGE_COINCIDENCE_TOL_FACTOR=1e3;class Ko{constructor(){Ko.constructor_.apply(this,arguments)}static constructor_(){if(this._ls=null,this._data=null,2===arguments.length){const t=arguments[0],e=arguments[1];this._ls=new Zt(t,e)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this._ls=new Zt(t,e),this._data=s}else if(6===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=arguments[4],r=arguments[5];Ko.constructor_.call(this,new p(t,e,s),new p(n,i,r))}else if(7===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3],i=arguments[4],r=arguments[5],o=arguments[6];Ko.constructor_.call(this,new p(t,e,s),new p(n,i,r),o)}}getLineSegment(){return this._ls}getEndZ(){return this._ls.getCoordinate(1).getZ()}getStartZ(){return this._ls.getCoordinate(0).getZ()}intersection(t){return this._ls.intersection(t.getLineSegment())}getStart(){return this._ls.getCoordinate(0)}getEnd(){return this._ls.getCoordinate(1)}getEndY(){return this._ls.getCoordinate(1).y}getStartX(){return this._ls.getCoordinate(0).x}equalsTopo(t){return this._ls.equalsTopo(t.getLineSegment())}getStartY(){return this._ls.getCoordinate(0).y}setData(t){this._data=t}getData(){return this._data}getEndX(){return this._ls.getCoordinate(1).x}toString(){return this._ls.toString()}}class Qo extends c{constructor(){super(),Qo.constructor_.apply(this,arguments)}static constructor_(){if(this._pt=null,1===arguments.length){const t=arguments[0];c.constructor_.call(this,t)}else if(2===arguments.length){const t=arguments[0],e=arguments[1];c.constructor_.call(this,Qo.msgWithCoord(t,e)),this._pt=new p(e)}}static msgWithCoord(t,e){return null!==e?t+" [ "+Ut.toPoint(e)+" ]":t}getCoordinate(){return this._pt}}class Jo{constructor(){Jo.constructor_.apply(this,arguments)}static constructor_(){this._initialVertices=null,this._segVertices=null,this._segments=new S,this._subdiv=null,this._incDel=null,this._convexHull=null,this._splitFinder=new Ao,this._kdt=null,this._vertexFactory=null,this._computeAreaEnv=null,this._splitPt=null,this._tolerance=null;const t=arguments[0],e=arguments[1];this._initialVertices=new S(t),this._tolerance=e,this._kdt=new cn(e)}static computeVertexEnvelope(t){const e=new P;for(let s=t.iterator();s.hasNext();){const t=s.next();e.expandToInclude(t.getCoordinate())}return e}getInitialVertices(){return this._initialVertices}getKDT(){return this._kdt}enforceConstraints(){this.addConstraintVertices();let t=0,e=0;do{e=this.enforceGabriel(this._segments),t++}while(e>0&&t0?t.getSegmentIndex()+1:t.getSegmentIndex()}getComponentIndex(){return this._componentIndex}getLine(){return this._currentLine}getVertexIndex(){return this._vertexIndex}getSegmentEnd(){return this._vertexIndex=this._currentLine.getNumPoints()&&(this._componentIndex++,this.loadCurrentLine(),this._vertexIndex=0)}loadCurrentLine(){if(this._componentIndex>=this._numLines)return this._currentLine=null,null;this._currentLine=this._linearGeom.getGeometryN(this._componentIndex)}getSegmentStart(){return this._currentLine.getCoordinateN(this._vertexIndex)}isEndOfLine(){return!(this._componentIndex>=this._numLines)&&!(this._vertexIndex=this._numLines)&&!(this._componentIndex===this._numLines-1&&this._vertexIndex>=this._currentLine.getNumPoints())}}class rl{constructor(){rl.constructor_.apply(this,arguments)}static constructor_(){this._linearGeom=null;const t=arguments[0];this._linearGeom=t}static indexOf(t,e){return new rl(t).indexOf(e)}static indexOfAfter(t,e,s){return new rl(t).indexOfAfter(e,s)}indexOf(t){return this.indexOfFromStart(t,-1)}indexOfFromStart(t,e){let s=i.MAX_VALUE,n=e,r=0;const o=new Zt,l=new il(this._linearGeom);for(;l.hasNext();){if(!l.isEndOfLine()){o.p0=l.getSegmentStart(),o.p1=l.getSegmentEnd();const i=o.distance(t),a=this.segmentNearestMeasure(o,t,r);ie&&(n=a,s=i),r+=o.getLength()}l.next()}return n}indexOfAfter(t,e){if(e<0)return this.indexOf(t);const s=this._linearGeom.getLength();if(s=e,"computed index is before specified minimum index"),n}segmentNearestMeasure(t,e,s){const n=t.projectionFactor(e);return n<=0?s:n<=1?s+n*t.getLength():s+t.getLength()}}class ll{constructor(){ll.constructor_.apply(this,arguments)}static constructor_(){if(this._componentIndex=0,this._segmentIndex=0,this._segmentFraction=0,0===arguments.length);else if(1===arguments.length){const t=arguments[0];this._componentIndex=t._componentIndex,this._segmentIndex=t._segmentIndex,this._segmentFraction=t._segmentFraction}else if(2===arguments.length){const t=arguments[0],e=arguments[1];ll.constructor_.call(this,0,t,e)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this._componentIndex=t,this._segmentIndex=e,this._segmentFraction=s,this.normalize()}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],n=arguments[3];this._componentIndex=t,this._segmentIndex=e,this._segmentFraction=s,n&&this.normalize()}}static getEndLocation(t){const e=new ll;return e.setToEnd(t),e}static pointAlongSegmentByFraction(t,e,s){if(s<=0)return t;if(s>=1)return e;const n=(e.x-t.x)*s+t.x,i=(e.y-t.y)*s+t.y,r=(e.getZ()-t.getZ())*s+t.getZ();return new p(n,i,r)}static compareLocationValues(t,e,s,n,i,r){return tn?1:ei?1:sr?1:0}static numSegments(t){const e=t.getNumPoints();return e<=1?0:e-1}getSegmentIndex(){return this._segmentIndex}getComponentIndex(){return this._componentIndex}isEndpoint(t){const e=t.getGeometryN(this._componentIndex),s=ll.numSegments(e);return this._segmentIndex>=s||this._segmentIndex===s-1&&this._segmentFraction>=1}isValid(t){if(this._componentIndex<0||this._componentIndex>=t.getNumGeometries())return!1;const e=t.getGeometryN(this._componentIndex);return!(this._segmentIndex<0||this._segmentIndex>e.getNumPoints())&&((this._segmentIndex!==e.getNumPoints()||0===this._segmentFraction)&&!(this._segmentFraction<0||this._segmentFraction>1))}normalize(){this._segmentFraction<0&&(this._segmentFraction=0),this._segmentFraction>1&&(this._segmentFraction=1),this._componentIndex<0&&(this._componentIndex=0,this._segmentIndex=0,this._segmentFraction=0),this._segmentIndex<0&&(this._segmentIndex=0,this._segmentFraction=0),1===this._segmentFraction&&(this._segmentFraction=0,this._segmentIndex+=1)}toLowest(t){const e=t.getGeometryN(this._componentIndex),s=ll.numSegments(e);return this._segmentIndex=ll.numSegments(e))return s;const n=e.getCoordinateN(this._segmentIndex+1);return ll.pointAlongSegmentByFraction(s,n,this._segmentFraction)}getSegmentFraction(){return this._segmentFraction}getSegment(t){const e=t.getGeometryN(this._componentIndex),s=e.getCoordinateN(this._segmentIndex);if(this._segmentIndex>=ll.numSegments(e)){const t=e.getCoordinateN(e.getNumPoints()-2);return new Zt(t,s)}const n=e.getCoordinateN(this._segmentIndex+1);return new Zt(s,n)}clamp(t){if(this._componentIndex>=t.getNumGeometries())return this.setToEnd(t),null;if(this._segmentIndex>=t.getNumPoints()){const e=t.getGeometryN(this._componentIndex);this._segmentIndex=ll.numSegments(e),this._segmentFraction=1}}setToEnd(t){this._componentIndex=t.getNumGeometries()-1;const e=t.getGeometryN(this._componentIndex);this._segmentIndex=ll.numSegments(e),this._segmentFraction=0}compareTo(t){const e=t;return this._componentIndexe._componentIndex?1:this._segmentIndexe._segmentIndex?1:this._segmentFractione._segmentFraction?1:0}copy(){return new ll(this._componentIndex,this._segmentIndex,this._segmentFraction)}toString(){return"LinearLoc["+this._componentIndex+", "+this._segmentIndex+", "+this._segmentFraction+"]"}isOnSameSegment(t){return this._componentIndex===t._componentIndex&&(this._segmentIndex===t._segmentIndex||(t._segmentIndex-this._segmentIndex==1&&0===t._segmentFraction||this._segmentIndex-t._segmentIndex==1&&0===this._segmentFraction))}snapToVertex(t,e){if(this._segmentFraction<=0||this._segmentFraction>=1)return null;const s=this.getSegmentLength(t),n=this._segmentFraction*s,i=s-n;n<=i&&nt?1:this._segmentIndexe?1:this._segmentFractions?1:0}getSegmentLength(t){const e=t.getGeometryN(this._componentIndex);let s=this._segmentIndex;this._segmentIndex>=ll.numSegments(e)&&(s=e.getNumPoints()-2);const n=e.getCoordinateN(s),i=e.getCoordinateN(s+1);return n.distance(i)}isVertex(){return this._segmentFraction<=0||this._segmentFraction>=1}get interfaces_(){return[r]}}class al{constructor(){al.constructor_.apply(this,arguments)}static constructor_(){this._linearGeom=null;const t=arguments[0];this._linearGeom=t}static indexOf(t,e){return new al(t).indexOf(e)}static indexOfAfter(t,e,s){return new al(t).indexOfAfter(e,s)}indexOf(t){return this.indexOfFromStart(t,null)}indexOfFromStart(t,e){let s=i.MAX_VALUE,n=0,r=0,o=-1;const l=new Zt;for(let i=new il(this._linearGeom);i.hasNext();i.next())if(!i.isEndOfLine()){l.p0=i.getSegmentStart(),l.p1=i.getSegmentEnd();const a=l.distance(t),c=l.segmentFraction(t),h=i.getComponentIndex(),u=i.getVertexIndex();a=0,"computed location is before specified minimum location"),n}}class cl{constructor(){cl.constructor_.apply(this,arguments)}static constructor_(){this._linearGeom=null;const t=arguments[0];this._linearGeom=t}static indicesOf(t,e){return new cl(t).indicesOf(e)}indicesOf(t){const e=t.getGeometryN(0).getCoordinateN(0),s=t.getGeometryN(t.getNumGeometries()-1),n=s.getCoordinateN(s.getNumPoints()-1),i=new al(this._linearGeom),r=new Array(2).fill(null);return r[0]=i.indexOf(e),0===t.getLength()?r[1]=r[0].copy():r[1]=i.indexOfAfter(n,r[0]),r}}class hl{constructor(){hl.constructor_.apply(this,arguments)}static constructor_(){this._linearGeom=null;const t=arguments[0];this._linearGeom=t}static getLength(t,e){return new hl(t).getLength(e)}static getLocation(){if(2===arguments.length){const t=arguments[1];return new hl(arguments[0]).getLocation(t)}if(3===arguments.length){const t=arguments[1],e=arguments[2];return new hl(arguments[0]).getLocation(t,e)}}getLength(t){let e=0;const s=new il(this._linearGeom);for(;s.hasNext();){if(!s.isEndOfLine()){const n=s.getSegmentStart(),i=s.getSegmentEnd().distance(n);if(t.getComponentIndex()===s.getComponentIndex()&&t.getSegmentIndex()===s.getVertexIndex())return e+i*t.getSegmentFraction();e+=i}s.next()}return e}resolveHigher(t){if(!t.isEndpoint(this._linearGeom))return t;let e=t.getComponentIndex();if(e>=this._linearGeom.getNumGeometries()-1)return t;do{e++}while(et){const n=(t-e)/i,r=s.getComponentIndex(),o=s.getVertexIndex();return new ll(r,o,n)}e+=i}s.next()}return ll.getEndLocation(this._linearGeom)}}class ul{constructor(){ul.constructor_.apply(this,arguments)}static constructor_(){this._geomFact=null,this._lines=new S,this._coordList=null,this._ignoreInvalidLines=!1,this._fixInvalidLines=!1,this._lastPt=null;const t=arguments[0];this._geomFact=t}getGeometry(){return this.endLine(),this._geomFact.buildGeometry(this._lines)}getLastCoordinate(){return this._lastPt}endLine(){if(null===this._coordList)return null;if(this._ignoreInvalidLines&&this._coordList.size()<2)return this._coordList=null,null;const t=this._coordList.toCoordinateArray();let e=t;this._fixInvalidLines&&(e=this.validCoordinateSequence(t)),this._coordList=null;let n=null;try{n=this._geomFact.createLineString(e)}catch(t){if(!(t instanceof s))throw t;if(!this._ignoreInvalidLines)throw t}null!==n&&this._lines.add(n)}setFixInvalidLines(t){this._fixInvalidLines=t}add(){if(1===arguments.length){const t=arguments[0];this.add(t,!0)}else if(2===arguments.length){const t=arguments[0],e=arguments[1];null===this._coordList&&(this._coordList=new T),this._coordList.add(t,e),this._lastPt=t}}setIgnoreInvalidLines(t){this._ignoreInvalidLines=t}validCoordinateSequence(t){if(t.length>=2)return t;return[t[0],t[0]]}}class gl{constructor(){gl.constructor_.apply(this,arguments)}static constructor_(){this._line=null;const t=arguments[0];this._line=t}static extract(t,e,s){return new gl(t).extract(e,s)}computeLinear(t,e){const s=new ul(this._line.getFactory());s.setFixInvalidLines(!0),t.isVertex()||s.add(t.getCoordinate(this._line));for(let n=new il(this._line,t);n.hasNext()&&!(e.compareLocationValues(n.getComponentIndex(),n.getVertexIndex(),0)<0);n.next()){const t=n.getSegmentStart();s.add(t),n.isEndOfLine()&&s.endLine()}return e.isVertex()||s.add(e.getCoordinate(this._line)),s.getGeometry()}computeLine(t,e){const s=this._line.getCoordinates(),n=new T;let i=t.getSegmentIndex();t.getSegmentFraction()>0&&(i+=1);let r=e.getSegmentIndex();1===e.getSegmentFraction()&&(r+=1),r>=s.length&&(r=s.length-1),t.isVertex()||n.add(t.getCoordinate(this._line));for(let t=i;t<=r;t++)n.add(s[t]);e.isVertex()||n.add(e.getCoordinate(this._line)),n.size()<=0&&n.add(t.getCoordinate(this._line));let o=n.toCoordinateArray();return o.length<=1&&(o=[o[0],o[0]]),this._line.getFactory().createLineString(o)}extract(t,e){return e.compareTo(t)<0?this.reverse(this.computeLinear(e,t)):this.computeLinear(t,e)}reverse(t){return E(t,H)?t.reverse():(u.shouldNeverReachHere("non-linear geometry encountered"),null)}}class dl{constructor(){dl.constructor_.apply(this,arguments)}static constructor_(){this._linearGeom=null;const t=arguments[0];this._linearGeom=t}clampIndex(t){const e=this.positiveIndex(t),s=this.getStartIndex();if(en?n:e}locationOf(){if(1===arguments.length){const t=arguments[0];return hl.getLocation(this._linearGeom,t)}if(2===arguments.length){const t=arguments[0],e=arguments[1];return hl.getLocation(this._linearGeom,t,e)}}project(t){return rl.indexOf(this._linearGeom,t)}positiveIndex(t){return t>=0?t:this._linearGeom.getLength()+t}extractPoint(){if(1===arguments.length){const t=arguments[0];return hl.getLocation(this._linearGeom,t).getCoordinate(this._linearGeom)}if(2===arguments.length){const t=arguments[0],e=arguments[1],s=hl.getLocation(this._linearGeom,t).toLowest(this._linearGeom);return s.getSegment(this._linearGeom).pointAlongOffset(s.getSegmentFraction(),e)}}isValidIndex(t){return t>=this.getStartIndex()&&t<=this.getEndIndex()}getEndIndex(){return this._linearGeom.getLength()}getStartIndex(){return 0}indexOfAfter(t,e){return rl.indexOfAfter(this._linearGeom,t,e)}extractLine(t,e){const s=this.clampIndex(t),n=this.clampIndex(e),i=s===n,r=this.locationOf(s,i),o=this.locationOf(n);return gl.extract(this._linearGeom,r,o)}indexOf(t){return rl.indexOf(this._linearGeom,t)}indicesOf(t){const e=cl.indicesOf(this._linearGeom,t);return[hl.getLength(this._linearGeom,e[0]),hl.getLength(this._linearGeom,e[1])]}}class _l{constructor(){_l.constructor_.apply(this,arguments)}static constructor_(){this._linearGeom=null;const t=arguments[0];this._linearGeom=t,this.checkGeometryType()}clampIndex(t){const e=t.copy();return e.clamp(this._linearGeom),e}project(t){return al.indexOf(this._linearGeom,t)}checkGeometryType(){if(!(this._linearGeom instanceof Q||this._linearGeom instanceof Ct))throw new s("Input geometry must be linear")}extractPoint(){if(1===arguments.length){return arguments[0].getCoordinate(this._linearGeom)}if(2===arguments.length){const t=arguments[1],e=arguments[0].toLowest(this._linearGeom);return e.getSegment(this._linearGeom).pointAlongOffset(e.getSegmentFraction(),t)}}isValidIndex(t){return t.isValid(this._linearGeom)}getEndIndex(){return ll.getEndLocation(this._linearGeom)}getStartIndex(){return new ll}indexOfAfter(t,e){return al.indexOfAfter(this._linearGeom,t,e)}extractLine(t,e){return gl.extract(this._linearGeom,t,e)}indexOf(t){return al.indexOf(this._linearGeom,t)}indicesOf(t){return cl.indicesOf(this._linearGeom,t)}}var pl=Object.freeze({__proto__:null,LengthIndexedLine:dl,LengthLocationMap:hl,LinearGeometryBuilder:ul,LinearIterator:il,LinearLocation:ll,LocationIndexedLine:_l});class ml{static transform(t,e){const s=new S;for(let n=t.iterator();n.hasNext();)s.add(e.execute(n.next()));return s}static select(t,e){const s=new S;for(let n=t.iterator();n.hasNext();){const t=n.next();Boolean.TRUE.equals(e.execute(t))&&s.add(t)}return s}static apply(t,e){for(let s=t.iterator();s.hasNext();)e.execute(s.next())}}ml.Function=function(){};class fl{constructor(){fl.constructor_.apply(this,arguments)}static constructor_(){this.pts=null,this.n=0;const t=arguments[0];this.pts=new Array(t).fill(null)}filter(t){this.pts[this.n++]=t}getCoordinates(){return this.pts}get interfaces_(){return[k]}}class yl{constructor(){yl.constructor_.apply(this,arguments)}static constructor_(){this._n=0}filter(t){this._n++}getCount(){return this._n}get interfaces_(){return[k]}}class xl{constructor(){xl.constructor_.apply(this,arguments)}static constructor_(){this._counts=new Et}count(t){const e=this._counts.get(t);return null===e?0:e.count()}add(t){const e=this._counts.get(t);null===e?this._counts.put(t,new El(1)):e.increment()}}class El{constructor(){El.constructor_.apply(this,arguments)}static constructor_(){if(this.count=0,0===arguments.length);else if(1===arguments.length){const t=arguments[0];this.count=t}}count(){return this.count}increment(){this.count++}}function Il(){}function Nl(){}function Cl(){}xl.Counter=El;class wl extends e{}function Sl(){}class Ll{static chars(t,e){const s=new Array(e).fill(null);for(let n=0;n=0;){const t=i.substring(0,r);n.add(t),i=i.substring(r+s),r=i.indexOf(e)}i.length>0&&n.add(i);const o=new Array(n.size()).fill(null);for(let t=0;t