UNPKG

@placemarkio/turf-jsts

Version:

A JavaScript library of spatial predicates and functions for processing geometry

1 lines 229 kB
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):(t="undefined"!=typeof globalThis?globalThis:t||self).jsts=e()}(this,(function(){"use strict";class t{constructor(){t.constructor_.apply(this,arguments)}static constructor_(){if(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS,this._endCapStyle=t.CAP_ROUND,this._joinStyle=t.JOIN_ROUND,this._mitreLimit=t.DEFAULT_MITRE_LIMIT,this._isSingleSided=!1,this._simplifyFactor=t.DEFAULT_SIMPLIFY_FACTOR,0===arguments.length);else if(1===arguments.length){const t=arguments[0];this.setQuadrantSegments(t)}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.setQuadrantSegments(t),this.setEndCapStyle(e)}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],i=arguments[3];this.setQuadrantSegments(t),this.setEndCapStyle(e),this.setJoinStyle(s),this.setMitreLimit(i)}}static bufferDistanceError(t){const e=Math.PI/2/t;return 1-Math.cos(e/2)}getEndCapStyle(){return this._endCapStyle}isSingleSided(){return this._isSingleSided}setQuadrantSegments(e){this._quadrantSegments=e,0===this._quadrantSegments&&(this._joinStyle=t.JOIN_BEVEL),this._quadrantSegments<0&&(this._joinStyle=t.JOIN_MITRE,this._mitreLimit=Math.abs(this._quadrantSegments)),e<=0&&(this._quadrantSegments=1),this._joinStyle!==t.JOIN_ROUND&&(this._quadrantSegments=t.DEFAULT_QUADRANT_SEGMENTS)}getJoinStyle(){return this._joinStyle}setJoinStyle(t){this._joinStyle=t}setSimplifyFactor(t){this._simplifyFactor=t<0?0:t}getSimplifyFactor(){return this._simplifyFactor}getQuadrantSegments(){return this._quadrantSegments}setEndCapStyle(t){this._endCapStyle=t}getMitreLimit(){return this._mitreLimit}setMitreLimit(t){this._mitreLimit=t}setSingleSided(t){this._isSingleSided=t}}t.CAP_ROUND=1,t.CAP_FLAT=2,t.CAP_SQUARE=3,t.JOIN_ROUND=1,t.JOIN_MITRE=2,t.JOIN_BEVEL=3,t.DEFAULT_QUADRANT_SEGMENTS=8,t.DEFAULT_MITRE_LIMIT=5,t.DEFAULT_SIMPLIFY_FACTOR=.01;class e extends Error{constructor(t){super(t),this.name=Object.keys({Exception:e})[0]}toString(){return this.message}}class s extends e{constructor(t){super(t),this.name=Object.keys({IllegalArgumentException:s})[0]}}class i{filter(t){}}function n(){}function r(){}function o(){}class l{static equalsWithTolerance(t,e,s){return Math.abs(t-e)<=s}}class a{constructor(t,e){this.low=e||0,this.high=t||0}static toBinaryString(t){let e,s="";for(e=2147483648;e>0;e>>>=1)s+=(t.high&e)===e?"1":"0";for(e=2147483648;e>0;e>>>=1)s+=(t.low&e)===e?"1":"0";return s}}function h(){}function c(){}h.NaN=NaN,h.isNaN=t=>Number.isNaN(t),h.isInfinite=t=>!Number.isFinite(t),h.MAX_VALUE=Number.MAX_VALUE,h.POSITIVE_INFINITY=Number.POSITIVE_INFINITY,h.NEGATIVE_INFINITY=Number.NEGATIVE_INFINITY,"function"==typeof Float64Array&&"function"==typeof Int32Array?function(){const t=2146435072,e=new Float64Array(1),s=new Int32Array(e.buffer);h.doubleToLongBits=function(i){e[0]=i;let n=0|s[0],r=0|s[1];return(r&t)===t&&0!=(1048575&r)&&0!==n&&(n=0,r=2146959360),new a(r,n)},h.longBitsToDouble=function(t){return s[0]=t.low,s[1]=t.high,e[0]}}():function(){const t=1023,e=Math.log2,s=Math.floor,i=Math.pow,n=function(){for(let t=53;t>0;t--){const n=i(2,t)-1;if(s(e(n))+1===t)return n}return 0}();h.doubleToLongBits=function(r){let o,l,h,c,u,g,d,_,p;if(r<0||1/r===Number.NEGATIVE_INFINITY?(g=1<<31,r=-r):g=0,0===r)return p=0,_=g,new a(_,p);if(r===1/0)return p=0,_=2146435072|g,new a(_,p);if(r!=r)return p=0,_=2146959360,new a(_,p);if(c=0,p=0,o=s(r),o>1)if(o<=n)c=s(e(o)),c<=20?(p=0,_=o<<20-c&1048575):(h=c-20,l=i(2,h),p=o%l<<32-h,_=o/l&1048575);else for(h=o,p=0;l=h/2,h=s(l),0!==h;)c++,p>>>=1,p|=(1&_)<<31,_>>>=1,l!==h&&(_|=524288);if(d=c+t,u=0===o,o=r-o,c<52&&0!==o)for(h=0;;){if(l=2*o,l>=1?(o=l-1,u?(d--,u=!1):(h<<=1,h|=1,c++)):(o=l,u?0==--d&&(c++,u=!1):(h<<=1,c++)),20===c)_|=h,h=0;else if(52===c){p|=h;break}if(1===l){c<20?_|=h<<20-c:c<52&&(p|=h<<52-c);break}}return _|=d<<20,_|=g,new a(_,p)},h.longBitsToDouble=function(e){let s,n,r,o;const l=e.high,a=e.low,h=l&1<<31?-1:1;for(r=((2146435072&l)>>20)-t,o=0,n=1<<19,s=1;s<=20;s++)l&n&&(o+=i(2,-s)),n>>>=1;for(n=1<<31,s=21;s<=52;s++)a&n&&(o+=i(2,-s)),n>>>=1;if(-1023===r){if(0===o)return 0*h;r=-1022}else{if(1024===r)return 0===o?h/0:NaN;o+=1}return h*o*i(2,r)}}();class u extends e{constructor(t){super(t),this.name=Object.keys({RuntimeException:u})[0]}}class g extends u{constructor(){super(),g.constructor_.apply(this,arguments)}static constructor_(){if(0===arguments.length)u.constructor_.call(this);else if(1===arguments.length){const t=arguments[0];u.constructor_.call(this,t)}}}class d{static shouldNeverReachHere(){if(0===arguments.length)d.shouldNeverReachHere(null);else if(1===arguments.length){const t=arguments[0];throw new g("Should never reach here"+(null!==t?": "+t:""))}}static isTrue(){if(1===arguments.length){const t=arguments[0];d.isTrue(t,null)}else if(2===arguments.length){const t=arguments[1];if(!arguments[0])throw null===t?new g:new g(t)}}static equals(){if(2===arguments.length){const t=arguments[0],e=arguments[1];d.equals(t,e,null)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];if(!e.equals(t))throw new g("Expected "+t+" but encountered "+e+(null!==s?": "+s:""))}}}const _=new ArrayBuffer(8),p=new Float64Array(_),f=new Int32Array(_);class m{constructor(){m.constructor_.apply(this,arguments)}static constructor_(){if(this.x=null,this.y=null,this.z=null,0===arguments.length)m.constructor_.call(this,0,0);else if(1===arguments.length){const t=arguments[0];m.constructor_.call(this,t.x,t.y,t.getZ())}else if(2===arguments.length){const t=arguments[0],e=arguments[1];m.constructor_.call(this,t,e,m.NULL_ORDINATE)}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];this.x=t,this.y=e,this.z=s}}static hashCode(t){return p[0]=t,f[0]^f[1]}getM(){return h.NaN}setOrdinate(t,e){switch(t){case m.X:this.x=e;break;case m.Y:this.y=e;break;case m.Z:this.setZ(e);break;default:throw new s("Invalid ordinate index: "+t)}}equals2D(){if(1===arguments.length){const t=arguments[0];return this.x===t.x&&this.y===t.y}if(2===arguments.length){const t=arguments[0],e=arguments[1];return!!l.equalsWithTolerance(this.x,t.x,e)&&!!l.equalsWithTolerance(this.y,t.y,e)}}setM(t){throw new s("Invalid ordinate index: "+m.M)}getZ(){return this.z}getOrdinate(t){switch(t){case m.X:return this.x;case m.Y:return this.y;case m.Z:return this.getZ()}throw new s("Invalid ordinate index: "+t)}equals3D(t){return this.x===t.x&&this.y===t.y&&(this.getZ()===t.getZ()||h.isNaN(this.getZ())&&h.isNaN(t.getZ()))}equals(t){return t instanceof m&&this.equals2D(t)}equalInZ(t,e){return l.equalsWithTolerance(this.getZ(),t.getZ(),e)}setX(t){this.x=t}compareTo(t){const e=t;return this.x<e.x?-1:this.x>e.x?1:this.y<e.y?-1:this.y>e.y?1:0}getX(){return this.x}setZ(t){this.z=t}clone(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return d.shouldNeverReachHere("this shouldn't happen because this class is Cloneable"),null;throw t}}copy(){return new m(this)}toString(){return"("+this.x+", "+this.y+", "+this.getZ()+")"}distance3D(t){const e=this.x-t.x,s=this.y-t.y,i=this.getZ()-t.getZ();return Math.sqrt(e*e+s*s+i*i)}getY(){return this.y}setY(t){this.y=t}distance(t){const e=this.x-t.x,s=this.y-t.y;return Math.sqrt(e*e+s*s)}hashCode(){let t=17;return t=37*t+m.hashCode(this.x),t=37*t+m.hashCode(this.y),t}setCoordinate(t){this.x=t.x,this.y=t.y,this.z=t.getZ()}get interfaces_(){return[n,r,o]}}class y{constructor(){y.constructor_.apply(this,arguments)}static constructor_(){if(this._dimensionsToTest=2,0===arguments.length)y.constructor_.call(this,2);else if(1===arguments.length){const t=arguments[0];if(2!==t&&3!==t)throw new s("only 2 or 3 dimensions may be specified");this._dimensionsToTest=t}}static compare(t,e){return t<e?-1:t>e?1:h.isNaN(t)?h.isNaN(e)?0:-1:h.isNaN(e)?1:0}compare(t,e){const s=y.compare(t.x,e.x);if(0!==s)return s;const i=y.compare(t.y,e.y);if(0!==i)return i;if(this._dimensionsToTest<=2)return 0;return y.compare(t.getZ(),e.getZ())}get interfaces_(){return[c]}}m.DimensionalComparator=y,m.NULL_ORDINATE=h.NaN,m.X=0,m.Y=1,m.Z=2,m.M=3;class x{constructor(){x.constructor_.apply(this,arguments)}static constructor_(){if(this._minx=null,this._maxx=null,this._miny=null,this._maxy=null,0===arguments.length)this.init();else if(1===arguments.length){if(arguments[0]instanceof m){const t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof x){const t=arguments[0];this.init(t)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.init(t.x,e.x,t.y,e.y)}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],i=arguments[3];this.init(t,e,s,i)}}static intersects(){if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];return s.x>=(t.x<e.x?t.x:e.x)&&s.x<=(t.x>e.x?t.x:e.x)&&s.y>=(t.y<e.y?t.y:e.y)&&s.y<=(t.y>e.y?t.y:e.y)}if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],i=arguments[3];let n=Math.min(s.x,i.x),r=Math.max(s.x,i.x),o=Math.min(t.x,e.x),l=Math.max(t.x,e.x);return!(o>r)&&(!(l<n)&&(n=Math.min(s.y,i.y),r=Math.max(s.y,i.y),o=Math.min(t.y,e.y),l=Math.max(t.y,e.y),!(o>r)&&!(l<n)))}}getArea(){return this.getWidth()*this.getHeight()}equals(t){if(!(t instanceof x))return!1;const e=t;return this.isNull()?e.isNull():this._maxx===e.getMaxX()&&this._maxy===e.getMaxY()&&this._minx===e.getMinX()&&this._miny===e.getMinY()}intersection(t){if(this.isNull()||t.isNull()||!this.intersects(t))return new x;const e=this._minx>t._minx?this._minx:t._minx,s=this._miny>t._miny?this._miny:t._miny,i=this._maxx<t._maxx?this._maxx:t._maxx,n=this._maxy<t._maxy?this._maxy:t._maxy;return new x(e,i,s,n)}isNull(){return this._maxx<this._minx}getMaxX(){return this._maxx}covers(){if(1===arguments.length){if(arguments[0]instanceof m){const t=arguments[0];return this.covers(t.x,t.y)}if(arguments[0]instanceof x){const t=arguments[0];return!this.isNull()&&!t.isNull()&&(t.getMinX()>=this._minx&&t.getMaxX()<=this._maxx&&t.getMinY()>=this._miny&&t.getMaxY()<=this._maxy)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];return!this.isNull()&&(t>=this._minx&&t<=this._maxx&&e>=this._miny&&e<=this._maxy)}}intersects(){if(1===arguments.length){if(arguments[0]instanceof x){const t=arguments[0];return!this.isNull()&&!t.isNull()&&!(t._minx>this._maxx||t._maxx<this._minx||t._miny>this._maxy||t._maxy<this._miny)}if(arguments[0]instanceof m){const t=arguments[0];return this.intersects(t.x,t.y)}}else if(2===arguments.length){if(arguments[0]instanceof m&&arguments[1]instanceof m){const t=arguments[0],e=arguments[1];if(this.isNull())return!1;if((t.x<e.x?t.x:e.x)>this._maxx)return!1;if((t.x>e.x?t.x:e.x)<this._minx)return!1;if((t.y<e.y?t.y:e.y)>this._maxy)return!1;return!((t.y>e.y?t.y:e.y)<this._miny)}if("number"==typeof arguments[0]&&"number"==typeof arguments[1]){const t=arguments[0],e=arguments[1];return!this.isNull()&&!(t>this._maxx||t<this._minx||e>this._maxy||e<this._miny)}}}getMinY(){return this._miny}getDiameter(){if(this.isNull())return 0;const t=this.getWidth(),e=this.getHeight();return Math.sqrt(t*t+e*e)}getMinX(){return this._minx}expandToInclude(){if(1===arguments.length){if(arguments[0]instanceof m){const t=arguments[0];this.expandToInclude(t.x,t.y)}else if(arguments[0]instanceof x){const t=arguments[0];if(t.isNull())return null;this.isNull()?(this._minx=t.getMinX(),this._maxx=t.getMaxX(),this._miny=t.getMinY(),this._maxy=t.getMaxY()):(t._minx<this._minx&&(this._minx=t._minx),t._maxx>this._maxx&&(this._maxx=t._maxx),t._miny<this._miny&&(this._miny=t._miny),t._maxy>this._maxy&&(this._maxy=t._maxy))}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.isNull()?(this._minx=t,this._maxx=t,this._miny=e,this._maxy=e):(t<this._minx&&(this._minx=t),t>this._maxx&&(this._maxx=t),e<this._miny&&(this._miny=e),e>this._maxy&&(this._maxy=e))}}minExtent(){if(this.isNull())return 0;const t=this.getWidth(),e=this.getHeight();return t<e?t:e}getWidth(){return this.isNull()?0:this._maxx-this._minx}compareTo(t){const e=t;return this.isNull()?e.isNull()?0:-1:e.isNull()?1:this._minx<e._minx?-1:this._minx>e._minx?1:this._miny<e._miny?-1:this._miny>e._miny?1:this._maxx<e._maxx?-1:this._maxx>e._maxx?1:this._maxy<e._maxy?-1:this._maxy>e._maxy?1:0}translate(t,e){if(this.isNull())return null;this.init(this.getMinX()+t,this.getMaxX()+t,this.getMinY()+e,this.getMaxY()+e)}copy(){return new x(this)}toString(){return"Env["+this._minx+" : "+this._maxx+", "+this._miny+" : "+this._maxy+"]"}setToNull(){this._minx=0,this._maxx=-1,this._miny=0,this._maxy=-1}disjoint(t){return!(!this.isNull()&&!t.isNull())||(t._minx>this._maxx||t._maxx<this._minx||t._miny>this._maxy||t._maxy<this._miny)}getHeight(){return this.isNull()?0:this._maxy-this._miny}maxExtent(){if(this.isNull())return 0;const t=this.getWidth(),e=this.getHeight();return t>e?t:e}expandBy(){if(1===arguments.length){const t=arguments[0];this.expandBy(t,t)}else if(2===arguments.length){const t=arguments[0],e=arguments[1];if(this.isNull())return null;this._minx-=t,this._maxx+=t,this._miny-=e,this._maxy+=e,(this._minx>this._maxx||this._miny>this._maxy)&&this.setToNull()}}contains(){if(1===arguments.length){if(arguments[0]instanceof x){const t=arguments[0];return this.covers(t)}if(arguments[0]instanceof m){const t=arguments[0];return this.covers(t)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];return this.covers(t,e)}}centre(){return this.isNull()?null:new m((this.getMinX()+this.getMaxX())/2,(this.getMinY()+this.getMaxY())/2)}init(){if(0===arguments.length)this.setToNull();else if(1===arguments.length){if(arguments[0]instanceof m){const t=arguments[0];this.init(t.x,t.x,t.y,t.y)}else if(arguments[0]instanceof x){const t=arguments[0];this._minx=t._minx,this._maxx=t._maxx,this._miny=t._miny,this._maxy=t._maxy}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.init(t.x,e.x,t.y,e.y)}else if(4===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2],i=arguments[3];t<e?(this._minx=t,this._maxx=e):(this._minx=e,this._maxx=t),s<i?(this._miny=s,this._maxy=i):(this._miny=i,this._maxy=s)}}getMaxY(){return this._maxy}distance(t){if(this.intersects(t))return 0;let e=0;this._maxx<t._minx?e=t._minx-this._maxx:this._minx>t._maxx&&(e=this._minx-t._maxx);let s=0;return this._maxy<t._miny?s=t._miny-this._maxy:this._miny>t._maxy&&(s=this._miny-t._maxy),0===e?s:0===s?e:Math.sqrt(e*e+s*s)}hashCode(){let t=17;return t=37*t+m.hashCode(this._minx),t=37*t+m.hashCode(this._maxx),t=37*t+m.hashCode(this._miny),t=37*t+m.hashCode(this._maxy),t}get interfaces_(){return[n,o]}}class I{constructor(){I.constructor_.apply(this,arguments)}isGeometryCollection(){return this.getTypeCode()===I.TYPECODE_GEOMETRYCOLLECTION}getFactory(){return this._factory}getGeometryN(t){return this}getArea(){return 0}isRectangle(){return!1}equalsExact(t){return this===t||this.equalsExact(t,0)}geometryChanged(){this.apply(I.geometryChangedFilter)}geometryChangedAction(){this._envelope=null}equalsNorm(t){return null!==t&&this.norm().equalsExact(t.norm())}getLength(){return 0}getNumGeometries(){return 1}compareTo(){let t;if(1===arguments.length){const e=arguments[0];return t=e,this.getTypeCode()!==t.getTypeCode()?this.getTypeCode()-t.getTypeCode():this.isEmpty()&&t.isEmpty()?0:this.isEmpty()?-1:t.isEmpty()?1:this.compareToSameClass(e)}if(2===arguments.length){const e=arguments[0],s=arguments[1];return t=e,this.getTypeCode()!==t.getTypeCode()?this.getTypeCode()-t.getTypeCode():this.isEmpty()&&t.isEmpty()?0:this.isEmpty()?-1:t.isEmpty()?1:this.compareToSameClass(e,s)}}getUserData(){return this._userData}getSRID(){return this._SRID}getEnvelope(){return this.getFactory().toGeometry(this.getEnvelopeInternal())}checkNotGeometryCollection(t){if(t.getTypeCode()===I.TYPECODE_GEOMETRYCOLLECTION)throw new s("This method does not support GeometryCollection arguments")}equal(t,e,s){return 0===s?t.equals(e):t.distance(e)<=s}norm(){const t=this.copy();return t.normalize(),t}reverse(){const t=this.reverseInternal();return null!=this.envelope&&(t.envelope=this.envelope.copy()),t.setSRID(this.getSRID()),t}copy(){const t=this.copyInternal();return t.envelope=null==this._envelope?null:this._envelope.copy(),t._SRID=this._SRID,t._userData=this._userData,t}getPrecisionModel(){return this._factory.getPrecisionModel()}getEnvelopeInternal(){return null===this._envelope&&(this._envelope=this.computeEnvelopeInternal()),new x(this._envelope)}setSRID(t){this._SRID=t}setUserData(t){this._userData=t}compare(t,e){const s=t.iterator(),i=e.iterator();for(;s.hasNext()&&i.hasNext();){const t=s.next(),e=i.next(),n=t.compareTo(e);if(0!==n)return n}return s.hasNext()?1:i.hasNext()?-1:0}hashCode(){return this.getEnvelopeInternal().hashCode()}isEquivalentClass(t){return this.getClass()===t.getClass()}isGeometryCollectionOrDerived(){return this.getTypeCode()===I.TYPECODE_GEOMETRYCOLLECTION||this.getTypeCode()===I.TYPECODE_MULTIPOINT||this.getTypeCode()===I.TYPECODE_MULTILINESTRING||this.getTypeCode()===I.TYPECODE_MULTIPOLYGON}get interfaces_(){return[r,n,o]}getClass(){return I}static hasNonEmptyElements(t){for(let e=0;e<t.length;e++)if(!t[e].isEmpty())return!0;return!1}static hasNullElements(t){for(let e=0;e<t.length;e++)if(null===t[e])return!0;return!1}}I.constructor_=function(t){t&&(this._envelope=null,this._userData=null,this._factory=t,this._SRID=t.getSRID())},I.TYPECODE_POINT=0,I.TYPECODE_MULTIPOINT=1,I.TYPECODE_LINESTRING=2,I.TYPECODE_LINEARRING=3,I.TYPECODE_MULTILINESTRING=4,I.TYPECODE_POLYGON=5,I.TYPECODE_MULTIPOLYGON=6,I.TYPECODE_GEOMETRYCOLLECTION=7,I.TYPENAME_POINT="Point",I.TYPENAME_MULTIPOINT="MultiPoint",I.TYPENAME_LINESTRING="LineString",I.TYPENAME_LINEARRING="LinearRing",I.TYPENAME_MULTILINESTRING="MultiLineString",I.TYPENAME_POLYGON="Polygon",I.TYPENAME_MULTIPOLYGON="MultiPolygon",I.TYPENAME_GEOMETRYCOLLECTION="GeometryCollection",I.geometryChangedFilter={get interfaces_(){return[i]},filter(t){t.geometryChangedAction()}};class E{static toLocationSymbol(t){switch(t){case E.EXTERIOR:return"e";case E.BOUNDARY:return"b";case E.INTERIOR:return"i";case E.NONE:return"-"}throw new s("Unknown location value: "+t)}}E.INTERIOR=0,E.BOUNDARY=1,E.EXTERIOR=2,E.NONE=-1;class N{add(){}addAll(){}isEmpty(){}iterator(){}size(){}toArray(){}remove(){}}class T extends e{constructor(t){super(t),this.name=Object.keys({NoSuchElementException:T})[0]}}class S extends e{constructor(t){super(t),this.name=Object.keys({UnsupportedOperationException:S})[0]}}class L extends N{contains(){}}class C extends L{constructor(t){super(),this.map=new Map,t instanceof N&&this.addAll(t)}contains(t){const e=t.hashCode?t.hashCode():t;return!!this.map.has(e)}add(t){const e=t.hashCode?t.hashCode():t;return!this.map.has(e)&&!!this.map.set(e,t)}addAll(t){for(const e of t)this.add(e);return!0}remove(){throw new S}size(){return this.map.size}isEmpty(){return 0===this.map.size}toArray(){return Array.from(this.map.values())}iterator(){return new R(this.map)}[Symbol.iterator](){return this.map}}class R{constructor(t){this.iterator=t.values();const{done:e,value:s}=this.iterator.next();this.done=e,this.value=s}next(){if(this.done)throw new T;const t=this.value,{done:e,value:s}=this.iterator.next();return this.done=e,this.value=s,t}hasNext(){return!this.done}remove(){throw new S}}class w{static opposite(t){return t===w.LEFT?w.RIGHT:t===w.RIGHT?w.LEFT:t}}w.ON=0,w.LEFT=1,w.RIGHT=2;class O extends e{constructor(t){super(t),this.name=Object.keys({EmptyStackException:O})[0]}}class M extends e{constructor(t){super(t),this.name=Object.keys({IndexOutOfBoundsException:M})[0]}}class b extends N{get(){}set(){}isEmpty(){}}class A extends b{constructor(){super(),this.array=[]}add(t){return this.array.push(t),!0}get(t){if(t<0||t>=this.size())throw new M;return this.array[t]}push(t){return this.array.push(t),t}pop(){if(0===this.array.length)throw new O;return this.array.pop()}peek(){if(0===this.array.length)throw new O;return this.array[this.array.length-1]}empty(){return 0===this.array.length}isEmpty(){return this.empty()}search(t){return this.array.indexOf(t)}size(){return this.array.length}toArray(){return this.array.slice()}}function P(t,e){return t.interfaces_&&t.interfaces_.indexOf(e)>-1}class D{constructor(t){this.str=t}append(t){this.str+=t}setCharAt(t,e){this.str=this.str.substr(0,t)+e+this.str.substr(t+1)}toString(){return this.str}}class v{constructor(t){this.value=t}intValue(){return this.value}compareTo(t){return this.value<t?-1:this.value>t?1:0}static compare(t,e){return t<e?-1:t>e?1:0}static isNan(t){return Number.isNaN(t)}static valueOf(t){return new v(t)}}class F{static isWhitespace(t){return t<=32&&t>=0||127===t}static toUpperCase(t){return t.toUpperCase()}}class G{constructor(){G.constructor_.apply(this,arguments)}static constructor_(){if(this._hi=0,this._lo=0,0===arguments.length)this.init(0);else if(1===arguments.length){if("number"==typeof arguments[0]){const t=arguments[0];this.init(t)}else if(arguments[0]instanceof G){const t=arguments[0];this.init(t)}else if("string"==typeof arguments[0]){const t=arguments[0];G.constructor_.call(this,G.parse(t))}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this.init(t,e)}}static determinant(){if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const t=arguments[0],e=arguments[1],s=arguments[2],i=arguments[3];return G.determinant(G.valueOf(t),G.valueOf(e),G.valueOf(s),G.valueOf(i))}if(arguments[3]instanceof G&&arguments[2]instanceof G&&arguments[0]instanceof G&&arguments[1]instanceof G){const t=arguments[1],e=arguments[2],s=arguments[3];return arguments[0].multiply(s).selfSubtract(t.multiply(e))}}static sqr(t){return G.valueOf(t).selfMultiply(t)}static valueOf(){if("string"==typeof arguments[0]){const t=arguments[0];return G.parse(t)}if("number"==typeof arguments[0]){return new G(arguments[0])}}static sqrt(t){return G.valueOf(t).sqrt()}static parse(t){let e=0;const s=t.length;for(;F.isWhitespace(t.charAt(e));)e++;let i=!1;if(e<s){const s=t.charAt(e);"-"!==s&&"+"!==s||(e++,"-"===s&&(i=!0))}const n=new G;let r=0,o=0,l=0,a=!1;for(;!(e>=s);){const s=t.charAt(e);if(e++,F.isDigit(s)){const t=s-"0";n.selfMultiply(G.TEN),n.selfAdd(t),r++}else{if("."!==s){if("e"===s||"E"===s){const s=t.substring(e);try{l=v.parseInt(s)}catch(e){throw e instanceof NumberFormatException?new NumberFormatException("Invalid exponent "+s+" in string "+t):e}break}throw new NumberFormatException("Unexpected character '"+s+"' at position "+e+" in string "+t)}o=r,a=!0}}let h=n;a||(o=r);const c=r-o-l;if(0===c)h=n;else if(c>0){const t=G.TEN.pow(c);h=n.divide(t)}else if(c<0){const t=G.TEN.pow(-c);h=n.multiply(t)}return i?h.negate():h}static createNaN(){return new G(h.NaN,h.NaN)}static copy(t){return new G(t)}static magnitude(t){const e=Math.abs(t),s=Math.log(e)/Math.log(10);let i=Math.trunc(Math.floor(s));return 10*Math.pow(10,i)<=e&&(i+=1),i}static stringOfChar(t,e){const s=new D;for(let i=0;i<e;i++)s.append(t);return s.toString()}le(t){return this._hi<t._hi||this._hi===t._hi&&this._lo<=t._lo}extractSignificantDigits(t,e){let s=this.abs(),i=G.magnitude(s._hi);const n=G.TEN.pow(i);s=s.divide(n),s.gt(G.TEN)?(s=s.divide(G.TEN),i+=1):s.lt(G.ONE)&&(s=s.multiply(G.TEN),i-=1);const r=i+1,o=new D,l=G.MAX_PRINT_DIGITS-1;for(let e=0;e<=l;e++){t&&e===r&&o.append(".");const i=Math.trunc(s._hi);if(i<0)break;let n=!1,a=0;i>9?(n=!0,a="9"):a="0"+i,o.append(a),s=s.subtract(G.valueOf(i)).multiply(G.TEN),n&&s.selfAdd(G.TEN);let h=!0;const c=G.magnitude(s._hi);if(c<0&&Math.abs(c)>=l-e&&(h=!1),!h)break}return e[0]=i,o.toString()}sqr(){return this.multiply(this)}doubleValue(){return this._hi+this._lo}subtract(){if(arguments[0]instanceof G){const t=arguments[0];return this.add(t.negate())}if("number"==typeof arguments[0]){const t=arguments[0];return this.add(-t)}}equals(){if(1===arguments.length&&arguments[0]instanceof G){const t=arguments[0];return this._hi===t._hi&&this._lo===t._lo}}isZero(){return 0===this._hi&&0===this._lo}selfSubtract(){if(arguments[0]instanceof G){const t=arguments[0];return this.isNaN()?this:this.selfAdd(-t._hi,-t._lo)}if("number"==typeof arguments[0]){const t=arguments[0];return this.isNaN()?this:this.selfAdd(-t,0)}}getSpecialNumberString(){return this.isZero()?"0.0":this.isNaN()?"NaN ":null}min(t){return this.le(t)?this:t}selfDivide(){if(1===arguments.length){if(arguments[0]instanceof G){const t=arguments[0];return this.selfDivide(t._hi,t._lo)}if("number"==typeof arguments[0]){const t=arguments[0];return this.selfDivide(t,0)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];let s=null,i=null,n=null,r=null,o=null,l=null,a=null,h=null;return o=this._hi/t,l=G.SPLIT*o,s=l-o,h=G.SPLIT*t,s=l-s,i=o-s,n=h-t,a=o*t,n=h-n,r=t-n,h=s*n-a+s*r+i*n+i*r,l=(this._hi-a-h+this._lo-o*e)/t,h=o+l,this._hi=h,this._lo=o-h+l,this}}dump(){return"DD<"+this._hi+", "+this._lo+">"}divide(){if(arguments[0]instanceof G){const t=arguments[0];let e=null,s=null,i=null,n=null,r=null,o=null,l=null,a=null;r=this._hi/t._hi,o=G.SPLIT*r,e=o-r,a=G.SPLIT*t._hi,e=o-e,s=r-e,i=a-t._hi,l=r*t._hi,i=a-i,n=t._hi-i,a=e*i-l+e*n+s*i+s*n,o=(this._hi-l-a+this._lo-r*t._lo)/t._hi,a=r+o;return new G(a,r-a+o)}if("number"==typeof arguments[0]){const t=arguments[0];return h.isNaN(t)?G.createNaN():G.copy(this).selfDivide(t,0)}}ge(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>=t._lo}pow(t){if(0===t)return G.valueOf(1);let e=new G(this),s=G.valueOf(1),i=Math.abs(t);if(i>1)for(;i>0;)i%2==1&&s.selfMultiply(e),i/=2,i>0&&(e=e.sqr());else s=e;return t<0?s.reciprocal():s}ceil(){if(this.isNaN())return G.NaN;const t=Math.ceil(this._hi);let e=0;return t===this._hi&&(e=Math.ceil(this._lo)),new G(t,e)}compareTo(t){const e=t;return this._hi<e._hi?-1:this._hi>e._hi?1:this._lo<e._lo?-1:this._lo>e._lo?1:0}rint(){if(this.isNaN())return this;return this.add(.5).floor()}setValue(){if(arguments[0]instanceof G){const t=arguments[0];return this.init(t),this}if("number"==typeof arguments[0]){const t=arguments[0];return this.init(t),this}}max(t){return this.ge(t)?this:t}sqrt(){if(this.isZero())return G.valueOf(0);if(this.isNegative())return G.NaN;const t=1/Math.sqrt(this._hi),e=this._hi*t,s=G.valueOf(e),i=this.subtract(s.sqr())._hi*(.5*t);return s.add(i)}selfAdd(){if(1===arguments.length){if(arguments[0]instanceof G){const t=arguments[0];return this.selfAdd(t._hi,t._lo)}if("number"==typeof arguments[0]){const t=arguments[0];let e=null,s=null,i=null,n=null,r=null,o=null;return i=this._hi+t,r=i-this._hi,n=i-r,n=t-r+(this._hi-n),o=n+this._lo,e=i+o,s=o+(i-e),this._hi=e+s,this._lo=s+(e-this._hi),this}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];let s=null,i=null,n=null,r=null,o=null,l=null,a=null,h=null;o=this._hi+t,n=this._lo+e,a=o-this._hi,h=n-this._lo,l=o-a,r=n-h,l=t-a+(this._hi-l),r=e-h+(this._lo-r),a=l+n,s=o+a,i=a+(o-s),a=r+i;const c=s+a,u=a+(s-c);return this._hi=c,this._lo=u,this}}selfMultiply(){if(1===arguments.length){if(arguments[0]instanceof G){const t=arguments[0];return this.selfMultiply(t._hi,t._lo)}if("number"==typeof arguments[0]){const t=arguments[0];return this.selfMultiply(t,0)}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];let s=null,i=null,n=null,r=null,o=null,l=null;o=G.SPLIT*this._hi,s=o-this._hi,l=G.SPLIT*t,s=o-s,i=this._hi-s,n=l-t,o=this._hi*t,n=l-n,r=t-n,l=s*n-o+s*r+i*n+i*r+(this._hi*e+this._lo*t);const a=o+l;s=o-a;const h=l+s;return this._hi=a,this._lo=h,this}}selfSqr(){return this.selfMultiply(this)}floor(){if(this.isNaN())return G.NaN;const t=Math.floor(this._hi);let e=0;return t===this._hi&&(e=Math.floor(this._lo)),new G(t,e)}negate(){return this.isNaN()?this:new G(-this._hi,-this._lo)}clone(){try{return null}catch(t){if(t instanceof CloneNotSupportedException)return null;throw t}}multiply(){if(arguments[0]instanceof G){const t=arguments[0];return t.isNaN()?G.createNaN():G.copy(this).selfMultiply(t)}if("number"==typeof arguments[0]){const t=arguments[0];return h.isNaN(t)?G.createNaN():G.copy(this).selfMultiply(t,0)}}isNaN(){return h.isNaN(this._hi)}intValue(){return Math.trunc(this._hi)}toString(){const t=G.magnitude(this._hi);return t>=-3&&t<=20?this.toStandardNotation():this.toSciNotation()}toStandardNotation(){const t=this.getSpecialNumberString();if(null!==t)return t;const e=new Array(1).fill(null),s=this.extractSignificantDigits(!0,e),i=e[0]+1;let n=s;if("."===s.charAt(0))n="0"+s;else if(i<0)n="0."+G.stringOfChar("0",-i)+s;else if(-1===s.indexOf(".")){const t=i-s.length;n=s+G.stringOfChar("0",t)+".0"}return this.isNegative()?"-"+n:n}reciprocal(){let t=null,e=null,s=null,i=null,n=null,r=null,o=null,l=null;n=1/this._hi,r=G.SPLIT*n,t=r-n,l=G.SPLIT*this._hi,t=r-t,e=n-t,s=l-this._hi,o=n*this._hi,s=l-s,i=this._hi-s,l=t*s-o+t*i+e*s+e*i,r=(1-o-l-n*this._lo)/this._hi;const a=n+r;return new G(a,n-a+r)}toSciNotation(){if(this.isZero())return G.SCI_NOT_ZERO;const t=this.getSpecialNumberString();if(null!==t)return t;const e=new Array(1).fill(null),s=this.extractSignificantDigits(!1,e),i=G.SCI_NOT_EXPONENT_CHAR+e[0];if("0"===s.charAt(0))throw new IllegalStateException("Found leading zero: "+s);let n="";s.length>1&&(n=s.substring(1));const r=s.charAt(0)+"."+n;return this.isNegative()?"-"+r+i:r+i}abs(){return this.isNaN()?G.NaN:this.isNegative()?this.negate():new G(this)}isPositive(){return this._hi>0||0===this._hi&&this._lo>0}lt(t){return this._hi<t._hi||this._hi===t._hi&&this._lo<t._lo}add(){if(arguments[0]instanceof G){const t=arguments[0];return G.copy(this).selfAdd(t)}if("number"==typeof arguments[0]){const t=arguments[0];return G.copy(this).selfAdd(t)}}init(){if(1===arguments.length){if("number"==typeof arguments[0]){const t=arguments[0];this._hi=t,this._lo=0}else if(arguments[0]instanceof G){const t=arguments[0];this._hi=t._hi,this._lo=t._lo}}else if(2===arguments.length){const t=arguments[0],e=arguments[1];this._hi=t,this._lo=e}}gt(t){return this._hi>t._hi||this._hi===t._hi&&this._lo>t._lo}isNegative(){return this._hi<0||0===this._hi&&this._lo<0}trunc(){return this.isNaN()?G.NaN:this.isPositive()?this.floor():this.ceil()}signum(){return this._hi>0?1:this._hi<0?-1:this._lo>0?1:this._lo<0?-1:0}get interfaces_(){return[o,n,r]}}G.PI=new G(3.141592653589793,12246467991473532e-32),G.TWO_PI=new G(6.283185307179586,24492935982947064e-32),G.PI_2=new G(1.5707963267948966,6123233995736766e-32),G.E=new G(2.718281828459045,14456468917292502e-32),G.NaN=new G(h.NaN,h.NaN),G.EPS=123259516440783e-46,G.SPLIT=134217729,G.MAX_PRINT_DIGITS=32,G.TEN=G.valueOf(10),G.ONE=G.valueOf(1),G.SCI_NOT_EXPONENT_CHAR="E",G.SCI_NOT_ZERO="0.0E0";class q{static orientationIndex(t,e,s){const i=q.orientationIndexFilter(t,e,s);if(i<=1)return i;const n=G.valueOf(e.x).selfAdd(-t.x),r=G.valueOf(e.y).selfAdd(-t.y),o=G.valueOf(s.x).selfAdd(-e.x),l=G.valueOf(s.y).selfAdd(-e.y);return n.selfMultiply(l).selfSubtract(r.selfMultiply(o)).signum()}static signOfDet2x2(){if(arguments[3]instanceof G&&arguments[2]instanceof G&&arguments[0]instanceof G&&arguments[1]instanceof G){const t=arguments[1],e=arguments[2],s=arguments[3];return arguments[0].multiply(s).selfSubtract(t.multiply(e)).signum()}if("number"==typeof arguments[3]&&"number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const t=arguments[0],e=arguments[1],s=arguments[2],i=arguments[3],n=G.valueOf(t),r=G.valueOf(e),o=G.valueOf(s),l=G.valueOf(i);return n.multiply(l).selfSubtract(r.multiply(o)).signum()}}static intersection(t,e,s,i){const n=new G(t.y).selfSubtract(e.y),r=new G(e.x).selfSubtract(t.x),o=new G(t.x).selfMultiply(e.y).selfSubtract(new G(e.x).selfMultiply(t.y)),l=new G(s.y).selfSubtract(i.y),a=new G(i.x).selfSubtract(s.x),c=new G(s.x).selfMultiply(i.y).selfSubtract(new G(i.x).selfMultiply(s.y)),u=r.multiply(c).selfSubtract(a.multiply(o)),g=l.multiply(o).selfSubtract(n.multiply(c)),d=n.multiply(a).selfSubtract(l.multiply(r)),_=u.selfDivide(d).doubleValue(),p=g.selfDivide(d).doubleValue();return h.isNaN(_)||h.isInfinite(_)||h.isNaN(p)||h.isInfinite(p)?null:new m(_,p)}static orientationIndexFilter(t,e,s){let i=null;const n=(t.x-s.x)*(e.y-s.y),r=(t.y-s.y)*(e.x-s.x),o=n-r;if(n>0){if(r<=0)return q.signum(o);i=n+r}else{if(!(n<0))return q.signum(o);if(r>=0)return q.signum(o);i=-n-r}const l=q.DP_SAFE_EPSILON*i;return o>=l||-o>=l?q.signum(o):2}static signum(t){return t>0?1:t<0?-1:0}}q.DP_SAFE_EPSILON=1e-15;class Y{getM(t){if(this.hasM()){const e=this.getDimension()-this.getMeasures();return this.getOrdinate(t,e)}return h.NaN}setOrdinate(t,e,s){}getZ(t){return this.hasZ()?this.getOrdinate(t,2):h.NaN}size(){}getOrdinate(t,e){}getCoordinate(){}getCoordinateCopy(t){}createCoordinate(){}getDimension(){}hasM(){return this.getMeasures()>0}getX(t){}hasZ(){return this.getDimension()-this.getMeasures()>2}getMeasures(){return 0}expandEnvelope(t){}copy(){}getY(t){}toCoordinateArray(){}get interfaces_(){return[r]}}Y.X=0,Y.Y=1,Y.Z=2,Y.M=3;class z{static index(t,e,s){return q.orientationIndex(t,e,s)}static isCCW(){if(arguments[0]instanceof Array){const t=arguments[0],e=t.length-1;if(e<3)throw new s("Ring has fewer than 4 points, so orientation cannot be determined");let i=t[0],n=0;for(let s=1;s<=e;s++){const e=t[s];e.y>i.y&&(i=e,n=s)}let r=n;do{r-=1,r<0&&(r=e)}while(t[r].equals2D(i)&&r!==n);let o=n;do{o=(o+1)%e}while(t[o].equals2D(i)&&o!==n);const l=t[r],a=t[o];if(l.equals2D(i)||a.equals2D(i)||l.equals2D(a))return!1;const h=z.index(l,i,a);let c=null;return c=0===h?l.x>a.x:h>0,c}if(P(arguments[0],Y)){const t=arguments[0],e=t.size()-1;if(e<3)throw new s("Ring has fewer than 4 points, so orientation cannot be determined");let i=t.getCoordinate(0),n=0;for(let s=1;s<=e;s++){const e=t.getCoordinate(s);e.y>i.y&&(i=e,n=s)}let r=null,o=n;do{o-=1,o<0&&(o=e),r=t.getCoordinate(o)}while(r.equals2D(i)&&o!==n);let l=null,a=n;do{a=(a+1)%e,l=t.getCoordinate(a)}while(l.equals2D(i)&&a!==n);if(r.equals2D(i)||l.equals2D(i)||r.equals2D(l))return!1;const h=z.index(r,i,l);let c=null;return c=0===h?r.x>l.x:h>0,c}}}z.CLOCKWISE=-1,z.RIGHT=z.CLOCKWISE,z.COUNTERCLOCKWISE=1,z.LEFT=z.COUNTERCLOCKWISE,z.COLLINEAR=0,z.STRAIGHT=z.COLLINEAR;class X{constructor(){X.constructor_.apply(this,arguments)}static constructor_(){this._minIndex=-1,this._minCoord=null,this._minDe=null,this._orientedDe=null}getCoordinate(){return this._minCoord}getRightmostSide(t,e){let s=this.getRightmostSideOfSegment(t,e);return s<0&&(s=this.getRightmostSideOfSegment(t,e-1)),s<0&&(this._minCoord=null,this.checkForRightmostCoordinate(t)),s}findRightmostEdgeAtVertex(){const t=this._minDe.getEdge().getCoordinates();d.isTrue(this._minIndex>0&&this._minIndex<t.length,"rightmost point expected to be interior vertex of edge");const e=t[this._minIndex-1],s=t[this._minIndex+1],i=z.index(this._minCoord,s,e);let n=!1;(e.y<this._minCoord.y&&s.y<this._minCoord.y&&i===z.COUNTERCLOCKWISE||e.y>this._minCoord.y&&s.y>this._minCoord.y&&i===z.CLOCKWISE)&&(n=!0),n&&(this._minIndex=this._minIndex-1)}getRightmostSideOfSegment(t,e){const s=t.getEdge().getCoordinates();if(e<0||e+1>=s.length)return-1;if(s[e].y===s[e+1].y)return-1;let i=w.LEFT;return s[e].y<s[e+1].y&&(i=w.RIGHT),i}getEdge(){return this._orientedDe}checkForRightmostCoordinate(t){const e=t.getEdge().getCoordinates();for(let s=0;s<e.length-1;s++)(null===this._minCoord||e[s].x>this._minCoord.x)&&(this._minDe=t,this._minIndex=s,this._minCoord=e[s])}findRightmostEdgeAtNode(){const t=this._minDe.getNode().getEdges();this._minDe=t.getRightmostEdge(),this._minDe.isForward()||(this._minDe=this._minDe.getSym(),this._minIndex=this._minDe.getEdge().getCoordinates().length-1)}findEdge(t){for(let e=t.iterator();e.hasNext();){const t=e.next();t.isForward()&&this.checkForRightmostCoordinate(t)}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)===w.LEFT&&(this._orientedDe=this._minDe.getSym())}}class B extends u{constructor(t,e){super(e?t+" [ "+e+" ]":t),this.pt=e?new m(e):void 0,this.name=Object.keys({TopologyException:B})[0]}getCoordinate(){return this.pt}}class U{constructor(){this.array=[]}addLast(t){this.array.push(t)}removeFirst(){return this.array.shift()}isEmpty(){return 0===this.array.length}}class k extends b{constructor(t){super(),this.array=[],t instanceof N&&this.addAll(t)}get interfaces_(){return[b,N]}ensureCapacity(){}add(t){return 1===arguments.length?this.array.push(t):this.array.splice(arguments[0],0,arguments[1]),!0}clear(){this.array=[]}addAll(t){for(const e of t)this.array.push(e)}set(t,e){const s=this.array[t];return this.array[t]=e,s}iterator(){return new V(this)}get(t){if(t<0||t>=this.size())throw new M;return this.array[t]}isEmpty(){return 0===this.array.length}sort(t){t?this.array.sort(((e,s)=>t.compare(e,s))):this.array.sort()}size(){return this.array.length}toArray(){return this.array.slice()}remove(t){for(let e=0,s=this.array.length;e<s;e++)if(this.array[e]===t)return!!this.array.splice(e,1);return!1}[Symbol.iterator](){return this.array.values()}}class V{constructor(t){this.arrayList=t,this.position=0}next(){if(this.position===this.arrayList.size())throw new T;return this.arrayList.get(this.position++)}hasNext(){return this.position<this.arrayList.size()}set(t){return this.arrayList.set(this.position-1,t)}remove(){this.arrayList.remove(this.arrayList.get(this.position))}}class H{constructor(){H.constructor_.apply(this,arguments)}static constructor_(){this._finder=null,this._dirEdgeList=new k,this._nodes=new k,this._rightMostCoord=null,this._env=null,this._finder=new X}clearVisitedEdges(){for(let t=this._dirEdgeList.iterator();t.hasNext();){t.next().setVisited(!1)}}getRightmostCoordinate(){return this._rightMostCoord}computeNodeDepth(t){let e=null;for(let s=t.getEdges().iterator();s.hasNext();){const t=s.next();if(t.isVisited()||t.getSym().isVisited()){e=t;break}}if(null===e)throw new B("unable to find edge to compute depths at "+t.getCoordinate());t.getEdges().computeDepths(e);for(let e=t.getEdges().iterator();e.hasNext();){const t=e.next();t.setVisited(!0),this.copySymDepths(t)}}computeDepth(t){this.clearVisitedEdges();const e=this._finder.getEdge();e.getNode(),e.getLabel(),e.setEdgeDepths(w.RIGHT,t),this.copySymDepths(e),this.computeDepths(e)}create(t){this.addReachable(t),this._finder.findEdge(this._dirEdgeList),this._rightMostCoord=this._finder.getCoordinate()}findResultEdges(){for(let t=this._dirEdgeList.iterator();t.hasNext();){const e=t.next();e.getDepth(w.RIGHT)>=1&&e.getDepth(w.LEFT)<=0&&!e.isInteriorAreaEdge()&&e.setInResult(!0)}}computeDepths(t){const e=new C,s=new U,i=t.getNode();for(s.addLast(i),e.add(i),t.setVisited(!0);!s.isEmpty();){const t=s.removeFirst();e.add(t),this.computeNodeDepth(t);for(let i=t.getEdges().iterator();i.hasNext();){const t=i.next().getSym();if(t.isVisited())continue;const n=t.getNode();e.contains(n)||(s.addLast(n),e.add(n))}}}compareTo(t){const e=t;return this._rightMostCoord.x<e._rightMostCoord.x?-1:this._rightMostCoord.x>e._rightMostCoord.x?1:0}getEnvelope(){if(null===this._env){const t=new x;for(let e=this._dirEdgeList.iterator();e.hasNext();){const s=e.next().getEdge().getCoordinates();for(let e=0;e<s.length-1;e++)t.expandToInclude(s[e])}this._env=t}return this._env}addReachable(t){const e=new A;for(e.add(t);!e.empty();){const t=e.pop();this.add(t,e)}}copySymDepths(t){const e=t.getSym();e.setDepth(w.LEFT,t.getDepth(w.RIGHT)),e.setDepth(w.RIGHT,t.getDepth(w.LEFT))}add(t,e){t.setVisited(!0),this._nodes.add(t);for(let s=t.getEdges().iterator();s.hasNext();){const t=s.next();this._dirEdgeList.add(t);const i=t.getSym().getNode();i.isVisited()||e.push(i)}}getNodes(){return this._nodes}getDirectedEdges(){return this._dirEdgeList}get interfaces_(){return[n]}}class Z{static intersection(t,e,s,i){const n=t.x<e.x?t.x:e.x,r=t.y<e.y?t.y:e.y,o=t.x>e.x?t.x:e.x,l=t.y>e.y?t.y:e.y,a=s.x<i.x?s.x:i.x,c=s.y<i.y?s.y:i.y,u=s.x>i.x?s.x:i.x,g=s.y>i.y?s.y:i.y,d=((n>a?n:a)+(o<u?o:u))/2,_=((r>c?r:c)+(l<g?l:g))/2,p=t.x-d,f=t.y-_,y=e.x-d,x=e.y-_,I=s.x-d,E=s.y-_,N=i.x-d,T=i.y-_,S=f-x,L=y-p,C=p*x-y*f,R=E-T,w=N-I,O=I*T-N*E,M=S*w-R*L,b=(L*O-w*C)/M,A=(R*C-S*O)/M;return h.isNaN(b)||h.isInfinite(b)||h.isNaN(A)||h.isInfinite(A)?null:new m(b+d,A+_)}}class W{static arraycopy(t,e,s,i,n){let r=0;for(let o=e;o<e+n;o++)s[i+r]=t[o],r++}static getProperty(t){return{"line.separator":"\n"}[t]}}class j{static log10(t){const e=Math.log(t);return h.isInfinite(e)||h.isNaN(e)?e:e/j.LOG_10}static min(t,e,s,i){let n=t;return e<n&&(n=e),s<n&&(n=s),i<n&&(n=i),n}static clamp(){if("number"==typeof arguments[2]&&"number"==typeof arguments[0]&&"number"==typeof arguments[1]){const t=arguments[0],e=arguments[1],s=arguments[2];return t<e?e:t>s?s:t}if(Number.isInteger(arguments[2])&&Number.isInteger(arguments[0])&&Number.isInteger(arguments[1])){const t=arguments[0],e=arguments[1],s=arguments[2];return t<e?e:t>s?s:t}}static wrap(t,e){return t<0?e- -t%e:t%e}static max(){if(3===arguments.length){const t=arguments[1],e=arguments[2];let s=arguments[0];return t>s&&(s=t),e>s&&(s=e),s}if(4===arguments.length){const t=arguments[1],e=arguments[2],s=arguments[3];let i=arguments[0];return t>i&&(i=t),e>i&&(i=e),s>i&&(i=s),i}}static average(t,e){return(t+e)/2}}j.LOG_10=Math.log(10);class K{static segmentToSegment(t,e,s,i){if(t.equals(e))return K.pointToSegment(t,s,i);if(s.equals(i))return K.pointToSegment(i,t,e);let n=!1;if(x.intersects(t,e,s,i)){const r=(e.x-t.x)*(i.y-s.y)-(e.y-t.y)*(i.x-s.x);if(0===r)n=!0;else{const o=(t.y-s.y)*(i.x-s.x)-(t.x-s.x)*(i.y-s.y),l=((t.y-s.y)*(e.x-t.x)-(t.x-s.x)*(e.y-t.y))/r,a=o/r;(a<0||a>1||l<0||l>1)&&(n=!0)}}else n=!0;return n?j.min(K.pointToSegment(t,s,i),K.pointToSegment(e,s,i),K.pointToSegment(s,t,e),K.pointToSegment(i,t,e)):0}static pointToSegment(t,e,s){if(e.x===s.x&&e.y===s.y)return t.distance(e);const i=(s.x-e.x)*(s.x-e.x)+(s.y-e.y)*(s.y-e.y),n=((t.x-e.x)*(s.x-e.x)+(t.y-e.y)*(s.y-e.y))/i;if(n<=0)return t.distance(e);if(n>=1)return t.distance(s);const r=((e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y))/i;return Math.abs(r)*Math.sqrt(i)}static pointToLinePerpendicular(t,e,s){const i=(s.x-e.x)*(s.x-e.x)+(s.y-e.y)*(s.y-e.y),n=((e.y-t.y)*(s.x-e.x)-(e.x-t.x)*(s.y-e.y))/i;return Math.abs(n)*Math.sqrt(i)}static pointToSegmentString(t,e){if(0===e.length)throw new s("Line array must contain at least one vertex");let i=t.distance(e[0]);for(let s=0;s<e.length-1;s++){const n=K.pointToSegment(t,e[s],e[s+1]);n<i&&(i=n)}return i}}class J{create(){if(1===arguments.length)arguments[0]instanceof Array||P(arguments[0],Y);else if(2===arguments.length);else if(3===arguments.length){const t=arguments[0],e=arguments[1];return this.create(t,e)}}}class Q{filter(t){}}class ${}class tt{static copyCoord(t,e,s,i){const n=Math.min(t.getDimension(),s.getDimension());for(let r=0;r<n;r++)s.setOrdinate(i,r,t.getOrdinate(e,r))}static isRing(t){const e=t.size();return 0===e||!(e<=3)&&(t.getOrdinate(0,Y.X)===t.getOrdinate(e-1,Y.X)&&t.getOrdinate(0,Y.Y)===t.getOrdinate(e-1,Y.Y))}static scroll(){if(2===arguments.length){if(P(arguments[0],Y)&&Number.isInteger(arguments[1])){const t=arguments[0],e=arguments[1];tt.scroll(t,e,tt.isRing(t))}else if(P(arguments[0],Y)&&arguments[1]instanceof m){const t=arguments[0],e=arguments[1],s=tt.indexOf(e,t);if(s<=0)return null;tt.scroll(t,s)}}else if(3===arguments.length){const t=arguments[0],e=arguments[1],s=arguments[2];if(e<=0)return null;const i=t.copy(),n=s?t.size()-1:t.size();for(let s=0;s<n;s++)for(let r=0;r<t.getDimension();r++)t.setOrdinate(s,r,i.getOrdinate((e+s)%n,r));if(s)for(let e=0;e<t.getDimension();e++)t.setOrdinate(n,e,t.getOrdinate(0,e))}}static isEqual(t,e){const s=t.size();if(s!==e.size())return!1;const i=Math.min(t.getDimension(),e.getDimension());for(let n=0;n<s;n++)for(let s=0;s<i;s++){const i=t.getOrdinate(n,s),r=e.getOrdinate(n,s);if(t.getOrdinate(n,s)!==e.getOrdinate(n,s)&&(!h.isNaN(i)||!h.isNaN(r)))return!1}return!0}static minCoordinateIndex(){if(1===arguments.length){const t=arguments[0];return tt.minCoordinateIndex(t,0,t.size()-1)}if(3===arguments.length){const t=arguments[0],e=arguments[2];let s=-1,i=null;for(let n=arguments[1];n<=e;n++){const e=t.getCoordinate(n);(null===i||i.compareTo(e)>0)&&(i=e,s=n)}return s}}static extend(t,e,s){const i=t.create(s,e.getDimension()),n=e.size();if(tt.copy(e,0,i,0,n),n>0)for(let t=n;t<s;t++)tt.copy(e,n-1,i,t,1);return i}static reverse(t){const e=t.size()-1,s=Math.trunc(e/2);for(let i=0;i<=s;i++)tt.swap(t,i,e-i)}static swap(t,e,s){if(e===s)return null;for(let i=0;i<t.getDimension();i++){const n=t.getOrdinate(e,i);t.setOrdinate(e,i,t.getOrdinate(s,i)),t.setOrdinate(s,i,n)}}static copy(t,e,s,i,n){for(let r=0;r<n;r++)tt.copyCoord(t,e+r,s,i+r)}static ensureValidRing(t,e){const s=e.size();if(0===s)return e;if(s<=3)return tt.createClosedRing(t,e,4);return e.getOrdinate(0,Y.X)===e.getOrdinate(s-1,Y.X)&&e.getOrdinate(0,Y.Y)===e.getOrdinate(s-1,Y.Y)?e:tt.createClosedRing(t,e,s+1)}static indexOf(t,e){for(let s=0;s<e.size();s++)if(t.x===e.getOrdinate(s,Y.X)&&t.y===e.getOrdinate(s,Y.Y))return s;return-1}static createClosedRing(t,e,s){const i=t.create(s,e.getDimension()),n=e.size();tt.copy(e,0,i,0,n);for(let t=n;t<s;t++)tt.copy(e,0,i,t,1);return i}static minCoordinate(t){let e=null;for(let s=0;s<t.size();s++){const i=t.getCoordinate(s);(null===e||e.compareTo(i)>0)&&(e=i)}return e}}class et{static toDimensionSymbol(t){switch(t){case et.FALSE:return et.SYM_FALSE;case et.TRUE:return et.SYM_TRUE;case et.DONTCARE:return et.SYM_DONTCARE;case et.P:return et.SYM_P;case et.L:return et.SYM_L;case et.A:return et.SYM_A}throw new s("Unknown dimension value: "+t)}static toDimensionValue(t){switch(F.toUpperCase(t)){case et.SYM_FALSE:return et.FALSE;case et.SYM_TRUE:return et.TRUE;case et.SYM_DONTCARE:return et.DONTCARE;case et.SYM_P:return et.P;case et.SYM_L:return et.L;case et.SYM_A:return et.A}throw new s("Unknown dimension symbol: "+t)}}et.P=0,et.L=1,et.A=2,et.FALSE=-1,et.TRUE=-2,et.DONTCARE=-3,et.SYM_FALSE="F",et.SYM_TRUE="T",et.SYM_DONTCARE="*",et.SYM_P="0",et.SYM_L="1",et.SYM_A="2";class st{filter(t){}}class it{filter(t,e){}isDone(){}isGeometryChanged(){}}class nt extends I{constructor(){super(),nt.constructor_.apply(this,arguments)}static constructor_(){if(this._points=null,0===arguments.length);else if(2===arguments.length){const t=arguments[0],e=arguments[1];I.constructor_.call(this,e),this.init(t)}}computeEnvelopeInternal(){return this.isEmpty()?new x:this._points.expandEnvelope(new x)}isRing(){return this.isClosed()&&this.isSimple()}getCoordinates(){return this._points.toCoordinateArray()}copyInternal(){return new nt(this._points.copy(),this._factory)}equalsExact(){if(2===arguments.length&&"number"==typeof arguments[1]&&arguments[0]instanceof I){const t=arguments[0],e=arguments[1];if(!this.isEquivalentClass(t))return!1;const s=t;if(this._points.size()!==s._points.size())return!1;for(let t=0;t<this._points.size();t++)if(!this.equal(this._points.getCoordinate(t),s._points.getCoordinate(t),e))return!1;return!0}return super.equalsExact.apply(this,arguments)}normalize(){for(let t=0;t<Math.trunc(this._points.size()/2);t++){const e=this._points.size()-1-t;if(!this._points.getCoordinate(t).equals(this._points.getCoordinate(e))){if(this._points.getCoordinate(t).compareTo(this._points.getCoordinate(e))>0){const t=this._points.copy();tt.reverse(t),this._points=t}return null}}}getCoordinate(){return this.isEmpty()?null:this._points.getCoordinate(0)}getBoundaryDimension(){return this.isClosed()?et.FALSE:0}isClosed(){return!this.isEmpty()&&this.getCoordinateN(0).equals2D(this.getCoordinateN(this.getNumPoints()-1))}reverseInternal(){const t=this._points.copy();return tt.reverse(t),this.getFactory().createLineString(t)}getEndPoint(){return this.isEmpty()?null:this.getPointN(this.getNumPoints()-1)}getTypeCode(){return I.TYPECODE_LINESTRING}getDimension(){return 1}getLength(){return class{static ofLine(t){const e=t.size();if(e<=1)return 0;let s=0;const i=new m;t.getCoordinate(0,i);let n=i.x,r=i.y;for(let o=1;o<e;o++){t.getCoordinate(o,i);const e=i.x,l=i.y,a=e-n,h=l-r;s+=Math.sqrt(a*a+h*h),n=e,r=l}return s}}.ofLine(this._points)}getNumPoints(){return this._points.size()}compareToSameClass(){if(1===arguments.length){const t=arguments[0];let e=0,s=0;for(;e<this._points.size()&&s<t._points.size();){const i=this._points.getCoordinate(e).compareTo(t._points.getCoordinate(s));if(0!==i)return i;e++,s++}return e<this._points.size()?1:s<t._points.size()?-1:0}if(2===arguments.length){const t=arguments[0];return arguments[1].compare(this._points,t._points)}}apply(){if(P(arguments[0],Q)){const t=arguments[0];for(let e=0;e<this._points.size();e++)t.filter(this._points.getCoordinate(e))}else if(P(arguments[0],it)){const t=arguments[0];if(0===this._points.size())return null;for(let e=0;e<this._points.size()&&(t.filter(this._points,e),!t.isDone());e++);t.isGeometryChanged()&&this.geometryChanged()}else if(P(arguments[0],st)){arguments[0].filter(this)}else if(P(arguments[0],i)){arguments[0].filter(this)}}getBoundary(){throw new S}isEquivalentClass(t){return t instanceof nt}getCoordinateN(t){return this._points.getCoordinate(t)}getGeometryType(){return I.TYPENAME_LINESTRING}getCoordinateSequence(){return this._points}isEmpty(){return 0===this._points.size()}init(t){if(null===t&&(t=this.getFactory().getCoordinateSequenceFactory().create([])),1===t.size())throw new s("Invalid number of points in LineString (found "+t.size()+" - must be 0 or >= 2)");this._points=t}isCoordinate(t){for(let e=0;e<this._points.size();e++)if(this._points.getCoordinate(e).equals(t))return!0;return!1}getStartPoint(){return this.isEmpty()?null:this.getPointN(0)}getPointN(t){return this.getFactory().createPoint(this._points.getCoordinate(t))}get interfaces_(){return[$]}}class rt{}class ot extends I{constructor(){super(),ot.constructor_.apply(this,arguments)}static constructor_(){this._coordinates=null;const t=arguments[0],e=arguments[1];I.constructor_.call(this,e),this.init(t)}computeEnvelopeInternal(){if(this.isEmpty())return new x;const t=new x;return t.e