!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).jsts=e()}(this,(function(){"use strict";function t(t,e){(null==e||e>t.length)&&(e=t.length);for(var n=0,i=Array(e);n=t.length?{done:!0}:{done:!1,value:t[i++]}},e:function(t){throw t},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var s,a=!0,o=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){o=!0,s=t},f:function(){try{a||null==n.return||n.return()}finally{if(o)throw s}}}}function o(){return o="undefined"!=typeof Reflect&&Reflect.get?Reflect.get.bind():function(t,e,n){var i=function(t,e){for(;!{}.hasOwnProperty.call(t,e)&&null!==(t=u(t)););return t}(t,e);if(i){var r=Object.getOwnPropertyDescriptor(i,e);return r.get?r.get.call(arguments.length<3?t:n):r.value}},o.apply(null,arguments)}function u(t){return u=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(t){return t.__proto__||Object.getPrototypeOf(t)},u(t)}function l(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),Object.defineProperty(t,"prototype",{writable:!1}),e&&c(t,e)}function h(){try{var t=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){})))}catch(t){}return(h=function(){return!!t})()}function c(t,e){return c=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,e){return t.__proto__=e,t},c(t,e)}function f(t,e,n,i){var r=o(u(1&i?t.prototype:t),e,n);return 2&i&&"function"==typeof r?function(t){return r.apply(n,t)}:r}function g(e){return function(e){if(Array.isArray(e))return t(e)}(e)||function(t){if("undefined"!=typeof Symbol&&null!=t[Symbol.iterator]||null!=t["@@iterator"])return Array.from(t)}(e)||y(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function v(t){var e=function(t,e){if("object"!=typeof t||!t)return t;var n=t[Symbol.toPrimitive];if(void 0!==n){var i=n.call(t,e);if("object"!=typeof i)return i;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(t)}(t,"string");return"symbol"==typeof e?e:e+""}function y(e,n){if(e){if("string"==typeof e)return t(e,n);var i={}.toString.call(e).slice(8,-1);return"Object"===i&&e.constructor&&(i=e.constructor.name),"Map"===i||"Set"===i?Array.from(e):"Arguments"===i||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?t(e,n):void 0}}function d(t){var e="function"==typeof Map?new Map:void 0;return d=function(t){if(null===t||!function(t){try{return-1!==Function.toString.call(t).indexOf("[native code]")}catch(e){return"function"==typeof t}}(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}function n(){return i(t,arguments,u(this).constructor)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),c(n,t)},d(t)}var _=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(e){this._quadrantSegments=e,0===this._quadrantSegments&&(this._joinStyle=t.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=t.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),e<=0&&(this._quadrantSegments=1),this._joinStyle!==t.JOIN_ROUND&&(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS)}},{key:"getJoinStyle",value:function(){return this._joinStyle}},{key:"setJoinStyle",value:function(t){this._joinStyle=t}},{key:"setSimplifyFactor",value:function(t){this._simplifyFactor=t<0?0:t}},{key:"getSimplifyFactor",value:function(){return this._simplifyFactor}},{key:"getQuadrantSegments",value:function(){return this._quadrantSegments}},{key:"setEndCapStyle",value:function(t){this._endCapStyle=t}},{key:"getMitreLimit",value:function(){return this._mitreLimit}},{key:"setMitreLimit",value:function(t){this._mitreLimit=t}},{key:"setSingleSided",value:function(t){this._isSingleSided=t}}],[{key:"constructor_",value:function(){if(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=t.CAP_ROUND,this._joinStyle=t.JOIN_ROUND,this._mitreLimit=t.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=t.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var e=arguments[0];this.setQuadrantSegments(e)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(i)}else if(4===arguments.length){var r=arguments[0],s=arguments[1],a=arguments[2],o=arguments[3];this.setQuadrantSegments(r),this.setEndCapStyle(s),this.setJoinStyle(a),this.setMitreLimit(o)}}},{key:"bufferDistanceError",value:function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)}}])}();_.CAP_ROUND=1,_.CAP_FLAT=2,_.CAP_SQUARE=3,_.JOIN_ROUND=1,_.JOIN_MITRE=2,_.JOIN_BEVEL=3,_.DEFAULT_QUADRANT_SEGMENTS=8,_.DEFAULT_MITRE_LIMIT=5,_.DEFAULT_SIMPLIFY_FACTOR=.01;var p=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({Exception:i})[0],r}return l(i,t),s(i,[{key:"toString",value:function(){return this.message}}])}(d(Error)),m=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({IllegalArgumentException:i})[0],r}return l(i,t),s(i)}(p),k=function(){return s((function t(){n(this,t)}),[{key:"filter",value:function(t){}}])}();function x(){}function I(){}function E(){}var N,T,S,L,C,R,w,O,b=function(){return s((function t(){n(this,t)}),null,[{key:"equalsWithTolerance",value:function(t,e,n){return Math.abs(t-e)<=n}}])}(),M=function(){return s((function t(e,i){n(this,t),this.low=i||0,this.high=e||0}),null,[{key:"toBinaryString",value:function(t){var e,n="";for(e=2147483648;e>0;e>>>=1)n+=(t.high&e)===e?"1":"0";for(e=2147483648;e>0;e>>>=1)n+=(t.low&e)===e?"1":"0";return n}}])}();function A(){}function P(){}A.NaN=NaN,A.isNaN=function(t){return Number.isNaN(t)},A.isInfinite=function(t){return!Number.isFinite(t)},A.MAX_VALUE=Number.MAX_VALUE,A.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,A.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?(R=2146435072,w=new Float64Array(1),O=new Int32Array(w.buffer),A.doubleToLongBits=function(t){w[0]=t;var e=0|O[0],n=0|O[1];return(n&R)===R&&1048575&n&&0!==e&&(e=0,n=2146959360),new M(n,e)},A.longBitsToDouble=function(t){return O[0]=t.low,O[1]=t.high,w[0]}):(N=1023,T=Math.log2,S=Math.floor,L=Math.pow,C=function(){for(var t=53;t>0;t--){var e=L(2,t)-1;if(S(T(e))+1===t)return e}return 0}(),A.doubleToLongBits=function(t){var e,n,i,r,s,a,o,u,l;if(t<0||1/t===Number.NEGATIVE_INFINITY?(a=1<<31,t=-t):a=0,0===t)return new M(u=a,l=0);if(t===1/0)return new M(u=2146435072|a,l=0);if(t!=t)return new M(u=2146959360,l=0);if(r=0,l=0,(e=S(t))>1)if(e<=C)(r=S(T(e)))<=20?(l=0,u=e<<20-r&1048575):(l=e%(n=L(2,i=r-20))<<32-i,u=e/n&1048575);else for(i=e,l=0;0!==(i=S(n=i/2));)r++,l>>>=1,l|=(1&u)<<31,u>>>=1,n!==i&&(u|=524288);if(o=r+N,s=0===e,e=t-e,r<52&&0!==e)for(i=0;;){if((n=2*e)>=1?(e=n-1,s?(o--,s=!1):(i<<=1,i|=1,r++)):(e=n,s?0==--o&&(r++,s=!1):(i<<=1,r++)),20===r)u|=i,i=0;else if(52===r){l|=i;break}if(1===n){r<20?u|=i<<20-r:r<52&&(l|=i<<52-r);break}}return u|=o<<20,new M(u|=a,l)},A.longBitsToDouble=function(t){var e,n,i,r,s=t.high,a=t.low,o=s&1<<31?-1:1;for(i=((2146435072&s)>>20)-N,r=0,n=1<<19,e=1;e<=20;e++)s&n&&(r+=L(2,-e)),n>>>=1;for(n=1<<31,e=21;e<=52;e++)a&n&&(r+=L(2,-e)),n>>>=1;if(-1023===i){if(0===r)return 0*o;i=-1022}else{if(1024===i)return 0===r?o/0:NaN;r+=1}return o*r*L(2,i)});var D=function(t){function i(t){var r;return n(this,i),(r=e(this,i,[t])).name=Object.keys({RuntimeException:i})[0],r}return l(i,t),s(i)}(p),F=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,null,[{key:"constructor_",value:function(){if(0===arguments.length)D.constructor_.call(this);else if(1===arguments.length){var t=arguments[0];D.constructor_.call(this,t)}}}])}(D),G=function(){function t(){n(this,t)}return s(t,null,[{key:"shouldNeverReachHere",value:function(){if(0===arguments.length)t.shouldNeverReachHere(null);else if(1===arguments.length){var e=arguments[0];throw new F("Should never reach here"+(null!==e?": "+e:""))}}},{key:"isTrue",value:function(){if(1===arguments.length){var e=arguments[0];t.isTrue(e,null)}else if(2===arguments.length){var n=arguments[1];if(!arguments[0])throw null===n?new F:new F(n)}}},{key:"equals",value:function(){if(2===arguments.length){var e=arguments[0],n=arguments[1];t.equals(e,n,null)}else if(3===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2];if(!r.equals(i))throw new F("Expected "+i+" but encountered "+r+(null!==s?": "+s:""))}}}])}(),q=new ArrayBuffer(8),Y=new Float64Array(q),z=new Int32Array(q),X=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"getM",value:function(){return A.NaN}},{key:"setOrdinate",value:function(e,n){switch(e){case t.X:this.x=n;break;case t.Y:this.y=n;break;case t.Z:this.setZ(n);break;default:throw new m("Invalid ordinate index: "+e)}}},{key:"equals2D",value:function(){if(1===arguments.length){var t=arguments[0];return this.x===t.x&&this.y===t.y}if(2===arguments.length){var e=arguments[0],n=arguments[1];return!!b.equalsWithTolerance(this.x,e.x,n)&&!!b.equalsWithTolerance(this.y,e.y,n)}}},{key:"setM",value:function(e){throw new m("Invalid ordinate index: "+t.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(e){switch(e){case t.X:return this.x;case t.Y:return this.y;case t.Z:return this.getZ()}throw new m("Invalid ordinate index: "+e)}},{key:"equals3D",value:function(t){return this.x===t.x&&this.y===t.y&&(this.getZ()===t.getZ()||A.isNaN(this.getZ())&&A.isNaN(t.getZ()))}},{key:"equals",value:function(e){return e instanceof t&&this.equals2D(e)}},{key:"equalInZ",value:function(t,e){return b.equalsWithTolerance(this.getZ(),t.getZ(),e)}},{key:"setX",value:function(t){this.x=t}},{key:"compareTo",value:function(t){var e=t;return this.xe.x?1:this.ye.y?1:0}},{key:"getX",value:function(){return this.x}},{key:"setZ",value:function(t){this.z=t}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return G.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}}},{key:"copy",value:function(){return new t(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}},{key:"distance3D",value:function(t){var e=this.x-t.x,n=this.y-t.y,i=this.getZ()-t.getZ();return Math.sqrt(e*e+n*n+i*i)}},{key:"getY",value:function(){return this.y}},{key:"setY",value:function(t){this.y=t}},{key:"distance",value:function(t){var e=this.x-t.x,n=this.y-t.y;return Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var e=17;return e=37*(e=37*e+t.hashCode(this.x))+t.hashCode(this.y)}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}},{key:"interfaces_",get:function(){return[x,I,E]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)t.constructor_.call(this,0,0);else if(1===arguments.length){var e=arguments[0];t.constructor_.call(this,e.x,e.y,e.getZ())}else if(2===arguments.length){var n=arguments[0],i=arguments[1];t.constructor_.call(this,n,i,t.NULL_ORDINATE)}else if(3===arguments.length){var r=arguments[0],s=arguments[1],a=arguments[2];this.x=r,this.y=s,this.z=a}}},{key:"hashCode",value:function(t){return Y[0]=t,z[0]^z[1]}}])}(),B=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"compare",value:function(e,n){var i=t.compare(e.x,n.x);if(0!==i)return i;var r=t.compare(e.y,n.y);return 0!==r?r:this._dimensionsToTest<=2?0:t.compare(e.getZ(),n.getZ())}},{key:"interfaces_",get:function(){return[P]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,0===arguments.length)t.constructor_.call(this,2);else if(1===arguments.length){var e=arguments[0];if(2!==e&&3!==e)throw new m("only 2 or 3 dimensions may be specified");this._dimensionsToTest=e}}},{key:"compare",value:function(t,e){return te?1:A.isNaN(t)?A.isNaN(e)?0:-1:A.isNaN(e)?1:0}}])}();X.DimensionalComparator=B,X.NULL_ORDINATE=A.NaN,X.X=0,X.Y=1,X.Z=2,X.M=3;var U=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(e){if(!(e instanceof t))return!1;var n=e;return this.isNull()?n.isNull():this._maxx===n.getMaxX()&&this._maxy===n.getMaxY()&&this._minx===n.getMinX()&&this._miny===n.getMinY()}},{key:"intersection",value:function(e){if(this.isNull()||e.isNull()||!this.intersects(e))return new t;var n=this._minx>e._minx?this._minx:e._minx,i=this._miny>e._miny?this._miny:e._miny;return new t(n,this._maxx=this._minx&&n.getMaxX()<=this._maxx&&n.getMinY()>=this._miny&&n.getMaxY()<=this._maxy)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return!this.isNull()&&(i>=this._minx&&i<=this._maxx&&r>=this._miny&&r<=this._maxy)}}},{key:"intersects",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return!this.isNull()&&!e.isNull()&&!(e._minx>this._maxx||e._maxxthis._maxy||e._maxythis._maxx)&&(!((i.x>r.x?i.x:r.x)this._maxy)&&!((i.y>r.y?i.y:r.y)this._maxx||sthis._maxy||athis._maxx&&(this._maxx=n._maxx),n._minythis._maxy&&(this._maxy=n._maxy))}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.isNull()?(this._minx=i,this._maxx=i,this._miny=r,this._maxy=r):(ithis._maxx&&(this._maxx=i),rthis._maxy&&(this._maxy=r))}}},{key:"minExtent",value:function(){if(this.isNull())return 0;var t=this.getWidth(),e=this.getHeight();return te._minx?1:this._minye._miny?1:this._maxxe._maxx?1:this._maxye._maxy?1:0}},{key:"translate",value:function(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)}},{key:"copy",value:function(){return new t(this)}},{key:"toString",value:function(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}},{key:"setToNull",value:function(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}},{key:"disjoint",value:function(t){return!(!this.isNull()&&!t.isNull())||(t._minx>this._maxx||t._maxxthis._maxy||t._maxye?t:e}},{key:"expandBy",value:function(){if(1===arguments.length){var t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];if(this.isNull())return null;this._minx-=e,this._maxx+=e,this._miny-=n,this._maxy+=n,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}},{key:"contains",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.covers(e)}if(arguments[0]instanceof X){var n=arguments[0];return this.covers(n)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];return this.covers(i,r)}}},{key:"centre",value:function(){return this.isNull()?null:new X((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}},{key:"init",value:function(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof X){var e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof t){var n=arguments[0];this._minx=n._minx,this._maxx=n._maxx,this._miny=n._miny,this._maxy=n._maxy}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i.x,r.x,i.y,r.y)}else if(4===arguments.length){var s=arguments[0],a=arguments[1],o=arguments[2],u=arguments[3];st._maxx&&(e=this._minx-t._maxx);var n=0;return this._maxyt._maxy&&(n=this._miny-t._maxy),0===e?n:0===n?e:Math.sqrt(e*e+n*n)}},{key:"hashCode",value:function(){var t=17;return t=37*(t=37*(t=37*(t=37*t+X.hashCode(this._minx))+X.hashCode(this._maxx))+X.hashCode(this._miny))+X.hashCode(this._maxy)}},{key:"interfaces_",get:function(){return[x,E]}}],[{key:"constructor_",value:function(){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 X){var e=arguments[0];this.init(e.x,e.x,e.y,e.y)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}}else if(2===arguments.length){var i=arguments[0],r=arguments[1];this.init(i.x,r.x,i.y,r.y)}else if(4===arguments.length){var s=arguments[0],a=arguments[1],o=arguments[2],u=arguments[3];this.init(s,a,o,u)}}},{key:"intersects",value:function(){if(3===arguments.length){var t=arguments[0],e=arguments[1],n=arguments[2];return n.x>=(t.xe.x?t.x:e.x)&&n.y>=(t.ye.y?t.y:e.y)}if(4===arguments.length){var i=arguments[0],r=arguments[1],s=arguments[2],a=arguments[3],o=Math.min(s.x,a.x),u=Math.max(s.x,a.x),l=Math.min(i.x,r.x),h=Math.max(i.x,r.x);return!(l>u)&&(!(hu)&&!(h=this.size())throw new et;return this.array[t]}},{key:"push",value:function(t){return this.array.push(t),t}},{key:"pop",value:function(){if(0===this.array.length)throw new tt;return this.array.pop()}},{key:"peek",value:function(){if(0===this.array.length)throw new tt;return this.array[this.array.length-1]}},{key:"empty",value:function(){return 0===this.array.length}},{key:"isEmpty",value:function(){return this.empty()}},{key:"search",value:function(t){return this.array.indexOf(t)}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}}])}(nt);function rt(t,e){return t.interfaces_&&t.interfaces_.indexOf(e)>-1}var st=function(){return s((function t(e){n(this,t),this.str=e}),[{key:"append",value:function(t){this.str+=t}},{key:"setCharAt",value:function(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}},{key:"toString",value:function(){return this.str}}])}(),at=function(){function t(e){n(this,t),this.value=e}return s(t,[{key:"intValue",value:function(){return this.value}},{key:"compareTo",value:function(t){return this.valuet?1:0}}],[{key:"compare",value:function(t,e){return te?1:0}},{key:"isNan",value:function(t){return Number.isNaN(t)}},{key:"valueOf",value:function(e){return new t(e)}}])}(),ot=function(){return s((function t(){n(this,t)}),null,[{key:"isWhitespace",value:function(t){return t<=32&&t>=0||127===t}},{key:"toUpperCase",value:function(t){return t.toUpperCase()}}])}(),ut=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"le",value:function(t){return this._hi9?(c=!0,f="9"):f="0"+h,o.append(f),i=i.subtract(t.valueOf(h)).multiply(t.TEN),c&&i.selfAdd(t.TEN);var g=!0,v=t.magnitude(i._hi);if(v<0&&Math.abs(v)>=u-l&&(g=!1),!g)break}return n[0]=r,o.toString()}},{key:"sqr",value:function(){return this.multiply(this)}},{key:"doubleValue",value:function(){return this._hi+this._lo}},{key:"subtract",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return this.add(e.negate())}if("number"==typeof arguments[0]){var n=arguments[0];return this.add(-n)}}},{key:"equals",value:function(){if(1===arguments.length&&arguments[0]instanceof t){var e=arguments[0];return this._hi===e._hi&&this._lo===e._lo}}},{key:"isZero",value:function(){return 0===this._hi&&0===this._lo}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return this.isNaN()?this:this.selfAdd(-e._hi,-e._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.isNaN()?this:this.selfAdd(-n,0)}}},{key:"getSpecialNumberString",value:function(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}},{key:"min",value:function(t){return this.le(t)?this:t}},{key:"selfDivide",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.selfDivide(e._hi,e._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfDivide(n,0)}}else if(2===arguments.length){var i,r,s,a,o=arguments[0],u=arguments[1],l=null,h=null,c=null,f=null;return s=this._hi/o,f=(l=(c=t.SPLIT*s)-(l=c-s))*(h=(f=t.SPLIT*o)-(h=f-o))-(a=s*o)+l*(r=o-h)+(i=s-l)*h+i*r,f=s+(c=(this._hi-a-f+this._lo-s*u)/o),this._hi=f,this._lo=s-f+c,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof t){var e,n,i,r,s=arguments[0],a=null,o=null,u=null,l=null;return e=(i=this._hi/s._hi)-(a=(u=t.SPLIT*i)-(a=u-i)),l=a*(o=(l=t.SPLIT*s._hi)-(o=l-s._hi))-(r=i*s._hi)+a*(n=s._hi-o)+e*o+e*n,new t(l=i+(u=(this._hi-r-l+this._lo-i*s._lo)/s._hi),i-l+u)}if("number"==typeof arguments[0]){var h=arguments[0];return A.isNaN(h)?t.createNaN():t.copy(this).selfDivide(h,0)}}},{key:"ge",value:function(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>=t._lo}},{key:"pow",value:function(e){if(0===e)return t.valueOf(1);var n=new t(this),i=t.valueOf(1),r=Math.abs(e);if(r>1)for(;r>0;)r%2==1&&i.selfMultiply(n),(r/=2)>0&&(n=n.sqr());else i=n;return e<0?i.reciprocal():i}},{key:"ceil",value:function(){if(this.isNaN())return t.NaN;var e=Math.ceil(this._hi),n=0;return e===this._hi&&(n=Math.ceil(this._lo)),new t(e,n)}},{key:"compareTo",value:function(t){var e=t;return this._hie._hi?1:this._loe._lo?1:0}},{key:"rint",value:function(){return this.isNaN()?this:this.add(.5).floor()}},{key:"setValue",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return this.init(e),this}if("number"==typeof arguments[0]){var n=arguments[0];return this.init(n),this}}},{key:"max",value:function(t){return this.ge(t)?this:t}},{key:"sqrt",value:function(){if(this.isZero())return t.valueOf(0);if(this.isNegative())return t.NaN;var e=1/Math.sqrt(this._hi),n=this._hi*e,i=t.valueOf(n),r=this.subtract(i.sqr())._hi*(.5*e);return i.add(r)}},{key:"selfAdd",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.selfAdd(e._hi,e._lo)}if("number"==typeof arguments[0]){var n,i,r,s,a,o=arguments[0],u=null;return u=(r=this._hi+o)-(s=r-this._hi),i=(a=(u=o-s+(this._hi-u))+this._lo)+(r-(n=r+a)),this._hi=n+i,this._lo=i+(n-this._hi),this}}else if(2===arguments.length){var l,h,c,f,g=arguments[0],v=arguments[1],y=null,d=null,_=null;c=this._hi+g,h=this._lo+v,d=c-(_=c-this._hi),y=h-(f=h-this._lo);var p=(l=c+(_=(d=g-_+(this._hi-d))+h))+(_=(y=v-f+(this._lo-y))+(_+(c-l))),m=_+(l-p);return this._hi=p,this._lo=m,this}}},{key:"selfMultiply",value:function(){if(1===arguments.length){if(arguments[0]instanceof t){var e=arguments[0];return this.selfMultiply(e._hi,e._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfMultiply(n,0)}}else if(2===arguments.length){var i,r,s=arguments[0],a=arguments[1],o=null,u=null,l=null,h=null;o=(l=t.SPLIT*this._hi)-this._hi,h=t.SPLIT*s,o=l-o,i=this._hi-o,u=h-s;var c=(l=this._hi*s)+(h=o*(u=h-u)-l+o*(r=s-u)+i*u+i*r+(this._hi*a+this._lo*s)),f=h+(o=l-c);return this._hi=c,this._lo=f,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return t.NaN;var e=Math.floor(this._hi),n=0;return e===this._hi&&(n=Math.floor(this._lo)),new t(e,n)}},{key:"negate",value:function(){return this.isNaN()?this:new t(-this._hi,-this._lo)}},{key:"clone",value:function(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return null;throw t}}},{key:"multiply",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return e.isNaN()?t.createNaN():t.copy(this).selfMultiply(e)}if("number"==typeof arguments[0]){var n=arguments[0];return A.isNaN(n)?t.createNaN():t.copy(this).selfMultiply(n,0)}}},{key:"isNaN",value:function(){return A.isNaN(this._hi)}},{key:"intValue",value:function(){return Math.trunc(this._hi)}},{key:"toString",value:function(){var e=t.magnitude(this._hi);return e>=-3&&e<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var e=this.getSpecialNumberString();if(null!==e)return e;var n=new Array(1).fill(null),i=this.extractSignificantDigits(!0,n),r=n[0]+1,s=i;if("."===i.charAt(0))s="0"+i;else if(r<0)s="0."+t.stringOfChar("0",-r)+i;else if(-1===i.indexOf(".")){var a=r-i.length;s=i+t.stringOfChar("0",a)+".0"}return this.isNegative()?"-"+s:s}},{key:"reciprocal",value:function(){var e,n,i,r,s=null,a=null,o=null,u=null;e=(i=1/this._hi)-(s=(o=t.SPLIT*i)-(s=o-i)),a=(u=t.SPLIT*this._hi)-this._hi;var l=i+(o=(1-(r=i*this._hi)-(u=s*(a=u-a)-r+s*(n=this._hi-a)+e*a+e*n)-i*this._lo)/this._hi);return new t(l,i-l+o)}},{key:"toSciNotation",value:function(){if(this.isZero())return t.SCI_NOT_ZERO;var e=this.getSpecialNumberString();if(null!==e)return e;var n=new Array(1).fill(null),i=this.extractSignificantDigits(!1,n),r=t.SCI_NOT_EXPONENT_CHAR+n[0];if("0"===i.charAt(0))throw new IllegalStateException("Found leading zero: "+i);var s="";i.length>1&&(s=i.substring(1));var a=i.charAt(0)+"."+s;return this.isNegative()?"-"+a+r:a+r}},{key:"abs",value:function(){return this.isNaN()?t.NaN:this.isNegative()?this.negate():new t(this)}},{key:"isPositive",value:function(){return this._hi>0||0===this._hi&&this._lo>0}},{key:"lt",value:function(t){return this._hit._hi||this._hi===t._hi&&this._lo>t._lo}},{key:"isNegative",value:function(){return this._hi<0||0===this._hi&&this._lo<0}},{key:"trunc",value:function(){return this.isNaN()?t.NaN:this.isPositive()?this.floor():this.ceil()}},{key:"signum",value:function(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}},{key:"interfaces_",get:function(){return[E,x,I]}}],[{key:"constructor_",value:function(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){var e=arguments[0];this.init(e)}else if(arguments[0]instanceof t){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){var i=arguments[0];t.constructor_.call(this,t.parse(i))}}else if(2===arguments.length){var r=arguments[0],s=arguments[1];this.init(r,s)}}},{key:"determinant",value:function(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1],i=arguments[2],r=arguments[3];return t.determinant(t.valueOf(e),t.valueOf(n),t.valueOf(i),t.valueOf(r))}if(arguments[3]instanceof t&&arguments[2]instanceof t&&arguments[0]instanceof t&&arguments[1]instanceof t){var s=arguments[1],a=arguments[2],o=arguments[3];return arguments[0].multiply(o).selfSubtract(s.multiply(a))}}},{key:"sqr",value:function(e){return t.valueOf(e).selfMultiply(e)}},{key:"valueOf",value:function(){if("string"==typeof arguments[0]){var e=arguments[0];return t.parse(e)}if("number"==typeof arguments[0])return new t(arguments[0])}},{key:"sqrt",value:function(e){return t.valueOf(e).sqrt()}},{key:"parse",value:function(e){for(var n=0,i=e.length;ot.isWhitespace(e.charAt(n));)n++;var r=!1;if(n=i);){var c=e.charAt(n);if(n++,ot.isDigit(c)){var f=c-"0";a.selfMultiply(t.TEN),a.selfAdd(f),o++}else{if("."!==c){if("e"===c||"E"===c){var g=e.substring(n);try{l=at.parseInt(g)}catch(t){throw t instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+g+" in string "+e):t}break}throw new NumberFormatException("Unexpected character '"+c+"' at position "+n+" in string "+e)}u=o,h=!0}}var v=a;h||(u=o);var y=o-u-l;if(0===y)v=a;else if(y>0){var d=t.TEN.pow(y);v=a.divide(d)}else if(y<0){var _=t.TEN.pow(-y);v=a.multiply(_)}return r?v.negate():v}},{key:"createNaN",value:function(){return new t(A.NaN,A.NaN)}},{key:"copy",value:function(e){return new t(e)}},{key:"magnitude",value:function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),i=Math.trunc(Math.floor(n));return 10*Math.pow(10,i)<=e&&(i+=1),i}},{key:"stringOfChar",value:function(t,e){for(var n=new st,i=0;i0){if(a<=0)return t.signum(o);r=s+a}else{if(!(s<0))return t.signum(o);if(a>=0)return t.signum(o);r=-s-a}var u=t.DP_SAFE_EPSILON*r;return o>=u||-o>=u?t.signum(o):2}},{key:"signum",value:function(t){return t>0?1:t<0?-1:0}}])}();lt.DP_SAFE_EPSILON=1e-15;var ht=function(){return s((function t(){n(this,t)}),[{key:"getM",value:function(t){if(this.hasM()){var e=this.getDimension()-this.getMeasures();return this.getOrdinate(t,e)}return A.NaN}},{key:"setOrdinate",value:function(t,e,n){}},{key:"getZ",value:function(t){return this.hasZ()?this.getOrdinate(t,2):A.NaN}},{key:"size",value:function(){}},{key:"getOrdinate",value:function(t,e){}},{key:"getCoordinate",value:function(){}},{key:"getCoordinateCopy",value:function(t){}},{key:"createCoordinate",value:function(){}},{key:"getDimension",value:function(){}},{key:"hasM",value:function(){return this.getMeasures()>0}},{key:"getX",value:function(t){}},{key:"hasZ",value:function(){return this.getDimension()-this.getMeasures()>2}},{key:"getMeasures",value:function(){return 0}},{key:"expandEnvelope",value:function(t){}},{key:"copy",value:function(){}},{key:"getY",value:function(t){}},{key:"toCoordinateArray",value:function(){}},{key:"interfaces_",get:function(){return[I]}}])}();ht.X=0,ht.Y=1,ht.Z=2,ht.M=3;var ct=function(){function t(){n(this,t)}return s(t,null,[{key:"index",value:function(t,e,n){return lt.orientationIndex(t,e,n)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var e=arguments[0],n=e.length-1;if(n<3)throw new m("Ring has fewer than 4 points, so orientation cannot be determined");for(var i=e[0],r=0,s=1;s<=n;s++){var a=e[s];a.y>i.y&&(i=a,r=s)}var o=r;do{(o-=1)<0&&(o=n)}while(e[o].equals2D(i)&&o!==r);var u=r;do{u=(u+1)%n}while(e[u].equals2D(i)&&u!==r);var l=e[o],h=e[u];if(l.equals2D(i)||h.equals2D(i)||l.equals2D(h))return!1;var c=t.index(l,i,h);return 0===c?l.x>h.x:c>0}if(rt(arguments[0],ht)){var f=arguments[0],g=f.size()-1;if(g<3)throw new m("Ring has fewer than 4 points, so orientation cannot be determined");for(var v=f.getCoordinate(0),y=0,d=1;d<=g;d++){var _=f.getCoordinate(d);_.y>v.y&&(v=_,y=d)}var p=null,k=y;do{(k-=1)<0&&(k=g),p=f.getCoordinate(k)}while(p.equals2D(v)&&k!==y);var x=null,I=y;do{I=(I+1)%g,x=f.getCoordinate(I)}while(x.equals2D(v)&&I!==y);if(p.equals2D(v)||x.equals2D(v)||p.equals2D(x))return!1;var E=t.index(p,v,x);return 0===E?p.x>x.x:E>0}}}])}();ct.CLOCKWISE=-1,ct.RIGHT=ct.CLOCKWISE,ct.COUNTERCLOCKWISE=1,ct.LEFT=ct.COUNTERCLOCKWISE,ct.COLLINEAR=0,ct.STRAIGHT=ct.COLLINEAR;var ft=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"getCoordinate",value:function(){return this._minCoord}},{key:"getRightmostSide",value:function(t,e){var n=this.getRightmostSideOfSegment(t,e);return n<0&&(n=this.getRightmostSideOfSegment(t,e-1)),n<0&&(this._minCoord=null,this.checkForRightmostCoordinate(t)),n}},{key:"findRightmostEdgeAtVertex",value:function(){var t=this._minDe.getEdge().getCoordinates();G.isTrue(this._minIndex>0&&this._minIndexthis._minCoord.y&&n.y>this._minCoord.y&&i===ct.CLOCKWISE)&&(r=!0),r&&(this._minIndex=this._minIndex-1)}},{key:"getRightmostSideOfSegment",value:function(t,e){var n=t.getEdge().getCoordinates();if(e<0||e+1>=n.length)return-1;if(n[e].y===n[e+1].y)return-1;var i=$.LEFT;return n[e].ythis._minCoord.x)&&(this._minDe=t,this._minIndex=n,this._minCoord=e[n])}},{key:"findRightmostEdgeAtNode",value:function(){var t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}},{key:"findEdge",value:function(t){for(var e=t.iterator();e.hasNext();){var n=e.next();n.isForward()&&this.checkForRightmostCoordinate(n)}G.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)===$.LEFT&&(this._orientedDe=this._minDe.getSym())}}],[{key:"constructor_",value:function(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}}])}(),gt=function(t){function i(t,r){var s;return n(this,i),(s=e(this,i,[r?t+" [ "+r+" ]":t])).pt=r?new X(r):void 0,s.name=Object.keys({TopologyException:i})[0],s}return l(i,t),s(i,[{key:"getCoordinate",value:function(){return this.pt}}])}(D),vt=function(){return s((function t(){n(this,t),this.array=[]}),[{key:"addLast",value:function(t){this.array.push(t)}},{key:"removeFirst",value:function(){return this.array.shift()}},{key:"isEmpty",value:function(){return 0===this.array.length}}])}(),yt=function(t){function i(t){var r;return n(this,i),(r=e(this,i)).array=[],t instanceof Z&&r.addAll(t),r}return l(i,t),s(i,[{key:"interfaces_",get:function(){return[nt,Z]}},{key:"ensureCapacity",value:function(){}},{key:"add",value:function(t){return 1===arguments.length?this.array.push(t):this.array.splice(arguments[0],0,arguments[1]),!0}},{key:"clear",value:function(){this.array=[]}},{key:"addAll",value:function(t){var e,n=a(t);try{for(n.s();!(e=n.n()).done;){var i=e.value;this.array.push(i)}}catch(t){n.e(t)}finally{n.f()}}},{key:"set",value:function(t,e){var n=this.array[t];return this.array[t]=e,n}},{key:"iterator",value:function(){return new dt(this)}},{key:"get",value:function(t){if(t<0||t>=this.size())throw new et;return this.array[t]}},{key:"isEmpty",value:function(){return 0===this.array.length}},{key:"sort",value:function(t){t?this.array.sort((function(e,n){return t.compare(e,n)})):this.array.sort()}},{key:"size",value:function(){return this.array.length}},{key:"toArray",value:function(){return this.array.slice()}},{key:"remove",value:function(t){for(var e=0,n=this.array.length;e=1&&e.getDepth($.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}}},{key:"computeDepths",value:function(t){var e=new J,n=new vt,i=t.getNode();for(n.addLast(i),e.add(i),t.setVisited(!0);!n.isEmpty();){var r=n.removeFirst();e.add(r),this.computeNodeDepth(r);for(var s=r.getEdges().iterator();s.hasNext();){var a=s.next().getSym();if(!a.isVisited()){var o=a.getNode();e.contains(o)||(n.addLast(o),e.add(o))}}}}},{key:"compareTo",value:function(t){var e=t;return this._rightMostCoord.xe._rightMostCoord.x?1:0}},{key:"getEnvelope",value:function(){if(null===this._env){for(var t=new U,e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),i=0;ie.x?t.x:e.x,o=t.y>e.y?t.y:e.y,u=n.xi.x?n.x:i.x,c=n.y>i.y?n.y:i.y,f=((r>u?r:u)+(al?s:l)+(on?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var i=arguments[0],r=arguments[1],s=arguments[2];return is?s:i}}},{key:"wrap",value:function(t,e){return t<0?e- -t%e:t%e}},{key:"max",value:function(){if(3===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[0];return t>n&&(n=t),e>n&&(n=e),n}if(4===arguments.length){var i=arguments[1],r=arguments[2],s=arguments[3],a=arguments[0];return i>a&&(a=i),r>a&&(a=r),s>a&&(a=s),a}}},{key:"average",value:function(t,e){return(t+e)/2}}])}();kt.LOG_10=Math.log(10);var xt=function(){function t(){n(this,t)}return s(t,null,[{key:"segmentToSegment",value:function(e,n,i,r){if(e.equals(n))return t.pointToSegment(e,i,r);if(i.equals(r))return t.pointToSegment(r,e,n);var s=!1;if(U.intersects(e,n,i,r)){var a=(n.x-e.x)*(r.y-i.y)-(n.y-e.y)*(r.x-i.x);if(0===a)s=!0;else{var o=(e.y-i.y)*(r.x-i.x)-(e.x-i.x)*(r.y-i.y),u=((e.y-i.y)*(n.x-e.x)-(e.x-i.x)*(n.y-e.y))/a,l=o/a;(l<0||l>1||u<0||u>1)&&(s=!0)}}else s=!0;return s?kt.min(t.pointToSegment(e,i,r),t.pointToSegment(n,i,r),t.pointToSegment(i,e,n),t.pointToSegment(r,e,n)):0}},{key:"pointToSegment",value:function(t,e,n){if(e.x===n.x&&e.y===n.y)return t.distance(e);var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/i;if(r<=0)return t.distance(e);if(r>=1)return t.distance(n);var s=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(s)*Math.sqrt(i)}},{key:"pointToLinePerpendicular",value:function(t,e,n){var i=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),r=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/i;return Math.abs(r)*Math.sqrt(i)}},{key:"pointToSegmentString",value:function(e,n){if(0===n.length)throw new m("Line array must contain at least one vertex");for(var i=e.distance(n[0]),r=0;r0)&&(s=o,r=a)}return r}}},{key:"extend",value:function(e,n,i){var r=e.create(i,n.getDimension()),s=n.size();if(t.copy(n,0,r,0,s),s>0)for(var a=s;a0)&&(e=i)}return e}}])}(),Lt=function(){function t(){n(this,t)}return s(t,null,[{key:"toDimensionSymbol",value:function(e){switch(e){case t.FALSE:return t.SYM_FALSE;case t.TRUE:return t.SYM_TRUE;case t.DONTCARE:return t.SYM_DONTCARE;case t.P:return t.SYM_P;case t.L:return t.SYM_L;case t.A:return t.SYM_A}throw new m("Unknown dimension value: "+e)}},{key:"toDimensionValue",value:function(e){switch(ot.toUpperCase(e)){case t.SYM_FALSE:return t.FALSE;case t.SYM_TRUE:return t.TRUE;case t.SYM_DONTCARE:return t.DONTCARE;case t.SYM_P:return t.P;case t.SYM_L:return t.L;case t.SYM_A:return t.A}throw new m("Unknown dimension symbol: "+e)}}])}();Lt.P=0,Lt.L=1,Lt.A=2,Lt.FALSE=-1,Lt.TRUE=-2,Lt.DONTCARE=-3,Lt.SYM_FALSE="F",Lt.SYM_TRUE="T",Lt.SYM_DONTCARE="*",Lt.SYM_P="0",Lt.SYM_L="1",Lt.SYM_A="2";var Ct=function(){return s((function t(){n(this,t)}),[{key:"filter",value:function(t){}}])}(),Rt=function(){return s((function t(){n(this,t)}),[{key:"filter",value:function(t,e){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}])}(),wt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new U:this._points.expandEnvelope(new U)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new i(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof V){var t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;var n=t;if(this._points.size()!==n._points.size())return!1;for(var r=0;r0){var n=this._points.copy();St.reverse(n),this._points=n}return null}}}},{key:"getCoordinate",value:function(){return this.isEmpty()?null:this._points.getCoordinate(0)}},{key:"getBoundaryDimension",value:function(){return this.isClosed()?Lt.FALSE:0}},{key:"isClosed",value:function(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}},{key:"reverseInternal",value:function(){var t=this._points.copy();return St.reverse(t),this.getFactory().createLineString(t)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return V.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return Nt.ofLine(this._points)}},{key:"getNumPoints",value:function(){return this._points.size()}},{key:"compareToSameClass",value:function(){if(1===arguments.length){for(var t=arguments[0],e=0,n=0;e= 2)");this._points=t}},{key:"isCoordinate",value:function(t){for(var e=0;e=1&&this.getCoordinateSequence().size()= 4)")}},{key:"getGeometryType",value:function(){return V.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];wt.constructor_.call(this,t,e),this.validateConstruction()}}])}(wt);Xt.MINIMUM_VALID_SIZE=4;var Bt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"setOrdinate",value:function(t,e){switch(t){case i.X:this.x=e;break;case i.Y:this.y=e;break;default:throw new m("Invalid ordinate index: "+t)}}},{key:"getZ",value:function(){return X.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case i.X:return this.x;case i.Y:return this.y}throw new m("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new m("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new i(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}}],[{key:"constructor_",value:function(){if(0===arguments.length)X.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof i){var t=arguments[0];X.constructor_.call(this,t.x,t.y)}else if(arguments[0]instanceof X){var e=arguments[0];X.constructor_.call(this,e.x,e.y)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];X.constructor_.call(this,n,r,X.NULL_ORDINATE)}}}])}(X);Bt.X=0,Bt.Y=1,Bt.Z=-1,Bt.M=-1;var Ut=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case i.X:this.x=e;break;case i.Y:this.y=e;break;case i.M:this._m=e;break;default:throw new m("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getZ",value:function(){return X.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case i.X:return this.x;case i.Y:return this.y;case i.M:return this._m}throw new m("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new m("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new i(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)X.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof i){var t=arguments[0];X.constructor_.call(this,t.x,t.y),this._m=t._m}else if(arguments[0]instanceof X){var e=arguments[0];X.constructor_.call(this,e.x,e.y),this._m=this.getM()}}else if(3===arguments.length){var n=arguments[0],r=arguments[1],s=arguments[2];X.constructor_.call(this,n,r,X.NULL_ORDINATE),this._m=s}}}])}(X);Ut.X=0,Ut.Y=1,Ut.Z=-1,Ut.M=2;var Vt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case X.X:this.x=e;break;case X.Y:this.y=e;break;case X.Z:this.z=e;break;case X.M:this._m=e;break;default:throw new m("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getOrdinate",value:function(t){switch(t){case X.X:return this.x;case X.Y:return this.y;case X.Z:return this.getZ();case X.M:return this.getM()}throw new m("Invalid ordinate index: "+t)}},{key:"copy",value:function(){return new i(this)}},{key:"toString",value:function(){return"("+this.x+", "+this.y+", "+this.getZ()+" m="+this.getM()+")"}},{key:"setCoordinate",value:function(t){this.x=t.x,this.y=t.y,this.z=t.getZ(),this._m=t.getM()}}],[{key:"constructor_",value:function(){if(this._m=null,0===arguments.length)X.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof i){var t=arguments[0];X.constructor_.call(this,t),this._m=t._m}else if(arguments[0]instanceof X){var e=arguments[0];X.constructor_.call(this,e),this._m=this.getM()}}else if(4===arguments.length){var n=arguments[0],r=arguments[1],s=arguments[2],a=arguments[3];X.constructor_.call(this,n,r,s),this._m=a}}}])}(X),Ht=function(){function t(){n(this,t)}return s(t,null,[{key:"measures",value:function(t){return t instanceof Bt?0:t instanceof Ut||t instanceof Vt?1:0}},{key:"dimension",value:function(t){return t instanceof Bt?2:t instanceof Ut?3:t instanceof Vt?4:3}},{key:"create",value:function(){if(1===arguments.length){var e=arguments[0];return t.create(e,0)}if(2===arguments.length){var n=arguments[0],i=arguments[1];return 2===n?new Bt:3===n&&0===i?new X:3===n&&1===i?new Ut:4===n&&1===i?new Vt:new X}}}])}(),Zt=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"getCoordinate",value:function(t){return this.get(t)}},{key:"addAll",value:function(){if(2===arguments.length&&"boolean"==typeof arguments[1]&&rt(arguments[0],Z)){for(var t=arguments[1],e=!1,n=arguments[0].iterator();n.hasNext();)this.add(n.next(),t),e=!0;return e}return f(i,"addAll",this,1).apply(this,arguments)}},{key:"clone",value:function(){for(var t=f(i,"clone",this,1).call(this),e=0;e=1)if(this.get(this.size()-1).equals2D(r))return null;f(i,"add",this,1).call(this,r)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var s=arguments[0],a=arguments[1];return this.add(s,a),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var o=arguments[0],u=arguments[1];if(arguments[2])for(var l=0;l=0;h--)this.add(o[h],u);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof X){var c=arguments[0],g=arguments[1];if(!arguments[2]){var v=this.size();if(v>0){if(c>0)if(this.get(c-1).equals2D(g))return null;if(cp&&(m=-1);for(var k=_;k!==p;k+=m)this.add(y[k],d);return!0}}},{key:"closeRing",value:function(){if(this.size()>0){var t=this.get(0).copy();this.add(t,!1)}}}],[{key:"constructor_",value:function(){if(0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.ensureCapacity(t.length),this.add(t,!0)}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this.ensureCapacity(e.length),this.add(e,n)}}}])}(yt);Zt.coordArrayType=new Array(0).fill(null);var jt=function(){function t(){n(this,t)}return s(t,null,[{key:"isRing",value:function(t){return!(t.length<4)&&!!t[0].equals2D(t[t.length-1])}},{key:"ptNotInList",value:function(e,n){for(var i=0;i=t?e:[]}},{key:"indexOf",value:function(t,e){for(var n=0;n0)&&(e=t[n]);return e}},{key:"extract",value:function(t,e,n){e=kt.clamp(e,0,t.length);var i=(n=kt.clamp(n,-1,t.length))-e+1;n<0&&(i=0),e>=t.length&&(i=0),ni.length)return 1;if(0===n.length)return 0;var r=jt.compare(n,i);return jt.isEqualReversed(n,i)?0:r}},{key:"OLDcompare",value:function(t,e){var n=t,i=e;if(n.lengthi.length)return 1;if(0===n.length)return 0;for(var r=jt.increasingDirection(n),s=jt.increasingDirection(i),a=r>0?0:n.length-1,o=s>0?0:n.length-1,u=0;u0){var t=new Jt(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e3&&(t=3),t<2&&(t=2),new Qt(arguments[0],t)}if(3===arguments.length){var e=arguments[2],n=arguments[1]-e;return e>1&&(e=1),n>3&&(n=3),n<2&&(n=2),new Qt(arguments[0],n+e,e)}}}},{key:"interfaces_",get:function(){return[It,E]}}],[{key:"instance",value:function(){return t.instanceObject}}])}();$t.instanceObject=new $t;var te=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e=0?t:e}}])}(),re=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"readResolve",value:function(){return t.nameToTypeMap.get(this._name)}},{key:"toString",value:function(){return this._name}},{key:"interfaces_",get:function(){return[E]}}],[{key:"constructor_",value:function(){this._name=null;var e=arguments[0];this._name=e,t.nameToTypeMap.put(e,this)}}])}();re.nameToTypeMap=new ne,ie.Type=re,ie.FIXED=new re("FIXED"),ie.FLOATING=new re("FLOATING"),ie.FLOATING_SINGLE=new re("FLOATING SINGLE"),ie.maximumPreciseValue=9007199254740992;var se=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e1){if(u instanceof Dt)return this.createMultiPolygon(t.toPolygonArray(e));if(u instanceof wt)return this.createMultiLineString(t.toLineStringArray(e));if(u instanceof bt)return this.createMultiPoint(t.toPointArray(e));G.shouldNeverReachHere("Unhandled geometry type: "+u.getGeometryType())}return u}},{key:"createMultiPointFromCoords",value:function(t){return this.createMultiPoint(null!==t?this.getCoordinateSequenceFactory().create(t):null)}},{key:"createPoint",value:function(){if(0===arguments.length)return this.createPoint(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof X){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(rt(arguments[0],ht))return new bt(arguments[0],this)}}},{key:"getCoordinateSequenceFactory",value:function(){return this._coordinateSequenceFactory}},{key:"createPolygon",value:function(){if(0===arguments.length)return this.createPolygon(null,null);if(1===arguments.length){if(rt(arguments[0],ht)){var t=arguments[0];return this.createPolygon(this.createLinearRing(t))}if(arguments[0]instanceof Array){var e=arguments[0];return this.createPolygon(this.createLinearRing(e))}if(arguments[0]instanceof Xt){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length){return new Dt(arguments[0],arguments[1],this)}}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){return 0===arguments.length?new Yt(null,this):1===arguments.length?new Yt(arguments[0],this):void 0}},{key:"getPrecisionModel",value:function(){return this._precisionModel}},{key:"createLinearRing",value:function(){if(0===arguments.length)return this.createLinearRing(this.getCoordinateSequenceFactory().create([]));if(1===arguments.length){if(arguments[0]instanceof Array){var t=arguments[0];return this.createLinearRing(null!==t?this.getCoordinateSequenceFactory().create(t):null)}if(rt(arguments[0],ht))return new Xt(arguments[0],this)}}},{key:"createMultiPolygon",value:function(){return 0===arguments.length?new te(null,this):1===arguments.length?new te(arguments[0],this):void 0}},{key:"createMultiPoint",value:function(){if(0===arguments.length)return new zt(null,this);if(1===arguments.length){if(arguments[0]instanceof Array)return new zt(arguments[0],this);if(rt(arguments[0],ht)){var t=arguments[0];if(null===t)return this.createMultiPoint(new Array(0).fill(null));for(var e=new Array(t.size()).fill(null),n=0;n="a"&&t<="z"||t>="A"&&t<="Z"}},{key:"isNumeric_",value:function(t,e){return t>="0"&&t<="9"||"."==t&&!(void 0!==e&&e)}},{key:"isWhiteSpace_",value:function(t){return" "==t||"\t"==t||"\r"==t||"\n"==t}},{key:"nextChar_",value:function(){return this.wkt.charAt(++this.index_)}},{key:"nextToken",value:function(){var t,e=this.nextChar_(),n=this.index_,i=e;if("("==e)t=ve;else if(","==e)t=_e;else if(")"==e)t=ye;else if(this.isNumeric_(e)||"-"==e)t=de,i=this.readNumber_();else if(this.isAlpha_(e))t=ge,i=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(""!==e)throw new Error("Unexpected character: "+e);t=pe}return{position:n,value:i,type:t}}},{key:"readNumber_",value:function(){var t,e=this.index_,n=!1,i=!1;do{"."==t?n=!0:"e"!=t&&"E"!=t||(i=!0),t=this.nextChar_()}while(this.isNumeric_(t,n)||!i&&("e"==t||"E"==t)||i&&("-"==t||"+"==t));return parseFloat(this.wkt.substring(e,this.index_--))}},{key:"readText_",value:function(){var t,e=this.index_;do{t=this.nextChar_()}while(this.isAlpha_(t));return this.wkt.substring(e,this.index_--).toUpperCase()}}])}(),xe=function(){return s((function t(e,i){n(this,t),this.lexer_=e,this.token_,this.layout_=oe,this.factory=i}),[{key:"consume_",value:function(){this.token_=this.lexer_.nextToken()}},{key:"isTokenType",value:function(t){return this.token_.type==t}},{key:"match",value:function(t){var e=this.isTokenType(t);return e&&this.consume_(),e}},{key:"parse",value:function(){return this.consume_(),this.parseGeometry_()}},{key:"parseGeometryLayout_",value:function(){var t=oe,e=this.token_;if(this.isTokenType(ge)){var n=e.value;"Z"===n?t=ue:"M"===n?t=le:"ZM"===n&&(t=he),t!==oe&&this.consume_()}return t}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(ve)){var t=[];do{t.push(this.parseGeometry_())}while(this.match(_e));if(this.match(ye))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(ve)){var t=this.parsePoint_();if(this.match(ye))return t}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(ve)){var t=this.parsePointList_();if(this.match(ye))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(ve)){var t=this.parseLineStringTextList_();if(this.match(ye))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var t;if(this.match(ve)){if(t=this.token_.type==ve?this.parsePointTextList_():this.parsePointList_(),this.match(ye))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(ve)){var t=this.parseLineStringTextList_();if(this.match(ye))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(ve)){var t=this.parsePolygonTextList_();if(this.match(ye))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePoint_",value:function(){for(var t=[],e=this.layout_.length,n=0;n1?t.createPolygon(i[0],i.slice(1)):t.createPolygon(i[0])},r=this.token_;if(this.match(ge)){var s=r.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==s){var a=this.parseGeometryCollectionText_();return t.createGeometryCollection(a)}switch(s){case"POINT":var o=this.parsePointText_();return o?t.createPoint(i(X,g(o))):t.createPoint();case"LINESTRING":var u=this.parseLineStringText_().map(e);return t.createLineString(u);case"LINEARRING":var l=this.parseLineStringText_().map(e);return t.createLinearRing(l);case"POLYGON":var h=this.parsePolygonText_();return h&&0!==h.length?n(h):t.createPolygon();case"MULTIPOINT":var c=this.parseMultiPointText_();if(!c||0===c.length)return t.createMultiPoint();var f=c.map(e).map((function(e){return t.createPoint(e)}));return t.createMultiPoint(f);case"MULTILINESTRING":var v=this.parseMultiLineStringText_().map((function(n){return t.createLineString(n.map(e))}));return t.createMultiLineString(v);case"MULTIPOLYGON":var y=this.parseMultiPolygonText_();if(!y||0===y.length)return t.createMultiPolygon();var d=y.map(n);return t.createMultiPolygon(d);default:throw new Error("Invalid geometry type: "+s)}}throw new Error(this.formatErrorMessage_())}}])}();function Ie(t){if(t.isEmpty())return"";var e=t.getCoordinate(),n=[e.x,e.y];return void 0===e.z||Number.isNaN(e.z)||n.push(e.z),void 0===e.m||Number.isNaN(e.m)||n.push(e.m),n.join(" ")}function Ee(t){for(var e=t.getCoordinates().map((function(t){var 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})),n=[],i=0,r=e.length;i0&&(e+=" "+i),t.isEmpty()?e+" "+fe:e+" ("+n(t)+")"}var Le=function(){return s((function t(e){n(this,t),this.geometryFactory=e||new ae,this.precisionModel=this.geometryFactory.getPrecisionModel()}),[{key:"read",value:function(t){var e=new ke(t);return new xe(e,this.geometryFactory).parse()}},{key:"write",value:function(t){return Se(t)}}])}(),Ce=function(){return s((function t(e){n(this,t),this.parser=new Le(e)}),[{key:"write",value:function(t){return this.parser.write(t)}}],[{key:"toLineString",value:function(t,e){if(2!==arguments.length)throw new Error("Not implemented");return"LINESTRING ( "+t.x+" "+t.y+", "+e.x+" "+e.y+" )"}}])}(),Re=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"getIndexAlongSegment",value:function(t,e){return this.computeIntLineIndex(),this._intLineIndex[t][e]}},{key:"getTopologySummary",value:function(){var t=new Jt;return this.isEndPoint()&&t.append(" endpoint"),this._isProper&&t.append(" proper"),this.isCollinear()&&t.append(" collinear"),t.toString()}},{key:"computeIntersection",value:function(t,e,n,i){this._inputLines[0][0]=t,this._inputLines[0][1]=e,this._inputLines[1][0]=n,this._inputLines[1][1]=i,this._result=this.computeIntersect(t,e,n,i)}},{key:"getIntersectionNum",value:function(){return this._result}},{key:"computeIntLineIndex",value:function(){if(0===arguments.length)null===this._intLineIndex&&(this._intLineIndex=Array(2).fill().map((function(){return Array(2)})),this.computeIntLineIndex(0),this.computeIntLineIndex(1));else if(1===arguments.length){var 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)}}},{key:"isProper",value:function(){return this.hasIntersection()&&this._isProper}},{key:"setPrecisionModel",value:function(t){this._precisionModel=t}},{key:"isInteriorIntersection",value:function(){if(0===arguments.length)return!!this.isInteriorIntersection(0)||!!this.isInteriorIntersection(1);if(1===arguments.length){for(var t=arguments[0],e=0;er?i:r;else{var a=Math.abs(t.x-e.x),o=Math.abs(t.y-e.y);0!==(s=i>r?a:o)||t.equals(e)||(s=Math.max(a,o))}return G.isTrue(!(0===s&&!t.equals(e)),"Bad distance calculation"),s}},{key:"nonRobustComputeEdgeDistance",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y,s=Math.sqrt(i*i+r*r);return G.isTrue(!(0===s&&!t.equals(e)),"Invalid distance calculation"),s}}])}();Re.DONT_INTERSECT=0,Re.DO_INTERSECT=1,Re.COLLINEAR=2,Re.NO_INTERSECTION=0,Re.POINT_INTERSECTION=1,Re.COLLINEAR_INTERSECTION=2;var we=function(t){function i(){return n(this,i),e(this,i)}return l(i,t),s(i,[{key:"isInSegmentEnvelopes",value:function(t){var e=new U(this._inputLines[0][0],this._inputLines[0][1]),n=new U(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t)}},{key:"computeIntersection",value:function(){if(3!==arguments.length)return f(i,"computeIntersection",this,1).apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2];if(this._isProper=!1,U.intersects(e,n,t)&&0===ct.index(e,n,t)&&0===ct.index(n,e,t))return this._isProper=!0,(t.equals(e)||t.equals(n))&&(this._isProper=!1),this._result=Re.POINT_INTERSECTION,null;this._result=Re.NO_INTERSECTION}},{key:"intersection",value:function(t,e,n,r){var s=this.intersectionSafe(t,e,n,r);return this.isInSegmentEnvelopes(s)||(s=new X(i.nearestEndpoint(t,e,n,r))),null!==this._precisionModel&&this._precisionModel.makePrecise(s),s}},{key:"checkDD",value:function(t,e,n,i,r){var s=lt.intersection(t,e,n,i),a=this.isInSegmentEnvelopes(s);mt.out.println("DD in env = "+a+" --------------------- "+s),r.distance(s)>1e-4&&mt.out.println("Distance = "+r.distance(s))}},{key:"intersectionSafe",value:function(t,e,n,r){var s=pt.intersection(t,e,n,r);return null===s&&(s=i.nearestEndpoint(t,e,n,r)),s}},{key:"computeCollinearIntersection",value:function(t,e,n,i){var r=U.intersects(t,e,n),s=U.intersects(t,e,i),a=U.intersects(n,i,t),o=U.intersects(n,i,e);return r&&s?(this._intPt[0]=n,this._intPt[1]=i,Re.COLLINEAR_INTERSECTION):a&&o?(this._intPt[0]=t,this._intPt[1]=e,Re.COLLINEAR_INTERSECTION):r&&a?(this._intPt[0]=n,this._intPt[1]=t,!n.equals(t)||s||o?Re.COLLINEAR_INTERSECTION:Re.POINT_INTERSECTION):r&&o?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||s||a?Re.COLLINEAR_INTERSECTION:Re.POINT_INTERSECTION):s&&a?(this._intPt[0]=i,this._intPt[1]=t,!i.equals(t)||r||o?Re.COLLINEAR_INTERSECTION:Re.POINT_INTERSECTION):s&&o?(this._intPt[0]=i,this._intPt[1]=e,!i.equals(e)||r||a?Re.COLLINEAR_INTERSECTION:Re.POINT_INTERSECTION):Re.NO_INTERSECTION}},{key:"computeIntersect",value:function(t,e,n,i){if(this._isProper=!1,!U.intersects(t,e,n,i))return Re.NO_INTERSECTION;var r=ct.index(t,e,n),s=ct.index(t,e,i);if(r>0&&s>0||r<0&&s<0)return Re.NO_INTERSECTION;var a=ct.index(n,i,t),o=ct.index(n,i,e);return a>0&&o>0||a<0&&o<0?Re.NO_INTERSECTION:0===r&&0===s&&0===a&&0===o?this.computeCollinearIntersection(t,e,n,i):(0===r||0===s||0===a||0===o?(this._isProper=!1,t.equals2D(n)||t.equals2D(i)?this._intPt[0]=t:e.equals2D(n)||e.equals2D(i)?this._intPt[0]=e:0===r?this._intPt[0]=new X(n):0===s?this._intPt[0]=new X(i):0===a?this._intPt[0]=new X(t):0===o&&(this._intPt[0]=new X(e))):(this._isProper=!0,this._intPt[0]=this.intersection(t,e,n,i)),Re.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(t,e,n,i){var r=t,s=xt.pointToSegment(t,n,i),a=xt.pointToSegment(e,n,i);return ai&&(n=e.x,i=t.x),this._p.x>=n&&this._p.x<=i&&(this._isPointOnSegment=!0),null}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var r=ct.index(t,e,this._p);if(r===ct.COLLINEAR)return this._isPointOnSegment=!0,null;e.ythis.location.length){var e=new Array(3).fill(null);e[$.ON]=this.location[$.ON],e[$.LEFT]=H.NONE,e[$.RIGHT]=H.NONE,this.location=e}for(var n=0;n1&&t.append(H.toLocationSymbol(this.location[$.LEFT])),t.append(H.toLocationSymbol(this.location[$.ON])),this.location.length>1&&t.append(H.toLocationSymbol(this.location[$.RIGHT])),t.toString()}},{key:"setLocations",value:function(t,e,n){this.location[$.ON]=t,this.location[$.LEFT]=e,this.location[$.RIGHT]=n}},{key:"get",value:function(t){return t1}},{key:"isAnyNull",value:function(){for(var t=0;tthis._maxNodeDegree&&(this._maxNodeDegree=e),t=this.getNext(t)}while(t!==this._startDe);this._maxNodeDegree*=2}},{key:"addPoints",value:function(t,e,n){var i=t.getCoordinates();if(e){var r=1;n&&(r=0);for(var s=r;s=0;o--)this._pts.add(i[o])}}},{key:"isHole",value:function(){return this._isHole}},{key:"setInResult",value:function(){var t=this._startDe;do{t.getEdge().setInResult(!0),t=t.getNext()}while(t!==this._startDe)}},{key:"containsPoint",value:function(t){var e=this.getLinearRing();if(!e.getEnvelopeInternal().contains(t))return!1;if(!be.isInRing(t,e.getCoordinates()))return!1;for(var n=this._holes.iterator();n.hasNext();){if(n.next().containsPoint(t))return!1}return!0}},{key:"addHole",value:function(t){this._holes.add(t)}},{key:"isShell",value:function(){return null===this._shell}},{key:"getLabel",value:function(){return this._label}},{key:"getEdges",value:function(){return this._edges}},{key:"getMaxNodeDegree",value:function(){return this._maxNodeDegree<0&&this.computeMaxNodeDegree(),this._maxNodeDegree}},{key:"getShell",value:function(){return this._shell}},{key:"mergeLabel",value:function(){if(1===arguments.length){var t=arguments[0];this.mergeLabel(t,0),this.mergeLabel(t,1)}else if(2===arguments.length){var e=arguments[1],n=arguments[0].getLocation(e,$.RIGHT);if(n===H.NONE)return null;if(this._label.getLocation(e)===H.NONE)return this._label.setLocation(e,n),null}}},{key:"setShell",value:function(t){this._shell=t,null!==t&&t.addHole(this)}},{key:"toPolygon",value:function(t){for(var e=new Array(this._holes.size()).fill(null),n=0;n=2,"found partial label"),this.computeIM(t)}},{key:"isInResult",value:function(){return this._isInResult}},{key:"isVisited",value:function(){return this._isVisited}}],[{key:"constructor_",value:function(){if(this._label=null,this._isInResult=!1,this._isCovered=!1,this._isCoveredSet=!1,this._isVisited=!1,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._label=t}}}])}(),qe=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"isIncidentEdgeInResult",value:function(){for(var t=this.getEdges().getEdges().iterator();t.hasNext();){if(t.next().getEdge().isInResult())return!0}return!1}},{key:"isIsolated",value:function(){return 1===this._label.getGeometryCount()}},{key:"getCoordinate",value:function(){return this._coord}},{key:"print",value:function(t){t.println("node "+this._coord+" lbl: "+this._label)}},{key:"computeIM",value:function(t){}},{key:"computeMergedLocation",value:function(t,e){var n=H.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var i=t.getLocation(e);n!==H.BOUNDARY&&(n=i)}return n}},{key:"setLabel",value:function(){if(2!==arguments.length||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return f(i,"setLabel",this,1).apply(this,arguments);var t=arguments[0],e=arguments[1];null===this._label?this._label=new Ae(t,e):this._label.setLocation(t,e)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof i){var t=arguments[0];this.mergeLabel(t._label)}else if(arguments[0]instanceof Ae)for(var e=arguments[0],n=0;n<2;n++){var r=this.computeMergedLocation(e,n);this._label.getLocation(n)===H.NONE&&this._label.setLocation(n,r)}}},{key:"add",value:function(t){this._edges.insert(t),t.setNode(this)}},{key:"setLabelBoundary",value:function(t){if(null===this._label)return null;var e=H.NONE;null!==this._label&&(e=this._label.getLocation(t));var n=null;switch(e){case H.BOUNDARY:n=H.INTERIOR;break;case H.INTERIOR:default:n=H.BOUNDARY}this._label.setLocation(t,n)}}],[{key:"constructor_",value:function(){this._coord=null,this._edges=null;var t=arguments[0],e=arguments[1];this._coord=t,this._edges=e,this._label=new Ae(0,H.NONE)}}])}(Ge),Ye=function(t){function i(){return n(this,i),e(this,i,arguments)}return l(i,t),s(i)}(ee);function ze(t){return null==t?0:t.color}function Xe(t){return null==t?null:t.parent}function Be(t,e){null!==t&&(t.color=e)}function Ue(t){return null==t?null:t.left}function Ve(t){return null==t?null:t.right}var He=function(t){function i(){var t;return n(this,i),(t=e(this,i)).root_=null,t.size_=0,t}return l(i,t),s(i,[{key:"get",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return e.value;e=e.right}}return null}},{key:"put",value:function(t,e){if(null===this.root_)return this.root_={key:t,value:e,left:null,right:null,parent:null,color:0,getValue:function(){return this.value},getKey:function(){return this.key}},this.size_=1,null;var n,i,r=this.root_;do{if(n=r,(i=t.compareTo(r.key))<0)r=r.left;else{if(!(i>0)){var s=r.value;return r.value=e,s}r=r.right}}while(null!==r);var a={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return i<0?n.left=a:n.right=a,this.fixAfterInsertion(a),this.size_++,null}},{key:"fixAfterInsertion",value:function(t){var e;for(t.color=1;null!=t&&t!==this.root_&&1===t.parent.color;)Xe(t)===Ue(Xe(Xe(t)))?1===ze(e=Ve(Xe(Xe(t))))?(Be(Xe(t),0),Be(e,0),Be(Xe(Xe(t)),1),t=Xe(Xe(t))):(t===Ve(Xe(t))&&(t=Xe(t),this.rotateLeft(t)),Be(Xe(t),0),Be(Xe(Xe(t)),1),this.rotateRight(Xe(Xe(t)))):1===ze(e=Ue(Xe(Xe(t))))?(Be(Xe(t),0),Be(e,0),Be(Xe(Xe(t)),1),t=Xe(Xe(t))):(t===Ue(Xe(t))&&(t=Xe(t),this.rotateRight(t)),Be(Xe(t),0),Be(Xe(Xe(t)),1),this.rotateLeft(Xe(Xe(t))));this.root_.color=0}},{key:"values",value:function(){var t=new yt,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=i.successor(e));)t.add(e.value);return t}},{key:"entrySet",value:function(){var t=new J,e=this.getFirstEntry();if(null!==e)for(t.add(e);null!==(e=i.successor(e));)t.add(e);return t}},{key:"rotateLeft",value:function(t){if(null!=t){var e=t.right;t.right=e.left,null!=e.left&&(e.left.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.left===t?t.parent.left=e:t.parent.right=e,e.left=t,t.parent=e}}},{key:"rotateRight",value:function(t){if(null!=t){var e=t.left;t.left=e.right,null!=e.right&&(e.right.parent=t),e.parent=t.parent,null==t.parent?this.root_=e:t.parent.right===t?t.parent.right=e:t.parent.left=e,e.right=t,t.parent=e}}},{key:"getFirstEntry",value:function(){var t=this.root_;if(null!=t)for(;null!=t.left;)t=t.left;return t}},{key:"size",value:function(){return this.size_}},{key:"containsKey",value:function(t){for(var e=this.root_;null!==e;){var n=t.compareTo(e.key);if(n<0)e=e.left;else{if(!(n>0))return!0;e=e.right}}return!1}}],[{key:"successor",value:function(t){var e;if(null===t)return null;if(null!==t.right){for(e=t.right;null!==e.left;)e=e.left;return e}e=t.parent;for(var n=t;null!==e&&n===e.right;)n=e,e=e.parent;return e}}])}(Ye),Ze=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"find",value:function(t){return this.nodeMap.get(t)}},{key:"addNode",value:function(){if(arguments[0]instanceof X){var t=arguments[0],e=this.nodeMap.get(t);return null===e&&(e=this.nodeFact.createNode(t),this.nodeMap.put(t,e)),e}if(arguments[0]instanceof qe){var n=arguments[0],i=this.nodeMap.get(n.getCoordinate());return null===i?(this.nodeMap.put(n.getCoordinate(),n),n):(i.mergeLabel(n),i)}}},{key:"print",value:function(t){for(var e=this.iterator();e.hasNext();){e.next().print(t)}}},{key:"iterator",value:function(){return this.nodeMap.values().iterator()}},{key:"values",value:function(){return this.nodeMap.values()}},{key:"getBoundaryNodes",value:function(t){for(var e=new yt,n=this.iterator();n.hasNext();){var i=n.next();i.getLabel().getLocation(t)===H.BOUNDARY&&e.add(i)}return e}},{key:"add",value:function(t){var e=t.getCoordinate();this.addNode(e).add(t)}}],[{key:"constructor_",value:function(){this.nodeMap=new He,this.nodeFact=null;var t=arguments[0];this.nodeFact=t}}])}(),je=function(){function t(){n(this,t)}return s(t,null,[{key:"isNorthern",value:function(e){return e===t.NE||e===t.NW}},{key:"isOpposite",value:function(t,e){return t!==e&&2===(t-e+4)%4}},{key:"commonHalfPlane",value:function(t,e){if(t===e)return t;if(2===(t-e+4)%4)return-1;var n=te?t:e)?3:n}},{key:"isInHalfPlane",value:function(e,n){return n===t.SE?e===t.SE||e===t.SW:e===n||e===n+1}},{key:"quadrant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var e=arguments[0],n=arguments[1];if(0===e&&0===n)throw new m("Cannot compute the quadrant for point ( "+e+", "+n+" )");return e>=0?n>=0?t.NE:t.SE:n>=0?t.NW:t.SW}if(arguments[0]instanceof X&&arguments[1]instanceof X){var i=arguments[0],r=arguments[1];if(r.x===i.x&&r.y===i.y)throw new m("Cannot compute the quadrant for two identical points "+i);return r.x>=i.x?r.y>=i.y?t.NE:t.SE:r.y>=i.y?t.NW:t.SW}}}])}();je.NE=0,je.NW=1,je.SW=2,je.SE=3;var We=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"compareDirection",value:function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant2){s.linkDirectedEdgesForMinimalEdgeRings();var a=s.buildMinimalRings(),o=this.findShell(a);null!==o?(this.placePolygonHoles(o,a),e.add(o)):n.addAll(a)}else i.add(s)}return i}},{key:"buildMaximalEdgeRings",value:function(t){for(var e=new yt,n=t.iterator();n.hasNext();){var i=n.next();if(i.isInResult()&&i.getLabel().isArea()&&null===i.getEdgeRing()){var r=new Fe(i,this._geometryFactory);e.add(r),r.setInResult()}}return e}},{key:"placePolygonHoles",value:function(t,e){for(var n=e.iterator();n.hasNext();){var i=n.next();i.isHole()&&i.setShell(t)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(t){for(var e=0,n=null,i=t.iterator();i.hasNext();){var r=i.next();r.isHole()||(n=r,e++)}return G.isTrue(e<=1,"found two shells in MinimalEdgeRing list"),n}},{key:"add",value:function(){if(1===arguments.length){var t=arguments[0];this.add(t.getEdgeEnds(),t.getNodes())}else if(2===arguments.length){var e=arguments[0],n=arguments[1];Qe.linkResultDirectedEdges(n);var i=this.buildMaximalEdgeRings(e),r=new yt,s=this.buildMinimalEdgeRings(i,this._shellList,r);this.sortShellsAndHoles(s,this._shellList,r),this.placeFreeHoles(this._shellList,r)}}}],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new yt;var t=arguments[0];this._geometryFactory=t}},{key:"findEdgeRingContaining",value:function(t,e){for(var n=t.getLinearRing(),i=n.getEnvelopeInternal(),r=n.getCoordinateN(0),s=null,a=null,o=e.iterator();o.hasNext();){var u=o.next(),l=u.getLinearRing(),h=l.getEnvelopeInternal();if(!h.equals(i)&&h.contains(i)){r=jt.ptNotInList(n.getCoordinates(),l.getCoordinates());var c=!1;be.isInRing(r,l.getCoordinates())&&(c=!0),c&&(null===s||a.contains(h))&&(a=(s=u).getLinearRing().getEnvelopeInternal())}}return s}}])}(),tn=function(){return s((function t(){n(this,t)}),[{key:"getBounds",value:function(){}}])}(),en=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[tn,E]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e}}])}(),nn=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"poll",value:function(){if(this.isEmpty())return null;var t=this._items.get(1);return this._items.set(1,this._items.get(this._size)),this._size-=1,this.reorder(1),t}},{key:"size",value:function(){return this._size}},{key:"reorder",value:function(t){for(var e=null,n=this._items.get(t);2*t<=this._size&&((e=2*t)!==this._size&&this._items.get(e+1).compareTo(this._items.get(e))<0&&e++,this._items.get(e).compareTo(n)<0);t=e)this._items.set(t,this._items.get(e));this._items.set(t,n)}},{key:"clear",value:function(){this._size=0,this._items.clear()}},{key:"peek",value:function(){return this.isEmpty()?null:this._items.get(1)}},{key:"isEmpty",value:function(){return 0===this._size}},{key:"add",value:function(t){this._items.add(null),this._size+=1;var e=this._size;for(this._items.set(0,t);t.compareTo(this._items.get(Math.trunc(e/2)))<0;e/=2)this._items.set(e,this._items.get(Math.trunc(e/2)));this._items.set(e,t)}}],[{key:"constructor_",value:function(){this._size=null,this._items=null,this._size=0,this._items=new yt,this._items.add(null)}}])}(),rn=function(){return s((function t(){n(this,t)}),[{key:"insert",value:function(t,e){}},{key:"remove",value:function(t,e){}},{key:"query",value:function(){}}])}(),sn=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"getLevel",value:function(){return this._level}},{key:"size",value:function(){return this._childBoundables.size()}},{key:"getChildBoundables",value:function(){return this._childBoundables}},{key:"addChildBoundable",value:function(t){G.isTrue(null===this._bounds),this._childBoundables.add(t)}},{key:"isEmpty",value:function(){return this._childBoundables.isEmpty()}},{key:"getBounds",value:function(){return null===this._bounds&&(this._bounds=this.computeBounds()),this._bounds}},{key:"interfaces_",get:function(){return[tn,E]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new yt,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t}}}])}(),an={reverseOrder:function(){return{compare:function(t,e){return e.compareTo(t)}}},min:function(t){return an.sort(t),t.get(0)},sort:function(t,e){var n=t.toArray();e?At.sort(n,e):At.sort(n);for(var i=t.iterator(),r=0,s=n.length;rt.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,e,n),null):(this.expand(this._boundable2,this._boundable1,!0,e,n),null);if(i)return this.expand(this._boundable1,this._boundable2,!1,e,n),null;if(r)return this.expand(this._boundable2,this._boundable1,!0,e,n),null;throw new m("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(t.isComposite(this._boundable1)||t.isComposite(this._boundable2))}},{key:"compareTo",value:function(t){var e=t;return this._distancee._distance?1:0}},{key:"expand",value:function(e,n,i,r,s){for(var a=e.getChildBoundables().iterator();a.hasNext();){var o=a.next(),u=null;(u=i?new t(n,o,this._itemDistance):new t(o,n,this._itemDistance)).getDistance()-2),i.getLevel()===n)return r.add(i),null;for(var s=i.getChildBoundables().iterator();s.hasNext();){var a=s.next();a instanceof sn?this.boundablesAtLevel(n,a,r):(G.isTrue(a instanceof en),-1===n&&r.add(a))}return null}}},{key:"query",value:function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new yt;return this.isEmpty()||this.getIntersectsOp().intersects(this._root.getBounds(),t)&&this.queryInternal(t,this._root,e),e}if(2===arguments.length){var n=arguments[0],i=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),n)&&this.queryInternal(n,this._root,i)}}},{key:"build",value:function(){if(this._built)return null;this._root=this._itemBoundables.isEmpty()?this.createNode(0):this.createHigherLevels(this._itemBoundables,-1),this._itemBoundables=null,this._built=!0}},{key:"getRoot",value:function(){return this.build(),this._root}},{key:"remove",value:function(){if(2===arguments.length){var 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){var n=arguments[0],i=arguments[1],r=arguments[2],s=this.removeItem(i,r);if(s)return!0;for(var a=null,o=i.getChildBoundables().iterator();o.hasNext();){var u=o.next();if(this.getIntersectsOp().intersects(u.getBounds(),n)&&(u instanceof sn&&(s=this.remove(n,u,r)))){a=u;break}}return null!==a&&a.getChildBoundables().isEmpty()&&i.getChildBoundables().remove(a),s}}},{key:"createHigherLevels",value:function(t,e){G.isTrue(!t.isEmpty());var n=this.createParentBoundables(t,e+1);return 1===n.size()?n.get(0):this.createHigherLevels(n,e+1)}},{key:"depth",value:function(){if(0===arguments.length)return this.isEmpty()?0:(this.build(),this.depth(this._root));if(1===arguments.length){for(var t=0,e=arguments[0].getChildBoundables().iterator();e.hasNext();){var n=e.next();if(n instanceof sn){var i=this.depth(n);i>t&&(t=i)}}return t+1}}},{key:"createParentBoundables",value:function(t,e){G.isTrue(!t.isEmpty());var n=new yt;n.add(this.createNode(e));var i=new yt(t);an.sort(i,this.getComparator());for(var r=i.iterator();r.hasNext();){var s=r.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(s)}return n}},{key:"isEmpty",value:function(){return this._built?this._root.isEmpty():this._itemBoundables.isEmpty()}},{key:"interfaces_",get:function(){return[E]}}],[{key:"constructor_",value:function(){if(this._root=null,this._built=!1,this._itemBoundables=new yt,this._nodeCapacity=null,0===arguments.length)t.constructor_.call(this,t.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var e=arguments[0];G.isTrue(e>1,"Node capacity must be greater than 1"),this._nodeCapacity=e}}},{key:"compareDoubles",value:function(t,e){return t>e?1:t0);for(var n=new yt,i=0;i=0;){var u=a.poll(),l=u.getDistance();if(l>=s)break;if(u.isLeaves())if(o.size()l&&(o.poll(),o.add(u)),s=o.peek().getDistance();else u.expandToQueue(a,s)}return i.getItems(o)}}},{key:"createNode",value:function(t){return new gn(t)}},{key:"size",value:function(){return 0===arguments.length?f(i,"size",this,1).call(this):f(i,"size",this,1).apply(this,arguments)}},{key:"insert",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof U))return f(i,"insert",this,1).apply(this,arguments);var t=arguments[0],e=arguments[1];if(t.isNull())return null;f(i,"insert",this,1).call(this,t,e)}},{key:"getIntersectsOp",value:function(){return i.intersectsOp}},{key:"verticalSlices",value:function(t,e){for(var n=Math.trunc(Math.ceil(t.size()/e)),i=new Array(e).fill(null),r=t.iterator(),s=0;s0;){var a=s.poll(),o=a.getDistance();if(o>=i)break;a.isLeaves()?(i=o,r=a):a.expandToQueue(s,i)}return null===r?null:[r.getBoundable(0).getItem(),r.getBoundable(1).getItem()]}}else{if(2===arguments.length){var u=arguments[0],l=arguments[1];if(this.isEmpty()||u.isEmpty())return null;var h=new un(this.getRoot(),u.getRoot(),l);return this.nearestNeighbour(h)}if(3===arguments.length){var c=arguments[2],f=new en(arguments[0],arguments[1]),g=new un(this.getRoot(),f,c);return this.nearestNeighbour(g)[0]}if(4===arguments.length){var v=arguments[2],y=arguments[3],d=new en(arguments[0],arguments[1]),_=new un(this.getRoot(),d,v);return this.nearestNeighbourK(_,y)}}}},{key:"isWithinDistance",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=A.POSITIVE_INFINITY,i=new nn;for(i.add(t);!i.isEmpty();){var r=i.poll(),s=r.getDistance();if(s>e)return!1;if(r.maximumDistance()<=e)return!0;if(r.isLeaves()){if((n=s)<=e)return!0}else r.expandToQueue(i,n)}return!1}if(3===arguments.length){var a=arguments[0],o=arguments[1],u=arguments[2],l=new un(this.getRoot(),a.getRoot(),o);return this.isWithinDistance(l,u)}}},{key:"interfaces_",get:function(){return[rn,E]}}],[{key:"constructor_",value:function(){if(0===arguments.length)i.constructor_.call(this,i.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];hn.constructor_.call(this,t)}}},{key:"centreX",value:function(t){return i.avg(t.getMinX(),t.getMaxX())}},{key:"avg",value:function(t,e){return(t+e)/2}},{key:"getItems",value:function(t){for(var e=new Array(t.size()).fill(null),n=0;!t.isEmpty();){var i=t.poll();e[n]=i.getBoundable(0).getItem(),n++}return e}},{key:"centreY",value:function(t){return i.avg(t.getMinY(),t.getMaxY())}}])}(hn),gn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"computeBounds",value:function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new U(n.getBounds()):t.expandToInclude(n.getBounds())}return t}}],[{key:"constructor_",value:function(){var t=arguments[0];sn.constructor_.call(this,t)}}])}(sn);fn.STRtreeNode=gn,fn.xComparator=new(function(){return s((function t(){n(this,t)}),[{key:"interfaces_",get:function(){return[P]}},{key:"compare",value:function(t,e){return hn.compareDoubles(fn.centreX(t.getBounds()),fn.centreX(e.getBounds()))}}])}()),fn.yComparator=new(function(){return s((function t(){n(this,t)}),[{key:"interfaces_",get:function(){return[P]}},{key:"compare",value:function(t,e){return hn.compareDoubles(fn.centreY(t.getBounds()),fn.centreY(e.getBounds()))}}])}()),fn.intersectsOp=new(function(){return s((function t(){n(this,t)}),[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(t,e){return t.intersects(e)}}])}()),fn.DEFAULT_NODE_CAPACITY=10;var vn=function(){function t(){n(this,t)}return s(t,null,[{key:"relativeSign",value:function(t,e){return te?1:0}},{key:"compare",value:function(e,n,i){if(n.equals2D(i))return 0;var r=t.relativeSign(n.x,i.x),s=t.relativeSign(n.y,i.y);switch(e){case 0:return t.compareValue(r,s);case 1:return t.compareValue(s,r);case 2:return t.compareValue(s,-r);case 3:return t.compareValue(-r,s);case 4:return t.compareValue(-r,-s);case 5:return t.compareValue(-s,-r);case 6:return t.compareValue(-s,r);case 7:return t.compareValue(r,-s)}return G.shouldNeverReachHere("invalid octant value"),0}},{key:"compareValue",value:function(t,e){return t<0?-1:t>0?1:e<0?-1:e>0?1:0}}])}(),yn=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"getCoordinate",value:function(){return this.coord}},{key:"print",value:function(t){t.print(this.coord),t.print(" seg # = "+this.segmentIndex)}},{key:"compareTo",value:function(t){var e=t;return this.segmentIndexe.segmentIndex?1:this.coord.equals2D(e.coord)?0:this._isInterior?e._isInterior?vn.compare(this._segmentOctant,this.coord,e.coord):1:-1}},{key:"isEndPoint",value:function(t){return 0===this.segmentIndex&&!this._isInterior||this.segmentIndex===t}},{key:"toString",value:function(){return this.segmentIndex+":"+this.coord.toString()}},{key:"isInterior",value:function(){return this._isInterior}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this._segString=null,this.coord=null,this.segmentIndex=null,this._segmentOctant=null,this._isInterior=null;var t=arguments[0],e=arguments[1],n=arguments[2],i=arguments[3];this._segString=t,this.coord=new X(e),this.segmentIndex=n,this._segmentOctant=i,this._isInterior=!e.equals2D(t.getCoordinate(n))}}])}(),dn=function(){return s((function t(){n(this,t)}),[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}])}(),_n=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"getSplitCoordinates",value:function(){var t=new Zt;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next();this.addEdgeCoordinates(n,i,t),n=i}return t.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var t=new yt;this.findCollapsesFromInsertedNodes(t),this.findCollapsesFromExistingVertices(t);for(var e=t.iterator();e.hasNext();){var n=e.next().intValue();this.add(this._edge.getCoordinate(n),n)}}},{key:"createSplitEdgePts",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2;if(2===n)return[new X(t.coord),new X(e.coord)];var i=this._edge.getCoordinate(e.segmentIndex),r=e.isInterior()||!e.coord.equals2D(i);r||n--;var s=new Array(n).fill(null),a=0;s[a++]=new X(t.coord);for(var o=t.segmentIndex+1;o<=e.segmentIndex;o++)s[a++]=this._edge.getCoordinate(o);return r&&(s[a]=new X(e.coord)),s}},{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();){e.next().print(t)}}},{key:"findCollapsesFromExistingVertices",value:function(t){for(var e=0;e=0?n>=0?i>=r?0:1:i>=r?7:6:n>=0?i>=r?3:2:i>=r?4:5}if(arguments[0]instanceof X&&arguments[1]instanceof X){var s=arguments[0],a=arguments[1],o=a.x-s.x,u=a.y-s.y;if(0===o&&0===u)throw new m("Cannot compute the octant for two identical points "+s);return t.octant(o,u)}}}])}(),mn=function(){return s((function t(){n(this,t)}),[{key:"getCoordinates",value:function(){}},{key:"size",value:function(){}},{key:"getCoordinate",value:function(t){}},{key:"isClosed",value:function(){}},{key:"setData",value:function(t){}},{key:"getData",value:function(){}}])}(),kn=function(){return s((function t(){n(this,t)}),[{key:"addIntersection",value:function(t,e){}},{key:"interfaces_",get:function(){return[mn]}}])}(),xn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"getCoordinates",value:function(){return this._pts}},{key:"size",value:function(){return this._pts.length}},{key:"getCoordinate",value:function(t){return this._pts[t]}},{key:"isClosed",value:function(){return this._pts[0].equals(this._pts[this._pts.length-1])}},{key:"getSegmentOctant",value:function(t){return t===this._pts.length-1?-1:this.safeOctant(this.getCoordinate(t),this.getCoordinate(t+1))}},{key:"setData",value:function(t){this._data=t}},{key:"safeOctant",value:function(t,e){return t.equals2D(e)?0:pn.octant(t,e)}},{key:"getData",value:function(){return this._data}},{key:"addIntersection",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1];this.addIntersectionNode(t,e)}else if(4===arguments.length){var n=arguments[1],i=arguments[3],r=new X(arguments[0].getIntersection(i));this.addIntersection(r,n)}}},{key:"toString",value:function(){return Ce.toLineString(new Qt(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(t,e){var n=e,i=n+1;if(i=0&&i>=0||n<=0&&i<=0?Math.max(n,i):0}if(arguments[0]instanceof X){var r=arguments[0];return ct.index(this.p0,this.p1,r)}}},{key:"toGeometry",value:function(t){return t.createLineString([this.p0,this.p1])}},{key:"isVertical",value:function(){return this.p0.x===this.p1.x}},{key:"equals",value:function(e){if(!(e instanceof t))return!1;var n=e;return this.p0.equals(n.p0)&&this.p1.equals(n.p1)}},{key:"intersection",value:function(t){var e=new we;return e.computeIntersection(this.p0,this.p1,t.p0,t.p1),e.hasIntersection()?e.getIntersection(0):null}},{key:"project",value:function(){if(arguments[0]instanceof X){var e=arguments[0];if(e.equals(this.p0)||e.equals(this.p1))return new X(e);var n=this.projectionFactor(e),i=new X;return i.x=this.p0.x+n*(this.p1.x-this.p0.x),i.y=this.p0.y+n*(this.p1.y-this.p0.y),i}if(arguments[0]instanceof t){var r=arguments[0],s=this.projectionFactor(r.p0),a=this.projectionFactor(r.p1);if(s>=1&&a>=1)return null;if(s<=0&&a<=0)return null;var o=this.project(r.p0);s<0&&(o=this.p0),s>1&&(o=this.p1);var u=this.project(r.p1);return a<0&&(u=this.p0),a>1&&(u=this.p1),new t(o,u)}}},{key:"normalize",value:function(){this.p1.compareTo(this.p0)<0&&this.reverse()}},{key:"angle",value:function(){return Math.atan2(this.p1.y-this.p0.y,this.p1.x-this.p0.x)}},{key:"getCoordinate",value:function(t){return 0===t?this.p0:this.p1}},{key:"distancePerpendicular",value:function(t){return xt.pointToLinePerpendicular(t,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return t.midPoint(this.p0,this.p1)}},{key:"projectionFactor",value:function(t){if(t.equals(this.p0))return 0;if(t.equals(this.p1))return 1;var e=this.p1.x-this.p0.x,n=this.p1.y-this.p0.y,i=e*e+n*n;return i<=0?A.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/i}},{key:"closestPoints",value:function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),i=A.MAX_VALUE,r=null,s=this.closestPoint(t.p0);i=s.distance(t.p0),n[0]=s,n[1]=t.p0;var a=this.closestPoint(t.p1);(r=a.distance(t.p1))0&&e<1?this.project(t):this.p0.distance(t)1||A.isNaN(e))&&(e=1),e}},{key:"toString",value:function(){return"LINESTRING( "+this.p0.x+" "+this.p0.y+", "+this.p1.x+" "+this.p1.y+")"}},{key:"isHorizontal",value:function(){return this.p0.y===this.p1.y}},{key:"reflect",value:function(t){var e=this.p1.getY()-this.p0.getY(),n=this.p0.getX()-this.p1.getX(),i=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),r=e*e+n*n,s=e*e-n*n,a=t.getX(),o=t.getY();return new X((-s*a-2*e*n*o-2*e*i)/r,(s*o-2*e*n*a-2*n*i)/r)}},{key:"distance",value:function(){if(arguments[0]instanceof t){var e=arguments[0];return xt.segmentToSegment(this.p0,this.p1,e.p0,e.p1)}if(arguments[0]instanceof X){var n=arguments[0];return xt.pointToSegment(n,this.p0,this.p1)}}},{key:"pointAlong",value:function(t){var e=new X;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}},{key:"hashCode",value:function(){var t=A.doubleToLongBits(this.p0.x);t^=31*A.doubleToLongBits(this.p0.y);var e=Math.trunc(t)^Math.trunc(t>>32),n=A.doubleToLongBits(this.p1.x);return n^=31*A.doubleToLongBits(this.p1.y),e^(Math.trunc(n)^Math.trunc(n>>32))}},{key:"interfaces_",get:function(){return[x,E]}}],[{key:"constructor_",value:function(){if(this.p0=null,this.p1=null,0===arguments.length)t.constructor_.call(this,new X,new X);else if(1===arguments.length){var e=arguments[0];t.constructor_.call(this,e.p0,e.p1)}else if(2===arguments.length){var n=arguments[0],i=arguments[1];this.p0=n,this.p1=i}else if(4===arguments.length){var r=arguments[0],s=arguments[1],a=arguments[2],o=arguments[3];t.constructor_.call(this,new X(r,s),new X(a,o))}}},{key:"midPoint",value:function(t,e){return new X((t.x+e.x)/2,(t.y+e.y)/2)}}])}(),En=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"overlap",value:function(){if(2===arguments.length);else if(4===arguments.length){var t=arguments[1],e=arguments[2],n=arguments[3];arguments[0].getLineSegment(t,this._overlapSeg1),e.getLineSegment(n,this._overlapSeg2),this.overlap(this._overlapSeg1,this._overlapSeg2)}}}],[{key:"constructor_",value:function(){this._overlapSeg1=new In,this._overlapSeg2=new In}}])}(),Nn=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"getLineSegment",value:function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]}},{key:"computeSelect",value:function(t,e,n,i){var r=this._pts[e],s=this._pts[n];if(n-e==1)return i.select(this,e),null;if(!t.intersects(r,s))return null;var a=Math.trunc((e+n)/2);e=t.length-1)return t.length-1;for(var i=je.quadrant(t[n],t[n+1]),r=e+1;rn.getId()&&(n.computeOverlaps(r,t),this._nOverlaps++),this._segInt.isDone())return null}}}],[{key:"constructor_",value:function(){if(this._monoChains=new yt,this._index=new fn,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,0===arguments.length);else if(1===arguments.length){var t=arguments[0];Ln.constructor_.call(this,t)}}}])}(Ln),Rn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"overlap",value:function(){if(4!==arguments.length)return f(i,"overlap",this,1).apply(this,arguments);var t=arguments[1],e=arguments[2],n=arguments[3],r=arguments[0].getContext(),s=e.getContext();this._si.processIntersections(r,t,s,n)}}],[{key:"constructor_",value:function(){this._si=null;var t=arguments[0];this._si=t}}])}(En);Cn.SegmentOverlapAction=Rn;var wn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"isDeletable",value:function(t,e,n,i){var r=this._inputLine[t],s=this._inputLine[e],a=this._inputLine[n];return!!this.isConcave(r,s,a)&&(!!this.isShallow(r,s,a,i)&&this.isShallowSampled(r,s,t,n,i))}},{key:"deleteShallowConcavities",value:function(){for(var e=1,n=this.findNextNonDeletedIndex(e),i=this.findNextNonDeletedIndex(n),r=!1;i=0;i--)this.addPt(t[i])}},{key:"isRedundant",value:function(t){if(this._ptList.size()<1)return!1;var e=this._ptList.get(this._ptList.size()-1);return t.distance(e)Math.PI;)e-=t.PI_TIMES_2;for(;e<=-Math.PI;)e+=t.PI_TIMES_2;return e}},{key:"angle",value:function(){if(1===arguments.length){var t=arguments[0];return Math.atan2(t.y,t.x)}if(2===arguments.length){var e=arguments[0],n=arguments[1],i=n.x-e.x,r=n.y-e.y;return Math.atan2(r,i)}}},{key:"isAcute",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)>0}},{key:"isObtuse",value:function(t,e,n){var i=t.x-e.x,r=t.y-e.y;return i*(n.x-e.x)+r*(n.y-e.y)<0}},{key:"interiorAngle",value:function(e,n,i){var r=t.angle(n,e),s=t.angle(n,i);return Math.abs(s-r)}},{key:"normalizePositive",value:function(e){if(e<0){for(;e<0;)e+=t.PI_TIMES_2;e>=t.PI_TIMES_2&&(e=0)}else{for(;e>=t.PI_TIMES_2;)e-=t.PI_TIMES_2;e<0&&(e=0)}return e}},{key:"angleBetween",value:function(e,n,i){var r=t.angle(n,e),s=t.angle(n,i);return t.diff(r,s)}},{key:"diff",value:function(t,e){var n=null;return(n=tMath.PI&&(n=2*Math.PI-n),n}},{key:"toRadians",value:function(t){return t*Math.PI/180}},{key:"getTurn",value:function(e,n){var i=Math.sin(n-e);return i>0?t.COUNTERCLOCKWISE:i<0?t.CLOCKWISE:t.NONE}},{key:"angleBetweenOriented",value:function(e,n,i){var r=t.angle(n,e),s=t.angle(n,i)-r;return s<=-Math.PI?s+t.PI_TIMES_2:s>Math.PI?s-t.PI_TIMES_2:s}}])}();bn.PI_TIMES_2=2*Math.PI,bn.PI_OVER_2=Math.PI/2,bn.PI_OVER_4=Math.PI/4,bn.COUNTERCLOCKWISE=ct.COUNTERCLOCKWISE,bn.CLOCKWISE=ct.CLOCKWISE,bn.NONE=ct.COLLINEAR;var Mn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"addNextSegment",value:function(t,e){if(this._s0=this._s1,this._s1=this._s2,this._s2=t,this._seg0.setCoordinates(this._s0,this._s1),this.computeOffsetSegment(this._seg0,this._side,this._distance,this._offset0),this._seg1.setCoordinates(this._s1,this._s2),this.computeOffsetSegment(this._seg1,this._side,this._distance,this._offset1),this._s1.equals(this._s2))return null;var n=ct.index(this._s0,this._s1,this._s2),i=n===ct.CLOCKWISE&&this._side===$.LEFT||n===ct.COUNTERCLOCKWISE&&this._side===$.RIGHT;0===n?this.addCollinear(e):i?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)}},{key:"addLineEndCap",value:function(t,e){var n=new In(t,e),i=new In;this.computeOffsetSegment(n,$.LEFT,this._distance,i);var r=new In;this.computeOffsetSegment(n,$.RIGHT,this._distance,r);var s=e.x-t.x,a=e.y-t.y,o=Math.atan2(a,s);switch(this._bufParams.getEndCapStyle()){case _.CAP_ROUND:this._segList.addPt(i.p1),this.addDirectedFillet(e,o+Math.PI/2,o-Math.PI/2,ct.CLOCKWISE,this._distance),this._segList.addPt(r.p1);break;case _.CAP_FLAT:this._segList.addPt(i.p1),this._segList.addPt(r.p1);break;case _.CAP_SQUARE:var u=new X;u.x=Math.abs(this._distance)*Math.cos(o),u.y=Math.abs(this._distance)*Math.sin(o);var l=new X(i.p1.x+u.x,i.p1.y+u.y),h=new X(r.p1.x+u.x,r.p1.y+u.y);this._segList.addPt(l),this._segList.addPt(h)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(t,e,n,i){var r=pt.intersection(e.p0,e.p1,n.p0,n.p1);if(null!==r&&(i<=0?1:r.distance(t)/Math.abs(i))<=this._bufParams.getMitreLimit())return this._segList.addPt(r),null;this.addLimitedMitreJoin(e,n,i,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(e,n){if(this._offset0.p1.distance(this._offset1.p0)=h&&(o-=2*Math.PI),this._segList.addPt(e),this.addDirectedFillet(t,o,h,i,r),this._segList.addPt(n)}},{key:"addLastSegment",value:function(){this._segList.addPt(this._offset1.p1)}},{key:"initSideSegments",value:function(t,e,n){this._s1=t,this._s2=e,this._side=n,this._seg1.setCoordinates(t,e),this.computeOffsetSegment(this._seg1,n,this._distance,this._offset1)}},{key:"addLimitedMitreJoin",value:function(t,e,n,i){var r=this._seg0.p1,s=bn.angle(r,this._seg0.p0),a=bn.angleBetweenOriented(this._seg0.p0,r,this._seg1.p1)/2,o=bn.normalize(s+a),u=bn.normalize(o+Math.PI),l=i*n,h=n-l*Math.abs(Math.sin(a)),c=r.x+l*Math.cos(u),f=r.y+l*Math.sin(u),g=new X(c,f),v=new In(r,g),y=v.pointAlongOffset(1,h),d=v.pointAlongOffset(1,-h);this._side===$.LEFT?(this._segList.addPt(y),this._segList.addPt(d)):(this._segList.addPt(d),this._segList.addPt(y))}},{key:"addDirectedFillet",value:function(t,e,n,i,r){var s=i===ct.CLOCKWISE?-1:1,a=Math.abs(e-n),o=Math.trunc(a/this._filletAngleQuantum+.5);if(o<1)return null;for(var u=a/o,l=new X,h=0;h0){var i=new X((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(i);var r=new X((this._closingSegLengthFactor*this._offset1.p0.x+this._s1.x)/(this._closingSegLengthFactor+1),(this._closingSegLengthFactor*this._offset1.p0.y+this._s1.y)/(this._closingSegLengthFactor+1));this._segList.addPt(r)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(t){var e=new X(t.x+this._distance,t.y);this._segList.addPt(e),this.addDirectedFillet(t,0,2*Math.PI,-1,this._distance),this._segList.closeRing()}},{key:"addBevelJoin",value:function(t,e){this._segList.addPt(t.p1),this._segList.addPt(e.p0)}},{key:"init",value:function(e){this._distance=e,this._maxCurveSegmentError=e*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new On,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(e*t.CURVE_VERTEX_SNAP_DISTANCE_FACTOR)}},{key:"addCollinear",value:function(t){this._li.computeIntersection(this._s0,this._s1,this._s1,this._s2),this._li.getIntersectionNum()>=2&&(this._bufParams.getJoinStyle()===_.JOIN_BEVEL||this._bufParams.getJoinStyle()===_.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,ct.CLOCKWISE,this._distance))}},{key:"closeRing",value:function(){this._segList.closeRing()}},{key:"hasNarrowConcaveAngle",value:function(){return this._hasNarrowConcaveAngle}}],[{key:"constructor_",value:function(){this._maxCurveSegmentError=0,this._filletAngleQuantum=null,this._closingSegLengthFactor=1,this._segList=null,this._distance=0,this._precisionModel=null,this._bufParams=null,this._li=null,this._s0=null,this._s1=null,this._s2=null,this._seg0=new In,this._seg1=new In,this._offset0=new In,this._offset1=new In,this._side=0,this._hasNarrowConcaveAngle=!1;var e=arguments[0],n=arguments[1],i=arguments[2];this._precisionModel=e,this._bufParams=n,this._li=new we,this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===_.JOIN_ROUND&&(this._closingSegLengthFactor=t.MAX_CLOSING_SEG_LEN_FACTOR),this.init(i)}}])}();Mn.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,Mn.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,Mn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,Mn.MAX_CLOSING_SEG_LEN_FACTOR=80;var An=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"getOffsetCurve",value:function(t,e){if(this._distance=e,0===e)return null;var n=e<0,i=Math.abs(e),r=this.getSegGen(i);t.length<=1?this.computePointCurve(t[0],r):this.computeOffsetCurve(t,n,r);var s=r.getCoordinates();return n&&jt.reverse(s),s}},{key:"computeSingleSidedBufferCurve",value:function(t,e,n){var i=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var r=wn.simplify(t,-i),s=r.length-1;n.initSideSegments(r[s],r[s-1],$.LEFT),n.addFirstSegment();for(var a=s-2;a>=0;a--)n.addNextSegment(r[a],!0)}else{n.addSegments(t,!1);var o=wn.simplify(t,i),u=o.length-1;n.initSideSegments(o[0],o[1],$.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(o[l],!0)}n.addLastSegment(),n.closeRing()}},{key:"computeRingBufferCurve",value:function(t,e,n){var i=this.simplifyTolerance(this._distance);e===$.RIGHT&&(i=-i);var r=wn.simplify(t,i),s=r.length-1;n.initSideSegments(r[s-1],r[0],e);for(var a=1;a<=s;a++){var o=1!==a;n.addNextSegment(r[a],o)}n.closeRing()}},{key:"computeLineBufferCurve",value:function(t,e){var n=this.simplifyTolerance(this._distance),i=wn.simplify(t,n),r=i.length-1;e.initSideSegments(i[0],i[1],$.LEFT);for(var s=2;s<=r;s++)e.addNextSegment(i[s],!0);e.addLastSegment(),e.addLineEndCap(i[r-1],i[r]);var a=wn.simplify(t,-n),o=a.length-1;e.initSideSegments(a[o],a[o-1],$.LEFT);for(var u=o-2;u>=0;u--)e.addNextSegment(a[u],!0);e.addLastSegment(),e.addLineEndCap(a[1],a[0]),e.closeRing()}},{key:"computePointCurve",value:function(t,e){switch(this._bufParams.getEndCapStyle()){case _.CAP_ROUND:e.createCircle(t);break;case _.CAP_SQUARE:e.createSquare(t)}}},{key:"getLineCurve",value:function(t,e){if(this._distance=e,this.isLineOffsetEmpty(e))return null;var n=Math.abs(e),i=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],i);else if(this._bufParams.isSingleSided()){var r=e<0;this.computeSingleSidedBufferCurve(t,r,i)}else this.computeLineBufferCurve(t,i);return i.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(t){return t*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(e,n,i){if(this._distance=i,e.length<=2)return this.getLineCurve(e,i);if(0===i)return t.copyCoordinates(e);var r=this.getSegGen(i);return this.computeRingBufferCurve(e,n,r),r.getCoordinates()}},{key:"computeOffsetCurve",value:function(t,e,n){var i=this.simplifyTolerance(this._distance);if(e){var r=wn.simplify(t,-i),s=r.length-1;n.initSideSegments(r[s],r[s-1],$.LEFT),n.addFirstSegment();for(var a=s-2;a>=0;a--)n.addNextSegment(r[a],!0)}else{var o=wn.simplify(t,i),u=o.length-1;n.initSideSegments(o[0],o[1],$.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(o[l],!0)}n.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(t){return 0===t||t<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(t){return new Mn(this._precisionModel,this._bufParams,t)}}],[{key:"constructor_",value:function(){this._distance=0,this._precisionModel=null,this._bufParams=null;var t=arguments[0],e=arguments[1];this._precisionModel=t,this._bufParams=e}},{key:"copyCoordinates",value:function(t){for(var e=new Array(t.length).fill(null),n=0;nr.getMaxY()||this.findStabbedSegments(t,i.getDirectedEdges(),e)}return e}if(3===arguments.length)if(rt(arguments[2],nt)&&arguments[0]instanceof X&&arguments[1]instanceof Ke)for(var s=arguments[0],a=arguments[1],o=arguments[2],u=a.getEdge().getCoordinates(),l=0;lthis._seg.p1.y&&this._seg.reverse(),!(Math.max(this._seg.p0.x,this._seg.p1.x)this._seg.p1.y||ct.index(this._seg.p0,this._seg.p1,s)===ct.RIGHT)){var h=a.getDepth($.LEFT);this._seg.p0.equals(u[l])||(h=a.getDepth($.RIGHT));var c=new Dn(this._seg,h);o.add(c)}}else if(rt(arguments[2],nt)&&arguments[0]instanceof X&&rt(arguments[1],nt))for(var f=arguments[0],g=arguments[2],v=arguments[1].iterator();v.hasNext();){var y=v.next();y.isForward()&&this.findStabbedSegments(f,y,g)}}},{key:"getDepth",value:function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:an.min(e)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new In;var t=arguments[0];this._subgraphs=t}}])}(),Dn=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"compareTo",value:function(t){var e=t;if(this._upwardSeg.minX()>=e._upwardSeg.maxX())return 1;if(this._upwardSeg.maxX()<=e._upwardSeg.minX())return-1;var n=this._upwardSeg.orientationIndex(e._upwardSeg);return 0!==n||0!==(n=-1*e._upwardSeg.orientationIndex(this._upwardSeg))?n:this._upwardSeg.compareTo(e._upwardSeg)}},{key:"compareX",value:function(t,e){var n=t.p0.compareTo(e.p0);return 0!==n?n:t.p1.compareTo(e.p1)}},{key:"toString",value:function(){return this._upwardSeg.toString()}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this._upwardSeg=null,this._leftDepth=null;var t=arguments[0],e=arguments[1];this._upwardSeg=new In(t),this._leftDepth=e}}])}();Pn.DepthSegment=Dn;var Fn=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,null,[{key:"constructor_",value:function(){p.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}])}(p),Gn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"getY",value:function(){var t=this.y/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new Fn;return t}},{key:"getX",value:function(){var t=this.x/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new Fn;return t}},{key:"getCoordinate",value:function(){var t=new X;return t.x=this.getX(),t.y=this.getY(),t}}],[{key:"constructor_",value:function(){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){var e=arguments[0];this.x=e.x,this.y=e.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[0],i=arguments[1];this.x=n,this.y=i,this.w=1}else if(arguments[0]instanceof t&&arguments[1]instanceof t){var r=arguments[0],s=arguments[1];this.x=r.y*s.w-s.y*r.w,this.y=s.x*r.w-r.x*s.w,this.w=r.x*s.y-s.x*r.y}else if(arguments[0]instanceof X&&arguments[1]instanceof X){var a=arguments[0],o=arguments[1];this.x=a.y-o.y,this.y=o.x-a.x,this.w=a.x*o.y-o.x*a.y}}else if(3===arguments.length){var u=arguments[0],l=arguments[1],h=arguments[2];this.x=u,this.y=l,this.w=h}else if(4===arguments.length){var c=arguments[0],f=arguments[1],g=arguments[2],v=arguments[3],y=c.y-f.y,d=f.x-c.x,_=c.x*f.y-f.x*c.y,p=g.y-v.y,m=v.x-g.x,k=g.x*v.y-v.x*g.y;this.x=d*k-m*_,this.y=p*_-y*k,this.w=y*m-p*d}}}])}(),qn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"area",value:function(){return t.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return t.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(e){if(null===e)throw new m("Supplied point is null.");return t.interpolateZ(e,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return t.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return t.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return t.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return t.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return t.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return t.inCentre(this.p0,this.p1,this.p2)}}],[{key:"constructor_",value:function(){this.p0=null,this.p1=null,this.p2=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.p0=t,this.p1=e,this.p2=n}},{key:"area",value:function(t,e,n){return Math.abs(((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2)}},{key:"signedArea",value:function(t,e,n){return((n.x-t.x)*(e.y-t.y)-(e.x-t.x)*(n.y-t.y))/2}},{key:"det",value:function(t,e,n,i){return t*i-e*n}},{key:"interpolateZ",value:function(t,e,n,i){var r=e.x,s=e.y,a=n.x-r,o=i.x-r,u=n.y-s,l=i.y-s,h=a*l-o*u,c=t.x-r,f=t.y-s,g=(l*c-o*f)/h,v=(-u*c+a*f)/h;return e.getZ()+g*(n.getZ()-e.getZ())+v*(i.getZ()-e.getZ())}},{key:"longestSideLength",value:function(t,e,n){var i=t.distance(e),r=e.distance(n),s=n.distance(t),a=i;return r>a&&(a=r),s>a&&(a=s),a}},{key:"circumcentreDD",value:function(t,e,n){var i=ut.valueOf(t.x).subtract(n.x),r=ut.valueOf(t.y).subtract(n.y),s=ut.valueOf(e.x).subtract(n.x),a=ut.valueOf(e.y).subtract(n.y),o=ut.determinant(i,r,s,a).multiply(2),u=i.sqr().add(r.sqr()),l=s.sqr().add(a.sqr()),h=ut.determinant(r,u,a,l),c=ut.determinant(i,u,s,l),f=ut.valueOf(n.x).subtract(h.divide(o)).doubleValue(),g=ut.valueOf(n.y).add(c.divide(o)).doubleValue();return new X(f,g)}},{key:"isAcute",value:function(t,e,n){return!!bn.isAcute(t,e,n)&&(!!bn.isAcute(e,n,t)&&!!bn.isAcute(n,t,e))}},{key:"circumcentre",value:function(e,n,i){var r=i.x,s=i.y,a=e.x-r,o=e.y-s,u=n.x-r,l=n.y-s,h=2*t.det(a,o,u,l),c=t.det(o,a*a+o*o,l,u*u+l*l),f=t.det(a,a*a+o*o,u,u*u+l*l);return new X(r-c/h,s+f/h)}},{key:"perpendicularBisector",value:function(t,e){var n=e.x-t.x,i=e.y-t.y,r=new Gn(t.x+n/2,t.y+i/2,1),s=new Gn(t.x-i+n/2,t.y+n+i/2,1);return new Gn(r,s)}},{key:"angleBisector",value:function(t,e,n){var i=e.distance(t),r=i/(i+e.distance(n)),s=n.x-t.x,a=n.y-t.y;return new X(t.x+r*s,t.y+r*a)}},{key:"area3D",value:function(t,e,n){var i=e.x-t.x,r=e.y-t.y,s=e.getZ()-t.getZ(),a=n.x-t.x,o=n.y-t.y,u=n.getZ()-t.getZ(),l=r*u-s*o,h=s*a-i*u,c=i*o-r*a,f=l*l+h*h+c*c,g=Math.sqrt(f)/2;return g}},{key:"centroid",value:function(t,e,n){var i=(t.x+e.x+n.x)/3,r=(t.y+e.y+n.y)/3;return new X(i,r)}},{key:"inCentre",value:function(t,e,n){var i=e.distance(n),r=t.distance(n),s=t.distance(e),a=i+r+s,o=(i*t.x+r*e.x+s*n.x)/a,u=(i*t.y+r*e.y+s*n.y)/a;return new X(o,u)}}])}(),Yn=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"addRingSide",value:function(t,e,n,i,r){if(0===e&&t.length=Xt.MINIMUM_VALID_SIZE&&ct.isCCW(t)&&(s=r,a=i,n=$.opposite(n));var o=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(o,s,a)}},{key:"addRingBothSides",value:function(t,e){this.addRingSide(t,e,$.LEFT,H.EXTERIOR,H.INTERIOR),this.addRingSide(t,e,$.RIGHT,H.INTERIOR,H.EXTERIOR)}},{key:"addPoint",value:function(t){if(this._distance<=0)return null;var e=t.getCoordinates(),n=this._curveBuilder.getLineCurve(e,this._distance);this.addCurve(n,H.EXTERIOR,H.INTERIOR)}},{key:"addPolygon",value:function(t){var e=this._distance,n=$.LEFT;this._distance<0&&(e=-this._distance,n=$.RIGHT);var i=t.getExteriorRing(),r=jt.removeRepeatedPoints(i.getCoordinates());if(this._distance<0&&this.isErodedCompletely(i,this._distance))return null;if(this._distance<=0&&r.length<3)return null;this.addRingSide(r,e,n,H.EXTERIOR,H.INTERIOR);for(var s=0;s0&&this.isErodedCompletely(a,-this._distance)||this.addRingSide(o,e,$.opposite(n),H.INTERIOR,H.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(t,e){var n=new qn(t[0],t[1],t[2]),i=n.inCentre();return xt.pointToSegment(i,n.p0,n.p1)r}},{key:"addCollection",value:function(t){for(var e=0;e=this._max)throw new j;var e=this._parent.getGeometryN(this._index++);return e instanceof Yt?(this._subcollectionIterator=new t(e),this._subcollectionIterator.next()):e}},{key:"remove",value:function(){throw new W(this.getClass().getName())}},{key:"hasNext",value:function(){if(this._atStart)return!0;if(null!==this._subcollectionIterator){if(this._subcollectionIterator.hasNext())return!0;this._subcollectionIterator=null}return!(this._index>=this._max)}},{key:"interfaces_",get:function(){return[dn]}}],[{key:"constructor_",value:function(){this._parent=null,this._atStart=null,this._max=null,this._index=null,this._subcollectionIterator=null;var t=arguments[0];this._parent=t,this._atStart=!0,this._index=0,this._max=t.getNumGeometries()}},{key:"isAtomic",value:function(t){return!(t instanceof Yt)}}])}(),Bn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"locate",value:function(e){return t.locate(e,this._geom)}},{key:"interfaces_",get:function(){return[zn]}}],[{key:"constructor_",value:function(){this._geom=null;var t=arguments[0];this._geom=t}},{key:"locatePointInPolygon",value:function(e,n){if(n.isEmpty())return H.EXTERIOR;var i=n.getExteriorRing(),r=t.locatePointInRing(e,i);if(r!==H.INTERIOR)return r;for(var s=0;s=0;n--){var i=this._edgeList.get(n),r=i.getSym();null===e&&(e=r),null!==t&&r.setNext(t),t=i}e.setNext(t)}},{key:"computeDepths",value:function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth($.LEFT),i=t.getDepth($.RIGHT),r=this.computeDepths(e+1,this._edgeList.size(),n);if(this.computeDepths(0,e,r)!==i)throw new gt("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var s=arguments[1],a=arguments[2],o=arguments[0];o=0;r--){var s=this._resultAreaEdgeList.get(r),a=s.getSym();switch(null===e&&s.getEdgeRing()===t&&(e=s),i){case this._SCANNING_FOR_INCOMING:if(a.getEdgeRing()!==t)continue;n=a,i=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(s.getEdgeRing()!==t)continue;n.setNextMin(s),i=this._SCANNING_FOR_INCOMING}}i===this._LINKING_TO_OUTGOING&&(G.isTrue(null!==e,"found null for first outgoing dirEdge"),G.isTrue(e.getEdgeRing()===t,"unable to link last incoming dirEdge"),n.setNextMin(e))}},{key:"getOutgoingDegree",value:function(){if(0===arguments.length){for(var t=0,e=this.iterator();e.hasNext();){e.next().isInResult()&&t++}return t}if(1===arguments.length){for(var n=arguments[0],i=0,r=this.iterator();r.hasNext();){r.next().getEdgeRing()===n&&i++}return i}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var t=H.NONE,e=this.iterator();e.hasNext();){var n=e.next(),i=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=H.INTERIOR;break}if(i.isInResult()){t=H.EXTERIOR;break}}}if(t===H.NONE)return null;for(var r=t,s=this.iterator();s.hasNext();){var a=s.next(),o=a.getSym();a.isLineEdge()?a.getEdge().setCovered(r===H.INTERIOR):(a.isInResult()&&(r=H.EXTERIOR),o.isInResult()&&(r=H.INTERIOR))}}},{key:"computeLabelling",value:function(t){f(i,"computeLabelling",this,1).call(this,t),this._label=new Ae(H.NONE);for(var e=this.iterator();e.hasNext();)for(var n=e.next().getEdge().getLabel(),r=0;r<2;r++){var s=n.getLocation(r);s!==H.INTERIOR&&s!==H.BOUNDARY||this._label.setLocation(r,H.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}])}(Un),Hn=function(t){function i(){return n(this,i),e(this,i)}return l(i,t),s(i,[{key:"createNode",value:function(t){return new qe(t,new Vn)}}])}(Je),Zn=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"compareTo",value:function(e){var n=e;return t.compareOriented(this._pts,this._orientation,n._pts,n._orientation)}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this._pts=null,this._orientation=null;var e=arguments[0];this._pts=e,this._orientation=t.orientation(e)}},{key:"orientation",value:function(t){return 1===jt.increasingDirection(t)}},{key:"compareOriented",value:function(t,e,n,i){for(var r=e?1:-1,s=i?1:-1,a=e?t.length:-1,o=i?n.length:-1,u=e?0:t.length-1,l=i?0:n.length-1;;){var h=t[u].compareTo(n[l]);if(0!==h)return h;var c=(u+=r)===a,f=(l+=s)===o;if(c&&!f)return-1;if(!c&&f)return 1;if(c&&f)return 0}}}])}(),jn=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"print",value:function(t){t.print("MULTILINESTRING ( ");for(var e=0;e0&&t.print(","),t.print("(");for(var i=n.getCoordinates(),r=0;r0&&t.print(","),t.print(i[r].x+" "+i[r].y);t.println(")")}t.print(") ")}},{key:"addAll",value:function(t){for(var e=t.iterator();e.hasNext();)this.add(e.next())}},{key:"findEdgeIndex",value:function(t){for(var e=0;et?1:this.diste?1:0}},{key:"interfaces_",get:function(){return[x]}}],[{key:"constructor_",value:function(){this.coord=null,this.segmentIndex=null,this.dist=null;var t=arguments[0],e=arguments[1],n=arguments[2];this.coord=new X(t),this.segmentIndex=e,this.dist=n}}])}(),Qn=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"print",value:function(t){t.println("Intersections:");for(var e=this.iterator();e.hasNext();){e.next().print(t)}}},{key:"iterator",value:function(){return this._nodeMap.values().iterator()}},{key:"addSplitEdges",value:function(t){this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var i=e.next(),r=this.createSplitEdge(n,i);t.add(r),n=i}}},{key:"addEndpoints",value:function(){var t=this.edge.pts.length-1;this.add(this.edge.pts[0],0,0),this.add(this.edge.pts[t],t,0)}},{key:"createSplitEdge",value:function(t,e){var n=e.segmentIndex-t.segmentIndex+2,i=this.edge.pts[e.segmentIndex],r=e.dist>0||!e.coord.equals2D(i);r||n--;var s=new Array(n).fill(null),a=0;s[a++]=new X(t.coord);for(var o=t.segmentIndex+1;o<=e.segmentIndex;o++)s[a++]=this.edge.pts[o];return r&&(s[a]=e.coord),new ri(s,new Ae(this.edge._label))}},{key:"add",value:function(t,e,n){var i=new Jn(t,e,n),r=this._nodeMap.get(i);return null!==r?r:(this._nodeMap.put(i,i),i)}},{key:"isIntersection",value:function(t){for(var e=this.iterator();e.hasNext();){if(e.next().coord.equals(t))return!0}return!1}}],[{key:"constructor_",value:function(){this._nodeMap=new He,this.edge=null;var t=arguments[0];this.edge=t}}])}(),$n=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(t.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])||t.isTrue(this._matrix[H.INTERIOR][H.BOUNDARY])||t.isTrue(this._matrix[H.BOUNDARY][H.INTERIOR])||t.isTrue(this._matrix[H.BOUNDARY][H.BOUNDARY]))&&this._matrix[H.EXTERIOR][H.INTERIOR]===Lt.FALSE&&this._matrix[H.EXTERIOR][H.BOUNDARY]===Lt.FALSE}},{key:"isCoveredBy",value:function(){return(t.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])||t.isTrue(this._matrix[H.INTERIOR][H.BOUNDARY])||t.isTrue(this._matrix[H.BOUNDARY][H.INTERIOR])||t.isTrue(this._matrix[H.BOUNDARY][H.BOUNDARY]))&&this._matrix[H.INTERIOR][H.EXTERIOR]===Lt.FALSE&&this._matrix[H.BOUNDARY][H.EXTERIOR]===Lt.FALSE}},{key:"set",value:function(){if(1===arguments.length)for(var t=arguments[0],e=0;e=0&&e>=0&&this.setAtLeast(t,e,n)}},{key:"isWithin",value:function(){return t.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&this._matrix[H.INTERIOR][H.EXTERIOR]===Lt.FALSE&&this._matrix[H.BOUNDARY][H.EXTERIOR]===Lt.FALSE}},{key:"isTouches",value:function(e,n){return e>n?this.isTouches(n,e):(e===Lt.A&&n===Lt.A||e===Lt.L&&n===Lt.L||e===Lt.L&&n===Lt.A||e===Lt.P&&n===Lt.A||e===Lt.P&&n===Lt.L)&&(this._matrix[H.INTERIOR][H.INTERIOR]===Lt.FALSE&&(t.isTrue(this._matrix[H.INTERIOR][H.BOUNDARY])||t.isTrue(this._matrix[H.BOUNDARY][H.INTERIOR])||t.isTrue(this._matrix[H.BOUNDARY][H.BOUNDARY])))}},{key:"isOverlaps",value:function(e,n){return e===Lt.P&&n===Lt.P||e===Lt.A&&n===Lt.A?t.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&t.isTrue(this._matrix[H.INTERIOR][H.EXTERIOR])&&t.isTrue(this._matrix[H.EXTERIOR][H.INTERIOR]):e===Lt.L&&n===Lt.L&&(1===this._matrix[H.INTERIOR][H.INTERIOR]&&t.isTrue(this._matrix[H.INTERIOR][H.EXTERIOR])&&t.isTrue(this._matrix[H.EXTERIOR][H.INTERIOR]))}},{key:"isEquals",value:function(e,n){return e===n&&(t.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&this._matrix[H.INTERIOR][H.EXTERIOR]===Lt.FALSE&&this._matrix[H.BOUNDARY][H.EXTERIOR]===Lt.FALSE&&this._matrix[H.EXTERIOR][H.INTERIOR]===Lt.FALSE&&this._matrix[H.EXTERIOR][H.BOUNDARY]===Lt.FALSE)}},{key:"toString",value:function(){for(var t=new Jt("123456789"),e=0;e<3;e++)for(var n=0;n<3;n++)t.setCharAt(3*e+n,Lt.toDimensionSymbol(this._matrix[e][n]));return t.toString()}},{key:"setAll",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this._matrix[e][n]=t}},{key:"get",value:function(t,e){return this._matrix[t][e]}},{key:"transpose",value:function(){var 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}},{key:"matches",value:function(e){if(9!==e.length)throw new m("Should be length 9: "+e);for(var n=0;n<3;n++)for(var i=0;i<3;i++)if(!t.matches(this._matrix[n][i],e.charAt(3*n+i)))return!1;return!0}},{key:"add",value:function(t){for(var e=0;e<3;e++)for(var n=0;n<3;n++)this.setAtLeast(e,n,t.get(e,n))}},{key:"isDisjoint",value:function(){return this._matrix[H.INTERIOR][H.INTERIOR]===Lt.FALSE&&this._matrix[H.INTERIOR][H.BOUNDARY]===Lt.FALSE&&this._matrix[H.BOUNDARY][H.INTERIOR]===Lt.FALSE&&this._matrix[H.BOUNDARY][H.BOUNDARY]===Lt.FALSE}},{key:"isCrosses",value:function(e,n){return e===Lt.P&&n===Lt.L||e===Lt.P&&n===Lt.A||e===Lt.L&&n===Lt.A?t.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&t.isTrue(this._matrix[H.INTERIOR][H.EXTERIOR]):e===Lt.L&&n===Lt.P||e===Lt.A&&n===Lt.P||e===Lt.A&&n===Lt.L?t.isTrue(this._matrix[H.INTERIOR][H.INTERIOR])&&t.isTrue(this._matrix[H.EXTERIOR][H.INTERIOR]):e===Lt.L&&n===Lt.L&&0===this._matrix[H.INTERIOR][H.INTERIOR]}},{key:"interfaces_",get:function(){return[I]}}],[{key:"constructor_",value:function(){if(this._matrix=null,0===arguments.length)this._matrix=Array(3).fill().map((function(){return Array(3)})),this.setAll(Lt.FALSE);else if(1===arguments.length)if("string"==typeof arguments[0]){var e=arguments[0];t.constructor_.call(this),this.set(e)}else if(arguments[0]instanceof t){var n=arguments[0];t.constructor_.call(this),this._matrix[H.INTERIOR][H.INTERIOR]=n._matrix[H.INTERIOR][H.INTERIOR],this._matrix[H.INTERIOR][H.BOUNDARY]=n._matrix[H.INTERIOR][H.BOUNDARY],this._matrix[H.INTERIOR][H.EXTERIOR]=n._matrix[H.INTERIOR][H.EXTERIOR],this._matrix[H.BOUNDARY][H.INTERIOR]=n._matrix[H.BOUNDARY][H.INTERIOR],this._matrix[H.BOUNDARY][H.BOUNDARY]=n._matrix[H.BOUNDARY][H.BOUNDARY],this._matrix[H.BOUNDARY][H.EXTERIOR]=n._matrix[H.BOUNDARY][H.EXTERIOR],this._matrix[H.EXTERIOR][H.INTERIOR]=n._matrix[H.EXTERIOR][H.INTERIOR],this._matrix[H.EXTERIOR][H.BOUNDARY]=n._matrix[H.EXTERIOR][H.BOUNDARY],this._matrix[H.EXTERIOR][H.EXTERIOR]=n._matrix[H.EXTERIOR][H.EXTERIOR]}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){var e=arguments[0],n=arguments[1];return n===Lt.SYM_DONTCARE||(n===Lt.SYM_TRUE&&(e>=0||e===Lt.TRUE)||(n===Lt.SYM_FALSE&&e===Lt.FALSE||(n===Lt.SYM_P&&e===Lt.P||(n===Lt.SYM_L&&e===Lt.L||n===Lt.SYM_A&&e===Lt.A))))}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){var i=arguments[1];return new t(arguments[0]).matches(i)}}},{key:"isTrue",value:function(t){return t>=0||t===Lt.TRUE}}])}(),ti=function(){function t(){n(this,t),t.constructor_.apply(this,arguments)}return s(t,[{key:"size",value:function(){return this._size}},{key:"addAll",value:function(t){return null===t||0===t.length?null:(this.ensureCapacity(this._size+t.length),mt.arraycopy(t,0,this._data,this._size,t.length),void(this._size+=t.length))}},{key:"ensureCapacity",value:function(t){if(t<=this._data.length)return null;var e=Math.max(t,2*this._data.length);this._data=At.copyOf(this._data,e)}},{key:"toArray",value:function(){var t=new Array(this._size).fill(null);return mt.arraycopy(this._data,0,t,0,this._size),t}},{key:"add",value:function(t){this.ensureCapacity(this._size+1),this._data[this._size]=t,++this._size}}],[{key:"constructor_",value:function(){if(this._data=null,this._size=0,0===arguments.length)t.constructor_.call(this,10);else if(1===arguments.length){var e=arguments[0];this._data=new Array(e).fill(null)}}}])}(),ei=function(){function t(){n(this,t)}return s(t,[{key:"getChainStartIndices",value:function(t){var e=0,n=new ti(Math.trunc(t.length/2));n.add(e);do{var i=this.findChainEnd(t,e);n.add(i),e=i}while(en?e:n}},{key:"getMinX",value:function(t){var e=this.pts[this.startIndex[t]].x,n=this.pts[this.startIndex[t+1]].x;return ee&&(i=1),this._depth[t][n]=i}}}},{key:"getDelta",value:function(t){return this._depth[t][$.RIGHT]-this._depth[t][$.LEFT]}},{key:"getLocation",value:function(t,e){return this._depth[t][e]<=0?H.EXTERIOR:H.INTERIOR}},{key:"toString",value:function(){return"A: "+this._depth[0][1]+","+this._depth[0][2]+" B: "+this._depth[1][1]+","+this._depth[1][2]}},{key:"add",value:function(){if(1===arguments.length)for(var e=arguments[0],n=0;n<2;n++)for(var i=1;i<3;i++){var r=e.getLocation(n,i);r!==H.EXTERIOR&&r!==H.INTERIOR||(this.isNull(n,i)?this._depth[n][i]=t.depthAtLocation(r):this._depth[n][i]+=t.depthAtLocation(r))}else if(3===arguments.length){var s=arguments[0],a=arguments[1];arguments[2]===H.INTERIOR&&this._depth[s][a]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map((function(){return Array(3)}));for(var e=0;e<2;e++)for(var n=0;n<3;n++)this._depth[e][n]=t.NULL_VALUE}},{key:"depthAtLocation",value:function(e){return e===H.EXTERIOR?0:e===H.INTERIOR?1:t.NULL_VALUE}}])}();ii.NULL_VALUE=-1;var ri=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"getDepth",value:function(){return this._depth}},{key:"getCollapsedEdge",value:function(){var t=new Array(2).fill(null);return t[0]=this.pts[0],t[1]=this.pts[1],new i(t,Ae.toLineLabel(this._label))}},{key:"isIsolated",value:function(){return this._isIsolated}},{key:"getCoordinates",value:function(){return this.pts}},{key:"setIsolated",value:function(t){this._isIsolated=t}},{key:"setName",value:function(t){this._name=t}},{key:"equals",value:function(t){if(!(t instanceof i))return!1;var e=t;if(this.pts.length!==e.pts.length)return!1;for(var n=!0,r=!0,s=this.pts.length,a=0;a0?this.pts[0]:null;if(1===arguments.length){var t=arguments[0];return this.pts[t]}}},{key:"print",value:function(t){t.print("edge "+this._name+": "),t.print("LINESTRING (");for(var e=0;e0&&t.print(","),t.print(this.pts[e].x+" "+this.pts[e].y);t.print(") "+this._label+" "+this._depthDelta)}},{key:"computeIM",value:function(t){i.updateIM(this._label,t)}},{key:"isCollapsed",value:function(){return!!this._label.isArea()&&(3===this.pts.length&&!!this.pts[0].equals(this.pts[2]))}},{key:"isClosed",value:function(){return this.pts[0].equals(this.pts[this.pts.length-1])}},{key:"getMaximumSegmentIndex",value:function(){return this.pts.length-1}},{key:"getDepthDelta",value:function(){return this._depthDelta}},{key:"getNumPoints",value:function(){return this.pts.length}},{key:"printReverse",value:function(t){t.print("edge "+this._name+": ");for(var e=this.pts.length-1;e>=0;e--)t.print(this.pts[e]+" ");t.println("")}},{key:"getMonotoneChainEdge",value:function(){return null===this._mce&&(this._mce=new ni(this)),this._mce}},{key:"getEnvelope",value:function(){if(null===this._env){this._env=new U;for(var t=0;t0&&t.append(","),t.append(this.pts[e].x+" "+this.pts[e].y);return t.append(") "+this._label+" "+this._depthDelta),t.toString()}},{key:"isPointwiseEqual",value:function(t){if(this.pts.length!==t.pts.length)return!1;for(var e=0;ei||this._maxys;if(a)return!1;var o=this.intersectsToleranceSquare(t,e);return G.isTrue(!(a&&o),"Found bad envelope test"),o}},{key:"initCorners",value:function(t){var e=.5;this._minx=t.x-e,this._maxx=t.x+e,this._miny=t.y-e,this._maxy=t.y+e,this._corner[0]=new X(this._maxx,this._maxy),this._corner[1]=new X(this._minx,this._maxy),this._corner[2]=new X(this._minx,this._miny),this._corner[3]=new X(this._maxx,this._miny)}},{key:"intersects",value:function(t,e){return 1===this._scaleFactor?this.intersectsScaled(t,e):(this.copyScaled(t,this._p0Scaled),this.copyScaled(e,this._p1Scaled),this.intersectsScaled(this._p0Scaled,this._p1Scaled))}},{key:"scale",value:function(t){return Math.round(t*this._scaleFactor)}},{key:"getCoordinate",value:function(){return this._originalPt}},{key:"copyScaled",value:function(t,e){e.x=this.scale(t.x),e.y=this.scale(t.y)}},{key:"getSafeEnvelope",value:function(){if(null===this._safeEnv){var e=t.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new U(this._originalPt.x-e,this._originalPt.x+e,this._originalPt.y-e,this._originalPt.y+e)}return this._safeEnv}},{key:"intersectsPixelClosure",value:function(t,e){return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),!!this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),!!this._li.hasIntersection()||(this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),!!this._li.hasIntersection())))}},{key:"intersectsToleranceSquare",value:function(t,e){var n=!1,i=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),!!this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),!!this._li.isProper()||(this._li.hasIntersection()&&(i=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),!!this._li.isProper()||(!(!n||!i)||(!!t.equals(this._pt)||!!e.equals(this._pt))))))}},{key:"addSnappedNode",value:function(t,e){var n=t.getCoordinate(e),i=t.getCoordinate(e+1);return!!this.intersects(n,i)&&(t.addIntersection(this.getCoordinate(),e),!0)}}],[{key:"constructor_",value:function(){this._li=null,this._pt=null,this._originalPt=null,this._ptScaled=null,this._p0Scaled=null,this._p1Scaled=null,this._scaleFactor=null,this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,this._corner=new Array(4).fill(null),this._safeEnv=null;var t=arguments[0],e=arguments[1],n=arguments[2];if(this._originalPt=t,this._pt=t,this._scaleFactor=e,this._li=n,e<=0)throw new m("Scale factor must be non-zero");1!==e&&(this._pt=new X(this.scale(t.x),this.scale(t.y)),this._p0Scaled=new X,this._p1Scaled=new X),this.initCorners(this._pt)}}])}();ui.SAFE_ENV_EXPANSION_FACTOR=.75;var li=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"select",value:function(){if(1===arguments.length);else if(2===arguments.length){var t=arguments[1];arguments[0].getLineSegment(t,this.selectedSegment),this.select(this.selectedSegment)}}}],[{key:"constructor_",value:function(){this.selectedSegment=new In}}])}(),hi=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"snap",value:function(){if(1===arguments.length){var t=arguments[0];return this.snap(t,null,-1)}if(3===arguments.length){var e=arguments[0],i=arguments[1],r=arguments[2],a=e.getSafeEnvelope(),o=new ci(e,i,r);return this._index.query(a,new(function(){return s((function t(){n(this,t)}),[{key:"interfaces_",get:function(){return[ln]}},{key:"visitItem",value:function(t){t.select(a,o)}}])}())),o.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var t=arguments[0];this._index=t}}])}(),ci=function(t){function i(){var t;return n(this,i),t=e(this,i),i.constructor_.apply(t,arguments),t}return l(i,t),s(i,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(2===arguments.length&&Number.isInteger(arguments[1])&&arguments[0]instanceof Nn))return f(i,"select",this,1).apply(this,arguments);var 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)}}],[{key:"constructor_",value:function(){this._hotPixel=null,this._parentEdge=null,this._hotPixelVertexIndex=null,this._isNodeAdded=!1;var t=arguments[0],e=arguments[1],n=arguments[2];this._hotPixel=t,this._parentEdge=e,this._hotPixelVertexIndex=n}}])}(li);hi.HotPixelSnapAction=ci;var fi=function(){return s((function t(){n(this,t),t.constructor_.apply(this,arguments)}),[{key:"processIntersections",value:function(t,e,n,i){if(t===n&&e===i)return null;var r=t.getCoordinates()[e],s=t.getCoordinates()[e+1],a=n.getCoordinates()[i],o=n.getCoordinates()[i+1];if(this._li.computeIntersection(r,s,a,o),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var u=0;u=0;e--){try{this.bufferReducedPrecision(e)}catch(t){if(!(t instanceof gt))throw t;this._saveException=t}if(null!==this._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var n=arguments[0],i=t.precisionScaleFactor(this._argGeom,this._distance,n),r=new ie(i);this.bufferFixedPrecision(r)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===ie.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(t){this._bufParams.setQuadrantSegments(t)}},{key:"bufferOriginalPrecision",value:function(){try{var t=new si(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(t){if(!(t instanceof D))throw t;this._saveException=t}}},{key:"getResultGeometry",value:function(t){return this._distance=t,this.computeGeometry(),this._resultGeometry}},{key:"setEndCapStyle",value:function(t){this._bufParams.setEndCapStyle(t)}}],[{key:"constructor_",value:function(){if(this._argGeom=null,this._distance=null,this._bufParams=new _,this._resultGeometry=null,this._saveException=null,1===arguments.length){var t=arguments[0];this._argGeom=t}else if(2===arguments.length){var e=arguments[0],n=arguments[1];this._argGeom=e,this._bufParams=n}}},{key:"bufferOp",value:function(){if(2===arguments.length){var e=arguments[1];return new t(arguments[0]).getResultGeometry(e)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof V&&"number"==typeof arguments[1]){var n=arguments[1],i=arguments[2],r=new t(arguments[0]);return r.setQuadrantSegments(i),r.getResultGeometry(n)}if(arguments[2]instanceof _&&arguments[0]instanceof V&&"number"==typeof arguments[1]){var s=arguments[1];return new t(arguments[0],arguments[2]).getResultGeometry(s)}}else if(4===arguments.length){var a=arguments[1],o=arguments[2],u=arguments[3],l=new t(arguments[0]);return l.setQuadrantSegments(o),l.setEndCapStyle(u),l.getResultGeometry(a)}}},{key:"precisionScaleFactor",value:function(t,e,n){var i=t.getEnvelopeInternal(),r=kt.max(Math.abs(i.getMaxX()),Math.abs(i.getMaxY()),Math.abs(i.getMinX()),Math.abs(i.getMinY()))+2*(e>0?e:0),s=n-Math.trunc(Math.log(r)/Math.log(10)+1);return Math.pow(10,s)}}])}();vi.CAP_ROUND=_.CAP_ROUND,vi.CAP_BUTT=_.CAP_FLAT,vi.CAP_FLAT=_.CAP_FLAT,vi.CAP_SQUARE=_.CAP_SQUARE,vi.MAX_PRECISION_DIGITS=12;var yi=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],di=function(){return s((function t(e){n(this,t),this.geometryFactory=e||new ae}),[{key:"read",value:function(t){var e,n=(e="string"==typeof t?JSON.parse(t):t).type;if(!_i[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==yi.indexOf(n)?_i[n].call(this,e.coordinates):"GeometryCollection"===n?_i[n].call(this,e.geometries):_i[n].call(this,e)}},{key:"write",value:function(t){var e=t.getGeometryType();if(!pi[e])throw new Error("Geometry is not supported");return pi[e].call(this,t)}}])}(),_i={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){var i=t.geometry.type;if(!_i[i])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=_i.bbox.call(this,t.bbox)),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n