@wootapa/polygraph-ol
Version:
Extension of @wootapa/polygraph for OpenLayers 7+.
2 lines • 50.8 kB
JavaScript
/*! @wootapa/polygraph-ol v1.0.8 | author:Andreas Petersson | license:MIT */
import t from"rbush";import{Feature as e}from"ol";import{getCenter as r}from"ol/extent";import n from"ol/format/GeoJSON";import o from"ol/format/GML3";import i from"ol/format/WKT";import a from"ol/geom/Circle";import s from"ol/geom/Geometry";import u from"ol/geom/LineString";import c from"ol/geom/MultiLineString";import l from"ol/geom/MultiPoint";import f from"ol/geom/MultiPolygon";import p from"ol/geom/Point";import h,{fromExtent as g,circular as y,fromCircle as d}from"ol/geom/Polygon";import{toLonLat as m,get as v}from"ol/proj";var _=function(t,e){return _=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&(t[r]=e[r])},_(t,e)};function w(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Class extends value "+String(e)+" is not a constructor or null");function r(){this.constructor=t}_(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var b=function(){return b=Object.assign||function(t){for(var e,r=1,n=arguments.length;r<n;r++)for(var o in e=arguments[r])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t},b.apply(this,arguments)};const P={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var E=class{constructor(t){this.code_=t.code,this.units_=t.units,this.extent_=void 0!==t.extent?t.extent:null,this.worldExtent_=void 0!==t.worldExtent?t.worldExtent:null,this.axisOrientation_=void 0!==t.axisOrientation?t.axisOrientation:"enu",this.global_=void 0!==t.global&&t.global,this.canWrapX_=!(!this.global_||!this.extent_),this.getPointResolutionFunc_=t.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=t.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||P[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(t){this.global_=t,this.canWrapX_=!(!t||!this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(t){this.defaultTileGrid_=t}setExtent(t){this.extent_=t,this.canWrapX_=!(!this.global_||!t)}setWorldExtent(t){this.worldExtent_=t}setGetPointResolution(func){this.getPointResolutionFunc_=func}getPointResolutionFunc(){return this.getPointResolutionFunc_}},O="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},x={exports:{}};(function(){var t,e,r,n,o,i;"undefined"!=typeof performance&&null!==performance&&performance.now?x.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(x.exports=function(){return(t()-o)/1e6},e=process.hrtime,n=(t=function(){var t;return 1e9*(t=e())[0]+t[1]})(),i=1e9*process.uptime(),o=n-i):Date.now?(x.exports=function(){return Date.now()-r},r=Date.now()):(x.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(O);var C,S=function(){function t(){}return t.resolveObjectValue=function(key,obj){var value=obj instanceof Function?t.resolveObjectValue(key,obj.apply(obj,[key])):obj instanceof Object?t.getDictValue(obj,key):obj;return value instanceof Function?t.resolveObjectValue(key,value.apply(value,[key])):value},t.resolveOperatorValue=function(value){return value instanceof Function?t.resolveOperatorValue(value.apply(value)):value},t.classOf=function(t){return t.constructor},t.getDictValue=function(obj,key){if(key in obj)return obj[key];var value=key.split(".").reduce((function(obj,t){return obj[t]||{}}),obj);return value instanceof Object&&0===Object.keys(value).length?void 0:value},t}(),A=function(){function t(t){this._id=t,this._start=0,this._duration=0,this._truths=0,this._falses=0}return t.prototype.start=function(){return this._start=x.exports(),this},t.prototype.stop=function(t){return this._duration+=x.exports()-this._start,t?this._truths++:this._falses++,this.getReport()},t.prototype.reset=function(){return this._truths=0,this._falses=0,this._duration=0,this},t.prototype.getReport=function(){return{id:this._id,duration:this._duration,truths:this._truths,falses:this._falses}},t}(),j=function(){function t(key,value){this._key=key,this._value=S.resolveOperatorValue(value)}return Object.defineProperty(t.prototype,"key",{get:function(){return this._key},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"value",{get:function(){return this._value},enumerable:!1,configurable:!0}),t}(),M=function(t){function e(key,value,opts){var e,r=this;return(r=t.call(this,key,value)||this)._opts=opts,(null===(e=r._opts)||void 0===e?void 0:e.isDate)&&(r._value,1)&&(r._value=new Date(Date.parse(r._value))),r._opts=b({isDate:r._value instanceof Date},opts),r._reporter=new A("".concat(r.getAlias(),":").concat(r.key)),r}return w(e,t),Object.defineProperty(e.prototype,"opts",{get:function(){return this._opts},enumerable:!1,configurable:!0}),e.prototype.getAlias=function(){return this.constructor.alias},e.prototype.getReport=function(){return this._reporter.getReport()},e.prototype.resetReport=function(){this._reporter.reset()},e.prototype.asJson=function(){return{type:this.getAlias(),ctorArgs:[this._key,this._value,this._opts]}},e.prototype.evaluate=function(obj){var t=S.resolveObjectValue(this._key,obj);this._reporter.start();var e=!1;return this instanceof k?e=t===this._value:this instanceof G?e=null==t:this instanceof T?e=t>this._value:this instanceof R?e=t>=this._value:this instanceof L?e=t<this._value:this instanceof F?e=t<=this._value:this instanceof N&&(e=this._valueRe.test(null==t?void 0:t.toString())),this._reporter.stop(e),e},e}(j),k=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="eq",e}(M),G=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="isnull",e}(M),T=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="gt",e}(M),R=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="gte",e}(M),L=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="lt",e}(M),F=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="lte",e}(M),N=function(t){function e(key,value,opts){var e=t.call(this,key,value,b({matchCase:!0,wildCard:"*"},opts))||this,r=e._value.toString().replace(/[-[\]/{}()+.\\^$|]/g,"\\$&").replace(new RegExp("\\".concat(e.opts.wildCard),"g"),".*").replace(/\?/g,"."),n=e.opts.matchCase?"":"i";return e._valueRe=new RegExp(r,n),e}return w(e,t),Object.defineProperty(e.prototype,"opts",{get:function(){return this._opts},enumerable:!1,configurable:!0}),e.alias="like",e}(M),I=function(t){function e(key,value,opts){return t.call(this,key,value,b(b({},opts),{matchCase:!1}))||this}return w(e,t),e.alias="ilike",e}(N),D=function(alias,func){this.alias=alias,this.func=func},q=function(t){function e(key,e){var r=t.call(this,key,"(custom operator)")||this;return r._def=e,r._reporter=new A("".concat(r.getAlias(),":").concat(r.key)),r}return w(e,t),e.fromJson=function(json,t){var r=json.ctorArgs,key=r[0],n=r[1];if(!(json.type in t)){var func=new Function("return ".concat(n))();t[json.type]=new D(json.type,func)}return new e(key,t[json.type])},e.prototype.getAlias=function(){return this._def.alias},e.prototype.getReport=function(){return this._reporter.getReport()},e.prototype.resetReport=function(){this._reporter.reset()},e.prototype.asJson=function(){return{isRuntime:!0,type:this.getAlias(),ctorArgs:[this.key,this._def.func.toString()]}},e.prototype.evaluate=function(obj){var t=S.resolveObjectValue(this.key,obj);this._reporter.start();var e=!!this._def.func.apply(this._def.func,[t]);return this._reporter.stop(e),e},e}(j),J=function(){function t(t){this._parent=t,this._operators=[],this._reporter=new A("".concat(this.getAlias()))}return t.fromJson=function(json,e,r){var n=new e[json.type](r);return json.operators.forEach((function(r){if(r.isLogical)return n.add(t.fromJson(r,e,n));if(r.isRuntime)return n.add(q.fromJson(r,e));var o=e[r.type];n.add(new(o.bind.apply(o,function(t,e,r){if(r||2===arguments.length)for(var n,o=0,i=e.length;o<i;o++)!n&&o in e||(n||(n=Array.prototype.slice.call(e,0,o)),n[o]=e[o]);return t.concat(n||Array.prototype.slice.call(e))}([void 0],r.ctorArgs,!1))))})),n},t.prototype.getParent=function(){return this._parent},t.prototype.getOperators=function(){return this._operators},t.prototype.getOperatorsTree=function(){var e=[],r=function(n){n.getOperators().forEach((function(n){e.push(n),n instanceof t&&r(n)}))};return r(this),e},t.prototype.add=function(t){return this._operators.push(t),t},t.prototype.clear=function(){this._operators=[]},t.prototype.getAlias=function(){return this.constructor.alias},t.prototype.getReport=function(){return this._reporter.getReport()},t.prototype.resetReport=function(){this._reporter.reset()},t.prototype.asJson=function(){return{type:this.getAlias(),isLogical:!0,operators:this.getOperators().map((function(t){return t.asJson()}))}},t.prototype.evaluate=function(obj){var t=!0;return this._reporter.start(),this._operators.length>0&&(this instanceof W?t=this._operators.every((function(t){return t.evaluate(obj)})):this instanceof V?t=this._operators.some((function(t){return t.evaluate(obj)})):this instanceof U&&(t=this._operators.every((function(t){return!t.evaluate(obj)})))),this._reporter.stop(t),t},t}(),W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="and",e}(J),V=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="or",e}(J),U=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="not",e}(J),X=((C={})[W.alias]=W,C[V.alias]=V,C[U.alias]=U,C[k.alias]=k,C[G.alias]=G,C[T.alias]=T,C[R.alias]=R,C[L.alias]=L,C[F.alias]=F,C[N.alias]=N,C[I.alias]=I,C),Y=function(){function t(){this._this=this._getPolygraph(),this._logical=new W(this._this),X=b(b({},X),this._this._getClassDict())}return t.fromJson=function(json){var t="string"==typeof json?JSON.parse(json):json,e=new this;return e._setConfiguration(t.polygraphOpts),e._logical=J.fromJson(t,X,e),e},t.and=function(){var t=new this;return t._logical=new W(t),t},t.or=function(){var t=new this;return t._logical=new V(t),t},t.not=function(){var t=new this;return t._logical=new U(t),t},t.define=function(alias,func){if(alias in X)throw new Error("Operator:".concat(alias," already defined"));X[alias]=new D(alias,func)},t.getOperatorAlias=function(){return Object.keys(X).sort()},t.prototype.asJson=function(){return b(b({},this._logical.asJson()),{polygraphOpts:this._getConfiguration()})},t.prototype.asTree=function(){var t=function(e,r){var n;if(void 0===r&&(r=0),e instanceof J)return"".concat("#".repeat(r)).concat(e.getAlias(),"↘\n ").concat(e.getOperators().map((function(n){return t(n,r+e.getAlias().length)})).join("\n"));var o=e;return"".concat("#".repeat(r)).concat(o.key," ").concat(e.getAlias()," ").concat(null!==(n=o.value)&&void 0!==n?n:"")};return t(this._logical).split("\n").map((function(t){return t.trim().replace(new RegExp("#","g")," ")})).join("\n")},t.prototype.getReport=function(){var t=this._logical.getReport(),e={duration:t.duration,truths:t.truths,falses:t.falses,details:[t]};return this._logical.getOperatorsTree().forEach((function(t){var r=t.getReport();e.duration+=r.duration,e.truths+=r.truths,e.falses+=r.falses,e.details.push(r)})),e},t.prototype.resetReport=function(){return this._logical.resetReport(),this._logical.getOperatorsTree().forEach((function(t){return t.resetReport()})),this._this},t.prototype.evaluate=function(obj){return this._logical.evaluate(obj)},t.prototype.clear=function(){return this._logical.clear(),this._this},t.prototype.done=function(){for(;this._logical.getParent()!==this._this;)this.up();return this._this},t.prototype.up=function(){return this._logical.getParent()===this._this||(this._logical=this._logical.getParent()),this._this},t.prototype.down=function(){var t=this._logical.getOperators().find((function(t){return t instanceof J}));return t&&(this._logical=t),this._this},t.prototype.next=function(){var t=this._logical.getParent();if(t instanceof J){var e=t.getOperators().filter((function(t){return t instanceof J})),r=e.indexOf(this._logical);r<e.length-1&&(this._logical=e[r+1])}return this._this},t.prototype.prev=function(){var t=this._logical.getParent();if(t instanceof J){var e=t.getOperators().filter((function(t){return t instanceof J})),r=e.indexOf(this._logical);r>0&&(this._logical=e[r-1])}return this._this},t.prototype.clone=function(){return S.classOf(this._this).fromJson(this._this.asJson())},t.prototype.addPolygraph=function(t){return this._logical.add(t._logical),this._this},t.prototype.getKeysAndValues=function(){var t={},e=function(r){r.forEach((function(r){if(r instanceof J)return e(r.getOperators());var n=r;t[n.key]=t[n.key]?Array.isArray(t[n.key])?t[n.key].concat(n.value):[t[n.key],n.value]:n.value}))};return e(this._logical.getOperators()),t},t.prototype.and=function(){return this._logical=this._logical.add(new W(this._logical)),this._this},t.prototype.or=function(){return this._logical=this._logical.add(new V(this._logical)),this._this},t.prototype.not=function(){return this._logical=this._logical.add(new U(this._logical)),this._this},t.prototype.equals=function(key,value){return this._logical.add(new k(key,value)),this._this},t.prototype.eq=function(key,value){return this.equals(key,value)},t.prototype.isNull=function(key){return this._logical.add(new G(key,null)),this._this},t.prototype.greaterThan=function(key,value){return this._logical.add(new T(key,value)),this._this},t.prototype.gt=function(key,value){return this.greaterThan(key,value)},t.prototype.greaterThanEquals=function(key,value){return this._logical.add(new R(key,value)),this._this},t.prototype.gte=function(key,value){return this.greaterThanEquals(key,value)},t.prototype.lessThan=function(key,value){return this._logical.add(new L(key,value)),this._this},t.prototype.lt=function(key,value){return this.lessThan(key,value)},t.prototype.lessThanEquals=function(key,value){return this._logical.add(new F(key,value)),this._this},t.prototype.lte=function(key,value){return this.lessThanEquals(key,value)},t.prototype.like=function(key,value){return this._logical.add(new N(key,value)),this._this},t.prototype.ilike=function(key,value){return this._logical.add(new I(key,value)),this._this},t.prototype.any=function(key,t){if(t.length){var e=this._logical.add(new V(this._logical));t.forEach((function(value){return e.add(new k(key,value))}))}return this._this},t.prototype.operator=function(alias,key,value,opts){if(!(alias in X))throw new Error("Invalid operator alias:".concat(alias));var t=X[alias],e=t instanceof D?new q(key,t):new t(key,value,opts);return this._logical.add(e),this._this},t.prototype.op=function(alias,key,value,opts){return this.operator(alias,key,value,opts)},t}();function B(t,e,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=t,n}function z(t,e,r){if(void 0===r&&(r={}),t.length<2)throw new Error("coordinates must be an array of two or more positions");return B({type:"LineString",coordinates:t},e,r)}function H(t,e){void 0===e&&(e={});var r={type:"FeatureCollection"};return e.id&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.features=t,r}function K(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function $(t){if(Array.isArray(t))return t;if("Feature"===t.type){if(null!==t.geometry)return t.geometry.coordinates}else if(t.coordinates)return t.coordinates;throw new Error("coords must be GeoJSON Feature, Geometry Object or an Array")}function Q(t){return"Feature"===t.type?t.geometry:t}function Z(t,e,r){if(void 0===r&&(r={}),!t)throw new Error("point is required");if(!e)throw new Error("polygon is required");var n=function(t){if(!t)throw new Error("coord is required");if(!Array.isArray(t)){if("Feature"===t.type&&null!==t.geometry&&"Point"===t.geometry.type)return t.geometry.coordinates;if("Point"===t.type)return t.coordinates}if(Array.isArray(t)&&t.length>=2&&!Array.isArray(t[0])&&!Array.isArray(t[1]))return t;throw new Error("coord must be GeoJSON Point or an Array of numbers")}(t),o=Q(e),i=o.type,a=e.bbox,s=o.coordinates;if(a&&!1===function(t,e){return e[0]<=t[0]&&e[1]<=t[1]&&e[2]>=t[0]&&e[3]>=t[1]}(n,a))return!1;"Polygon"===i&&(s=[s]);for(var u=!1,c=0;c<s.length&&!u;c++)if(tt(n,s[c][0],r.ignoreBoundary)){for(var l=!1,f=1;f<s[c].length&&!l;)tt(n,s[c][f],!r.ignoreBoundary)&&(l=!0),f++;l||(u=!0)}return u}function tt(t,e,r){var n=!1;e[0][0]===e[e.length-1][0]&&e[0][1]===e[e.length-1][1]&&(e=e.slice(0,e.length-1));for(var o=0,i=e.length-1;o<e.length;i=o++){var a=e[o][0],s=e[o][1],u=e[i][0],c=e[i][1];if(t[1]*(a-u)+s*(u-t[0])+c*(t[0]-a)==0&&(a-t[0])*(u-t[0])<=0&&(s-t[1])*(c-t[1])<=0)return!r;s>t[1]!=c>t[1]&&t[0]<(u-a)*(t[1]-s)/(c-s)+a&&(n=!n)}return n}function et(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var r=0;r<t.features.length&&!1!==e(t.features[r],r);r++);}function rt(t,e){!function(t,e){var r,n,o,i,a,s,u,c,l,f,p=0,h="FeatureCollection"===t.type,g="Feature"===t.type,y=h?t.features.length:1;for(r=0;r<y;r++){for(s=h?t.features[r].geometry:g?t.geometry:t,c=h?t.features[r].properties:g?t.properties:{},l=h?t.features[r].bbox:g?t.bbox:void 0,f=h?t.features[r].id:g?t.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(i,p,c,l,f))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===e(i.geometries[n],p,c,l,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,p,c,l,f))return!1;p++}}(t,(function(t,r,n,o,i){var a,s=null===t?null:t.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==e(B(t,n,{bbox:o,id:i}),r,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var u=0;u<t.coordinates.length;u++){var c=t.coordinates[u];if(!1===e(B({type:a,coordinates:c},n),r,u))return!1}}))}function nt(t){if(!t)throw new Error("geojson is required");var e=[];return rt(t,(function(t){!function(t,e){var r=[],n=t.geometry;if(null!==n){switch(n.type){case"Polygon":r=$(n);break;case"LineString":r=[$(n)]}r.forEach((function(r){var n=function(t,e){var r=[];return t.reduce((function(t,n){var o,i,a,s,u,c,l=z([t,n],e);return l.bbox=(i=n,a=(o=t)[0],s=o[1],u=i[0],c=i[1],[a<u?a:u,s<c?s:c,a>u?a:u,s>c?s:c]),r.push(l),n})),r}(r,t.properties);n.forEach((function(t){t.id=e.length,e.push(t)}))}))}}(t,e)})),H(e)}!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}w(e,t),e.prototype._setConfiguration=function(){},e.prototype._getConfiguration=function(){return{}},e.prototype._getClassDict=function(){return{}},e.prototype._getPolygraph=function(){return this}}(Y);var ot={exports:{}},it={};!function(t){function e(t,e,r){void 0===r&&(r={});var n={type:"Feature"};return(0===r.id||r.id)&&(n.id=r.id),r.bbox&&(n.bbox=r.bbox),n.properties=e||{},n.geometry=t,n}function r(t,r,n){if(void 0===n&&(n={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!p(t[0])||!p(t[1]))throw new Error("coordinates must contain numbers");return e({type:"Point",coordinates:t},r,n)}function n(t,r,n){void 0===n&&(n={});for(var o=0,i=t;o<i.length;o++){var a=i[o];if(a.length<4)throw new Error("Each LinearRing of a Polygon must have 4 or more Positions.");for(var s=0;s<a[a.length-1].length;s++)if(a[a.length-1][s]!==a[0][s])throw new Error("First and last Position are not equivalent.")}return e({type:"Polygon",coordinates:t},r,n)}function o(t,r,n){if(void 0===n&&(n={}),t.length<2)throw new Error("coordinates must be an array of two or more positions");return e({type:"LineString",coordinates:t},r,n)}function i(t,e){void 0===e&&(e={});var r={type:"FeatureCollection"};return e.id&&(r.id=e.id),e.bbox&&(r.bbox=e.bbox),r.features=t,r}function a(t,r,n){return void 0===n&&(n={}),e({type:"MultiLineString",coordinates:t},r,n)}function s(t,r,n){return void 0===n&&(n={}),e({type:"MultiPoint",coordinates:t},r,n)}function u(t,r,n){return void 0===n&&(n={}),e({type:"MultiPolygon",coordinates:t},r,n)}function c(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e*n}function l(e,r){void 0===r&&(r="kilometers");var n=t.factors[r];if(!n)throw new Error(r+" units is invalid");return e/n}function f(t){return 180*(t%(2*Math.PI))/Math.PI}function p(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}Object.defineProperty(t,"__esModule",{value:!0}),t.earthRadius=6371008.8,t.factors={centimeters:100*t.earthRadius,centimetres:100*t.earthRadius,degrees:t.earthRadius/111325,feet:3.28084*t.earthRadius,inches:39.37*t.earthRadius,kilometers:t.earthRadius/1e3,kilometres:t.earthRadius/1e3,meters:t.earthRadius,metres:t.earthRadius,miles:t.earthRadius/1609.344,millimeters:1e3*t.earthRadius,millimetres:1e3*t.earthRadius,nauticalmiles:t.earthRadius/1852,radians:1,yards:1.0936*t.earthRadius},t.unitsFactors={centimeters:100,centimetres:100,degrees:1/111325,feet:3.28084,inches:39.37,kilometers:.001,kilometres:.001,meters:1,metres:1,miles:1/1609.344,millimeters:1e3,millimetres:1e3,nauticalmiles:1/1852,radians:1/t.earthRadius,yards:1.0936133},t.areaFactors={acres:247105e-9,centimeters:1e4,centimetres:1e4,feet:10.763910417,hectares:1e-4,inches:1550.003100006,kilometers:1e-6,kilometres:1e-6,meters:1,metres:1,miles:386e-9,millimeters:1e6,millimetres:1e6,yards:1.195990046},t.feature=e,t.geometry=function(t,e,i){switch(t){case"Point":return r(e).geometry;case"LineString":return o(e).geometry;case"Polygon":return n(e).geometry;case"MultiPoint":return s(e).geometry;case"MultiLineString":return a(e).geometry;case"MultiPolygon":return u(e).geometry;default:throw new Error(t+" is invalid")}},t.point=r,t.points=function(t,e,n){return void 0===n&&(n={}),i(t.map((function(t){return r(t,e)})),n)},t.polygon=n,t.polygons=function(t,e,r){return void 0===r&&(r={}),i(t.map((function(t){return n(t,e)})),r)},t.lineString=o,t.lineStrings=function(t,e,r){return void 0===r&&(r={}),i(t.map((function(t){return o(t,e)})),r)},t.featureCollection=i,t.multiLineString=a,t.multiPoint=s,t.multiPolygon=u,t.geometryCollection=function(t,r,n){return void 0===n&&(n={}),e({type:"GeometryCollection",geometries:t},r,n)},t.round=function(t,e){if(void 0===e&&(e=0),e&&!(e>=0))throw new Error("precision must be a positive number");var r=Math.pow(10,e||0);return Math.round(t*r)/r},t.radiansToLength=c,t.lengthToRadians=l,t.lengthToDegrees=function(t,e){return f(l(t,e))},t.bearingToAzimuth=function(t){var e=t%360;return e<0&&(e+=360),e},t.radiansToDegrees=f,t.degreesToRadians=function(t){return t%360*Math.PI/180},t.convertLength=function(t,e,r){if(void 0===e&&(e="kilometers"),void 0===r&&(r="kilometers"),!(t>=0))throw new Error("length must be a positive number");return c(l(t,e),r)},t.convertArea=function(e,r,n){if(void 0===r&&(r="meters"),void 0===n&&(n="kilometers"),!(e>=0))throw new Error("area must be a positive number");var o=t.areaFactors[r];if(!o)throw new Error("invalid original units");var i=t.areaFactors[n];if(!i)throw new Error("invalid final units");return e/o*i},t.isNumber=p,t.isObject=function(t){return!!t&&t.constructor===Object},t.validateBBox=function(t){if(!t)throw new Error("bbox is required");if(!Array.isArray(t))throw new Error("bbox must be an Array");if(4!==t.length&&6!==t.length)throw new Error("bbox must be an Array of 4 or 6 numbers");t.forEach((function(t){if(!p(t))throw new Error("bbox must only contain numbers")}))},t.validateId=function(t){if(!t)throw new Error("id is required");if(-1===["string","number"].indexOf(typeof t))throw new Error("id must be a number or a string")}}(it);var at={};Object.defineProperty(at,"__esModule",{value:!0});var st=it;function ut(t,e,r){if(null!==t)for(var n,o,i,a,s,u,c,l,f=0,p=0,h=t.type,g="FeatureCollection"===h,y="Feature"===h,d=g?t.features.length:1,m=0;m<d;m++){s=(l=!!(c=g?t.features[m].geometry:y?t.geometry:t)&&"GeometryCollection"===c.type)?c.geometries.length:1;for(var v=0;v<s;v++){var _=0,w=0;if(null!==(a=l?c.geometries[v]:c)){u=a.coordinates;var b=a.type;switch(f=!r||"Polygon"!==b&&"MultiPolygon"!==b?0:1,b){case null:break;case"Point":if(!1===e(u,p,m,_,w))return!1;p++,_++;break;case"LineString":case"MultiPoint":for(n=0;n<u.length;n++){if(!1===e(u[n],p,m,_,w))return!1;p++,"MultiPoint"===b&&_++}"LineString"===b&&_++;break;case"Polygon":case"MultiLineString":for(n=0;n<u.length;n++){for(o=0;o<u[n].length-f;o++){if(!1===e(u[n][o],p,m,_,w))return!1;p++}"MultiLineString"===b&&_++,"Polygon"===b&&w++}"Polygon"===b&&_++;break;case"MultiPolygon":for(n=0;n<u.length;n++){for(w=0,o=0;o<u[n].length;o++){for(i=0;i<u[n][o].length-f;i++){if(!1===e(u[n][o][i],p,m,_,w))return!1;p++}w++}_++}break;case"GeometryCollection":for(n=0;n<a.geometries.length;n++)if(!1===ut(a.geometries[n],e,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function ct(t,e){var r;switch(t.type){case"FeatureCollection":for(r=0;r<t.features.length&&!1!==e(t.features[r].properties,r);r++);break;case"Feature":e(t.properties,0)}}function lt(t,e){if("Feature"===t.type)e(t,0);else if("FeatureCollection"===t.type)for(var r=0;r<t.features.length&&!1!==e(t.features[r],r);r++);}function ft(t,e){var r,n,o,i,a,s,u,c,l,f,p=0,h="FeatureCollection"===t.type,g="Feature"===t.type,y=h?t.features.length:1;for(r=0;r<y;r++){for(s=h?t.features[r].geometry:g?t.geometry:t,c=h?t.features[r].properties:g?t.properties:{},l=h?t.features[r].bbox:g?t.bbox:void 0,f=h?t.features[r].id:g?t.id:void 0,a=(u=!!s&&"GeometryCollection"===s.type)?s.geometries.length:1,o=0;o<a;o++)if(null!==(i=u?s.geometries[o]:s))switch(i.type){case"Point":case"LineString":case"MultiPoint":case"Polygon":case"MultiLineString":case"MultiPolygon":if(!1===e(i,p,c,l,f))return!1;break;case"GeometryCollection":for(n=0;n<i.geometries.length;n++)if(!1===e(i.geometries[n],p,c,l,f))return!1;break;default:throw new Error("Unknown Geometry Type")}else if(!1===e(null,p,c,l,f))return!1;p++}}function pt(t,e){ft(t,(function(t,r,n,o,i){var a,s=null===t?null:t.type;switch(s){case null:case"Point":case"LineString":case"Polygon":return!1!==e(st.feature(t,n,{bbox:o,id:i}),r,0)&&void 0}switch(s){case"MultiPoint":a="Point";break;case"MultiLineString":a="LineString";break;case"MultiPolygon":a="Polygon"}for(var u=0;u<t.coordinates.length;u++){var c={type:a,coordinates:t.coordinates[u]};if(!1===e(st.feature(c,n),r,u))return!1}}))}function ht(t,e){pt(t,(function(t,r,n){var o=0;if(t.geometry){var i=t.geometry.type;if("Point"!==i&&"MultiPoint"!==i){var a,s=0,u=0,c=0;return!1!==ut(t,(function(i,l,f,p,h){if(void 0===a||r>s||p>u||h>c)return a=i,s=r,u=p,c=h,void(o=0);var g=st.lineString([a,i],t.properties);if(!1===e(g,r,n,h,o))return!1;o++,a=i}))&&void 0}}}))}function gt(t,e){if(!t)throw new Error("geojson is required");pt(t,(function(t,r,n){if(null!==t.geometry){var o=t.geometry.type,i=t.geometry.coordinates;switch(o){case"LineString":if(!1===e(t,r,n,0,0))return!1;break;case"Polygon":for(var a=0;a<i.length;a++)if(!1===e(st.lineString(i[a],t.properties),r,n,a))return!1}}}))}at.coordAll=function(t){var e=[];return ut(t,(function(t){e.push(t)})),e},at.coordEach=ut,at.coordReduce=function(t,e,r,n){var o=r;return ut(t,(function(t,n,i,a,s){o=0===n&&void 0===r?t:e(o,t,n,i,a,s)}),n),o},at.featureEach=lt,at.featureReduce=function(t,e,r){var n=r;return lt(t,(function(t,o){n=0===o&&void 0===r?t:e(n,t,o)})),n},at.findPoint=function(t,e){if(e=e||{},!st.isObject(e))throw new Error("options is invalid");var r,n=e.featureIndex||0,o=e.multiFeatureIndex||0,i=e.geometryIndex||0,a=e.coordIndex||0,s=e.properties;switch(t.type){case"FeatureCollection":n<0&&(n=t.features.length+n),s=s||t.features[n].properties,r=t.features[n].geometry;break;case"Feature":s=s||t.properties,r=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=t;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var u=r.coordinates;switch(r.type){case"Point":return st.point(u,s,e);case"MultiPoint":return o<0&&(o=u.length+o),st.point(u[o],s,e);case"LineString":return a<0&&(a=u.length+a),st.point(u[a],s,e);case"Polygon":return i<0&&(i=u.length+i),a<0&&(a=u[i].length+a),st.point(u[i][a],s,e);case"MultiLineString":return o<0&&(o=u.length+o),a<0&&(a=u[o].length+a),st.point(u[o][a],s,e);case"MultiPolygon":return o<0&&(o=u.length+o),i<0&&(i=u[o].length+i),a<0&&(a=u[o][i].length-a),st.point(u[o][i][a],s,e)}throw new Error("geojson is invalid")},at.findSegment=function(t,e){if(e=e||{},!st.isObject(e))throw new Error("options is invalid");var r,n=e.featureIndex||0,o=e.multiFeatureIndex||0,i=e.geometryIndex||0,a=e.segmentIndex||0,s=e.properties;switch(t.type){case"FeatureCollection":n<0&&(n=t.features.length+n),s=s||t.features[n].properties,r=t.features[n].geometry;break;case"Feature":s=s||t.properties,r=t.geometry;break;case"Point":case"MultiPoint":return null;case"LineString":case"Polygon":case"MultiLineString":case"MultiPolygon":r=t;break;default:throw new Error("geojson is invalid")}if(null===r)return null;var u=r.coordinates;switch(r.type){case"Point":case"MultiPoint":return null;case"LineString":return a<0&&(a=u.length+a-1),st.lineString([u[a],u[a+1]],s,e);case"Polygon":return i<0&&(i=u.length+i),a<0&&(a=u[i].length+a-1),st.lineString([u[i][a],u[i][a+1]],s,e);case"MultiLineString":return o<0&&(o=u.length+o),a<0&&(a=u[o].length+a-1),st.lineString([u[o][a],u[o][a+1]],s,e);case"MultiPolygon":return o<0&&(o=u.length+o),i<0&&(i=u[o].length+i),a<0&&(a=u[o][i].length-a-1),st.lineString([u[o][i][a],u[o][i][a+1]],s,e)}throw new Error("geojson is invalid")},at.flattenEach=pt,at.flattenReduce=function(t,e,r){var n=r;return pt(t,(function(t,o,i){n=0===o&&0===i&&void 0===r?t:e(n,t,o,i)})),n},at.geomEach=ft,at.geomReduce=function(t,e,r){var n=r;return ft(t,(function(t,o,i,a,s){n=0===o&&void 0===r?t:e(n,t,o,i,a,s)})),n},at.lineEach=gt,at.lineReduce=function(t,e,r){var n=r;return gt(t,(function(t,o,i,a){n=0===o&&void 0===r?t:e(n,t,o,i,a)})),n},at.propEach=ct,at.propReduce=function(t,e,r){var n=r;return ct(t,(function(t,o){n=0===o&&void 0===r?t:e(n,t,o)})),n},at.segmentEach=ht,at.segmentReduce=function(t,e,r){var n=r,o=!1;return ht(t,(function(t,i,a,s,u){n=!1===o&&void 0===r?t:e(n,t,i,a,s,u),o=!0})),n};var yt={};Object.defineProperty(yt,"__esModule",{value:!0});var dt=at;function mt(t){var e=[1/0,1/0,-1/0,-1/0];return dt.coordEach(t,(function(t){e[0]>t[0]&&(e[0]=t[0]),e[1]>t[1]&&(e[1]=t[1]),e[2]<t[0]&&(e[2]=t[0]),e[3]<t[1]&&(e[3]=t[1])})),e}mt.default=mt,yt.default=mt;var vt=t,_t=it,wt=at,bt=yt.default,Pt=wt.featureEach;wt.coordEach;var Et=_t.featureCollection;function Ot(t){var e=new vt(t);return e.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:bt(t),vt.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:bt(t),e.push(t)})):Pt(t,(function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:bt(t),e.push(t)})),vt.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:bt(t),vt.prototype.remove.call(this,t,e)},e.clear=function(){return vt.prototype.clear.call(this)},e.search=function(t){var e=vt.prototype.search.call(this,this.toBBox(t));return Et(e)},e.collides=function(t){return vt.prototype.collides.call(this,this.toBBox(t))},e.all=function(){var t=vt.prototype.all.call(this);return Et(t)},e.toJSON=function(){return vt.prototype.toJSON.call(this)},e.fromJSON=function(json){return vt.prototype.fromJSON.call(this,json)},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=bt(t);else{if("FeatureCollection"!==t.type)throw new Error("invalid geojson");e=bt(t)}return{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}function xt(t,e){var r={},n=[];if("LineString"===t.type&&(t=B(t)),"LineString"===e.type&&(e=B(e)),"Feature"===t.type&&"Feature"===e.type&&null!==t.geometry&&null!==e.geometry&&"LineString"===t.geometry.type&&"LineString"===e.geometry.type&&2===t.geometry.coordinates.length&&2===e.geometry.coordinates.length){var o=Ct(t,e);return o&&n.push(o),H(n)}var i=ot.exports();return i.load(nt(e)),et(nt(t),(function(t){et(i.search(t),(function(e){var o=Ct(t,e);if(o){var key=$(o).join(",");r[key]||(r[key]=!0,n.push(o))}}))})),H(n)}function Ct(t,e){var r=$(t),n=$(e);if(2!==r.length)throw new Error("<intersects> line1 must only contain 2 coordinates");if(2!==n.length)throw new Error("<intersects> line2 must only contain 2 coordinates");var o=r[0][0],i=r[0][1],a=r[1][0],s=r[1][1],u=n[0][0],c=n[0][1],l=n[1][0],f=n[1][1],p=(f-c)*(a-o)-(l-u)*(s-i),h=(l-u)*(i-c)-(f-c)*(o-u),g=(a-o)*(i-c)-(s-i)*(o-u);if(0===p)return null;var y=h/p,d=g/p;return y>=0&&y<=1&&d>=0&&d<=1?function(t,e,r){if(void 0===r&&(r={}),!t)throw new Error("coordinates is required");if(!Array.isArray(t))throw new Error("coordinates must be an Array");if(t.length<2)throw new Error("coordinates must be at least 2 numbers long");if(!K(t[0])||!K(t[1]))throw new Error("coordinates must contain numbers");return B({type:"Point",coordinates:t},e,r)}([o+y*(a-o),i+y*(s-i)]):null}function St(t,e){void 0===e&&(e={});var r=Q(t);switch(e.properties||"Feature"!==t.type||(e.properties=t.properties),r.type){case"Polygon":return function(t,e){void 0===e&&(e={});var r=Q(t).coordinates,n=e.properties?e.properties:"Feature"===t.type?t.properties:{};return At(r,n)}(r,e);case"MultiPolygon":return function(t,e){void 0===e&&(e={});var r=Q(t).coordinates,n=e.properties?e.properties:"Feature"===t.type?t.properties:{},o=[];return r.forEach((function(t){o.push(At(t,n))})),H(o)}(r,e);default:throw new Error("invalid poly")}}function At(t,e){return t.length>1?function(t,e,r){return void 0===r&&(r={}),B({type:"MultiLineString",coordinates:t},e,r)}(t,e):z(t[0],e)}function jt(t,e){var r=!0;return rt(t,(function(t){rt(e,(function(e){if(!1===r)return!1;r=function(t,e){switch(t.type){case"Point":switch(e.type){case"Point":return r=t.coordinates,n=e.coordinates,!(r[0]===n[0]&&r[1]===n[1]);case"LineString":return!Mt(e,t);case"Polygon":return!Z(t,e)}break;case"LineString":switch(e.type){case"Point":return!Mt(t,e);case"LineString":return!function(t,e){if(xt(t,e).features.length>0)return!0;return!1}(t,e);case"Polygon":return!kt(e,t)}break;case"Polygon":switch(e.type){case"Point":return!Z(e,t);case"LineString":return!kt(t,e);case"Polygon":return!function(t,e){for(var r=0,n=t.coordinates[0];r<n.length;r++){if(Z(n[r],e))return!0}for(var o=0,i=e.coordinates[0];o<i.length;o++){if(Z(i[o],t))return!0}if(xt(St(t),St(e)).features.length>0)return!0;return!1}(e,t)}}var r,n;return!1}(t.geometry,e.geometry)}))})),r}function Mt(t,e){for(var r=0;r<t.coordinates.length-1;r++)if(Gt(t.coordinates[r],t.coordinates[r+1],e.coordinates))return!0;return!1}function kt(t,e){for(var r=0,n=e.coordinates;r<n.length;r++){if(Z(n[r],t))return!0}return xt(e,St(t)).features.length>0}function Gt(t,e,r){var n=r[0]-t[0],o=r[1]-t[1],i=e[0]-t[0],a=e[1]-t[1];return 0==n*a-o*i&&(Math.abs(i)>=Math.abs(a)?i>0?t[0]<=r[0]&&r[0]<=e[0]:e[0]<=r[0]&&r[0]<=t[0]:a>0?t[1]<=r[1]&&r[1]<=e[1]:e[1]<=r[1]&&r[1]<=t[1])}function Tt(t){return t*Math.PI/180}ot.exports=Ot,ot.exports.default=Ot;var Rt=new i,Lt=new n,Ft=new o({featureNS:"https:/foo"}),Nt=function(){function t(t){this._feature=t}return t.transform=function(t,e,r){return t.clone().transform(e,r)},t.isSquare=function(t){if(!(t instanceof h))return!1;var e=g(t.getExtent());return t.getFlatCoordinates().length===e.getFlatCoordinates().length&&t.getArea()===e.getArea()},t.distanceSphere=function(e,r,n,o){void 0===o&&(o=64);var i=m(e,r),a=i[0],s=i[1],u=y([a,s],n,o);return t.transform(u,t.WGS84_CODE,r)},t.prototype.assertValid=function(){if(!(this.getGeometry()instanceof s))throw new Error("Not a valid geometry");return this},t.prototype.getGeometry=function(){var t=this._feature.getGeometry();return t instanceof a?d(t):t},t.prototype.getGeometryAsArray=function(){var t=this.getGeometry();return t instanceof l?t.getPoints():t instanceof c?t.getLineStrings():t instanceof f?t.getPolygons():[t]},t.prototype.getGeometryTransformed=function(e,r){return t.transform(this.getGeometry(),e,r)},t.prototype.getGeometryName=function(){return this._feature.getGeometryName()},t.prototype.setGeometryName=function(t){if(t!==this.getGeometryName()){var e=this.getOlFeature();e.set(t,e.getGeometry()),e.unset(e.getGeometryName()),e.setGeometryName(t)}},t.prototype.getExtent=function(){return this.getGeometry().getExtent()},t.prototype.getProperties=function(){return this._feature.getProperties()},t.prototype.getCenter=function(){return r(this.getExtent())},t.prototype.getOlFeature=function(){return this._feature},t.prototype.serialize=function(t,opts,e){var r=opts?this.getGeometryTransformed(opts.sourceProj,opts.targetProj):this.getGeometry();switch(t){case"wkt":return Rt.writeGeometry(r,{decimals:e});case"json":return Lt.writeGeometry(r,{decimals:e});case"turf":return Lt.writeGeometryObject(r);case"gml":return Ft.writeGeometry(r,{decimals:e})}},t.prototype.asWkt=function(t,opts){return this.serialize("wkt",opts,t)},t.prototype.asGeoJson=function(t,opts){return this.serialize("json",opts,t)},t.prototype.asTurf=function(e){var opts={sourceProj:e,targetProj:t.WGS84_CODE};return this.serialize("turf",opts)},t.prototype.asGml=function(t,opts){return this.serialize("gml",opts,t)},t.prototype.intersects=function(e,r){var n=this.getGeometryAsArray(),o=e.getGeometryAsArray();return n.some((function(e){return o.some((function(n){return e instanceof p?n.intersectsCoordinate(e.getCoordinates()):n instanceof p?e.intersectsCoordinate(n.getCoordinates()):t.isSquare(e)?n.intersectsExtent(e.getExtent()):t.isSquare(n)?e.intersectsExtent(n.getExtent()):e.intersectsExtent(n.getExtent())&&(o=t.factory(e).asTurf(r),i=t.factory(n).asTurf(r),a=!1,rt(o,(function(t){rt(i,(function(e){if(!0===a)return!0;a=!jt(t.geometry,e.geometry)}))})),a);var o,i,a}))}))},t.prototype.contains=function(t){var e=this.getGeometryAsArray(),r=t.getGeometryAsArray();return e.some((function(t){return r.every((function(e){return e instanceof p?t.intersectsCoordinate(e.getCoordinates()):e instanceof u?e.getCoordinates().every((function(e){return t.intersectsCoordinate(e)})):e.getLinearRing(0).getCoordinates().every((function(e){return t.intersectsCoordinate(e)}))}))}))},t.prototype.dwithin=function(e,n,o,i){void 0===o&&(o=!0);var a=this.getGeometry(),s=e.getGeometry();if(a instanceof p&&s.intersectsCoordinate(a.getCoordinates()))return!0;if(s instanceof p&&a.intersectsCoordinate(s.getCoordinates()))return!0;if(!o){var c=s.getClosestPoint(r(a.getExtent())),l=a.getClosestPoint(c);return new u([l,c]).getLength()<=n||this.intersects(e,i)}a=this.getGeometryTransformed(i,t.WGS84_CODE);var f=(s=e.getGeometryTransformed(i,t.WGS84_CODE)).getClosestPoint(r(a.getExtent()));return function(t,e,r){r=r||6371008.8;const n=Tt(t[1]),o=Tt(e[1]),i=(o-n)/2,a=Tt(e[0]-t[0])/2,s=Math.sin(i)*Math.sin(i)+Math.sin(a)*Math.sin(a)*Math.cos(n)*Math.cos(o);return 2*r*Math.atan2(Math.sqrt(s),Math.sqrt(1-s))}(a.getClosestPoint(f),f)<=n||this.intersects(e,i)},t.GEOMETRYNAME_DEFAULT="geometry",t.GEOMETRYNAME_HINT="polygraph_geometryname",t.WGS84_CODE="EPSG:4326",t.factory=function(obj){if(obj instanceof t)return obj;if(obj instanceof Function)return t.factory(obj.call(obj,t.GEOMETRYNAME_DEFAULT));if(obj instanceof e)return new t(obj).assertValid();if(obj instanceof s)return new t(new e(obj)).assertValid();if(obj instanceof Array){if(obj.length>0&&obj.length%2==0){if(2==obj.length)return new t(new e(new p(obj,"XY")));if(4==obj.length)return new t(new e(g(obj)));if(6==obj.length)return new t(new e(new u(obj,"XY")));var r=obj.slice(0,2),n=r[0],o=r[1],i=obj.slice(-2),a=i[0],c=i[1];return new t(n===a&&o===c?new e(new h(obj,"XY",[obj.length])):new e(new u(obj,"XY")))}}else{if(obj instanceof Object){if(t.GEOMETRYNAME_HINT in obj){var l=obj[t.GEOMETRYNAME_HINT];return t.factory(obj[l])}var f=Object.entries(obj).find((function(t){return t[1]instanceof s}));if(f){var y=new e(obj),key=f[0],d=f[1];return y.setGeometryName(key),y.setGeometry(d),new t(y).assertValid()}return new t(Lt.readFeature(obj)).assertValid()}if("string"==typeof obj)return"{"===obj.trimStart().charAt(0)?new t(Lt.readFeature(obj)).assertValid():new t(Rt.readFeature(obj)).assertValid()}throw new Error("Unsupported geometry type")},t}(),It=function(t){function e(value,opts){var e=this,r=Nt.factory(value);return opts.geometryName&&r.setGeometryName(opts.geometryName),(e=t.call(this,r.getGeometryName(),r.asWkt())||this)._feature=r,e._opts=b({geometryName:r.getGeometryName()},opts),e._reporter=new A("".concat(e.getAlias(),":").concat(e.key)),e}return w(e,t),Object.defineProperty(e.prototype,"feature",{get:function(){return this._feature},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"opts",{get:function(){return this._opts},enumerable:!1,configurable:!0}),e.prototype.getAlias=function(){return this.constructor.alias},e.prototype.getReport=function(){return this._reporter.getReport()},e.prototype.resetReport=function(){this._reporter.reset()},e.prototype.asJson=function(){return{type:this.getAlias(),ctorArgs:[this.value,this.opts]}},e.prototype.evaluate=function(obj){var t=Nt.factory(obj);this._reporter.start();var e=!1,r=this._opts.polygraphOpts.projCode;if(this instanceof Dt)e=this.feature.intersects(t,r);else if(this instanceof qt)e=!this.feature.intersects(t,r);else if(this instanceof Jt)e=t.contains(this.feature);else if(this instanceof Wt)e=this.feature.contains(t);else if(this instanceof Ut){var opts=this._opts;e=this.feature.dwithin(t,opts.distance,opts.greatCircle,r)}else if(this instanceof Xt){opts=this._opts;e=!this.feature.dwithin(t,opts.distance,opts.greatCircle,r)}return this._reporter.stop(e),e},e}(j),Dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="intersects",e}(It),qt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="disjoint",e}(It),Jt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="contains",e}(It),Wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="within",e}(It),Vt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),Object.defineProperty(e.prototype,"opts",{get:function(){return this._opts},enumerable:!1,configurable:!0}),e}(It),Ut=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="dwithin",e}(Vt),Xt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return w(e,t),e.alias="beyond",e}(Vt),Yt=function(){function t(){}return t.metersToUnit=function(t,e,n,o){var i=v(n);if("degrees"===i.getUnits()){var a=r(Nt.transform(t,e,i).getExtent())[1];return o/(i.getMetersPerUnit()*Math.cos(a*(Math.PI/180)))}return o/i.getMetersPerUnit()},t.asOgcCql=function(t,opts){var e=function(t){var r,n,o;if(t instanceof It){var i=null!==(r=null==opts?void 0:opts.geometryName)&&void 0!==r?r:t.key,value=(null==opts?void 0:opts.projection)?t.feature.asWkt(null==opts?void 0:opts.decimals,{sourceProj:t.opts.polygraphOpts.projCode,targetProj:opts.projection}):t.feature.asWkt(null==opts?void 0:opts.decimals);if(null==opts?void 0:opts.eWkt){var a=v(null!==(n=opts.projection)&&void 0!==n?n:t.opts.polygraphOpts.projCode);value="SRID=".concat(a.getCode().split(":").pop(),";").concat(value)}if(t instanceof Dt)return"INTERSECTS(".concat(i,", ").concat(value,")");if(t instanceof qt)return"DISJOINT(".concat(i,", ").concat(value,")");if(t instanceof Jt)return"CONTAINS(".concat(i,", ").concat(value,")");if(t instanceof Wt)return"WITHIN(".concat(i,", ").concat(value,")");if(t instanceof Vt){var s=t.opts.distance,u=t.opts.polygraphOpts.projCode,c=null!==(o=null==opts?void 0:opts.projection)&&void 0!==o?o:u,l=Nt.distanceSphere(t.feature.getCenter(),u,s);if(value=Nt.factory(l).asWkt(null==opts?void 0:opts.decimals,{sourceProj:u,targetProj:c}),t instanceof Ut)return"INTERSECTS(".concat(i,", ").concat(value,")");if(t instanceof Xt)return"DISJOINT(".concat(i,", ").concat(value,")")}}if(t instanceof M){value=t.value instanceof Date?t.value.toISOString():"string"==typeof t.value?"'".concat(t.value,"'"):t.value;if(t instanceof k)return"".concat(t.key," = ").concat(value);if(t instanceof G)return"".concat(t.key," IS NULL");if(t instanceof T)return"".concat(t.key," > ").concat(value);if(t instanceof R)return"".concat(t.key," >= ").concat(value);if(t instanceof L)return"".concat(t.key," < ").concat(value);if(t instanceof F)return"".concat(t.key," <= ").concat(value);if(t instanceof N){var f=t.value.toString().replace(new RegExp("\\".concat(t.opts.wildCard),"g"),"%");return"".concat(t.key," ").concat(t.opts.matchCase?"LIKE":"ILIKE"," '").concat(f,"'")}}if(t instanceof J){var p=t.getOperators();if(p.length>0){if(t instanceof W)return"(".concat(p.map(e).join(" AND "),")");if(t instanceof V)return"(".concat(p.map(e).join(" OR "),")");if(t instanceof U)return"(NOT ".concat(p.map(e).join(" AND NOT "),")")}return"(1=1)"}};return e(t)},t.asOgcXml=function(t,opts){var e=function(t){var r,n;if(t instanceof It){var o="<ogc:PropertyName>".concat(null!==(r=null==opts?void 0:opts.geometryName)&&void 0!==r?r:t.key,"</ogc:PropertyName>"),value=(null==opts?void 0:opts.projection)?t.feature.asGml(null==opts?void 0:opts.decimals,{sourceProj:t.opts.polygraphOpts.projCode,targetProj:opts.projection}):t.feature.asGml(null==opts?void 0:opts.decimals);if(t instanceof Dt)return"<ogc:Intersects>".concat(o).concat(value,"</ogc:Intersects>");if(t instanceof qt)return"<ogc:Disjoint>".concat(o).concat(value,"</ogc:Disjoint>");if(t instanceof Jt)return"<ogc:Contains>".concat(o).concat(value,"</ogc:Contains>");if(t instanceof Wt)return"<ogc:Within>".concat(o).concat(value,"</ogc:Within>");if(t instanceof Vt){var i=t.opts.distance,a=t.opts.polygraphOpts.projCode,s=null!==(n=null==opts?void 0:opts.projection)&&void 0!==n?n:a,u=Nt.distanceSphere(t.feature.getCenter(),a,i);if(value=Nt.factory(u).asGml(null==opts?void 0:opts.decimals,{sourceProj:a,targetProj:s}),t instanceof Ut)return"<ogc:Intersects>".concat(o).concat(value,"</ogc:Intersects>");if(t instanceof Xt)return"<ogc:Disjoint>".concat(o).concat(value,"</ogc:Disjoint>")}}if(t instanceof M){o="<ogc:PropertyName>".concat(t.key,"</ogc:PropertyName>"),value="<ogc:Literal>".concat(t.value instanceof Date?t.value.toISOString():t.value,"</ogc:Literal>");if(t instanceof k)return'<ogc:PropertyIsEqualTo matchCase="true">'.concat(o).concat(value,"</ogc:PropertyIsEqualTo>");if(t instanceof G)return"<ogc:PropertyIsNull>".concat(o,"</ogc:PropertyIsNull>");if(t instanceof T)return"<ogc:PropertyIsGreaterThan>".concat(o).concat(value,"</ogc:PropertyIsGreaterThan>");if(t instanceof R)return"<ogc:PropertyIsGreaterThanOrEqualTo>".concat(o).concat(value,"</ogc:PropertyIsGreaterThanOrEqualTo>");if(t instanceof L)return"<ogc:PropertyIsLessThan>".concat(o).concat(value,"</ogc:PropertyIsLessThan>");if(t instanceof F)return"<ogc:PropertyIsLessThanOrEqualTo>".concat(o).concat(value,"</ogc:PropertyIsLessThanOrEqualTo>");if(t instanceof N)return'<ogc:PropertyIsLike matchCase="'.concat(t.opts.matchCase,'" wildCard="').concat(t.opts.wildCard,'" escapeChar="\\" singleChar=".">').concat(o).concat(value,"</ogc:PropertyIsLike>")}if(t instanceof J){var c=t.getOperators();if(c.length>0){if(t instanceof W)return"<ogc:And>".concat(c.map(e).join(""),"</ogc:And>");if(t instanceof V)return"<ogc:Or>".concat(c.map(e).join(""),"</ogc:Or>");if(t instanceof U)return"<ogc:Not>".concat(c.map(e).join(""),"</ogc:Not>")}return""}};return'<ogc:Filter xmlns:gml="http://www.opengis.net/gml" xmlns:ogc="http://www.opengis.net/ogc">'.concat(e(t),"</ogc:Filter>")},t}(),Bt="EPSG:3857",zt=function(){this.projCode=Bt},Ht=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._opts=new zt,e}return w(e,t),e.prototype._getConfiguration=function(){return this._opts},e.prototype._setConfiguration=function(t){this._opts=t},e.prototype._getPolygraph=function(){return this},e.prototype._getClassDict=function(){var t;return(t={})[Dt.alias]=Dt,t[qt.alias]=qt,t[Jt.alias]=Jt,t[Wt.alias]=Wt,t[Ut.alias]=Ut,t[Xt.alias]=Xt,t},e.defaultProjection=function(t){Bt=t instanceof E?t.getCode():t},e.prototype.projection=function(t){return this._opts.projCode=t instanceof E?t.getCode():t,this},e.prototype.evaluate=function(obj){var t=Nt.factory(obj),e=t.getProperties();return e[Nt.GEOMETRYNAME_HINT]=t.getGeometryName(),this._logical.evaluate(e)},e.prototype.intersects=function(value){return this._logical.add(new Dt(value,{polygraphOpts:this._opts})),this},e.prototype.disjoint=function(value){return this._logical.add(new qt(value,{polygraphOpts:this._opts})),this},e.prototype.contains=function(value){return this._logical.add(new Jt(value,{polygraphOpts:this._opts})),this},e.prototype.within=function(value){return this._logical.add(new Wt(value,{polygraphOpts:this._opts})),this},e.prototype.distanceWithin=function(value,t,e){return this._logical.add(new Ut(value,{p