=0&&(n=[].concat(t.slice(r,t.length),t.slice(1,r+1))),n}},{key:"comparePath",value:function(t,e){var n=this;return t.every((function(t,r){return n.compareCoord(t,e[r])}))}},{key:"comparePolygon",value:function(t,e){var n=this;if(this.compareLine(t.coordinates[0],e.coordinates[0],1,!0)){var r=t.coordinates.slice(1,t.coordinates.length),i=e.coordinates.slice(1,e.coordinates.length);return r.every((function(t){return i.some((function(e){return n.compareLine(t,e,1,!0)}))}))}return!1}},{key:"compareGeometryCollection",value:function(t,e){var n=this;return ve(t.geometries,e.geometries)&&this.compareBBox(t,e)&&t.geometries.every((function(t,r){return n.compare(t,e.geometries[r])}))}},{key:"compareFeature",value:function(t,e){return t.id===e.id&&(!this.compareProperties||be(t.properties,e.properties))&&this.compareBBox(t,e)&&this.compare(t.geometry,e.geometry)}},{key:"compareFeatureCollection",value:function(t,e){var n=this;return ve(t.features,e.features)&&this.compareBBox(t,e)&&t.features.every((function(t,r){return n.compare(t,e.features[r])}))}},{key:"compareBBox",value:function(t,e){return Boolean(!t.bbox&&!e.bbox)||!(!t.bbox||!e.bbox)&&this.compareCoord(t.bbox,e.bbox)}}]),t}();de(ge,"GeojsonEquality");var ye=ge;function ve(t,e){return t.coordinates?t.coordinates.length===e.coordinates.length:t.length===e.length}function me(t){return t.coordinates.map((function(e){return{type:t.type.replace("Multi",""),coordinates:e}}))}function _e(t,e,n){return new ye(n).compare(t,e)}function be(t,e){if(null===t&&null===e)return!0;if(null===t||null===e)return!1;var n=Object.keys(t),r=Object.keys(e);if(n.length!==r.length)return!1;for(var i=0,o=n;i1&&void 0!==arguments[1]?arguments[1]:{},n="object"===r(e)?e.mutate:e;if(!t)throw new Error("geojson is required");var i=Q(t),o=[];switch(i){case"LineString":o=Oe(t,i);break;case"MultiLineString":case"Polygon":W(t).forEach((function(t){o.push(Oe(t,i))}));break;case"MultiPolygon":W(t).forEach((function(t){var e=[];t.forEach((function(t){e.push(Oe(t,i))})),o.push(e)}));break;case"Point":return t;case"MultiPoint":var a={};W(t).forEach((function(t){var e=t.join("-");Object.prototype.hasOwnProperty.call(a,e)||(o.push(t),a[e]=!0)}));break;default:throw new Error(i+" geometry not supported")}return t.coordinates?!0===n?(t.coordinates=o,t):{type:i,coordinates:o}:!0===n?(t.geometry.coordinates=o,t):v({type:i,coordinates:o},t.properties,{bbox:t.bbox,id:t.id})}function Oe(t,e){var n=W(t);if(2===n.length&&!Ee(n[0],n[1]))return n;var r=[],i=n.length-1,o=r.length;r.push(n[0]);for(var a=1;a2&&Se(r[o-3],r[o-1],r[o-2])&&r.splice(r.length-2,1))}if(r.push(n[n.length-1]),o=r.length,("Polygon"===e||"MultiPolygon"===e)&&Ee(n[0],n[n.length-1])&&o<4)throw new Error("invalid polygon");return"LineString"===e&&o<3||Se(r[o-3],r[o-1],r[o-2])&&r.splice(r.length-2,1),r}function Ee(t,e){return t[0]===e[0]&&t[1]===e[1]}function Se(t,e,n){var r=n[0],i=n[1],o=t[0],a=t[1],s=e[0],u=e[1],l=s-o,c=u-a;return 0==(r-o)*c-(i-a)*l&&(Math.abs(l)>=Math.abs(c)?l>0?o<=r&&r<=s:s<=r&&r<=o:c>0?a<=i&&i<=u:u<=i&&i<=a)}function Me(t,e){var n,r=null!=(n=(arguments.length>2&&void 0!==arguments[2]?arguments[2]:{}).ignoreSelfIntersections)&&n,i=!1;return dt(t,(function(t){dt(e,(function(e){if(!0===i)return!0;i=!le(t.geometry,e.geometry,{ignoreSelfIntersections:r})}))})),i}function Ce(t,e,n,r,i){!function t(e,n,r,i,o){for(;i>r;){if(i-r>600){var a=i-r+1,s=n-r+1,u=Math.log(a),l=.5*Math.exp(2*u/3),c=.5*Math.sqrt(u*l*(a-l)/a)*(s-a/2<0?-1:1);t(e,n,Math.max(r,Math.floor(n-s*l/a+c)),Math.min(i,Math.floor(n+(a-s)*l/a+c)),o)}var h=e[n],f=r,p=i;for(ke(e,r,n),o(e[i],h)>0&&ke(e,r,i);f0;)p--}0===o(e[r],h)?ke(e,r,p):ke(e,++p,i),p<=n&&(r=p+1),n<=p&&(i=p-1)}}(t,e,n||0,r||t.length-1,i||Ne)}function ke(t,e,n){var r=t[e];t[e]=t[n],t[n]=r}function Ne(t,e){return te?1:0}var je=function(){function t(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9;i(this,t),this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(.4*this._maxEntries)),this.clear()}return a(t,[{key:"all",value:function(){return this._all(this.data,[])}},{key:"search",value:function(t){var e=this.data,n=[];if(!Ge(t,e))return n;for(var r=this.toBBox,i=[];e;){for(var o=0;o=0&&i[e].children.length>this._maxEntries;)this._split(i,e),e--;this._adjustParentBBoxes(r,i,e)}},{key:"_split",value:function(t,e){var n=t[e],r=n.children.length,i=this._minEntries;this._chooseSplitAxis(n,i,r);var o=this._chooseSplitIndex(n,i,r),a=qe(n.children.splice(o,n.children.length-o));a.height=n.height,a.leaf=n.leaf,Pe(n,this.toBBox),Pe(a,this.toBBox),e?t[e-1].children.push(a):this._splitRoot(n,a)}},{key:"_splitRoot",value:function(t,e){this.data=qe([t,e]),this.data.height=t.height+1,this.data.leaf=!1,Pe(this.data,this.toBBox)}},{key:"_chooseSplitIndex",value:function(t,e,n){for(var r,i,o,a,s,u,l,c=1/0,h=1/0,f=e;f<=n-e;f++){var p=Ie(t,0,f,this.toBBox),d=Ie(t,f,n,this.toBBox),g=(i=p,o=d,a=Math.max(i.minX,o.minX),s=Math.max(i.minY,o.minY),u=Math.min(i.maxX,o.maxX),l=Math.min(i.maxY,o.maxY),Math.max(0,u-a)*Math.max(0,l-s)),y=Fe(p)+Fe(d);g=e;c--){var h=t.children[c];Ae(a,t.leaf?i(h):h),s+=De(a)}return s}},{key:"_adjustParentBBoxes",value:function(t,e,n){for(var r=n;r>=0;r--)Ae(e[r],t)}},{key:"_condense",value:function(t){for(var e,n=t.length-1;n>=0;n--)0===t[n].children.length?n>0?(e=t[n-1].children).splice(e.indexOf(t[n]),1):this.clear():Pe(t[n],this.toBBox)}}]),t}();function Le(t,e,n){if(!n)return e.indexOf(t);for(var r=0;r=t.minX&&e.maxY>=t.minY}function qe(t){return{children:t,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function ze(t,e,n,r,i){for(var o=[e,n];o.length;)if(!((n=o.pop())-(e=o.pop())<=r)){var a=e+Math.ceil((n-e)/r/2)*r;Ce(t,a,e,n,i),o.push(e,a,a,n)}}var Ue=Object.freeze({__proto__:null,default:je});function Ve(t){var e=new je(t);return e.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:Ct(t),je.prototype.insert.call(this,t)},e.load=function(t){var e=[];return Array.isArray(t)?t.forEach((function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:Ct(t),e.push(t)})):lt(t,(function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:Ct(t),e.push(t)})),je.prototype.load.call(this,e)},e.remove=function(t,e){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:Ct(t),je.prototype.remove.call(this,t,e)},e.clear=function(){return je.prototype.clear.call(this)},e.search=function(t){return S(je.prototype.search.call(this,this.toBBox(t)))},e.collides=function(t){return je.prototype.collides.call(this,this.toBBox(t))},e.all=function(){return S(je.prototype.all.call(this))},e.toJSON=function(){return je.prototype.toJSON.call(this)},e.fromJSON=function(t){return je.prototype.fromJSON.call(this,t)},e.toBBox=function(t){var e;if(t.bbox)e=t.bbox;else if(Array.isArray(t)&&4===t.length)e=t;else if(Array.isArray(t)&&6===t.length)e=[t[0],t[1],t[3],t[4]];else if("Feature"===t.type)e=Ct(t);else{if("FeatureCollection"!==t.type)throw new Error("invalid geojson");e=Ct(t)}return{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}function Ye(t){if(!t)throw new Error("geojson is required");var e=[];return dt(t,(function(t){!function(t,e){var n=[],r=t.geometry;if(null!==r){switch(r.type){case"Polygon":n=W(r);break;case"LineString":n=[W(r)]}n.forEach((function(n){(function(t,e){var n=[];return t.reduce((function(t,r){var i=O([t,r],e);return i.bbox=function(t,e){var n=t[0],r=t[1],i=e[0],o=e[1];return[ni?n:i,r>o?r:o]}(t,r),n.push(i),r})),n})(n,t.properties).forEach((function(t){t.id=e.length,e.push(t)}))}))}}(t,e)})),S(e)}var We=Object.defineProperty,Xe=Object.defineProperties,He=Object.getOwnPropertyDescriptors,Ze=Object.getOwnPropertySymbols,Ke=Object.prototype.hasOwnProperty,Je=Object.prototype.propertyIsEnumerable,Qe=function(t,e,n){return e in t?We(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n},$e=function(t,e){for(var n in e||(e={}))Ke.call(e,n)&&Qe(t,n,e[n]);if(Ze){var r,i=f(Ze(e));try{for(i.s();!(r=i.n()).done;)n=r.value,Je.call(e,n)&&Qe(t,n,e[n])}catch(t){i.e(t)}finally{i.f()}}return t},tn=function(t,e){return Xe(t,He(e))};function en(t,e){var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{};if(!t||!e)throw new Error("lines and pt are required arguments");var r=_([1/0,1/0],{dist:1/0,index:-1,multiFeatureIndex:-1,location:-1}),i=0;return dt(t,(function(t,o,a){for(var s=W(t),u=0;u0&&y.features[0]&&(v=tn($e({},y.features[0]),{properties:{dist:nt(e,y.features[0],n),multiFeatureIndex:a,location:i+nt(l,y.features[0],n)}})),l.properties.dist2&&void 0!==arguments[2]?arguments[2]:{};if(!q(n=n||{}))throw new Error("options is invalid");var r,i=n.tolerance||0,o=[],a=Ve(),s=Ye(t);a.load(s);var u=[];return yt(e,(function(t){var e=!1;t&&(lt(a.search(t),(function(n){if(!1===e){var o=W(t).sort(),a=W(n).sort();if(on(o,a))e=!0,r=r?sn(r,t)||r:t;else if(0===i?Ft(o[0],n)&&Ft(o[1],n):en(n,o[0]).properties.dist<=i&&en(n,o[1]).properties.dist<=i)e=!0,r=r?sn(r,t)||r:t;else if(0===i?Ft(a[0],t)&&Ft(a[1],t):en(t,a[0]).properties.dist<=i&&en(t,a[1]).properties.dist<=i)if(r){var s=sn(r,n);s?r=s:u.push(n)}else r=n}})),!1===e&&r&&(o.push(r),u.length&&(o=o.concat(u),u=[]),r=void 0))})),r&&o.push(r),S(o)}function sn(t,e){var n=W(e),r=W(t),i=r[0],o=r[r.length-1],a=t.geometry.coordinates;if(on(n[0],i))a.unshift(n[1]);else if(on(n[0],o))a.push(n[1]);else if(on(n[1],i))a.unshift(n[0]);else{if(!on(n[1],o))return;a.push(n[0])}return t}function un(t,e){var n=A(rt(t[0],t[1])),r=A(rt(e[0],e[1]));return n===r||(r-n)%180==0}function ln(t,e){if(t.geometry&&t.geometry.type)return t.geometry.type;if(t.type)return t.type;throw new Error("Invalid GeoJSON object for "+e)}function cn(t,e){return!!hn(e.coordinates[0],t.coordinates)||!!hn(e.coordinates[e.coordinates.length-1],t.coordinates)}function hn(t,e){return t[0]===e[0]&&t[1]===e[1]}function fn(t){return t[0][0]===t[t.length-1][0]&&t[0][1]===t[t.length-1][1]}function pn(t){for(var e=0;ee[0]||t[2]e[1]||t[3]1&&void 0!==arguments[1]?arguments[1]:{},n=Ct(t);return _([(n[0]+n[2])/2,(n[1]+n[3])/2],e.properties,e)}var bn={exports:{}};!function(t,e){t.exports=function(){function t(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function e(t,e){for(var n=0;nt.length)&&(e=t.length);for(var n=0,r=new Array(e);n=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:i}}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 o,a=!0,s=!1;return{s:function(){n=n.call(t)},n:function(){var t=n.next();return a=t.done,t},e:function(t){s=!0,o=t},f:function(){try{a||null==n.return||n.return()}finally{if(s)throw o}}}}var m=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getEndCapStyle",value:function(){return this._endCapStyle}},{key:"isSingleSided",value:function(){return this._isSingleSided}},{key:"setQuadrantSegments",value:function(t){this._quadrantSegments=t,0===this._quadrantSegments&&(this._joinStyle=e.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=e.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),t<=0&&(this._quadrantSegments=1),this._joinStyle!==e.JOIN_ROUND&&(this._quadrantSegments=e.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=e.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=e.CAP_ROUND,this._joinStyle=e.JOIN_ROUND,this._mitreLimit=e.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=e.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this.setQuadrantSegments(t)}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.setQuadrantSegments(n),this.setEndCapStyle(r)}else if(4===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2],s=arguments[3];this.setQuadrantSegments(i),this.setEndCapStyle(o),this.setJoinStyle(a),this.setMitreLimit(s)}}},{key:"bufferDistanceError",value:function(t){var e=Math.PI/2/t;return 1-Math.cos(e/2)}}]),e}();m.CAP_ROUND=1,m.CAP_FLAT=2,m.CAP_SQUARE=3,m.JOIN_ROUND=1,m.JOIN_MITRE=2,m.JOIN_BEVEL=3,m.DEFAULT_QUADRANT_SEGMENTS=8,m.DEFAULT_MITRE_LIMIT=5,m.DEFAULT_SIMPLIFY_FACTOR=.01;var _=function(e){i(o,e);var r=f(o);function o(e){var n;return t(this,o),(n=r.call(this,e)).name=Object.keys({Exception:o})[0],n}return n(o,[{key:"toString",value:function(){return this.message}}]),o}(l(Error)),b=function(e){i(r,e);var n=f(r);function r(e){var i;return t(this,r),(i=n.call(this,e)).name=Object.keys({IllegalArgumentException:r})[0],i}return r}(_),w=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t){}}]),e}();function x(){}function O(){}function E(){}var S,M,C,k,N,j,L,P=function(){function e(){t(this,e)}return n(e,null,[{key:"equalsWithTolerance",value:function(t,e,n){return Math.abs(t-e)<=n}}]),e}(),I=function(){function e(n,r){t(this,e),this.low=r||0,this.high=n||0}return n(e,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}}]),e}();function A(){}function R(){}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?(N=2146435072,j=new Float64Array(1),L=new Int32Array(j.buffer),A.doubleToLongBits=function(t){j[0]=t;var e=0|L[0],n=0|L[1];return(n&N)===N&&0!=(1048575&n)&&0!==e&&(e=0,n=2146959360),new I(n,e)},A.longBitsToDouble=function(t){return L[0]=t.low,L[1]=t.high,j[0]}):(S=Math.log2,M=Math.floor,C=Math.pow,k=function(){for(var t=53;t>0;t--){var e=C(2,t)-1;if(M(S(e))+1===t)return e}return 0}(),A.doubleToLongBits=function(t){var e,n,r,i,o,a,s,u,l;if(t<0||1/t===Number.NEGATIVE_INFINITY?(a=1<<31,t=-t):a=0,0===t)return new I(u=a,l=0);if(t===1/0)return new I(u=2146435072|a,l=0);if(t!=t)return new I(u=2146959360,l=0);if(i=0,l=0,(e=M(t))>1)if(e<=k)(i=M(S(e)))<=20?(l=0,u=e<<20-i&1048575):(l=e%(n=C(2,r=i-20))<<32-r,u=e/n&1048575);else for(r=e,l=0;0!==(r=M(n=r/2));)i++,l>>>=1,l|=(1&u)<<31,u>>>=1,n!==r&&(u|=524288);if(s=i+1023,o=0===e,e=t-e,i<52&&0!==e)for(r=0;;){if((n=2*e)>=1?(e=n-1,o?(s--,o=!1):(r<<=1,r|=1,i++)):(e=n,o?0==--s&&(i++,o=!1):(r<<=1,i++)),20===i)u|=r,r=0;else if(52===i){l|=r;break}if(1===n){i<20?u|=r<<20-i:i<52&&(l|=r<<52-i);break}}return u|=s<<20,new I(u|=a,l)},A.longBitsToDouble=function(t){var e,n,r,i,o=t.high,a=t.low,s=o&1<<31?-1:1;for(r=((2146435072&o)>>20)-1023,i=0,n=1<<19,e=1;e<=20;e++)o&n&&(i+=C(2,-e)),n>>>=1;for(n=1<<31,e=21;e<=52;e++)a&n&&(i+=C(2,-e)),n>>>=1;if(-1023===r){if(0===i)return 0*s;r=-1022}else{if(1024===r)return 0===i?s/0:NaN;i+=1}return s*i*C(2,r)});var T=function(e){i(r,e);var n=f(r);function r(e){var i;return t(this,r),(i=n.call(this,e)).name=Object.keys({RuntimeException:r})[0],i}return r}(_),F=function(e){i(o,e);var r=f(o);function o(){var e;return t(this,o),e=r.call(this),o.constructor_.apply(c(e),arguments),e}return n(o,null,[{key:"constructor_",value:function(){if(0===arguments.length)T.constructor_.call(this);else if(1===arguments.length){var t=arguments[0];T.constructor_.call(this,t)}}}]),o}(T),D=function(){function e(){t(this,e)}return n(e,null,[{key:"shouldNeverReachHere",value:function(){if(0===arguments.length)e.shouldNeverReachHere(null);else if(1===arguments.length){var t=arguments[0];throw new F("Should never reach here"+(null!==t?": "+t:""))}}},{key:"isTrue",value:function(){if(1===arguments.length){var t=arguments[0];e.isTrue(t,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 t=arguments[0],n=arguments[1];e.equals(t,n,null)}else if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2];if(!i.equals(r))throw new F("Expected "+r+" but encountered "+i+(null!==o?": "+o:""))}}}]),e}(),B=new ArrayBuffer(8),G=new Float64Array(B),q=new Int32Array(B),z=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getM",value:function(){return A.NaN}},{key:"setOrdinate",value:function(t,n){switch(t){case e.X:this.x=n;break;case e.Y:this.y=n;break;case e.Z:this.setZ(n);break;default:throw new b("Invalid ordinate index: "+t)}}},{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!!P.equalsWithTolerance(this.x,e.x,n)&&!!P.equalsWithTolerance(this.y,e.y,n)}}},{key:"setM",value:function(t){throw new b("Invalid ordinate index: "+e.M)}},{key:"getZ",value:function(){return this.z}},{key:"getOrdinate",value:function(t){switch(t){case e.X:return this.x;case e.Y:return this.y;case e.Z:return this.getZ()}throw new b("Invalid ordinate index: "+t)}},{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(t){return t instanceof e&&this.equals2D(t)}},{key:"equalInZ",value:function(t,e){return P.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 D.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}}},{key:"copy",value:function(){return new e(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,r=this.getZ()-t.getZ();return Math.sqrt(e*e+n*n+r*r)}},{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 t=17;return 37*(t=37*t+e.hashCode(this.x))+e.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,O,E]}}],[{key:"constructor_",value:function(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)e.constructor_.call(this,0,0);else if(1===arguments.length){var t=arguments[0];e.constructor_.call(this,t.x,t.y,t.getZ())}else if(2===arguments.length){var n=arguments[0],r=arguments[1];e.constructor_.call(this,n,r,e.NULL_ORDINATE)}else if(3===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2];this.x=i,this.y=o,this.z=a}}},{key:"hashCode",value:function(t){return G[0]=t,q[0]^q[1]}}]),e}(),U=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compare",value:function(t,n){var r=e.compare(t.x,n.x);if(0!==r)return r;var i=e.compare(t.y,n.y);return 0!==i?i:this._dimensionsToTest<=2?0:e.compare(t.getZ(),n.getZ())}},{key:"interfaces_",get:function(){return[R]}}],[{key:"constructor_",value:function(){if(this._dimensionsToTest=2,0===arguments.length)e.constructor_.call(this,2);else if(1===arguments.length){var t=arguments[0];if(2!==t&&3!==t)throw new b("only 2 or 3 dimensions may be specified");this._dimensionsToTest=t}}},{key:"compare",value:function(t,e){return te?1:A.isNaN(t)?A.isNaN(e)?0:-1:A.isNaN(e)?1:0}}]),e}();z.DimensionalComparator=U,z.NULL_ORDINATE=A.NaN,z.X=0,z.Y=1,z.Z=2,z.M=3;var V=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getArea",value:function(){return this.getWidth()*this.getHeight()}},{key:"equals",value:function(t){if(!(t instanceof e))return!1;var n=t;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(t){if(this.isNull()||t.isNull()||!this.intersects(t))return new e;var n=this._minx>t._minx?this._minx:t._minx,r=this._miny>t._miny?this._miny:t._miny;return new e(n,this._maxx=this._minx&&n.getMaxX()<=this._maxx&&n.getMinY()>=this._miny&&n.getMaxY()<=this._maxy}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];return!this.isNull()&&r>=this._minx&&r<=this._maxx&&i>=this._miny&&i<=this._maxy}}},{key:"intersects",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxxthis._maxy||t._maxythis._maxx||(r.x>i.x?r.x:i.x)this._maxy||(r.y>i.y?r.y:i.y)this._maxx||othis._maxy||athis._maxx&&(this._maxx=n._maxx),n._minythis._maxy&&(this._maxy=n._maxy))}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.isNull()?(this._minx=r,this._maxx=r,this._miny=i,this._maxy=i):(rthis._maxx&&(this._maxx=r),ithis._maxy&&(this._maxy=i))}}},{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 e(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 e){var t=arguments[0];return this.covers(t)}if(arguments[0]instanceof z){var n=arguments[0];return this.covers(n)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];return this.covers(r,i)}}},{key:"centre",value:function(){return this.isNull()?null:new z((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 z){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof e){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 r=arguments[0],i=arguments[1];this.init(r.x,i.x,r.y,i.y)}else if(4===arguments.length){var o=arguments[0],a=arguments[1],s=arguments[2],u=arguments[3];ot._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 37*(t=37*(t=37*(t=37*t+z.hashCode(this._minx))+z.hashCode(this._maxx))+z.hashCode(this._miny))+z.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 z){var t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof e){var n=arguments[0];this.init(n)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1];this.init(r.x,i.x,r.y,i.y)}else if(4===arguments.length){var o=arguments[0],a=arguments[1],s=arguments[2],u=arguments[3];this.init(o,a,s,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 r=arguments[0],i=arguments[1],o=arguments[2],a=arguments[3],s=Math.min(o.x,a.x),u=Math.max(o.x,a.x),l=Math.min(r.x,i.x),c=Math.max(r.x,i.x);return!(l>u||cu||c=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()}}]),o}(nt);function it(t,e){return t.interfaces_&&t.interfaces_.indexOf(e)>-1}var ot=function(){function e(n){t(this,e),this.str=n}return n(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}}]),e}(),at=function(){function e(n){t(this,e),this.value=n}return n(e,[{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(t){return new e(t)}}]),e}(),st=function(){function e(){t(this,e)}return n(e,null,[{key:"isWhitespace",value:function(t){return t<=32&&t>=0||127===t}},{key:"toUpperCase",value:function(t){return t.toUpperCase()}}]),e}(),ut=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"le",value:function(t){return this._hi9?(h=!0,f="9"):f="0"+c,s.append(f),r=r.subtract(e.valueOf(c)).multiply(e.TEN),h&&r.selfAdd(e.TEN);var p=!0,d=e.magnitude(r._hi);if(d<0&&Math.abs(d)>=u-l&&(p=!1),!p)break}return n[0]=i,s.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 e){var t=arguments[0];return this.add(t.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 e){var t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}}},{key:"isZero",value:function(){return 0===this._hi&&0===this._lo}},{key:"selfSubtract",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._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 e){var t=arguments[0];return this.selfDivide(t._hi,t._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfDivide(n,0)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1],o=null,a=null,s=null,u=null,l=null,c=null,h=null,f=null;return l=this._hi/r,f=(o=(c=e.SPLIT*l)-(o=c-l))*(s=(f=e.SPLIT*r)-(s=f-r))-(h=l*r)+o*(u=r-s)+(a=l-o)*s+a*u,f=l+(c=(this._hi-h-f+this._lo-l*i)/r),this._hi=f,this._lo=l-f+c,this}}},{key:"dump",value:function(){return"DD<"+this._hi+", "+this._lo+">"}},{key:"divide",value:function(){if(arguments[0]instanceof e){var t=arguments[0],n=null,r=null,i=null,o=null,a=null,s=null,u=null,l=null;return r=(a=this._hi/t._hi)-(n=(s=e.SPLIT*a)-(n=s-a)),l=n*(i=(l=e.SPLIT*t._hi)-(i=l-t._hi))-(u=a*t._hi)+n*(o=t._hi-i)+r*i+r*o,new e(l=a+(s=(this._hi-u-l+this._lo-a*t._lo)/t._hi),a-l+s)}if("number"==typeof arguments[0]){var c=arguments[0];return A.isNaN(c)?e.createNaN():e.copy(this).selfDivide(c,0)}}},{key:"ge",value:function(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>=t._lo}},{key:"pow",value:function(t){if(0===t)return e.valueOf(1);var n=new e(this),r=e.valueOf(1),i=Math.abs(t);if(i>1)for(;i>0;)i%2==1&&r.selfMultiply(n),(i/=2)>0&&(n=n.sqr());else r=n;return t<0?r.reciprocal():r}},{key:"ceil",value:function(){if(this.isNaN())return e.NaN;var t=Math.ceil(this._hi),n=0;return t===this._hi&&(n=Math.ceil(this._lo)),new e(t,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 e){var t=arguments[0];return this.init(t),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 e.valueOf(0);if(this.isNegative())return e.NaN;var t=1/Math.sqrt(this._hi),n=this._hi*t,r=e.valueOf(n),i=this.subtract(r.sqr())._hi*(.5*t);return r.add(i)}},{key:"selfAdd",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){var n=arguments[0],r=null,i=null,o=null,a=null,s=null,u=null;return a=(o=this._hi+n)-(s=o-this._hi),i=(u=(a=n-s+(this._hi-a))+this._lo)+(o-(r=o+u)),this._hi=r+i,this._lo=i+(r-this._hi),this}}else if(2===arguments.length){var l=arguments[0],c=arguments[1],h=null,f=null,p=null,d=null,g=null,y=null,v=null;d=this._hi+l,f=this._lo+c,g=d-(y=d-this._hi),p=f-(v=f-this._lo);var m=(h=d+(y=(g=l-y+(this._hi-g))+f))+(y=(p=c-v+(this._lo-p))+(y+(d-h))),_=y+(h-m);return this._hi=m,this._lo=_,this}}},{key:"selfMultiply",value:function(){if(1===arguments.length){if(arguments[0]instanceof e){var t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if("number"==typeof arguments[0]){var n=arguments[0];return this.selfMultiply(n,0)}}else if(2===arguments.length){var r=arguments[0],i=arguments[1],o=null,a=null,s=null,u=null,l=null,c=null;o=(l=e.SPLIT*this._hi)-this._hi,c=e.SPLIT*r,o=l-o,a=this._hi-o,s=c-r;var h=(l=this._hi*r)+(c=o*(s=c-s)-l+o*(u=r-s)+a*s+a*u+(this._hi*i+this._lo*r)),f=c+(o=l-h);return this._hi=h,this._lo=f,this}}},{key:"selfSqr",value:function(){return this.selfMultiply(this)}},{key:"floor",value:function(){if(this.isNaN())return e.NaN;var t=Math.floor(this._hi),n=0;return t===this._hi&&(n=Math.floor(this._lo)),new e(t,n)}},{key:"negate",value:function(){return this.isNaN()?this:new e(-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 e){var t=arguments[0];return t.isNaN()?e.createNaN():e.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){var n=arguments[0];return A.isNaN(n)?e.createNaN():e.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 t=e.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()}},{key:"toStandardNotation",value:function(){var t=this.getSpecialNumberString();if(null!==t)return t;var n=new Array(1).fill(null),r=this.extractSignificantDigits(!0,n),i=n[0]+1,o=r;if("."===r.charAt(0))o="0"+r;else if(i<0)o="0."+e.stringOfChar("0",-i)+r;else if(-1===r.indexOf(".")){var a=i-r.length;o=r+e.stringOfChar("0",a)+".0"}return this.isNegative()?"-"+o:o}},{key:"reciprocal",value:function(){var t,n,r,i,o=null,a=null,s=null,u=null;t=(r=1/this._hi)-(o=(s=e.SPLIT*r)-(o=s-r)),a=(u=e.SPLIT*this._hi)-this._hi;var l=r+(s=(1-(i=r*this._hi)-(u=o*(a=u-a)-i+o*(n=this._hi-a)+t*a+t*n)-r*this._lo)/this._hi);return new e(l,r-l+s)}},{key:"toSciNotation",value:function(){if(this.isZero())return e.SCI_NOT_ZERO;var t=this.getSpecialNumberString();if(null!==t)return t;var n=new Array(1).fill(null),r=this.extractSignificantDigits(!1,n),i=e.SCI_NOT_EXPONENT_CHAR+n[0];if("0"===r.charAt(0))throw new IllegalStateException("Found leading zero: "+r);var o="";r.length>1&&(o=r.substring(1));var a=r.charAt(0)+"."+o;return this.isNegative()?"-"+a+i:a+i}},{key:"abs",value:function(){return this.isNaN()?e.NaN:this.isNegative()?this.negate():new e(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()?e.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,O]}}],[{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 t=arguments[0];this.init(t)}else if(arguments[0]instanceof e){var n=arguments[0];this.init(n)}else if("string"==typeof arguments[0]){var r=arguments[0];e.constructor_.call(this,e.parse(r))}}else if(2===arguments.length){var i=arguments[0],o=arguments[1];this.init(i,o)}}},{key:"determinant",value:function(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],n=arguments[1],r=arguments[2],i=arguments[3];return e.determinant(e.valueOf(t),e.valueOf(n),e.valueOf(r),e.valueOf(i))}if(arguments[3]instanceof e&&arguments[2]instanceof e&&arguments[0]instanceof e&&arguments[1]instanceof e){var o=arguments[1],a=arguments[2],s=arguments[3];return arguments[0].multiply(s).selfSubtract(o.multiply(a))}}},{key:"sqr",value:function(t){return e.valueOf(t).selfMultiply(t)}},{key:"valueOf",value:function(){if("string"==typeof arguments[0]){var t=arguments[0];return e.parse(t)}if("number"==typeof arguments[0])return new e(arguments[0])}},{key:"sqrt",value:function(t){return e.valueOf(t).sqrt()}},{key:"parse",value:function(t){for(var n=0,r=t.length;st.isWhitespace(t.charAt(n));)n++;var i=!1;if(n=r);){var h=t.charAt(n);if(n++,st.isDigit(h)){var f=h-"0";a.selfMultiply(e.TEN),a.selfAdd(f),s++}else{if("."!==h){if("e"===h||"E"===h){var p=t.substring(n);try{l=at.parseInt(p)}catch(e){throw e instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+p+" in string "+t):e}break}throw new NumberFormatException("Unexpected character '"+h+"' at position "+n+" in string "+t)}u=s,c=!0}}var d=a;c||(u=s);var g=s-u-l;if(0===g)d=a;else if(g>0){var y=e.TEN.pow(g);d=a.divide(y)}else if(g<0){var v=e.TEN.pow(-g);d=a.multiply(v)}return i?d.negate():d}},{key:"createNaN",value:function(){return new e(A.NaN,A.NaN)}},{key:"copy",value:function(t){return new e(t)}},{key:"magnitude",value:function(t){var e=Math.abs(t),n=Math.log(e)/Math.log(10),r=Math.trunc(Math.floor(n));return 10*Math.pow(10,r)<=e&&(r+=1),r}},{key:"stringOfChar",value:function(t,e){for(var n=new ot,r=0;r0){if(a<=0)return e.signum(s);i=o+a}else{if(!(o<0))return e.signum(s);if(a>=0)return e.signum(s);i=-o-a}var u=e.DP_SAFE_EPSILON*i;return s>=u||-s>=u?e.signum(s):2}},{key:"signum",value:function(t){return t>0?1:t<0?-1:0}}]),e}();lt.DP_SAFE_EPSILON=1e-15;var ct=function(){function e(){t(this,e)}return n(e,[{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[O]}}]),e}();ct.X=0,ct.Y=1,ct.Z=2,ct.M=3;var ht=function(){function e(){t(this,e)}return n(e,null,[{key:"index",value:function(t,e,n){return lt.orientationIndex(t,e,n)}},{key:"isCCW",value:function(){if(arguments[0]instanceof Array){var t=arguments[0],n=t.length-1;if(n<3)throw new b("Ring has fewer than 4 points, so orientation cannot be determined");for(var r=t[0],i=0,o=1;o<=n;o++){var a=t[o];a.y>r.y&&(r=a,i=o)}var s=i;do{(s-=1)<0&&(s=n)}while(t[s].equals2D(r)&&s!==i);var u=i;do{u=(u+1)%n}while(t[u].equals2D(r)&&u!==i);var l=t[s],c=t[u];if(l.equals2D(r)||c.equals2D(r)||l.equals2D(c))return!1;var h=e.index(l,r,c);return 0===h?l.x>c.x:h>0}if(it(arguments[0],ct)){var f=arguments[0],p=f.size()-1;if(p<3)throw new b("Ring has fewer than 4 points, so orientation cannot be determined");for(var d=f.getCoordinate(0),g=0,y=1;y<=p;y++){var v=f.getCoordinate(y);v.y>d.y&&(d=v,g=y)}var m=null,_=g;do{(_-=1)<0&&(_=p),m=f.getCoordinate(_)}while(m.equals2D(d)&&_!==g);var w=null,x=g;do{x=(x+1)%p,w=f.getCoordinate(x)}while(w.equals2D(d)&&x!==g);if(m.equals2D(d)||w.equals2D(d)||m.equals2D(w))return!1;var O=e.index(m,d,w);return 0===O?m.x>w.x:O>0}}}]),e}();ht.CLOCKWISE=-1,ht.RIGHT=ht.CLOCKWISE,ht.COUNTERCLOCKWISE=1,ht.LEFT=ht.COUNTERCLOCKWISE,ht.COLLINEAR=0,ht.STRAIGHT=ht.COLLINEAR;var ft=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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();D.isTrue(this._minIndex>0&&this._minIndexthis._minCoord.y&&n.y>this._minCoord.y&&r===ht.CLOCKWISE)&&(i=!0),i&&(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 r=$.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)}D.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}}]),e}(),pt=function(e){i(o,e);var r=f(o);function o(e,n){var i;return t(this,o),(i=r.call(this,n?e+" [ "+n+" ]":e)).pt=n?new z(n):void 0,i.name=Object.keys({TopologyException:o})[0],i}return n(o,[{key:"getCoordinate",value:function(){return this.pt}}]),o}(T),dt=function(){function e(){t(this,e),this.array=[]}return n(e,[{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}}]),e}(),gt=function(e,r){i(a,e);var o=f(a);function a(e){var n;return t(this,a),(n=o.call(this)).array=[],e instanceof X&&n.addAll(e),n}return n(a,[{key:"interfaces_",get:function(){return[nt,X]}},{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=v(t);try{for(n.s();!(e=n.n()).done;){var r=e.value;this.array.push(r)}}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 yt(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 dt,r=t.getNode();for(n.addLast(r),e.add(r),t.setVisited(!0);!n.isEmpty();){var i=n.removeFirst();e.add(i),this.computeNodeDepth(i);for(var o=i.getEdges().iterator();o.hasNext();){var a=o.next().getSym();if(!a.isVisited()){var s=a.getNode();e.contains(s)||(n.addLast(s),e.add(s))}}}}},{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 V,e=this._dirEdgeList.iterator();e.hasNext();)for(var n=e.next().getEdge().getCoordinates(),r=0;re.x?t.x:e.x,s=t.y>e.y?t.y:e.y,u=n.xr.x?n.x:r.x,h=n.y>r.y?n.y:r.y,f=((i>u?i:u)+(al?o:l)+(sn?n:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){var r=arguments[0],i=arguments[1],o=arguments[2];return ro?o:r}}},{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 r=arguments[1],i=arguments[2],o=arguments[3],a=arguments[0];return r>a&&(a=r),i>a&&(a=i),o>a&&(a=o),a}}},{key:"average",value:function(t,e){return(t+e)/2}}]),e}();bt.LOG_10=Math.log(10);var wt=function(){function e(){t(this,e)}return n(e,null,[{key:"segmentToSegment",value:function(t,n,r,i){if(t.equals(n))return e.pointToSegment(t,r,i);if(r.equals(i))return e.pointToSegment(i,t,n);var o=!1;if(V.intersects(t,n,r,i)){var a=(n.x-t.x)*(i.y-r.y)-(n.y-t.y)*(i.x-r.x);if(0===a)o=!0;else{var s=(t.y-r.y)*(i.x-r.x)-(t.x-r.x)*(i.y-r.y),u=((t.y-r.y)*(n.x-t.x)-(t.x-r.x)*(n.y-t.y))/a,l=s/a;(l<0||l>1||u<0||u>1)&&(o=!0)}}else o=!0;return o?bt.min(e.pointToSegment(t,r,i),e.pointToSegment(n,r,i),e.pointToSegment(r,t,n),e.pointToSegment(i,t,n)):0}},{key:"pointToSegment",value:function(t,e,n){if(e.x===n.x&&e.y===n.y)return t.distance(e);var r=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),i=((t.x-e.x)*(n.x-e.x)+(t.y-e.y)*(n.y-e.y))/r;if(i<=0)return t.distance(e);if(i>=1)return t.distance(n);var o=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/r;return Math.abs(o)*Math.sqrt(r)}},{key:"pointToLinePerpendicular",value:function(t,e,n){var r=(n.x-e.x)*(n.x-e.x)+(n.y-e.y)*(n.y-e.y),i=((e.y-t.y)*(n.x-e.x)-(e.x-t.x)*(n.y-e.y))/r;return Math.abs(i)*Math.sqrt(r)}},{key:"pointToSegmentString",value:function(t,n){if(0===n.length)throw new b("Line array must contain at least one vertex");for(var r=t.distance(n[0]),i=0;i0)&&(o=s,i=a)}return i}}},{key:"extend",value:function(t,n,r){var i=t.create(r,n.getDimension()),o=n.size();if(e.copy(n,0,i,0,o),o>0)for(var a=o;a0)&&(e=r)}return e}}]),e}(),Ct=function(){function e(){t(this,e)}return n(e,null,[{key:"toDimensionSymbol",value:function(t){switch(t){case e.FALSE:return e.SYM_FALSE;case e.TRUE:return e.SYM_TRUE;case e.DONTCARE:return e.SYM_DONTCARE;case e.P:return e.SYM_P;case e.L:return e.SYM_L;case e.A:return e.SYM_A}throw new b("Unknown dimension value: "+t)}},{key:"toDimensionValue",value:function(t){switch(st.toUpperCase(t)){case e.SYM_FALSE:return e.FALSE;case e.SYM_TRUE:return e.TRUE;case e.SYM_DONTCARE:return e.DONTCARE;case e.SYM_P:return e.P;case e.SYM_L:return e.L;case e.SYM_A:return e.A}throw new b("Unknown dimension symbol: "+t)}}]),e}();Ct.P=0,Ct.L=1,Ct.A=2,Ct.FALSE=-1,Ct.TRUE=-2,Ct.DONTCARE=-3,Ct.SYM_FALSE="F",Ct.SYM_TRUE="T",Ct.SYM_DONTCARE="*",Ct.SYM_P="0",Ct.SYM_L="1",Ct.SYM_A="2";var kt=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t){}}]),e}(),Nt=function(){function e(){t(this,e)}return n(e,[{key:"filter",value:function(t,e){}},{key:"isDone",value:function(){}},{key:"isGeometryChanged",value:function(){}}]),e}(),jt=function(e){i(a,e);var r=f(a);function a(){var e;return t(this,a),e=r.call(this),a.constructor_.apply(c(e),arguments),e}return n(a,[{key:"computeEnvelopeInternal",value:function(){return this.isEmpty()?new V:this._points.expandEnvelope(new V)}},{key:"isRing",value:function(){return this.isClosed()&&this.isSimple()}},{key:"getCoordinates",value:function(){return this._points.toCoordinateArray()}},{key:"copyInternal",value:function(){return new a(this._points.copy(),this._factory)}},{key:"equalsExact",value:function(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof Y){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();Mt.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()?Ct.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 Mt.reverse(t),this.getFactory().createLineString(t)}},{key:"getEndPoint",value:function(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}},{key:"getTypeCode",value:function(){return Y.TYPECODE_LINESTRING}},{key:"getDimension",value:function(){return 1}},{key:"getLength",value:function(){return Et.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 Y.TYPENAME_LINEARRING}}],[{key:"constructor_",value:function(){var t=arguments[0],e=arguments[1];jt.constructor_.call(this,t,e),this.validateConstruction()}}]),a}(jt);qt.MINIMUM_VALID_SIZE=4;var zt=function(e){i(o,e);var r=f(o);function o(){var e;return t(this,o),e=r.call(this),o.constructor_.apply(c(e),arguments),e}return n(o,[{key:"setOrdinate",value:function(t,e){switch(t){case o.X:this.x=e;break;case o.Y:this.y=e;break;default:throw new b("Invalid ordinate index: "+t)}}},{key:"getZ",value:function(){return z.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case o.X:return this.x;case o.Y:return this.y}throw new b("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new b("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new o(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)z.constructor_.call(this);else if(1===arguments.length){if(arguments[0]instanceof o){var t=arguments[0];z.constructor_.call(this,t.x,t.y)}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e.x,e.y)}}else if(2===arguments.length){var n=arguments[0],r=arguments[1];z.constructor_.call(this,n,r,z.NULL_ORDINATE)}}}]),o}(z);zt.X=0,zt.Y=1,zt.Z=-1,zt.M=-1;var Ut=function(e){i(o,e);var r=f(o);function o(){var e;return t(this,o),e=r.call(this),o.constructor_.apply(c(e),arguments),e}return n(o,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case o.X:this.x=e;break;case o.Y:this.y=e;break;case o.M:this._m=e;break;default:throw new b("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getZ",value:function(){return z.NULL_ORDINATE}},{key:"getOrdinate",value:function(t){switch(t){case o.X:return this.x;case o.Y:return this.y;case o.M:return this._m}throw new b("Invalid ordinate index: "+t)}},{key:"setZ",value:function(t){throw new b("CoordinateXY dimension 2 does not support z-ordinate")}},{key:"copy",value:function(){return new o(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)z.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof o){var t=arguments[0];z.constructor_.call(this,t.x,t.y),this._m=t._m}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e.x,e.y),this._m=this.getM()}}else if(3===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2];z.constructor_.call(this,n,r,z.NULL_ORDINATE),this._m=i}}}]),o}(z);Ut.X=0,Ut.Y=1,Ut.Z=-1,Ut.M=2;var Vt=function(e){i(o,e);var r=f(o);function o(){var e;return t(this,o),e=r.call(this),o.constructor_.apply(c(e),arguments),e}return n(o,[{key:"getM",value:function(){return this._m}},{key:"setOrdinate",value:function(t,e){switch(t){case z.X:this.x=e;break;case z.Y:this.y=e;break;case z.Z:this.z=e;break;case z.M:this._m=e;break;default:throw new b("Invalid ordinate index: "+t)}}},{key:"setM",value:function(t){this._m=t}},{key:"getOrdinate",value:function(t){switch(t){case z.X:return this.x;case z.Y:return this.y;case z.Z:return this.getZ();case z.M:return this.getM()}throw new b("Invalid ordinate index: "+t)}},{key:"copy",value:function(){return new o(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)z.constructor_.call(this),this._m=0;else if(1===arguments.length){if(arguments[0]instanceof o){var t=arguments[0];z.constructor_.call(this,t),this._m=t._m}else if(arguments[0]instanceof z){var e=arguments[0];z.constructor_.call(this,e),this._m=this.getM()}}else if(4===arguments.length){var n=arguments[0],r=arguments[1],i=arguments[2],a=arguments[3];z.constructor_.call(this,n,r,i),this._m=a}}}]),o}(z),Yt=function(){function e(){t(this,e)}return n(e,null,[{key:"measures",value:function(t){return t instanceof zt?0:t instanceof Ut||t instanceof Vt?1:0}},{key:"dimension",value:function(t){return t instanceof zt?2:t instanceof Ut?3:t instanceof Vt?4:3}},{key:"create",value:function(){if(1===arguments.length){var t=arguments[0];return e.create(t,0)}if(2===arguments.length){var n=arguments[0],r=arguments[1];return 2===n?new zt:3===n&&0===r?new z:3===n&&1===r?new Ut:4===n&&1===r?new Vt:new z}}}]),e}(),Wt=function(e){i(a,e);var r=f(a);function a(){var e;return t(this,a),e=r.call(this),a.constructor_.apply(c(e),arguments),e}return n(a,[{key:"getCoordinate",value:function(t){return this.get(t)}},{key:"addAll",value:function(){if(2===arguments.length&&"boolean"==typeof arguments[1]&&it(arguments[0],X)){for(var t=arguments[1],e=!1,n=arguments[0].iterator();n.hasNext();)this.add(n.next(),t),e=!0;return e}return p(o(a.prototype),"addAll",this).apply(this,arguments)}},{key:"clone",value:function(){for(var t=p(o(a.prototype),"clone",this).call(this),e=0;e=1&&this.get(this.size()-1).equals2D(r))return null;p(o(a.prototype),"add",this).call(this,r)}else if(arguments[0]instanceof Object&&"boolean"==typeof arguments[1]){var i=arguments[0],s=arguments[1];return this.add(i,s),!0}}else if(3===arguments.length){if("boolean"==typeof arguments[2]&&arguments[0]instanceof Array&&"boolean"==typeof arguments[1]){var u=arguments[0],l=arguments[1];if(arguments[2])for(var c=0;c=0;h--)this.add(u[h],l);return!0}if("boolean"==typeof arguments[2]&&Number.isInteger(arguments[0])&&arguments[1]instanceof z){var f=arguments[0],d=arguments[1];if(!arguments[2]){var g=this.size();if(g>0){if(f>0&&this.get(f-1).equals2D(d))return null;if(f_&&(b=-1);for(var w=m;w!==_;w+=b)this.add(y[w],v);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)}}}]),a}(gt);Wt.coordArrayType=new Array(0).fill(null);var Xt=function(){function e(){t(this,e)}return n(e,null,[{key:"isRing",value:function(t){return!(t.length<4||!t[0].equals2D(t[t.length-1]))}},{key:"ptNotInList",value:function(t,n){for(var r=0;r=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=bt.clamp(e,0,t.length);var r=(n=bt.clamp(n,-1,t.length))-e+1;n<0&&(r=0),e>=t.length&&(r=0),nr.length)return 1;if(0===n.length)return 0;var i=Xt.compare(n,r);return Xt.isEqualReversed(n,r)?0:i}},{key:"OLDcompare",value:function(t,e){var n=t,r=e;if(n.lengthr.length)return 1;if(0===n.length)return 0;for(var i=Xt.increasingDirection(n),o=Xt.increasingDirection(r),a=i>0?0:n.length-1,s=o>0?0:n.length-1,u=0;u0){var t=new Kt(17*this._coordinates.length);t.append("("),t.append(this._coordinates[0]);for(var e=1;e3&&(t=3),t<2&&(t=2),new Jt(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 Jt(arguments[0],n+e,e)}}}},{key:"interfaces_",get:function(){return[xt,E]}}],[{key:"instance",value:function(){return e.instanceObject}}]),e}();Qt.instanceObject=new Qt;var $t=function(e){i(a,e);var r=f(a);function a(){var e;return t(this,a),e=r.call(this),a.constructor_.apply(c(e),arguments),e}return n(a,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e=0?t:e}}]),e}(),re=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"readResolve",value:function(){return e.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 t=arguments[0];this._name=t,e.nameToTypeMap.put(t,this)}}]),e}();re.nameToTypeMap=new ee,ne.Type=re,ne.FIXED=new re("FIXED"),ne.FLOATING=new re("FLOATING"),ne.FLOATING_SINGLE=new re("FLOATING SINGLE"),ne.maximumPreciseValue=9007199254740992;var ie=function(e){i(a,e);var r=f(a);function a(){var e;return t(this,a),e=r.call(this),a.constructor_.apply(c(e),arguments),e}return n(a,[{key:"copyInternal",value:function(){for(var t=new Array(this._geometries.length).fill(null),e=0;e1){if(u instanceof Tt)return this.createMultiPolygon(e.toPolygonArray(t));if(u instanceof jt)return this.createMultiLineString(e.toLineStringArray(t));if(u instanceof Pt)return this.createMultiPoint(e.toPointArray(t));D.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 z){var t=arguments[0];return this.createPoint(null!==t?this.getCoordinateSequenceFactory().create([t]):null)}if(it(arguments[0],ct))return new Pt(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(it(arguments[0],ct)){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 qt){var n=arguments[0];return this.createPolygon(n,null)}}else if(2===arguments.length)return new Tt(arguments[0],arguments[1],this)}},{key:"getSRID",value:function(){return this._SRID}},{key:"createGeometryCollection",value:function(){return 0===arguments.length?new Bt(null,this):1===arguments.length?new Bt(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(it(arguments[0],ct))return new qt(arguments[0],this)}}},{key:"createMultiPolygon",value:function(){return 0===arguments.length?new $t(null,this):1===arguments.length?new $t(arguments[0],this):void 0}},{key:"createMultiPoint",value:function(){if(0===arguments.length)return new Gt(null,this);if(1===arguments.length){if(arguments[0]instanceof Array)return new Gt(arguments[0],this);if(it(arguments[0],ct)){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_,r=e;if("("==e)t=2;else if(","==e)t=5;else if(")"==e)t=3;else if(this.isNumeric_(e)||"-"==e)t=4,r=this.readNumber_();else if(this.isAlpha_(e))t=1,r=this.readText_();else{if(this.isWhiteSpace_(e))return this.nextToken();if(""!==e)throw new Error("Unexpected character: "+e);t=6}return{position:n,value:r,type:t}}},{key:"readNumber_",value:function(){var t,e=this.index_,n=!1,r=!1;do{"."==t?n=!0:"e"!=t&&"E"!=t||(r=!0),t=this.nextChar_()}while(this.isNumeric_(t,n)||!r&&("e"==t||"E"==t)||r&&("-"==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()}}]),e}(),le=function(){function e(n,r){t(this,e),this.lexer_=n,this.token_,this.layout_="XY",this.factory=r}return n(e,[{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="XY",e=this.token_;if(this.isTokenType(1)){var n=e.value;"Z"===n?t="XYZ":"M"===n?t="XYM":"ZM"===n&&(t="XYZM"),"XY"!==t&&this.consume_()}return t}},{key:"parseGeometryCollectionText_",value:function(){if(this.match(2)){var t=[];do{t.push(this.parseGeometry_())}while(this.match(5));if(this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePointText_",value:function(){if(this.match(2)){var t=this.parsePoint_();if(this.match(3))return t}else if(this.isEmptyGeometry_())return null;throw new Error(this.formatErrorMessage_())}},{key:"parseLineStringText_",value:function(){if(this.match(2)){var t=this.parsePointList_();if(this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parsePolygonText_",value:function(){if(this.match(2)){var t=this.parseLineStringTextList_();if(this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPointText_",value:function(){var t;if(this.match(2)){if(t=2==this.token_.type?this.parsePointTextList_():this.parsePointList_(),this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiLineStringText_",value:function(){if(this.match(2)){var t=this.parseLineStringTextList_();if(this.match(3))return t}else if(this.isEmptyGeometry_())return[];throw new Error(this.formatErrorMessage_())}},{key:"parseMultiPolygonText_",value:function(){if(this.match(2)){var t=this.parsePolygonTextList_();if(this.match(3))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(r[0],r.slice(1)):t.createPolygon(r[0])},r=this.token_;if(this.match(1)){var i=r.value;if(this.layout_=this.parseGeometryLayout_(),"GEOMETRYCOLLECTION"==i){var o=this.parseGeometryCollectionText_();return t.createGeometryCollection(o)}switch(i){case"POINT":var a=this.parsePointText_();return a?t.createPoint(u(z,d(a))):t.createPoint();case"LINESTRING":var s=this.parseLineStringText_().map(e);return t.createLineString(s);case"LINEARRING":var l=this.parseLineStringText_().map(e);return t.createLinearRing(l);case"POLYGON":var c=this.parsePolygonText_();return c&&0!==c.length?n(c):t.createPolygon();case"MULTIPOINT":var h=this.parseMultiPointText_();if(!h||0===h.length)return t.createMultiPoint();var f=h.map(e).map((function(e){return t.createPoint(e)}));return t.createMultiPoint(f);case"MULTILINESTRING":var p=this.parseMultiLineStringText_().map((function(n){return t.createLineString(n.map(e))}));return t.createMultiLineString(p);case"MULTIPOLYGON":var g=this.parseMultiPolygonText_();if(!g||0===g.length)return t.createMultiPolygon();var y=g.map(n);return t.createMultiPolygon(y);default:throw new Error("Invalid geometry type: "+i)}}throw new Error(this.formatErrorMessage_())}}]),e}();function ce(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 he(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=[],r=0,i=e.length;r0&&(e+=" "+r),t.isEmpty()?e+" EMPTY":e+" ("+n(t)+")"}var ge=function(){function e(n){t(this,e),this.geometryFactory=n||new oe,this.precisionModel=this.geometryFactory.getPrecisionModel()}return n(e,[{key:"read",value:function(t){var e=new ue(t);return new le(e,this.geometryFactory).parse()}},{key:"write",value:function(t){return de(t)}}]),e}(),ye=function(){function e(n){t(this,e),this.parser=new ge(n)}return n(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+" )"}}]),e}(),ve=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getIndexAlongSegment",value:function(t,e){return this.computeIntLineIndex(),this._intLineIndex[t][e]}},{key:"getTopologySummary",value:function(){var t=new Kt;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,r){this._inputLines[0][0]=t,this._inputLines[0][1]=e,this._inputLines[1][0]=n,this._inputLines[1][1]=r,this._result=this.computeIntersect(t,e,n,r)}},{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;ei?r:i;else{var a=Math.abs(t.x-e.x),s=Math.abs(t.y-e.y);0!==(o=r>i?a:s)||t.equals(e)||(o=Math.max(a,s))}return D.isTrue(!(0===o&&!t.equals(e)),"Bad distance calculation"),o}},{key:"nonRobustComputeEdgeDistance",value:function(t,e,n){var r=t.x-e.x,i=t.y-e.y,o=Math.sqrt(r*r+i*i);return D.isTrue(!(0===o&&!t.equals(e)),"Invalid distance calculation"),o}}]),e}();ve.DONT_INTERSECT=0,ve.DO_INTERSECT=1,ve.COLLINEAR=2,ve.NO_INTERSECTION=0,ve.POINT_INTERSECTION=1,ve.COLLINEAR_INTERSECTION=2;var me=function(e){i(a,e);var r=f(a);function a(){return t(this,a),r.call(this)}return n(a,[{key:"isInSegmentEnvelopes",value:function(t){var e=new V(this._inputLines[0][0],this._inputLines[0][1]),n=new V(this._inputLines[1][0],this._inputLines[1][1]);return e.contains(t)&&n.contains(t)}},{key:"computeIntersection",value:function(){if(3!==arguments.length)return p(o(a.prototype),"computeIntersection",this).apply(this,arguments);var t=arguments[0],e=arguments[1],n=arguments[2];if(this._isProper=!1,V.intersects(e,n,t)&&0===ht.index(e,n,t)&&0===ht.index(n,e,t))return this._isProper=!0,(t.equals(e)||t.equals(n))&&(this._isProper=!1),this._result=ve.POINT_INTERSECTION,null;this._result=ve.NO_INTERSECTION}},{key:"intersection",value:function(t,e,n,r){var i=this.intersectionSafe(t,e,n,r);return this.isInSegmentEnvelopes(i)||(i=new z(a.nearestEndpoint(t,e,n,r))),null!==this._precisionModel&&this._precisionModel.makePrecise(i),i}},{key:"checkDD",value:function(t,e,n,r,i){var o=lt.intersection(t,e,n,r),a=this.isInSegmentEnvelopes(o);_t.out.println("DD in env = "+a+" --------------------- "+o),i.distance(o)>1e-4&&_t.out.println("Distance = "+i.distance(o))}},{key:"intersectionSafe",value:function(t,e,n,r){var i=mt.intersection(t,e,n,r);return null===i&&(i=a.nearestEndpoint(t,e,n,r)),i}},{key:"computeCollinearIntersection",value:function(t,e,n,r){var i=V.intersects(t,e,n),o=V.intersects(t,e,r),a=V.intersects(n,r,t),s=V.intersects(n,r,e);return i&&o?(this._intPt[0]=n,this._intPt[1]=r,ve.COLLINEAR_INTERSECTION):a&&s?(this._intPt[0]=t,this._intPt[1]=e,ve.COLLINEAR_INTERSECTION):i&&a?(this._intPt[0]=n,this._intPt[1]=t,!n.equals(t)||o||s?ve.COLLINEAR_INTERSECTION:ve.POINT_INTERSECTION):i&&s?(this._intPt[0]=n,this._intPt[1]=e,!n.equals(e)||o||a?ve.COLLINEAR_INTERSECTION:ve.POINT_INTERSECTION):o&&a?(this._intPt[0]=r,this._intPt[1]=t,!r.equals(t)||i||s?ve.COLLINEAR_INTERSECTION:ve.POINT_INTERSECTION):o&&s?(this._intPt[0]=r,this._intPt[1]=e,!r.equals(e)||i||a?ve.COLLINEAR_INTERSECTION:ve.POINT_INTERSECTION):ve.NO_INTERSECTION}},{key:"computeIntersect",value:function(t,e,n,r){if(this._isProper=!1,!V.intersects(t,e,n,r))return ve.NO_INTERSECTION;var i=ht.index(t,e,n),o=ht.index(t,e,r);if(i>0&&o>0||i<0&&o<0)return ve.NO_INTERSECTION;var a=ht.index(n,r,t),s=ht.index(n,r,e);return a>0&&s>0||a<0&&s<0?ve.NO_INTERSECTION:0===i&&0===o&&0===a&&0===s?this.computeCollinearIntersection(t,e,n,r):(0===i||0===o||0===a||0===s?(this._isProper=!1,t.equals2D(n)||t.equals2D(r)?this._intPt[0]=t:e.equals2D(n)||e.equals2D(r)?this._intPt[0]=e:0===i?this._intPt[0]=new z(n):0===o?this._intPt[0]=new z(r):0===a?this._intPt[0]=new z(t):0===s&&(this._intPt[0]=new z(e))):(this._isProper=!0,this._intPt[0]=this.intersection(t,e,n,r)),ve.POINT_INTERSECTION)}}],[{key:"nearestEndpoint",value:function(t,e,n,r){var i=t,o=wt.pointToSegment(t,n,r),a=wt.pointToSegment(e,n,r);return ar&&(n=e.x,r=t.x),this._p.x>=n&&this._p.x<=r&&(this._isPointOnSegment=!0),null}if(t.y>this._p.y&&e.y<=this._p.y||e.y>this._p.y&&t.y<=this._p.y){var i=ht.index(t,e,this._p);if(i===ht.COLLINEAR)return this._isPointOnSegment=!0,null;e.ythis.location.length){var e=new Array(3).fill(null);e[$.ON]=this.location[$.ON],e[$.LEFT]=W.NONE,e[$.RIGHT]=W.NONE,this.location=e}for(var n=0;n1&&t.append(W.toLocationSymbol(this.location[$.LEFT])),t.append(W.toLocationSymbol(this.location[$.ON])),this.location.length>1&&t.append(W.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 r=t.getCoordinates();if(e){var i=1;n&&(i=0);for(var o=i;o=0;s--)this._pts.add(r[s])}}},{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===W.NONE)return null;if(this._label.getLocation(e)===W.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}}}]),e}(),Ce=function(e){i(a,e);var r=f(a);function a(){var e;return t(this,a),e=r.call(this),a.constructor_.apply(c(e),arguments),e}return n(a,[{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=W.NONE;if(n=this._label.getLocation(e),!t.isNull(e)){var r=t.getLocation(e);n!==W.BOUNDARY&&(n=r)}return n}},{key:"setLabel",value:function(){if(2!==arguments.length||!Number.isInteger(arguments[1])||!Number.isInteger(arguments[0]))return p(o(a.prototype),"setLabel",this).apply(this,arguments);var t=arguments[0],e=arguments[1];null===this._label?this._label=new xe(t,e):this._label.setLocation(t,e)}},{key:"getEdges",value:function(){return this._edges}},{key:"mergeLabel",value:function(){if(arguments[0]instanceof a){var t=arguments[0];this.mergeLabel(t._label)}else if(arguments[0]instanceof xe)for(var e=arguments[0],n=0;n<2;n++){var r=this.computeMergedLocation(e,n);this._label.getLocation(n)===W.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=W.NONE;null!==this._label&&(e=this._label.getLocation(t));var n=null;switch(e){case W.BOUNDARY:n=W.INTERIOR;break;case W.INTERIOR:default:n=W.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 xe(0,W.NONE)}}]),a}(Me);function ke(t){return null==t?0:t.color}function Ne(t){return null==t?null:t.parent}function je(t,e){null!==t&&(t.color=e)}function Le(t){return null==t?null:t.left}function Pe(t){return null==t?null:t.right}var Ie=function(e){i(o,e);var r=f(o);function o(){var e;return t(this,o),(e=r.call(this)).root_=null,e.size_=0,e}return n(o,[{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,r,i=this.root_;do{if(n=i,(r=t.compareTo(i.key))<0)i=i.left;else{if(!(r>0)){var o=i.value;return i.value=e,o}i=i.right}}while(null!==i);var a={key:t,left:null,right:null,value:e,parent:n,color:0,getValue:function(){return this.value},getKey:function(){return this.key}};return r<0?n.left=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;)Ne(t)===Le(Ne(Ne(t)))?1===ke(e=Pe(Ne(Ne(t))))?(je(Ne(t),0),je(e,0),je(Ne(Ne(t)),1),t=Ne(Ne(t))):(t===Pe(Ne(t))&&(t=Ne(t),this.rotateLeft(t)),je(Ne(t),0),je(Ne(Ne(t)),1),this.rotateRight(Ne(Ne(t)))):1===ke(e=Le(Ne(Ne(t))))?(je(Ne(t),0),je(e,0),je(Ne(Ne(t)),1),t=Ne(Ne(t))):(t===Le(Ne(t))&&(t=Ne(t),this.rotateRight(t)),je(Ne(t),0),je(Ne(Ne(t)),1),this.rotateLeft(Ne(Ne(t))));this.root_.color=0}},{key:"values",value:function(){var t=new gt,e=this.getFirstEntry();if(null!==e)for(t.add(e.value);null!==(e=o.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=o.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}}]),o}(function(e){i(r,e);var n=f(r);function r(){return t(this,r),n.apply(this,arguments)}return r}(te)),Ae=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"find",value:function(t){return this.nodeMap.get(t)}},{key:"addNode",value:function(){if(arguments[0]instanceof z){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 Ce){var n=arguments[0],r=this.nodeMap.get(n.getCoordinate());return null===r?(this.nodeMap.put(n.getCoordinate(),n),n):(r.mergeLabel(n),r)}}},{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 gt,n=this.iterator();n.hasNext();){var r=n.next();r.getLabel().getLocation(t)===W.BOUNDARY&&e.add(r)}return e}},{key:"add",value:function(t){var e=t.getCoordinate();this.addNode(e).add(t)}}],[{key:"constructor_",value:function(){this.nodeMap=new Ie,this.nodeFact=null;var t=arguments[0];this.nodeFact=t}}]),e}(),Re=function(){function e(){t(this,e)}return n(e,null,[{key:"isNorthern",value:function(t){return t===e.NE||t===e.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(t,n){return n===e.SE?t===e.SE||t===e.SW:t===n||t===n+1}},{key:"quadrant",value:function(){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var t=arguments[0],n=arguments[1];if(0===t&&0===n)throw new b("Cannot compute the quadrant for point ( "+t+", "+n+" )");return t>=0?n>=0?e.NE:e.SE:n>=0?e.NW:e.SW}if(arguments[0]instanceof z&&arguments[1]instanceof z){var r=arguments[0],i=arguments[1];if(i.x===r.x&&i.y===r.y)throw new b("Cannot compute the quadrant for two identical points "+r);return i.x>=r.x?i.y>=r.y?e.NE:e.SE:i.y>=r.y?e.NW:e.SW}}}]),e}();Re.NE=0,Re.NW=1,Re.SW=2,Re.SE=3;var Te=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"compareDirection",value:function(t){return this._dx===t._dx&&this._dy===t._dy?0:this._quadrant>t._quadrant?1:this._quadrant2){o.linkDirectedEdgesForMinimalEdgeRings();var a=o.buildMinimalRings(),s=this.findShell(a);null!==s?(this.placePolygonHoles(s,a),e.add(s)):n.addAll(a)}else r.add(o)}return r}},{key:"buildMaximalEdgeRings",value:function(t){for(var e=new gt,n=t.iterator();n.hasNext();){var r=n.next();if(r.isInResult()&&r.getLabel().isArea()&&null===r.getEdgeRing()){var i=new Se(r,this._geometryFactory);e.add(i),i.setInResult()}}return e}},{key:"placePolygonHoles",value:function(t,e){for(var n=e.iterator();n.hasNext();){var r=n.next();r.isHole()&&r.setShell(t)}}},{key:"getPolygons",value:function(){return this.computePolygons(this._shellList)}},{key:"findShell",value:function(t){for(var e=0,n=null,r=t.iterator();r.hasNext();){var i=r.next();i.isHole()||(n=i,e++)}return D.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];Be.linkResultDirectedEdges(n);var r=this.buildMaximalEdgeRings(e),i=new gt,o=this.buildMinimalEdgeRings(r,this._shellList,i);this.sortShellsAndHoles(o,this._shellList,i),this.placeFreeHoles(this._shellList,i)}}}],[{key:"constructor_",value:function(){this._geometryFactory=null,this._shellList=new gt;var t=arguments[0];this._geometryFactory=t}},{key:"findEdgeRingContaining",value:function(t,e){for(var n=t.getLinearRing(),r=n.getEnvelopeInternal(),i=n.getCoordinateN(0),o=null,a=null,s=e.iterator();s.hasNext();){var u=s.next(),l=u.getLinearRing(),c=l.getEnvelopeInternal();if(!c.equals(r)&&c.contains(r)){i=Xt.ptNotInList(n.getCoordinates(),l.getCoordinates());var h=!1;be.isInRing(i,l.getCoordinates())&&(h=!0),h&&(null===o||a.contains(c))&&(a=(o=u).getLinearRing().getEnvelopeInternal())}}return o}}]),e}(),qe=function(){function e(){t(this,e)}return n(e,[{key:"getBounds",value:function(){}}]),e}(),ze=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getItem",value:function(){return this._item}},{key:"getBounds",value:function(){return this._bounds}},{key:"interfaces_",get:function(){return[qe,E]}}],[{key:"constructor_",value:function(){this._bounds=null,this._item=null;var t=arguments[0],e=arguments[1];this._bounds=t,this._item=e}}]),e}(),Ue=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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 gt,this._items.add(null)}}]),e}(),Ve=function(){function e(){t(this,e)}return n(e,[{key:"insert",value:function(t,e){}},{key:"remove",value:function(t,e){}},{key:"query",value:function(){}}]),e}(),Ye=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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){D.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[qe,E]}}],[{key:"constructor_",value:function(){if(this._childBoundables=new gt,this._bounds=null,this._level=null,0===arguments.length);else if(1===arguments.length){var t=arguments[0];this._level=t}}}]),e}(),We={reverseOrder:function(){return{compare:function(t,e){return e.compareTo(t)}}},min:function(t){return We.sort(t),t.get(0)},sort:function(t,e){var n=t.toArray();e?At.sort(n,e):At.sort(n);for(var r=t.iterator(),i=0,o=n.length;ie.area(this._boundable2)?(this.expand(this._boundable1,this._boundable2,!1,t,n),null):(this.expand(this._boundable2,this._boundable1,!0,t,n),null);if(r)return this.expand(this._boundable1,this._boundable2,!1,t,n),null;if(i)return this.expand(this._boundable2,this._boundable1,!0,t,n),null;throw new b("neither boundable is composite")}},{key:"isLeaves",value:function(){return!(e.isComposite(this._boundable1)||e.isComposite(this._boundable2))}},{key:"compareTo",value:function(t){var e=t;return this._distancee._distance?1:0}},{key:"expand",value:function(t,n,r,i,o){for(var a=t.getChildBoundables().iterator();a.hasNext();){var s=a.next(),u=null;(u=r?new e(n,s,this._itemDistance):new e(s,n,this._itemDistance)).getDistance()-2),r.getLevel()===n)return i.add(r),null;for(var o=r.getChildBoundables().iterator();o.hasNext();){var a=o.next();a instanceof Ye?this.boundablesAtLevel(n,a,i):(D.isTrue(a instanceof ze),-1===n&&i.add(a))}return null}}},{key:"query",value:function(){if(1===arguments.length){var t=arguments[0];this.build();var e=new gt;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],r=arguments[1];if(this.build(),this.isEmpty())return null;this.getIntersectsOp().intersects(this._root.getBounds(),n)&&this.queryInternal(n,this._root,r)}}},{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],r=arguments[1],i=arguments[2],o=this.removeItem(r,i);if(o)return!0;for(var a=null,s=r.getChildBoundables().iterator();s.hasNext();){var u=s.next();if(this.getIntersectsOp().intersects(u.getBounds(),n)&&u instanceof Ye&&(o=this.remove(n,u,i))){a=u;break}}return null!==a&&a.getChildBoundables().isEmpty()&&r.getChildBoundables().remove(a),o}}},{key:"createHigherLevels",value:function(t,e){D.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 Ye){var r=this.depth(n);r>t&&(t=r)}}return t+1}}},{key:"createParentBoundables",value:function(t,e){D.isTrue(!t.isEmpty());var n=new gt;n.add(this.createNode(e));var r=new gt(t);We.sort(r,this.getComparator());for(var i=r.iterator();i.hasNext();){var o=i.next();this.lastNode(n).getChildBoundables().size()===this.getNodeCapacity()&&n.add(this.createNode(e)),this.lastNode(n).addChildBoundable(o)}return n}},{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 gt,this._nodeCapacity=null,0===arguments.length)e.constructor_.call(this,e.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];D.isTrue(t>1,"Node capacity must be greater than 1"),this._nodeCapacity=t}}},{key:"compareDoubles",value:function(t,e){return t>e?1:t0);for(var n=new gt,r=0;r=0;){var u=o.poll(),l=u.getDistance();if(l>=i)break;u.isLeaves()?s.size()l&&(s.poll(),s.add(u)),i=s.peek().getDistance()):u.expandToQueue(o,i)}return a.getItems(s)}}},{key:"createNode",value:function(t){return new $e(t)}},{key:"size",value:function(){return 0===arguments.length?p(o(a.prototype),"size",this).call(this):p(o(a.prototype),"size",this).apply(this,arguments)}},{key:"insert",value:function(){if(!(2===arguments.length&&arguments[1]instanceof Object&&arguments[0]instanceof V))return p(o(a.prototype),"insert",this).apply(this,arguments);var t=arguments[0],e=arguments[1];if(t.isNull())return null;p(o(a.prototype),"insert",this).call(this,t,e)}},{key:"getIntersectsOp",value:function(){return a.intersectsOp}},{key:"verticalSlices",value:function(t,e){for(var n=Math.trunc(Math.ceil(t.size()/e)),r=new Array(e).fill(null),i=t.iterator(),o=0;o0;){var a=o.poll(),s=a.getDistance();if(s>=r)break;a.isLeaves()?(r=s,i=a):a.expandToQueue(o,r)}return null===i?null:[i.getBoundable(0).getItem(),i.getBoundable(1).getItem()]}}else{if(2===arguments.length){var u=arguments[0],l=arguments[1];if(this.isEmpty()||u.isEmpty())return null;var c=new He(this.getRoot(),u.getRoot(),l);return this.nearestNeighbour(c)}if(3===arguments.length){var h=arguments[2],f=new ze(arguments[0],arguments[1]),p=new He(this.getRoot(),f,h);return this.nearestNeighbour(p)[0]}if(4===arguments.length){var d=arguments[2],g=arguments[3],y=new ze(arguments[0],arguments[1]),v=new He(this.getRoot(),y,d);return this.nearestNeighbourK(v,g)}}}},{key:"isWithinDistance",value:function(){if(2===arguments.length){var t=arguments[0],e=arguments[1],n=A.POSITIVE_INFINITY,r=new Ue;for(r.add(t);!r.isEmpty();){var i=r.poll(),o=i.getDistance();if(o>e)return!1;if(i.maximumDistance()<=e)return!0;if(i.isLeaves()){if((n=o)<=e)return!0}else i.expandToQueue(r,n)}return!1}if(3===arguments.length){var a=arguments[0],s=arguments[1],u=arguments[2],l=new He(this.getRoot(),a.getRoot(),s);return this.isWithinDistance(l,u)}}},{key:"interfaces_",get:function(){return[Ve,E]}}],[{key:"constructor_",value:function(){if(0===arguments.length)a.constructor_.call(this,a.DEFAULT_NODE_CAPACITY);else if(1===arguments.length){var t=arguments[0];Ke.constructor_.call(this,t)}}},{key:"centreX",value:function(t){return a.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 r=t.poll();e[n]=r.getBoundable(0).getItem(),n++}return e}},{key:"centreY",value:function(t){return a.avg(t.getMinY(),t.getMaxY())}}]),a}(Ke),$e=function(e){i(o,e);var r=f(o);function o(){var e;return t(this,o),e=r.call(this),o.constructor_.apply(c(e),arguments),e}return n(o,[{key:"computeBounds",value:function(){for(var t=null,e=this.getChildBoundables().iterator();e.hasNext();){var n=e.next();null===t?t=new V(n.getBounds()):t.expandToInclude(n.getBounds())}return t}}],[{key:"constructor_",value:function(){var t=arguments[0];Ye.constructor_.call(this,t)}}]),o}(Ye);Qe.STRtreeNode=$e,Qe.xComparator=new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[R]}},{key:"compare",value:function(t,e){return Ke.compareDoubles(Qe.centreX(t.getBounds()),Qe.centreX(e.getBounds()))}}]),e}()),Qe.yComparator=new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[R]}},{key:"compare",value:function(t,e){return Ke.compareDoubles(Qe.centreY(t.getBounds()),Qe.centreY(e.getBounds()))}}]),e}()),Qe.intersectsOp=new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[IntersectsOp]}},{key:"intersects",value:function(t,e){return t.intersects(e)}}]),e}()),Qe.DEFAULT_NODE_CAPACITY=10;var tn=function(){function e(){t(this,e)}return n(e,null,[{key:"relativeSign",value:function(t,e){return te?1:0}},{key:"compare",value:function(t,n,r){if(n.equals2D(r))return 0;var i=e.relativeSign(n.x,r.x),o=e.relativeSign(n.y,r.y);switch(t){case 0:return e.compareValue(i,o);case 1:return e.compareValue(o,i);case 2:return e.compareValue(o,-i);case 3:return e.compareValue(-i,o);case 4:return e.compareValue(-i,-o);case 5:return e.compareValue(-o,-i);case 6:return e.compareValue(-o,i);case 7:return e.compareValue(i,-o)}return D.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}}]),e}(),en=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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?tn.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],r=arguments[3];this._segString=t,this.coord=new z(e),this.segmentIndex=n,this._segmentOctant=r,this._isInterior=!e.equals2D(t.getCoordinate(n))}}]),e}(),nn=function(){function e(){t(this,e)}return n(e,[{key:"hasNext",value:function(){}},{key:"next",value:function(){}},{key:"remove",value:function(){}}]),e}(),rn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getSplitCoordinates",value:function(){var t=new Wt;this.addEndpoints();for(var e=this.iterator(),n=e.next();e.hasNext();){var r=e.next();this.addEdgeCoordinates(n,r,t),n=r}return t.toCoordinateArray()}},{key:"addCollapsedNodes",value:function(){var t=new gt;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 z(t.coord),new z(e.coord)];var r=this._edge.getCoordinate(e.segmentIndex),i=e.isInterior()||!e.coord.equals2D(r);i||n--;var o=new Array(n).fill(null),a=0;o[a++]=new z(t.coord);for(var s=t.segmentIndex+1;s<=e.segmentIndex;s++)o[a++]=this._edge.getCoordinate(s);return i&&(o[a]=new z(e.coord)),o}},{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?r>=i?0:1:r>=i?7:6:n>=0?r>=i?3:2:r>=i?4:5}if(arguments[0]instanceof z&&arguments[1]instanceof z){var o=arguments[0],a=arguments[1],s=a.x-o.x,u=a.y-o.y;if(0===s&&0===u)throw new b("Cannot compute the octant for two identical points "+o);return e.octant(s,u)}}}]),e}(),an=function(){function e(){t(this,e)}return n(e,[{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(){}}]),e}(),sn=function(){function e(){t(this,e)}return n(e,[{key:"addIntersection",value:function(t,e){}},{key:"interfaces_",get:function(){return[an]}}]),e}(),un=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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:on.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],r=arguments[3],i=new z(arguments[0].getIntersection(r));this.addIntersection(i,n)}}},{key:"toString",value:function(){return ye.toLineString(new Jt(this._pts))}},{key:"getNodeList",value:function(){return this._nodeList}},{key:"addIntersectionNode",value:function(t,e){var n=e,r=n+1;if(r=0&&r>=0||n<=0&&r<=0?Math.max(n,r):0}if(arguments[0]instanceof z){var i=arguments[0];return ht.index(this.p0,this.p1,i)}}},{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(t){if(!(t instanceof e))return!1;var n=t;return this.p0.equals(n.p0)&&this.p1.equals(n.p1)}},{key:"intersection",value:function(t){var e=new me;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 z){var t=arguments[0];if(t.equals(this.p0)||t.equals(this.p1))return new z(t);var n=this.projectionFactor(t),r=new z;return r.x=this.p0.x+n*(this.p1.x-this.p0.x),r.y=this.p0.y+n*(this.p1.y-this.p0.y),r}if(arguments[0]instanceof e){var i=arguments[0],o=this.projectionFactor(i.p0),a=this.projectionFactor(i.p1);if(o>=1&&a>=1)return null;if(o<=0&&a<=0)return null;var s=this.project(i.p0);o<0&&(s=this.p0),o>1&&(s=this.p1);var u=this.project(i.p1);return a<0&&(u=this.p0),a>1&&(u=this.p1),new e(s,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 wt.pointToLinePerpendicular(t,this.p0,this.p1)}},{key:"minY",value:function(){return Math.min(this.p0.y,this.p1.y)}},{key:"midPoint",value:function(){return e.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,r=e*e+n*n;return r<=0?A.NaN:((t.x-this.p0.x)*e+(t.y-this.p0.y)*n)/r}},{key:"closestPoints",value:function(t){var e=this.intersection(t);if(null!==e)return[e,e];var n=new Array(2).fill(null),r=A.MAX_VALUE,i=null,o=this.closestPoint(t.p0);r=o.distance(t.p0),n[0]=o,n[1]=t.p0;var a=this.closestPoint(t.p1);(i=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(),r=this.p0.getY()*(this.p1.getX()-this.p0.getX())-this.p0.getX()*(this.p1.getY()-this.p0.getY()),i=e*e+n*n,o=e*e-n*n,a=t.getX(),s=t.getY();return new z((-o*a-2*e*n*s-2*e*r)/i,(o*s-2*e*n*a-2*n*r)/i)}},{key:"distance",value:function(){if(arguments[0]instanceof e){var t=arguments[0];return wt.segmentToSegment(this.p0,this.p1,t.p0,t.p1)}if(arguments[0]instanceof z){var n=arguments[0];return wt.pointToSegment(n,this.p0,this.p1)}}},{key:"pointAlong",value:function(t){var e=new z;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)e.constructor_.call(this,new z,new z);else if(1===arguments.length){var t=arguments[0];e.constructor_.call(this,t.p0,t.p1)}else if(2===arguments.length){var n=arguments[0],r=arguments[1];this.p0=n,this.p1=r}else if(4===arguments.length){var i=arguments[0],o=arguments[1],a=arguments[2],s=arguments[3];e.constructor_.call(this,new z(i,o),new z(a,s))}}},{key:"midPoint",value:function(t,e){return new z((t.x+e.x)/2,(t.y+e.y)/2)}}]),e}(),cn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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 ln,this._overlapSeg2=new ln}}]),e}(),hn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getLineSegment",value:function(t,e){e.p0=this._pts[t],e.p1=this._pts[t+1]}},{key:"computeSelect",value:function(t,e,n,r){var i=this._pts[e],o=this._pts[n];if(n-e==1)return r.select(this,e),null;if(!t.intersects(i,o))return null;var a=Math.trunc((e+n)/2);e=t.length-1)return t.length-1;for(var r=Re.quadrant(t[n],t[n+1]),i=e+1;in.getId()&&(n.computeOverlaps(i,t),this._nOverlaps++),this._segInt.isDone())return null}}}],[{key:"constructor_",value:function(){if(this._monoChains=new gt,this._index=new Qe,this._idCounter=0,this._nodedSegStrings=null,this._nOverlaps=0,0===arguments.length);else if(1===arguments.length){var t=arguments[0];dn.constructor_.call(this,t)}}}]),o}(dn),yn=function(e){i(a,e);var r=f(a);function a(){var e;return t(this,a),e=r.call(this),a.constructor_.apply(c(e),arguments),e}return n(a,[{key:"overlap",value:function(){if(4!==arguments.length)return p(o(a.prototype),"overlap",this).apply(this,arguments);var t=arguments[1],e=arguments[2],n=arguments[3],r=arguments[0].getContext(),i=e.getContext();this._si.processIntersections(r,t,i,n)}}],[{key:"constructor_",value:function(){this._si=null;var t=arguments[0];this._si=t}}]),a}(cn);gn.SegmentOverlapAction=yn;var vn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"isDeletable",value:function(t,e,n,r){var i=this._inputLine[t],o=this._inputLine[e],a=this._inputLine[n];return!!this.isConcave(i,o,a)&&!!this.isShallow(i,o,a,r)&&this.isShallowSampled(i,o,t,n,r)}},{key:"deleteShallowConcavities",value:function(){for(var t=1,n=this.findNextNonDeletedIndex(t),r=this.findNextNonDeletedIndex(n),i=!1;r=0;r--)this.addPt(t[r])}},{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;)t-=e.PI_TIMES_2;for(;t<=-Math.PI;)t+=e.PI_TIMES_2;return t}},{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],r=n.x-e.x,i=n.y-e.y;return Math.atan2(i,r)}}},{key:"isAcute",value:function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)>0}},{key:"isObtuse",value:function(t,e,n){var r=t.x-e.x,i=t.y-e.y;return r*(n.x-e.x)+i*(n.y-e.y)<0}},{key:"interiorAngle",value:function(t,n,r){var i=e.angle(n,t),o=e.angle(n,r);return Math.abs(o-i)}},{key:"normalizePositive",value:function(t){if(t<0){for(;t<0;)t+=e.PI_TIMES_2;t>=e.PI_TIMES_2&&(t=0)}else{for(;t>=e.PI_TIMES_2;)t-=e.PI_TIMES_2;t<0&&(t=0)}return t}},{key:"angleBetween",value:function(t,n,r){var i=e.angle(n,t),o=e.angle(n,r);return e.diff(i,o)}},{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(t,n){var r=Math.sin(n-t);return r>0?e.COUNTERCLOCKWISE:r<0?e.CLOCKWISE:e.NONE}},{key:"angleBetweenOriented",value:function(t,n,r){var i=e.angle(n,t),o=e.angle(n,r)-i;return o<=-Math.PI?o+e.PI_TIMES_2:o>Math.PI?o-e.PI_TIMES_2:o}}]),e}();_n.PI_TIMES_2=2*Math.PI,_n.PI_OVER_2=Math.PI/2,_n.PI_OVER_4=Math.PI/4,_n.COUNTERCLOCKWISE=ht.COUNTERCLOCKWISE,_n.CLOCKWISE=ht.CLOCKWISE,_n.NONE=ht.COLLINEAR;var bn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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=ht.index(this._s0,this._s1,this._s2),r=n===ht.CLOCKWISE&&this._side===$.LEFT||n===ht.COUNTERCLOCKWISE&&this._side===$.RIGHT;0===n?this.addCollinear(e):r?this.addOutsideTurn(n,e):this.addInsideTurn(n,e)}},{key:"addLineEndCap",value:function(t,e){var n=new ln(t,e),r=new ln;this.computeOffsetSegment(n,$.LEFT,this._distance,r);var i=new ln;this.computeOffsetSegment(n,$.RIGHT,this._distance,i);var o=e.x-t.x,a=e.y-t.y,s=Math.atan2(a,o);switch(this._bufParams.getEndCapStyle()){case m.CAP_ROUND:this._segList.addPt(r.p1),this.addDirectedFillet(e,s+Math.PI/2,s-Math.PI/2,ht.CLOCKWISE,this._distance),this._segList.addPt(i.p1);break;case m.CAP_FLAT:this._segList.addPt(r.p1),this._segList.addPt(i.p1);break;case m.CAP_SQUARE:var u=new z;u.x=Math.abs(this._distance)*Math.cos(s),u.y=Math.abs(this._distance)*Math.sin(s);var l=new z(r.p1.x+u.x,r.p1.y+u.y),c=new z(i.p1.x+u.x,i.p1.y+u.y);this._segList.addPt(l),this._segList.addPt(c)}}},{key:"getCoordinates",value:function(){return this._segList.getCoordinates()}},{key:"addMitreJoin",value:function(t,e,n,r){var i=mt.intersection(e.p0,e.p1,n.p0,n.p1);if(null!==i&&(r<=0?1:i.distance(t)/Math.abs(r))<=this._bufParams.getMitreLimit())return this._segList.addPt(i),null;this.addLimitedMitreJoin(e,n,r,this._bufParams.getMitreLimit())}},{key:"addOutsideTurn",value:function(t,n){if(this._offset0.p1.distance(this._offset1.p0)=c&&(s-=2*Math.PI),this._segList.addPt(e),this.addDirectedFillet(t,s,c,r,i),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,r){var i=this._seg0.p1,o=_n.angle(i,this._seg0.p0),a=_n.angleBetweenOriented(this._seg0.p0,i,this._seg1.p1)/2,s=_n.normalize(o+a),u=_n.normalize(s+Math.PI),l=r*n,c=n-l*Math.abs(Math.sin(a)),h=i.x+l*Math.cos(u),f=i.y+l*Math.sin(u),p=new z(h,f),d=new ln(i,p),g=d.pointAlongOffset(1,c),y=d.pointAlongOffset(1,-c);this._side===$.LEFT?(this._segList.addPt(g),this._segList.addPt(y)):(this._segList.addPt(y),this._segList.addPt(g))}},{key:"addDirectedFillet",value:function(t,e,n,r,i){var o=r===ht.CLOCKWISE?-1:1,a=Math.abs(e-n),s=Math.trunc(a/this._filletAngleQuantum+.5);if(s<1)return null;for(var u=a/s,l=new z,c=0;c0){var r=new z((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(r);var i=new z((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(i)}else this._segList.addPt(this._s1);this._segList.addPt(this._offset1.p0)}}},{key:"createCircle",value:function(t){var e=new z(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(t){this._distance=t,this._maxCurveSegmentError=t*(1-Math.cos(this._filletAngleQuantum/2)),this._segList=new mn,this._segList.setPrecisionModel(this._precisionModel),this._segList.setMinimumVertexDistance(t*e.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()===m.JOIN_BEVEL||this._bufParams.getJoinStyle()===m.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,ht.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 ln,this._seg1=new ln,this._offset0=new ln,this._offset1=new ln,this._side=0,this._hasNarrowConcaveAngle=!1;var t=arguments[0],n=arguments[1],r=arguments[2];this._precisionModel=t,this._bufParams=n,this._li=new me,this._filletAngleQuantum=Math.PI/2/n.getQuadrantSegments(),n.getQuadrantSegments()>=8&&n.getJoinStyle()===m.JOIN_ROUND&&(this._closingSegLengthFactor=e.MAX_CLOSING_SEG_LEN_FACTOR),this.init(r)}}]),e}();bn.OFFSET_SEGMENT_SEPARATION_FACTOR=.001,bn.INSIDE_TURN_VERTEX_SNAP_DISTANCE_FACTOR=.001,bn.CURVE_VERTEX_SNAP_DISTANCE_FACTOR=1e-6,bn.MAX_CLOSING_SEG_LEN_FACTOR=80;var wn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getOffsetCurve",value:function(t,e){if(this._distance=e,0===e)return null;var n=e<0,r=Math.abs(e),i=this.getSegGen(r);t.length<=1?this.computePointCurve(t[0],i):this.computeOffsetCurve(t,n,i);var o=i.getCoordinates();return n&&Xt.reverse(o),o}},{key:"computeSingleSidedBufferCurve",value:function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){n.addSegments(t,!0);var i=vn.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],$.LEFT),n.addFirstSegment();for(var a=o-2;a>=0;a--)n.addNextSegment(i[a],!0)}else{n.addSegments(t,!1);var s=vn.simplify(t,r),u=s.length-1;n.initSideSegments(s[0],s[1],$.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(s[l],!0)}n.addLastSegment(),n.closeRing()}},{key:"computeRingBufferCurve",value:function(t,e,n){var r=this.simplifyTolerance(this._distance);e===$.RIGHT&&(r=-r);var i=vn.simplify(t,r),o=i.length-1;n.initSideSegments(i[o-1],i[0],e);for(var a=1;a<=o;a++){var s=1!==a;n.addNextSegment(i[a],s)}n.closeRing()}},{key:"computeLineBufferCurve",value:function(t,e){var n=this.simplifyTolerance(this._distance),r=vn.simplify(t,n),i=r.length-1;e.initSideSegments(r[0],r[1],$.LEFT);for(var o=2;o<=i;o++)e.addNextSegment(r[o],!0);e.addLastSegment(),e.addLineEndCap(r[i-1],r[i]);var a=vn.simplify(t,-n),s=a.length-1;e.initSideSegments(a[s],a[s-1],$.LEFT);for(var u=s-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 m.CAP_ROUND:e.createCircle(t);break;case m.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),r=this.getSegGen(n);if(t.length<=1)this.computePointCurve(t[0],r);else if(this._bufParams.isSingleSided()){var i=e<0;this.computeSingleSidedBufferCurve(t,i,r)}else this.computeLineBufferCurve(t,r);return r.getCoordinates()}},{key:"getBufferParameters",value:function(){return this._bufParams}},{key:"simplifyTolerance",value:function(t){return t*this._bufParams.getSimplifyFactor()}},{key:"getRingCurve",value:function(t,n,r){if(this._distance=r,t.length<=2)return this.getLineCurve(t,r);if(0===r)return e.copyCoordinates(t);var i=this.getSegGen(r);return this.computeRingBufferCurve(t,n,i),i.getCoordinates()}},{key:"computeOffsetCurve",value:function(t,e,n){var r=this.simplifyTolerance(this._distance);if(e){var i=vn.simplify(t,-r),o=i.length-1;n.initSideSegments(i[o],i[o-1],$.LEFT),n.addFirstSegment();for(var a=o-2;a>=0;a--)n.addNextSegment(i[a],!0)}else{var s=vn.simplify(t,r),u=s.length-1;n.initSideSegments(s[0],s[1],$.LEFT),n.addFirstSegment();for(var l=2;l<=u;l++)n.addNextSegment(s[l],!0)}n.addLastSegment()}},{key:"isLineOffsetEmpty",value:function(t){return 0===t||t<0&&!this._bufParams.isSingleSided()}},{key:"getSegGen",value:function(t){return new bn(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;ni.getMaxY()||this.findStabbedSegments(t,r.getDirectedEdges(),e)}return e}if(3===arguments.length)if(it(arguments[2],nt)&&arguments[0]instanceof z&&arguments[1]instanceof Fe){for(var o=arguments[0],a=arguments[1],s=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||ht.index(this._seg.p0,this._seg.p1,o)===ht.RIGHT)){var c=a.getDepth($.LEFT);this._seg.p0.equals(u[l])||(c=a.getDepth($.RIGHT));var h=new On(this._seg,c);s.add(h)}}else if(it(arguments[2],nt)&&arguments[0]instanceof z&&it(arguments[1],nt))for(var f=arguments[0],p=arguments[2],d=arguments[1].iterator();d.hasNext();){var g=d.next();g.isForward()&&this.findStabbedSegments(f,g,p)}}},{key:"getDepth",value:function(t){var e=this.findStabbedSegments(t);return 0===e.size()?0:We.min(e)._leftDepth}}],[{key:"constructor_",value:function(){this._subgraphs=null,this._seg=new ln;var t=arguments[0];this._subgraphs=t}}]),e}(),On=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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 ln(t),this._leftDepth=e}}]),e}();xn.DepthSegment=On;var En=function(e){i(o,e);var r=f(o);function o(){var e;return t(this,o),e=r.call(this),o.constructor_.apply(c(e),arguments),e}return n(o,null,[{key:"constructor_",value:function(){_.constructor_.call(this,"Projective point not representable on the Cartesian plane.")}}]),o}(_),Sn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getY",value:function(){var t=this.y/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new En;return t}},{key:"getX",value:function(){var t=this.x/this.w;if(A.isNaN(t)||A.isInfinite(t))throw new En;return t}},{key:"getCoordinate",value:function(){var t=new z;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 t=arguments[0];this.x=t.x,this.y=t.y,this.w=1}else if(2===arguments.length){if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){var n=arguments[0],r=arguments[1];this.x=n,this.y=r,this.w=1}else if(arguments[0]instanceof e&&arguments[1]instanceof e){var i=arguments[0],o=arguments[1];this.x=i.y*o.w-o.y*i.w,this.y=o.x*i.w-i.x*o.w,this.w=i.x*o.y-o.x*i.y}else if(arguments[0]instanceof z&&arguments[1]instanceof z){var a=arguments[0],s=arguments[1];this.x=a.y-s.y,this.y=s.x-a.x,this.w=a.x*s.y-s.x*a.y}}else if(3===arguments.length){var u=arguments[0],l=arguments[1],c=arguments[2];this.x=u,this.y=l,this.w=c}else if(4===arguments.length){var h=arguments[0],f=arguments[1],p=arguments[2],d=arguments[3],g=h.y-f.y,y=f.x-h.x,v=h.x*f.y-f.x*h.y,m=p.y-d.y,_=d.x-p.x,b=p.x*d.y-d.x*p.y;this.x=y*b-_*v,this.y=m*v-g*b,this.w=g*_-m*y}}}]),e}(),Mn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"area",value:function(){return e.area(this.p0,this.p1,this.p2)}},{key:"signedArea",value:function(){return e.signedArea(this.p0,this.p1,this.p2)}},{key:"interpolateZ",value:function(t){if(null===t)throw new b("Supplied point is null.");return e.interpolateZ(t,this.p0,this.p1,this.p2)}},{key:"longestSideLength",value:function(){return e.longestSideLength(this.p0,this.p1,this.p2)}},{key:"isAcute",value:function(){return e.isAcute(this.p0,this.p1,this.p2)}},{key:"circumcentre",value:function(){return e.circumcentre(this.p0,this.p1,this.p2)}},{key:"area3D",value:function(){return e.area3D(this.p0,this.p1,this.p2)}},{key:"centroid",value:function(){return e.centroid(this.p0,this.p1,this.p2)}},{key:"inCentre",value:function(){return e.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,r){return t*r-e*n}},{key:"interpolateZ",value:function(t,e,n,r){var i=e.x,o=e.y,a=n.x-i,s=r.x-i,u=n.y-o,l=r.y-o,c=a*l-s*u,h=t.x-i,f=t.y-o,p=(l*h-s*f)/c,d=(-u*h+a*f)/c;return e.getZ()+p*(n.getZ()-e.getZ())+d*(r.getZ()-e.getZ())}},{key:"longestSideLength",value:function(t,e,n){var r=t.distance(e),i=e.distance(n),o=n.distance(t),a=r;return i>a&&(a=i),o>a&&(a=o),a}},{key:"circumcentreDD",value:function(t,e,n){var r=ut.valueOf(t.x).subtract(n.x),i=ut.valueOf(t.y).subtract(n.y),o=ut.valueOf(e.x).subtract(n.x),a=ut.valueOf(e.y).subtract(n.y),s=ut.determinant(r,i,o,a).multiply(2),u=r.sqr().add(i.sqr()),l=o.sqr().add(a.sqr()),c=ut.determinant(i,u,a,l),h=ut.determinant(r,u,o,l),f=ut.valueOf(n.x).subtract(c.divide(s)).doubleValue(),p=ut.valueOf(n.y).add(h.divide(s)).doubleValue();return new z(f,p)}},{key:"isAcute",value:function(t,e,n){return!!_n.isAcute(t,e,n)&&!!_n.isAcute(e,n,t)&&!!_n.isAcute(n,t,e)}},{key:"circumcentre",value:function(t,n,r){var i=r.x,o=r.y,a=t.x-i,s=t.y-o,u=n.x-i,l=n.y-o,c=2*e.det(a,s,u,l),h=e.det(s,a*a+s*s,l,u*u+l*l),f=e.det(a,a*a+s*s,u,u*u+l*l);return new z(i-h/c,o+f/c)}},{key:"perpendicularBisector",value:function(t,e){var n=e.x-t.x,r=e.y-t.y,i=new Sn(t.x+n/2,t.y+r/2,1),o=new Sn(t.x-r+n/2,t.y+n+r/2,1);return new Sn(i,o)}},{key:"angleBisector",value:function(t,e,n){var r=e.distance(t),i=r/(r+e.distance(n)),o=n.x-t.x,a=n.y-t.y;return new z(t.x+i*o,t.y+i*a)}},{key:"area3D",value:function(t,e,n){var r=e.x-t.x,i=e.y-t.y,o=e.getZ()-t.getZ(),a=n.x-t.x,s=n.y-t.y,u=n.getZ()-t.getZ(),l=i*u-o*s,c=o*a-r*u,h=r*s-i*a,f=l*l+c*c+h*h;return Math.sqrt(f)/2}},{key:"centroid",value:function(t,e,n){var r=(t.x+e.x+n.x)/3,i=(t.y+e.y+n.y)/3;return new z(r,i)}},{key:"inCentre",value:function(t,e,n){var r=e.distance(n),i=t.distance(n),o=t.distance(e),a=r+i+o,s=(r*t.x+i*e.x+o*n.x)/a,u=(r*t.y+i*e.y+o*n.y)/a;return new z(s,u)}}]),e}(),Cn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"addRingSide",value:function(t,e,n,r,i){if(0===e&&t.length=qt.MINIMUM_VALID_SIZE&&ht.isCCW(t)&&(o=i,a=r,n=$.opposite(n));var s=this._curveBuilder.getRingCurve(t,n,e);this.addCurve(s,o,a)}},{key:"addRingBothSides",value:function(t,e){this.addRingSide(t,e,$.LEFT,W.EXTERIOR,W.INTERIOR),this.addRingSide(t,e,$.RIGHT,W.INTERIOR,W.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,W.EXTERIOR,W.INTERIOR)}},{key:"addPolygon",value:function(t){var e=this._distance,n=$.LEFT;this._distance<0&&(e=-this._distance,n=$.RIGHT);var r=t.getExteriorRing(),i=Xt.removeRepeatedPoints(r.getCoordinates());if(this._distance<0&&this.isErodedCompletely(r,this._distance))return null;if(this._distance<=0&&i.length<3)return null;this.addRingSide(i,e,n,W.EXTERIOR,W.INTERIOR);for(var o=0;o0&&this.isErodedCompletely(a,-this._distance)||this.addRingSide(s,e,$.opposite(n),W.INTERIOR,W.EXTERIOR)}}},{key:"isTriangleErodedCompletely",value:function(t,e){var n=new Mn(t[0],t[1],t[2]),r=n.inCentre();return wt.pointToSegment(r,n.p0,n.p1)i}},{key:"addCollection",value:function(t){for(var e=0;e=this._max)throw new H;var t=this._parent.getGeometryN(this._index++);return t instanceof Bt?(this._subcollectionIterator=new e(t),this._subcollectionIterator.next()):t}},{key:"remove",value:function(){throw new Z(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[nn]}}],[{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 Bt)}}]),e}(),jn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"locate",value:function(t){return e.locate(t,this._geom)}},{key:"interfaces_",get:function(){return[kn]}}],[{key:"constructor_",value:function(){this._geom=null;var t=arguments[0];this._geom=t}},{key:"locatePointInPolygon",value:function(t,n){if(n.isEmpty())return W.EXTERIOR;var r=n.getExteriorRing(),i=e.locatePointInRing(t,r);if(i!==W.INTERIOR)return i;for(var o=0;o=0;n--){var r=this._edgeList.get(n),i=r.getSym();null===e&&(e=i),null!==t&&i.setNext(t),t=r}e.setNext(t)}},{key:"computeDepths",value:function(){if(1===arguments.length){var t=arguments[0],e=this.findIndex(t),n=t.getDepth($.LEFT),r=t.getDepth($.RIGHT),i=this.computeDepths(e+1,this._edgeList.size(),n);if(this.computeDepths(0,e,i)!==r)throw new pt("depth mismatch at "+t.getCoordinate())}else if(3===arguments.length){for(var o=arguments[1],a=arguments[2],s=arguments[0];s=0;i--){var o=this._resultAreaEdgeList.get(i),a=o.getSym();switch(null===e&&o.getEdgeRing()===t&&(e=o),r){case this._SCANNING_FOR_INCOMING:if(a.getEdgeRing()!==t)continue;n=a,r=this._LINKING_TO_OUTGOING;break;case this._LINKING_TO_OUTGOING:if(o.getEdgeRing()!==t)continue;n.setNextMin(o),r=this._SCANNING_FOR_INCOMING}}r===this._LINKING_TO_OUTGOING&&(D.isTrue(null!==e,"found null for first outgoing dirEdge"),D.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],r=0,i=this.iterator();i.hasNext();)i.next().getEdgeRing()===n&&r++;return r}}},{key:"getLabel",value:function(){return this._label}},{key:"findCoveredLineEdges",value:function(){for(var t=W.NONE,e=this.iterator();e.hasNext();){var n=e.next(),r=n.getSym();if(!n.isLineEdge()){if(n.isInResult()){t=W.INTERIOR;break}if(r.isInResult()){t=W.EXTERIOR;break}}}if(t===W.NONE)return null;for(var i=t,o=this.iterator();o.hasNext();){var a=o.next(),s=a.getSym();a.isLineEdge()?a.getEdge().setCovered(i===W.INTERIOR):(a.isInResult()&&(i=W.EXTERIOR),s.isInResult()&&(i=W.INTERIOR))}}},{key:"computeLabelling",value:function(t){p(o(a.prototype),"computeLabelling",this).call(this,t),this._label=new xe(W.NONE);for(var e=this.iterator();e.hasNext();)for(var n=e.next().getEdge().getLabel(),r=0;r<2;r++){var i=n.getLocation(r);i!==W.INTERIOR&&i!==W.BOUNDARY||this._label.setLocation(r,W.INTERIOR)}}}],[{key:"constructor_",value:function(){this._resultAreaEdgeList=null,this._label=null,this._SCANNING_FOR_INCOMING=1,this._LINKING_TO_OUTGOING=2}}]),a}(function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"getNextCW",value:function(t){this.getEdges();var e=this._edgeList.indexOf(t),n=e-1;return 0===e&&(n=this._edgeList.size()-1),this._edgeList.get(n)}},{key:"propagateSideLabels",value:function(t){for(var e=W.NONE,n=this.iterator();n.hasNext();){var r=n.next().getLabel();r.isArea(t)&&r.getLocation(t,$.LEFT)!==W.NONE&&(e=r.getLocation(t,$.LEFT))}if(e===W.NONE)return null;for(var i=e,o=this.iterator();o.hasNext();){var a=o.next(),s=a.getLabel();if(s.getLocation(t,$.ON)===W.NONE&&s.setLocation(t,$.ON,i),s.isArea(t)){var u=s.getLocation(t,$.LEFT),l=s.getLocation(t,$.RIGHT);if(l!==W.NONE){if(l!==i)throw new pt("side location conflict",a.getCoordinate());u===W.NONE&&D.shouldNeverReachHere("found single null side (at "+a.getCoordinate()+")"),i=u}else D.isTrue(s.getLocation(t,$.LEFT)===W.NONE,"found single null side"),s.setLocation(t,$.RIGHT,i),s.setLocation(t,$.LEFT,i)}}}},{key:"getCoordinate",value:function(){var t=this.iterator();return t.hasNext()?t.next().getCoordinate():null}},{key:"print",value:function(t){_t.out.println("EdgeEndStar: "+this.getCoordinate());for(var e=this.iterator();e.hasNext();)e.next().print(t)}},{key:"isAreaLabelsConsistent",value:function(t){return this.computeEdgeEndLabels(t.getBoundaryNodeRule()),this.checkAreaLabelsConsistent(0)}},{key:"checkAreaLabelsConsistent",value:function(t){var e=this.getEdges();if(e.size()<=0)return!0;var n=e.size()-1,r=e.get(n).getLabel().getLocation(t,$.LEFT);D.isTrue(r!==W.NONE,"Found unlabelled area edge");for(var i=r,o=this.iterator();o.hasNext();){var a=o.next().getLabel();D.isTrue(a.isArea(t),"Found non-area edge");var s=a.getLocation(t,$.LEFT),u=a.getLocation(t,$.RIGHT);if(s===u)return!1;if(u!==i)return!1;i=s}return!0}},{key:"findIndex",value:function(t){this.iterator();for(var e=0;e0&&t.print(","),t.print("(");for(var r=n.getCoordinates(),i=0;i0&&t.print(","),t.print(r[i].x+" "+r[i].y);t.println(")")}t.print(") ")}},{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 z(t),this.segmentIndex=e,this.dist=n}}]),e}(),Dn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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 r=e.next(),i=this.createSplitEdge(n,r);t.add(i),n=r}}},{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,r=this.edge.pts[e.segmentIndex],i=e.dist>0||!e.coord.equals2D(r);i||n--;var o=new Array(n).fill(null),a=0;o[a++]=new z(t.coord);for(var s=t.segmentIndex+1;s<=e.segmentIndex;s++)o[a++]=this.edge.pts[s];return i&&(o[a]=e.coord),new Vn(o,new xe(this.edge._label))}},{key:"add",value:function(t,e,n){var r=new Fn(t,e,n),i=this._nodeMap.get(r);return null!==i?i:(this._nodeMap.put(r,r),r)}},{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 Ie,this.edge=null;var t=arguments[0];this.edge=t}}]),e}(),Bn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"isIntersects",value:function(){return!this.isDisjoint()}},{key:"isCovers",value:function(){return(e.isTrue(this._matrix[W.INTERIOR][W.INTERIOR])||e.isTrue(this._matrix[W.INTERIOR][W.BOUNDARY])||e.isTrue(this._matrix[W.BOUNDARY][W.INTERIOR])||e.isTrue(this._matrix[W.BOUNDARY][W.BOUNDARY]))&&this._matrix[W.EXTERIOR][W.INTERIOR]===Ct.FALSE&&this._matrix[W.EXTERIOR][W.BOUNDARY]===Ct.FALSE}},{key:"isCoveredBy",value:function(){return(e.isTrue(this._matrix[W.INTERIOR][W.INTERIOR])||e.isTrue(this._matrix[W.INTERIOR][W.BOUNDARY])||e.isTrue(this._matrix[W.BOUNDARY][W.INTERIOR])||e.isTrue(this._matrix[W.BOUNDARY][W.BOUNDARY]))&&this._matrix[W.INTERIOR][W.EXTERIOR]===Ct.FALSE&&this._matrix[W.BOUNDARY][W.EXTERIOR]===Ct.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 e.isTrue(this._matrix[W.INTERIOR][W.INTERIOR])&&this._matrix[W.INTERIOR][W.EXTERIOR]===Ct.FALSE&&this._matrix[W.BOUNDARY][W.EXTERIOR]===Ct.FALSE}},{key:"isTouches",value:function(t,n){return t>n?this.isTouches(n,t):(t===Ct.A&&n===Ct.A||t===Ct.L&&n===Ct.L||t===Ct.L&&n===Ct.A||t===Ct.P&&n===Ct.A||t===Ct.P&&n===Ct.L)&&this._matrix[W.INTERIOR][W.INTERIOR]===Ct.FALSE&&(e.isTrue(this._matrix[W.INTERIOR][W.BOUNDARY])||e.isTrue(this._matrix[W.BOUNDARY][W.INTERIOR])||e.isTrue(this._matrix[W.BOUNDARY][W.BOUNDARY]))}},{key:"isOverlaps",value:function(t,n){return t===Ct.P&&n===Ct.P||t===Ct.A&&n===Ct.A?e.isTrue(this._matrix[W.INTERIOR][W.INTERIOR])&&e.isTrue(this._matrix[W.INTERIOR][W.EXTERIOR])&&e.isTrue(this._matrix[W.EXTERIOR][W.INTERIOR]):t===Ct.L&&n===Ct.L&&1===this._matrix[W.INTERIOR][W.INTERIOR]&&e.isTrue(this._matrix[W.INTERIOR][W.EXTERIOR])&&e.isTrue(this._matrix[W.EXTERIOR][W.INTERIOR])}},{key:"isEquals",value:function(t,n){return t===n&&e.isTrue(this._matrix[W.INTERIOR][W.INTERIOR])&&this._matrix[W.INTERIOR][W.EXTERIOR]===Ct.FALSE&&this._matrix[W.BOUNDARY][W.EXTERIOR]===Ct.FALSE&&this._matrix[W.EXTERIOR][W.INTERIOR]===Ct.FALSE&&this._matrix[W.EXTERIOR][W.BOUNDARY]===Ct.FALSE}},{key:"toString",value:function(){for(var t=new Kt("123456789"),e=0;e<3;e++)for(var n=0;n<3;n++)t.setCharAt(3*e+n,Ct.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(t){if(9!==t.length)throw new b("Should be length 9: "+t);for(var n=0;n<3;n++)for(var r=0;r<3;r++)if(!e.matches(this._matrix[n][r],t.charAt(3*n+r)))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[W.INTERIOR][W.INTERIOR]===Ct.FALSE&&this._matrix[W.INTERIOR][W.BOUNDARY]===Ct.FALSE&&this._matrix[W.BOUNDARY][W.INTERIOR]===Ct.FALSE&&this._matrix[W.BOUNDARY][W.BOUNDARY]===Ct.FALSE}},{key:"isCrosses",value:function(t,n){return t===Ct.P&&n===Ct.L||t===Ct.P&&n===Ct.A||t===Ct.L&&n===Ct.A?e.isTrue(this._matrix[W.INTERIOR][W.INTERIOR])&&e.isTrue(this._matrix[W.INTERIOR][W.EXTERIOR]):t===Ct.L&&n===Ct.P||t===Ct.A&&n===Ct.P||t===Ct.A&&n===Ct.L?e.isTrue(this._matrix[W.INTERIOR][W.INTERIOR])&&e.isTrue(this._matrix[W.EXTERIOR][W.INTERIOR]):t===Ct.L&&n===Ct.L&&0===this._matrix[W.INTERIOR][W.INTERIOR]}},{key:"interfaces_",get:function(){return[O]}}],[{key:"constructor_",value:function(){if(this._matrix=null,0===arguments.length)this._matrix=Array(3).fill().map((function(){return Array(3)})),this.setAll(Ct.FALSE);else if(1===arguments.length)if("string"==typeof arguments[0]){var t=arguments[0];e.constructor_.call(this),this.set(t)}else if(arguments[0]instanceof e){var n=arguments[0];e.constructor_.call(this),this._matrix[W.INTERIOR][W.INTERIOR]=n._matrix[W.INTERIOR][W.INTERIOR],this._matrix[W.INTERIOR][W.BOUNDARY]=n._matrix[W.INTERIOR][W.BOUNDARY],this._matrix[W.INTERIOR][W.EXTERIOR]=n._matrix[W.INTERIOR][W.EXTERIOR],this._matrix[W.BOUNDARY][W.INTERIOR]=n._matrix[W.BOUNDARY][W.INTERIOR],this._matrix[W.BOUNDARY][W.BOUNDARY]=n._matrix[W.BOUNDARY][W.BOUNDARY],this._matrix[W.BOUNDARY][W.EXTERIOR]=n._matrix[W.BOUNDARY][W.EXTERIOR],this._matrix[W.EXTERIOR][W.INTERIOR]=n._matrix[W.EXTERIOR][W.INTERIOR],this._matrix[W.EXTERIOR][W.BOUNDARY]=n._matrix[W.EXTERIOR][W.BOUNDARY],this._matrix[W.EXTERIOR][W.EXTERIOR]=n._matrix[W.EXTERIOR][W.EXTERIOR]}}},{key:"matches",value:function(){if(Number.isInteger(arguments[0])&&"string"==typeof arguments[1]){var t=arguments[0],n=arguments[1];return n===Ct.SYM_DONTCARE||n===Ct.SYM_TRUE&&(t>=0||t===Ct.TRUE)||n===Ct.SYM_FALSE&&t===Ct.FALSE||n===Ct.SYM_P&&t===Ct.P||n===Ct.SYM_L&&t===Ct.L||n===Ct.SYM_A&&t===Ct.A}if("string"==typeof arguments[0]&&"string"==typeof arguments[1]){var r=arguments[1];return new e(arguments[0]).matches(r)}}},{key:"isTrue",value:function(t){return t>=0||t===Ct.TRUE}}]),e}(),Gn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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),_t.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 _t.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)e.constructor_.call(this,10);else if(1===arguments.length){var t=arguments[0];this._data=new Array(t).fill(null)}}}]),e}(),qn=function(){function e(){t(this,e)}return n(e,[{key:"getChainStartIndices",value:function(t){var e=0,n=new Gn(Math.trunc(t.length/2));n.add(e);do{var r=this.findChainEnd(t,e);n.add(r),e=r}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&&(r=1),this._depth[t][n]=r}}}},{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?W.EXTERIOR:W.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 t=arguments[0],n=0;n<2;n++)for(var r=1;r<3;r++){var i=t.getLocation(n,r);i!==W.EXTERIOR&&i!==W.INTERIOR||(this.isNull(n,r)?this._depth[n][r]=e.depthAtLocation(i):this._depth[n][r]+=e.depthAtLocation(i))}else if(3===arguments.length){var o=arguments[0],a=arguments[1];arguments[2]===W.INTERIOR&&this._depth[o][a]++}}}],[{key:"constructor_",value:function(){this._depth=Array(2).fill().map((function(){return Array(3)}));for(var t=0;t<2;t++)for(var n=0;n<3;n++)this._depth[t][n]=e.NULL_VALUE}},{key:"depthAtLocation",value:function(t){return t===W.EXTERIOR?0:t===W.INTERIOR?1:e.NULL_VALUE}}]),e}();Un.NULL_VALUE=-1;var Vn=function(e){i(a,e);var r=f(a);function a(){var e;return t(this,a),e=r.call(this),a.constructor_.apply(c(e),arguments),e}return n(a,[{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 a(t,xe.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 a))return!1;var e=t;if(this.pts.length!==e.pts.length)return!1;for(var n=!0,r=!0,i=this.pts.length,o=0;o0?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){a.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 zn(this)),this._mce}},{key:"getEnvelope",value:function(){if(null===this._env){this._env=new V;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;er||this._maxyo;if(a)return!1;var s=this.intersectsToleranceSquare(t,e);return D.isTrue(!(a&&s),"Found bad envelope test"),s}},{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 z(this._maxx,this._maxy),this._corner[1]=new z(this._minx,this._maxy),this._corner[2]=new z(this._minx,this._miny),this._corner[3]=new z(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 t=e.SAFE_ENV_EXPANSION_FACTOR/this._scaleFactor;this._safeEnv=new V(this._originalPt.x-t,this._originalPt.x+t,this._originalPt.y-t,this._originalPt.y+t)}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,r=!1;return this._li.computeIntersection(t,e,this._corner[0],this._corner[1]),!!(this._li.isProper()||(this._li.computeIntersection(t,e,this._corner[1],this._corner[2]),this._li.isProper()||(this._li.hasIntersection()&&(n=!0),this._li.computeIntersection(t,e,this._corner[2],this._corner[3]),this._li.isProper()||(this._li.hasIntersection()&&(r=!0),this._li.computeIntersection(t,e,this._corner[3],this._corner[0]),this._li.isProper()||n&&r||t.equals(this._pt)||e.equals(this._pt)))))}},{key:"addSnappedNode",value:function(t,e){var n=t.getCoordinate(e),r=t.getCoordinate(e+1);return!!this.intersects(n,r)&&(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 b("Scale factor must be non-zero");1!==e&&(this._pt=new z(this.scale(t.x),this.scale(t.y)),this._p0Scaled=new z,this._p1Scaled=new z),this.initCorners(this._pt)}}]),e}();Hn.SAFE_ENV_EXPANSION_FACTOR=.75;var Zn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{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 ln}}]),e}(),Kn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"snap",value:function(){if(1===arguments.length){var e=arguments[0];return this.snap(e,null,-1)}if(3===arguments.length){var r=arguments[0],i=arguments[1],o=arguments[2],a=r.getSafeEnvelope(),s=new Jn(r,i,o);return this._index.query(a,new(function(){function e(){t(this,e)}return n(e,[{key:"interfaces_",get:function(){return[Ze]}},{key:"visitItem",value:function(t){t.select(a,s)}}]),e}())),s.isNodeAdded()}}}],[{key:"constructor_",value:function(){this._index=null;var t=arguments[0];this._index=t}}]),e}(),Jn=function(e){i(a,e);var r=f(a);function a(){var e;return t(this,a),e=r.call(this),a.constructor_.apply(c(e),arguments),e}return n(a,[{key:"isNodeAdded",value:function(){return this._isNodeAdded}},{key:"select",value:function(){if(!(2===arguments.length&&Number.isInteger(arguments[1])&&arguments[0]instanceof hn))return p(o(a.prototype),"select",this).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}}]),a}(Zn);Kn.HotPixelSnapAction=Jn;var Qn=function(){function e(){t(this,e),e.constructor_.apply(this,arguments)}return n(e,[{key:"processIntersections",value:function(t,e,n,r){if(t===n&&e===r)return null;var i=t.getCoordinates()[e],o=t.getCoordinates()[e+1],a=n.getCoordinates()[r],s=n.getCoordinates()[r+1];if(this._li.computeIntersection(i,o,a,s),this._li.hasIntersection()&&this._li.isInteriorIntersection()){for(var u=0;u=0;t--){try{this.bufferReducedPrecision(t)}catch(t){if(!(t instanceof pt))throw t;this._saveException=t}if(null!==this._resultGeometry)return null}throw this._saveException}if(1===arguments.length){var n=arguments[0],r=e.precisionScaleFactor(this._argGeom,this._distance,n),i=new ne(r);this.bufferFixedPrecision(i)}}},{key:"computeGeometry",value:function(){if(this.bufferOriginalPrecision(),null!==this._resultGeometry)return null;var t=this._argGeom.getFactory().getPrecisionModel();t.getType()===ne.FIXED?this.bufferFixedPrecision(t):this.bufferReducedPrecision()}},{key:"setQuadrantSegments",value:function(t){this._bufParams.setQuadrantSegments(t)}},{key:"bufferOriginalPrecision",value:function(){try{var t=new Yn(this._bufParams);this._resultGeometry=t.buffer(this._argGeom,this._distance)}catch(t){if(!(t instanceof T))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 m,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 t=arguments[1];return new e(arguments[0]).getResultGeometry(t)}if(3===arguments.length){if(Number.isInteger(arguments[2])&&arguments[0]instanceof Y&&"number"==typeof arguments[1]){var n=arguments[1],r=arguments[2],i=new e(arguments[0]);return i.setQuadrantSegments(r),i.getResultGeometry(n)}if(arguments[2]instanceof m&&arguments[0]instanceof Y&&"number"==typeof arguments[1]){var o=arguments[1];return new e(arguments[0],arguments[2]).getResultGeometry(o)}}else if(4===arguments.length){var a=arguments[1],s=arguments[2],u=arguments[3],l=new e(arguments[0]);return l.setQuadrantSegments(s),l.setEndCapStyle(u),l.getResultGeometry(a)}}},{key:"precisionScaleFactor",value:function(t,e,n){var r=t.getEnvelopeInternal(),i=bt.max(Math.abs(r.getMaxX()),Math.abs(r.getMaxY()),Math.abs(r.getMinX()),Math.abs(r.getMinY()))+2*(e>0?e:0),o=n-Math.trunc(Math.log(i)/Math.log(10)+1);return Math.pow(10,o)}}]),e}();tr.CAP_ROUND=m.CAP_ROUND,tr.CAP_BUTT=m.CAP_FLAT,tr.CAP_FLAT=m.CAP_FLAT,tr.CAP_SQUARE=m.CAP_SQUARE,tr.MAX_PRECISION_DIGITS=12;var er=["Point","MultiPoint","LineString","MultiLineString","Polygon","MultiPolygon"],nr=function(){function e(n){t(this,e),this.geometryFactory=n||new oe}return n(e,[{key:"read",value:function(t){var e,n=(e="string"==typeof t?JSON.parse(t):t).type;if(!rr[n])throw new Error("Unknown GeoJSON type: "+e.type);return-1!==er.indexOf(n)?rr[n].call(this,e.coordinates):"GeometryCollection"===n?rr[n].call(this,e.geometries):rr[n].call(this,e)}},{key:"write",value:function(t){var e=t.getGeometryType();if(!ir[e])throw new Error("Geometry is not supported");return ir[e].call(this,t)}}]),e}(),rr={Feature:function(t){var e={};for(var n in t)e[n]=t[n];if(t.geometry){var r=t.geometry.type;if(!rr[r])throw new Error("Unknown GeoJSON type: "+t.type);e.geometry=this.read(t.geometry)}return t.bbox&&(e.bbox=rr.bbox.call(this,t.bbox)),e},FeatureCollection:function(t){var e={};if(t.features){e.features=[];for(var n=0;n1?0:t<-1?Cn:Math.acos(t)}function Gn(t){return t>1?kn:t<-1?-kn:Math.asin(t)}function qn(){}function zn(t,e){t&&Wn.hasOwnProperty(t.type)&&Wn[t.type](t,e)}var Un,Vn,Yn={Feature:function(t,e){zn(t.geometry,e)},FeatureCollection:function(t,e){for(var n=t.features,r=-1,i=n.length;++rCn?t-jn:t<-Cn?t+jn:t,e]}function ir(t){return function(e,n){return[(e+=t)>Cn?e-jn:e<-Cn?e+jn:e,n]}}function or(t){var e=ir(t);return e.invert=ir(-t),e}function ar(t,e){var n=Tn(t),r=Fn(t),i=Tn(e),o=Fn(e);function a(t,e){var a=Tn(e),s=Tn(t)*a,u=Fn(t)*a,l=Fn(e),c=l*n+s*r;return[Rn(u*i-c*o,s*n-l*r),Gn(c*i+u*o)]}return a.invert=function(t,e){var a=Tn(e),s=Tn(t)*a,u=Fn(t)*a,l=Fn(e),c=l*i-u*o;return[Rn(u*i+l*o,s*n+c*r),Gn(c*n-s*r)]},a}function sr(t,e){(e=Kn(e))[0]-=t,er(e);var n=Bn(-e[1]);return((-e[2]<0?-n:n)+jn-Mn)%jn}function ur(){var t,e=[];return{point:function(e,n){t.push([e,n])},lineStart:function(){e.push(t=[])},lineEnd:qn,rejoin:function(){e.length>1&&e.push(e.pop().concat(e.shift()))},result:function(){var n=e;return e=[],t=null,n}}}function lr(t,e){return In(t[0]-e[0])=0;--o)i.point((c=l[o])[0],c[1]);else r(f.x,f.p.x,-1,i);f=f.p}l=(f=f.o).z,p=!p}while(!f.v);i.lineEnd()}}}function fr(t){if(e=t.length){for(var e,n,r=0,i=t[0];++re?1:t>=e?0:NaN}function dr(t){for(var e,n,r,i=t.length,o=-1,a=0;++o=0;)for(e=(r=t[i]).length;--e>=0;)n[--a]=r[e];return n}xn(),xn(),xn(),rr.invert=rr,1===(Un=pr).length&&(Vn=Un,Un=function(t,e){return pr(Vn(t),e)});var gr=1e9,yr=-gr;function vr(t,e,n,r){function i(i,o){return t<=i&&i<=n&&e<=o&&o<=r}function o(i,o,s,l){var c=0,h=0;if(null==i||(c=a(i,s))!==(h=a(o,s))||u(i,o)<0^s>0)do{l.point(0===c||3===c?t:n,c>1?r:e)}while((c=(c+s+4)%4)!==h);else l.point(o[0],o[1])}function a(r,i){return In(r[0]-t)0?0:3:In(r[0]-n)0?2:1:In(r[1]-e)0?1:0:i>0?3:2}function s(t,e){return u(t.x,e.x)}function u(t,e){var n=a(t,1),r=a(e,1);return n!==r?n-r:0===n?e[1]-t[1]:1===n?t[0]-e[0]:2===n?t[1]-e[1]:e[0]-t[0]}return function(a){var u,l,c,h,f,p,d,g,y,v,m,_=a,b=ur(),w={point:x,lineStart:function(){w.point=O,l&&l.push(c=[]),v=!0,y=!1,d=g=NaN},lineEnd:function(){u&&(O(h,f),p&&y&&b.rejoin(),u.push(b.result())),w.point=x,y&&_.lineEnd()},polygonStart:function(){_=b,u=[],l=[],m=!0},polygonEnd:function(){var e=function(){for(var e=0,n=0,i=l.length;nr&&(f-o)*(r-a)>(p-a)*(t-o)&&++e:p<=r&&(f-o)*(r-a)<(p-a)*(t-o)&&--e;return e}(),n=m&&e,i=(u=dr(u)).length;(n||i)&&(a.polygonStart(),n&&(a.lineStart(),o(null,null,1,a),a.lineEnd()),i&&hr(u,s,e,o,a),a.polygonEnd()),_=a,u=l=c=null}};function x(t,e){i(t,e)&&_.point(t,e)}function O(o,a){var s=i(o,a);if(l&&c.push([o,a]),v)h=o,f=a,p=s,v=!1,s&&(_.lineStart(),_.point(o,a));else if(s&&y)_.point(o,a);else{var u=[d=Math.max(yr,Math.min(gr,d)),g=Math.max(yr,Math.min(gr,g))],b=[o=Math.max(yr,Math.min(gr,o)),a=Math.max(yr,Math.min(gr,a))];!function(t,e,n,r,i,o){var a,s=t[0],u=t[1],l=0,c=1,h=e[0]-s,f=e[1]-u;if(a=n-s,h||!(a>0)){if(a/=h,h<0){if(a0){if(a>c)return;a>l&&(l=a)}if(a=i-s,h||!(a<0)){if(a/=h,h<0){if(a>c)return;a>l&&(l=a)}else if(h>0){if(a0)){if(a/=f,f<0){if(a0){if(a>c)return;a>l&&(l=a)}if(a=o-u,f||!(a<0)){if(a/=f,f<0){if(a>c)return;a>l&&(l=a)}else if(f>0){if(a0&&(t[0]=s+l*h,t[1]=u+l*f),c<1&&(e[0]=s+c*h,e[1]=u+c*f),!0}}}}}(u,b,t,e,n,r)?s&&(_.lineStart(),_.point(o,a),m=!1):(y||(_.lineStart(),_.point(u[0],u[1])),_.point(b[0],b[1]),s||_.lineEnd(),m=!1)}d=o,g=a,y=s}return w}}var mr=xn();function _r(t){return t}xn(),xn(),xn();var br=1/0,wr=br,xr=-br,Or=xr,Er={point:function(t,e){t
xr&&(xr=t),eOr&&(Or=e)},lineStart:qn,lineEnd:qn,polygonStart:qn,polygonEnd:qn,result:function(){var t=[[br,wr],[xr,Or]];return xr=Or=-(wr=br=1/0),t}};function Sr(t,e,n,r){return function(i,o){var a,s,u,l=e(o),c=i.invert(r[0],r[1]),h=ur(),f=e(h),p=!1,d={point:g,lineStart:v,lineEnd:m,polygonStart:function(){d.point=_,d.lineStart=b,d.lineEnd=w,s=[],a=[]},polygonEnd:function(){d.point=g,d.lineStart=v,d.lineEnd=m,s=dr(s);var t=function(t,e){var n=e[0],r=e[1],i=[Fn(n),-Tn(n),0],o=0,a=0;mr.reset();for(var s=0,u=t.length;s=0?1:-1,E=O*x,S=E>Cn,M=d*b;if(mr.add(Rn(M*O*Fn(E),g*w+M*Tn(E))),o+=S?x+O*jn:x,S^f>=n^m>=n){var C=Qn(Kn(h),Kn(v));er(C);var k=Qn(i,C);er(k);var N=(S^x>=0?-1:1)*Gn(k[2]);(r>N||r===N&&(C[0]||C[1]))&&(a+=S^x>=0?1:-1)}}return(o<-Mn||o0){for(p||(o.polygonStart(),p=!0),o.lineStart(),t=0;t1&&2&i&&l.push(l.pop().concat(l.shift())),s.push(l.filter(Mr))}return d}}function Mr(t){return t.length>1}function Cr(t,e){return((t=t.x)[0]<0?t[1]-kn-Mn:kn-t[1])-((e=e.x)[0]<0?e[1]-kn-Mn:kn-e[1])}xn();var kr=Sr((function(){return!0}),(function(t){var e,n=NaN,r=NaN,i=NaN;return{lineStart:function(){t.lineStart(),e=1},point:function(o,a){var s=o>0?Cn:-Cn,u=In(o-n);In(u-Cn)0?kn:-kn),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),t.point(o,r),e=0):i!==s&&u>=Cn&&(In(n-i)Mn?An((Fn(e)*(o=Tn(r))*Fn(n)-Fn(r)*(i=Tn(e))*Fn(t))/(i*o*a)):(e+r)/2}(n,r,o,a),t.point(i,r),t.lineEnd(),t.lineStart(),t.point(s,r),e=0),t.point(n=o,r=a),i=s},lineEnd:function(){t.lineEnd(),n=r=NaN},clean:function(){return 2-e}}}),(function(t,e,n,r){var i;if(null==t)i=n*kn,r.point(-Cn,i),r.point(0,i),r.point(Cn,i),r.point(Cn,0),r.point(Cn,-i),r.point(0,-i),r.point(-Cn,-i),r.point(-Cn,0),r.point(-Cn,i);else if(In(t[0]-e[0])>Mn){var o=t[0]0,i=In(n)>Mn;function o(t,e){return Tn(t)*Tn(e)>n}function a(t,e,r){var i=[1,0,0],o=Qn(Kn(t),Kn(e)),a=Jn(o,o),s=o[0],u=a-s*s;if(!u)return!r&&t;var l=n*a/u,c=-n*s/u,h=Qn(i,o),f=tr(i,l);$n(f,tr(o,c));var p=h,d=Jn(f,p),g=Jn(p,p),y=d*d-g*(Jn(f,f)-1);if(!(y<0)){var v=Dn(y),m=tr(p,(-d-v)/g);if($n(m,f),m=Zn(m),!r)return m;var _,b=t[0],w=e[0],x=t[1],O=e[1];w0^m[1]<(In(m[0]-b)Cn^(b<=m[0]&&m[0]<=w)){var M=tr(p,(-d+v)/g);return $n(M,f),[m,Zn(M)]}}}function s(e,n){var i=r?t:Cn-t,o=0;return e<-i?o|=1:e>i&&(o|=2),n<-i?o|=4:n>i&&(o|=8),o}return Sr(o,(function(t){var e,n,u,l,c;return{lineStart:function(){l=u=!1,c=1},point:function(h,f){var p,d=[h,f],g=o(h,f),y=r?g?0:s(h,f):g?s(h+(h<0?Cn:-Cn),f):0;if(!e&&(l=u=g)&&t.lineStart(),g!==u&&(!(p=a(e,d))||lr(e,p)||lr(d,p))&&(d[0]+=Mn,d[1]+=Mn,g=o(d[0],d[1])),g!==u)c=0,g?(t.lineStart(),p=a(d,e),t.point(p[0],p[1])):(p=a(e,d),t.point(p[0],p[1]),t.lineEnd()),e=p;else if(i&&e&&r^g){var v;y&n||!(v=a(d,e,!0))||(c=0,r?(t.lineStart(),t.point(v[0][0],v[0][1]),t.point(v[1][0],v[1][1]),t.lineEnd()):(t.point(v[1][0],v[1][1]),t.lineEnd(),t.lineStart(),t.point(v[0][0],v[0][1])))}!g||e&&lr(e,d)||t.point(d[0],d[1]),e=d,u=g,n=y},lineEnd:function(){u&&t.lineEnd(),e=null},clean:function(){return c|(l&&u)<<1}}}),(function(n,r,i,o){!function(t,e,n,r,i,o){if(n){var a=Tn(e),s=Fn(e),u=r*n;null==i?(i=e+r*jn,o=e-u/2):(i=sr(a,i),o=sr(a,o),(r>0?io)&&(i+=r*jn));for(var l,c=i;r>0?c>o:c4*e&&g--){var b=a+f,w=s+p,x=u+d,O=Dn(b*b+w*w+x*x),E=Gn(x/=O),S=In(In(x)-1)e||In((v*N+m*j)/_-.5)>.3||a*f+s*p+u*d2?t[2]%360*Pn:0,k()):[y*Ln,v*Ln,m*Ln]},S.precision=function(t){return arguments.length?(E=Ar(C,O=t*t),N()):Dn(O)},S.fitExtent=function(t,e){return Pr(S,t,e)},S.fitSize=function(t,e){return function(t,e,n){return Pr(t,[[0,0],e],n)}(S,t,e)},function(){return e=t.apply(this,arguments),S.invert=e.invert&&M,k()}}((function(){return t}))()}(Dr).scale(79.4188).clipAngle(179.999)}function Gr(t,e){return[t,e]}Dr.invert=Fr((function(t){return t})),Gr.invert=Gr;var qr=wn.BufferOp,zr=wn.GeoJSONReader,Ur=wn.GeoJSONWriter;function Vr(t,e,n,r){var i=t.properties||{},o="Feature"===t.type?t.geometry:t;if("GeometryCollection"===o.type){var a=[];return ft(t,(function(t){var i=Vr(t,e,n,r);i&&a.push(i)})),S(a)}var s=function(t){var e=_n(t).geometry.coordinates,n=[-e[0],-e[1]];return Br().rotate(n).scale(d)}(o),u={type:o.type,coordinates:Yr(o.coordinates,s)},l=(new zr).read(u),c=L(P(e,n),"meters"),h=qr.bufferOp(l,c,r);if(!function t(e){return Array.isArray(e[0])?t(e[0]):isNaN(e[0])}((h=(new Ur).write(h)).coordinates))return v({type:h.type,coordinates:Wr(h.coordinates,s)},i)}function Yr(t,e){return"object"!==r(t[0])?e(t):t.map((function(t){return Yr(t,e)}))}function Wr(t,e){return"object"!==r(t[0])?e.invert(t):t.map((function(t){return Wr(t,e)}))}function Xr(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,r=0,i=0;return ft(t,(function(t,o,a){var s=e.weight?null==a?void 0:a[e.weight]:void 0;if(!G(s=null==s?1:s))throw new Error("weight value must be a number for feature index "+o);(s=Number(s))>0&&ot(t,(function(t){n+=t[0]*s,r+=t[1]*s,i+=s}))})),_([n/i,r/i],e.properties,e)}function Hr(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=0,r=0,i=0;return ot(t,(function(t){n+=t[0],r+=t[1],i++}),!0),_([n/i,r/i],e.properties)}function Zr(t,e,n,r,i){var o=r.tolerance||.001,a=0,s=0,u=0,l=0;if(lt(n,(function(e){var n,r=null==(n=e.properties)?void 0:n.weight,i=null==r?1:r;if(!G(i=Number(i)))throw new Error("weight value must be a number");if(i>0){l+=1;var o=i*nt(e,t);0===o&&(o=1);var c=i/o;a+=e.geometry.coordinates[0]*c,s+=e.geometry.coordinates[1]*c,u+=c}})),l<1)throw new Error("no features to measure");var c=a/u,h=s/u;return 1===l||0===i||Math.abs(c-e[0])0&&void 0!==arguments[0]?arguments[0]:[],n=arguments.length>1&&void 0!==arguments[1]?arguments[1]:$r;if(i(this,t),this.data=e,this.length=this.data.length,this.compare=n,this.length>0)for(var r=(this.length>>1)-1;r>=0;r--)this._down(r)}return a(t,[{key:"push",value:function(t){this.data.push(t),this.length++,this._up(this.length-1)}},{key:"pop",value:function(){if(0!==this.length){var t=this.data[0],e=this.data.pop();return this.length--,this.length>0&&(this.data[0]=e,this._down(0)),t}}},{key:"peek",value:function(){return this.data[0]}},{key:"_up",value:function(t){for(var e=this.data,n=this.compare,r=e[t];t>0;){var i=t-1>>1,o=e[i];if(n(r,o)>=0)break;e[t]=o,t=i}e[t]=r}},{key:"_down",value:function(t){for(var e=this.data,n=this.compare,r=this.length>>1,i=e[t];t=0)break;e[t]=a,t=o}e[t]=i}}]),t}();function $r(t,e){return te?1:0}var ti=rn(Object.freeze({__proto__:null,default:Qr})),ei={exports:{}},ni=function(t,e,n,r){var i=t[0],o=t[1],a=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);for(var s=(r-n)/2,u=0,l=s-1;uo!=p>o&&i<(f-c)*(o-h)/(p-h)+c&&(a=!a)}return a},ri=function(t,e,n,r){var i=t[0],o=t[1],a=!1;void 0===n&&(n=0),void 0===r&&(r=e.length);for(var s=r-n,u=0,l=s-1;uo!=p>o&&i<(f-c)*(o-h)/(p-h)+c&&(a=!a)}return a};ei.exports=function(t,e,n,r){return e.length>0&&Array.isArray(e[0])?ri(t,e,n,r):ni(t,e,n,r)},ei.exports.nested=ri,ei.exports.flat=ni;var ii=ei.exports,oi={exports:{}};!function(t,e){!function(t){var e=134217729;function n(t,e,n,r,i){var o,a,s,u,l=e[0],c=r[0],h=0,f=0;c>l==c>-l?(o=l,l=e[++h]):(o=c,c=r[++f]);var p=0;if(hl==c>-l?(s=o-((a=l+o)-l),l=e[++h]):(s=o-((a=c+o)-c),c=r[++f]),o=a,0!==s&&(i[p++]=s);hl==c>-l?(s=o-((a=o+l)-(u=a-o))+(l-u),l=e[++h]):(s=o-((a=o+c)-(u=a-o))+(c-u),c=r[++f]),o=a,0!==s&&(i[p++]=s);for(;h0!=d>0)return g;var y=Math.abs(p+d);return Math.abs(g)>=33306690738754716e-32*y?g:-function(t,r,l,c,h,f,p){var d,g,y,v,m,_,b,w,x,O,E,S,M,C,k,N,j,L,P=t-h,I=l-h,A=r-f,R=c-f;m=(k=(w=P-(b=(_=e*P)-(_-P)))*(O=R-(x=(_=e*R)-(_-R)))-((C=P*R)-b*x-w*x-b*O))-(E=k-(j=(w=A-(b=(_=e*A)-(_-A)))*(O=I-(x=(_=e*I)-(_-I)))-((N=A*I)-b*x-w*x-b*O))),i[0]=k-(E+m)+(m-j),m=(M=C-((S=C+E)-(m=S-C))+(E-m))-(E=M-N),i[1]=M-(E+m)+(m-N),m=(L=S+E)-S,i[2]=S-(L-m)+(E-m),i[3]=L;var T=function(t,e){for(var n=e[0],r=1;r<4;r++)n+=e[r];return n}(0,i),F=22204460492503146e-32*p;if(T>=F||-T>=F)return T;if(d=t-(P+(m=t-P))+(m-h),y=l-(I+(m=l-I))+(m-h),g=r-(A+(m=r-A))+(m-f),v=c-(R+(m=c-R))+(m-f),0===d&&0===g&&0===y&&0===v)return T;if(F=11093356479670487e-47*p+33306690738754706e-32*Math.abs(T),(T+=P*v+R*d-(A*y+I*g))>=F||-T>=F)return T;m=(k=(w=d-(b=(_=e*d)-(_-d)))*(O=R-(x=(_=e*R)-(_-R)))-((C=d*R)-b*x-w*x-b*O))-(E=k-(j=(w=g-(b=(_=e*g)-(_-g)))*(O=I-(x=(_=e*I)-(_-I)))-((N=g*I)-b*x-w*x-b*O))),u[0]=k-(E+m)+(m-j),m=(M=C-((S=C+E)-(m=S-C))+(E-m))-(E=M-N),u[1]=M-(E+m)+(m-N),m=(L=S+E)-S,u[2]=S-(L-m)+(E-m),u[3]=L;var D=n(4,i,4,u,o);m=(k=(w=P-(b=(_=e*P)-(_-P)))*(O=v-(x=(_=e*v)-(_-v)))-((C=P*v)-b*x-w*x-b*O))-(E=k-(j=(w=A-(b=(_=e*A)-(_-A)))*(O=y-(x=(_=e*y)-(_-y)))-((N=A*y)-b*x-w*x-b*O))),u[0]=k-(E+m)+(m-j),m=(M=C-((S=C+E)-(m=S-C))+(E-m))-(E=M-N),u[1]=M-(E+m)+(m-N),m=(L=S+E)-S,u[2]=S-(L-m)+(E-m),u[3]=L;var B=n(D,o,4,u,a);m=(k=(w=d-(b=(_=e*d)-(_-d)))*(O=v-(x=(_=e*v)-(_-v)))-((C=d*v)-b*x-w*x-b*O))-(E=k-(j=(w=g-(b=(_=e*g)-(_-g)))*(O=y-(x=(_=e*y)-(_-y)))-((N=g*y)-b*x-w*x-b*O))),u[0]=k-(E+m)+(m-j),m=(M=C-((S=C+E)-(m=S-C))+(E-m))-(E=M-N),u[1]=M-(E+m)+(m-N),m=(L=S+E)-S,u[2]=S-(L-m)+(E-m),u[3]=L;var G=n(B,a,4,u,s);return s[G-1]}(t,r,l,c,h,f,y)},t.orient2dfast=function(t,e,n,r,i,o){return(e-o)*(n-i)-(t-i)*(r-o)},Object.defineProperty(t,"__esModule",{value:!0})}(e)}(0,oi.exports);var ai=Jr,si=ti,ui=ii,li=oi.exports.orient2d;function ci(t,e,n){e=Math.max(0,void 0===e?2:e),n=n||0;var r=function(t){for(var e=t[0],n=t[0],r=t[0],i=t[0],o=0;or[0]&&(r=a),a[1]i[1]&&(i=a)}var s=[e,n,r,i],u=s.slice();for(o=0;o=2&&yi(e[e.length-2],e[e.length-1],t[n])<=0;)e.pop();e.push(t[n])}for(var r=[],i=t.length-1;i>=0;i--){for(;r.length>=2&&yi(r[r.length-2],r[r.length-1],t[i])<=0;)r.pop();r.push(t[i])}return r.pop(),e.pop(),e.concat(r)}(u)}(t),i=new ai(16);i.toBBox=function(t){return{minX:t[0],minY:t[1],maxX:t[0],maxY:t[1]}},i.compareMinX=function(t,e){return t[0]-e[0]},i.compareMinY=function(t,e){return t[1]-e[1]},i.load(t);for(var o,a=[],s=0;so||s.push({node:c,dist:h})}for(;s.length&&!s.peek().node.children;){var f=s.pop(),p=f.node,d=bi(p,e,n),g=bi(p,r,i);if(f.dist=e.minX&&t[0]<=e.maxX&&t[1]>=e.minY&&t[1]<=e.maxY}function gi(t,e,n){for(var r,i,o,a,s=Math.min(t[0],e[0]),u=Math.min(t[1],e[1]),l=Math.max(t[0],e[0]),c=Math.max(t[1],e[1]),h=n.search({minX:s,minY:u,maxX:l,maxY:c}),f=0;f0!=yi(r,i,a)>0&&yi(o,a,r)>0!=yi(o,a,i)>0)return!1;return!0}function yi(t,e,n){return li(t[0],t[1],e[0],e[1],n[0],n[1])}function vi(t){var e=t.p,n=t.next.p;return t.minX=Math.min(e[0],n[0]),t.minY=Math.min(e[1],n[1]),t.maxX=Math.max(e[0],n[0]),t.maxY=Math.max(e[1],n[1]),t}function mi(t,e){var n={p:t,prev:null,next:null,minX:0,minY:0,maxX:0,maxY:0};return e?(n.next=e.next,n.prev=e,e.next.prev=n,e.next=n):(n.prev=n,n.next=n),n}function _i(t,e){var n=t[0]-e[0],r=t[1]-e[1];return n*n+r*r}function bi(t,e,n){var r=e[0],i=e[1],o=n[0]-r,a=n[1]-i;if(0!==o||0!==a){var s=((t[0]-r)*o+(t[1]-i)*a)/(o*o+a*a);s>1?(r=n[0],i=n[1]):s>0&&(r+=o*s,i+=a*s)}return(o=t[0]-r)*o+(a=t[1]-i)*a}function wi(t,e,n,r,i,o,a,s){var u,l,c,h,f=n-t,p=r-e,d=a-i,g=s-o,y=t-i,v=e-o,m=f*f+p*p,_=f*d+p*g,b=d*d+g*g,w=f*y+p*v,x=d*y+g*v,O=m*b-_*_,E=O,S=O;0===O?(l=0,E=1,h=x,S=b):(h=m*x-_*w,(l=_*x-b*w)<0?(l=0,h=x,S=b):l>E&&(l=E,h=x+_,S=b)),h<0?(h=0,-w<0?l=0:-w>m?l=E:(l=-w,E=m)):h>S&&(h=S,-w+_<0?l=0:-w+_>m?l=E:(l=-w+_,E=m));var M=(1-(c=0===h?0:h/S))*i+c*a-((1-(u=0===l?0:l/E))*t+u*n),C=(1-c)*o+c*s-((1-u)*e+u*r);return M*M+C*C}function xi(t,e){return t[0]===e[0]?t[1]-e[1]:t[0]-e[0]}si.default&&(si=si.default),Kr.exports=ci,Kr.exports.default=ci;var Oi=nn(Kr.exports);function Ei(t){var e=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{};e.concavity=e.concavity||1/0;var n=[];if(ot(t,(function(t){n.push([t[0],t[1]])})),!n.length)return null;var r=Oi(n,e.concavity);return r.length>3?w([r]):null}function Si(t,e){for(var n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},r=n.steps||64,i=n.properties?n.properties:!Array.isArray(t)&&"Feature"===t.type&&t.properties?t.properties:{},o=[],a=0;a0;r.length0;){var s=t[Math.floor(Math.random()*o)],u=a?s.join("_"):""+s;n[u]||(n[u]=!0,r.push(s))}if(r.length0,a=t[Math.floor(Math.random()*i)];for(o&&a.join("_"),r.push(a);r.length