@wootapa/polygraph-ol
Version:
Extension of @wootapa/polygraph for OpenLayers 7+.
2 lines • 51.9 kB
JavaScript
/*! @wootapa/polygraph-ol v1.0.8 | author:Andreas Petersson | license:MIT */
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports,require("rbush"),require("ol"),require("ol/extent"),require("ol/format/GeoJSON"),require("ol/format/GML3"),require("ol/format/WKT"),require("ol/geom/Circle"),require("ol/geom/Geometry"),require("ol/geom/LineString"),require("ol/geom/MultiLineString"),require("ol/geom/MultiPoint"),require("ol/geom/MultiPolygon"),require("ol/geom/Point"),require("ol/geom/Polygon"),require("ol/proj")):"function"==typeof define&&define.amd?define(["exports","rbush","ol","ol/extent","ol/format/GeoJSON","ol/format/GML3","ol/format/WKT","ol/geom/Circle","ol/geom/Geometry","ol/geom/LineString","ol/geom/MultiLineString","ol/geom/MultiPoint","ol/geom/MultiPolygon","ol/geom/Point","ol/geom/Polygon","ol/proj"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).polygraph={},t.rbush,t.ol,t.ol.extent,t.ol.format.GeoJSON,t.ol.format.GML3,t.ol.format.WKT,t.ol.geom.Circle,t.ol.geom.Geometry,t.ol.geom.LineString,t.ol.geom.MultiLineString,t.ol.geom.MultiPoint,t.ol.geom.MultiPolygon,t.ol.geom.Point,t.ol.geom.Polygon,t.ol.proj)}(this,(function(t,e,r,n,o,i,a,s,u,c,l,f,p,h,g,y){"use strict";function d(t){return t&&t.__esModule?t:{default:t}}var m=d(e),v=d(o),_=d(i),w=d(a),b=d(s),P=d(u),E=d(c),O=d(l),x=d(f),C=d(p),S=d(h),A=d(g),j=function(t,e){return j=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])},j(t,e)};function M(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}j(t,e),t.prototype=null===e?Object.create(e):(r.prototype=e.prototype,new r)}var G=function(){return G=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},G.apply(this,arguments)};const k={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};var T=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_||k[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_}},L="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},R={exports:{}};(function(){var t,e,r,n,o,i;"undefined"!=typeof performance&&null!==performance&&performance.now?R.exports=function(){return performance.now()}:"undefined"!=typeof process&&null!==process&&process.hrtime?(R.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?(R.exports=function(){return Date.now()-r},r=Date.now()):(R.exports=function(){return(new Date).getTime()-r},r=(new Date).getTime())}).call(L);var F,N=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}(),I=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=R.exports(),this},t.prototype.stop=function(t){return this._duration+=R.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}(),q=function(){function t(key,value){this._key=key,this._value=N.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}(),D=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=G({isDate:r._value instanceof Date},opts),r._reporter=new I("".concat(r.getAlias(),":").concat(r.key)),r}return M(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=N.resolveObjectValue(this._key,obj);this._reporter.start();var e=!1;return this instanceof J?e=t===this._value:this instanceof W?e=null==t:this instanceof V?e=t>this._value:this instanceof U?e=t>=this._value:this instanceof X?e=t<this._value:this instanceof Y?e=t<=this._value:this instanceof B&&(e=this._valueRe.test(null==t?void 0:t.toString())),this._reporter.stop(e),e},e}(q),J=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="eq",e}(D),W=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="isnull",e}(D),V=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="gt",e}(D),U=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="gte",e}(D),X=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="lt",e}(D),Y=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="lte",e}(D),B=function(t){function e(key,value,opts){var e=t.call(this,key,value,G({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 M(e,t),Object.defineProperty(e.prototype,"opts",{get:function(){return this._opts},enumerable:!1,configurable:!0}),e.alias="like",e}(D),z=function(t){function e(key,value,opts){return t.call(this,key,value,G(G({},opts),{matchCase:!1}))||this}return M(e,t),e.alias="ilike",e}(B),K=function(alias,func){this.alias=alias,this.func=func},H=function(t){function e(key,e){var r=t.call(this,key,"(custom operator)")||this;return r._def=e,r._reporter=new I("".concat(r.getAlias(),":").concat(r.key)),r}return M(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 K(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=N.resolveObjectValue(this.key,obj);this._reporter.start();var e=!!this._def.func.apply(this._def.func,[t]);return this._reporter.stop(e),e},e}(q),$=function(){function t(t){this._parent=t,this._operators=[],this._reporter=new I("".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(H.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 Q?t=this._operators.every((function(t){return t.evaluate(obj)})):this instanceof Z?t=this._operators.some((function(t){return t.evaluate(obj)})):this instanceof tt&&(t=this._operators.every((function(t){return!t.evaluate(obj)})))),this._reporter.stop(t),t},t}(),Q=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="and",e}($),Z=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="or",e}($),tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="not",e}($),et=((F={})[Q.alias]=Q,F[Z.alias]=Z,F[tt.alias]=tt,F[J.alias]=J,F[W.alias]=W,F[V.alias]=V,F[U.alias]=U,F[X.alias]=X,F[Y.alias]=Y,F[B.alias]=B,F[z.alias]=z,F),rt=function(){function t(){this._this=this._getPolygraph(),this._logical=new Q(this._this),et=G(G({},et),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=$.fromJson(t,et,e),e},t.and=function(){var t=new this;return t._logical=new Q(t),t},t.or=function(){var t=new this;return t._logical=new Z(t),t},t.not=function(){var t=new this;return t._logical=new tt(t),t},t.define=function(alias,func){if(alias in et)throw new Error("Operator:".concat(alias," already defined"));et[alias]=new K(alias,func)},t.getOperatorAlias=function(){return Object.keys(et).sort()},t.prototype.asJson=function(){return G(G({},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 $)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 $}));return t&&(this._logical=t),this._this},t.prototype.next=function(){var t=this._logical.getParent();if(t instanceof $){var e=t.getOperators().filter((function(t){return t instanceof $})),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 $){var e=t.getOperators().filter((function(t){return t instanceof $})),r=e.indexOf(this._logical);r>0&&(this._logical=e[r-1])}return this._this},t.prototype.clone=function(){return N.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 $)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 Q(this._logical)),this._this},t.prototype.or=function(){return this._logical=this._logical.add(new Z(this._logical)),this._this},t.prototype.not=function(){return this._logical=this._logical.add(new tt(this._logical)),this._this},t.prototype.equals=function(key,value){return this._logical.add(new J(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 W(key,null)),this._this},t.prototype.greaterThan=function(key,value){return this._logical.add(new V(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 U(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 X(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 Y(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 B(key,value)),this._this},t.prototype.ilike=function(key,value){return this._logical.add(new z(key,value)),this._this},t.prototype.any=function(key,t){if(t.length){var e=this._logical.add(new Z(this._logical));t.forEach((function(value){return e.add(new J(key,value))}))}return this._this},t.prototype.operator=function(alias,key,value,opts){if(!(alias in et))throw new Error("Invalid operator alias:".concat(alias));var t=et[alias],e=t instanceof K?new H(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 nt(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 ot(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 nt({type:"LineString",coordinates:t},e,r)}function it(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 at(t){return!isNaN(t)&&null!==t&&!Array.isArray(t)}function st(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 ut(t){return"Feature"===t.type?t.geometry:t}function ct(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=ut(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(lt(n,s[c][0],r.ignoreBoundary)){for(var l=!1,f=1;f<s[c].length&&!l;)lt(n,s[c][f],!r.ignoreBoundary)&&(l=!0),f++;l||(u=!0)}return u}function lt(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 ft(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 pt(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(nt(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(nt({type:a,coordinates:c},n),r,u))return!1}}))}function ht(t){if(!t)throw new Error("geojson is required");var e=[];return pt(t,(function(t){!function(t,e){var r=[],n=t.geometry;if(null!==n){switch(n.type){case"Polygon":r=st(n);break;case"LineString":r=[st(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=ot([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)})),it(e)}!function(t){function e(){return null!==t&&t.apply(this,arguments)||this}M(e,t),e.prototype._setConfiguration=function(){},e.prototype._getConfiguration=function(){return{}},e.prototype._getClassDict=function(){return{}},e.prototype._getPolygraph=function(){return this}}(rt);var gt={exports:{}},yt={};!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")}}(yt);var dt={};Object.defineProperty(dt,"__esModule",{value:!0});var mt=yt;function vt(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===vt(a.geometries[n],e,r))return!1;break;default:throw new Error("Unknown Geometry Type")}}}}}function _t(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 wt(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 bt(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){bt(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(mt.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(mt.feature(c,n),r,u))return!1}}))}function Et(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!==vt(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=mt.lineString([a,i],t.properties);if(!1===e(g,r,n,h,o))return!1;o++,a=i}))&&void 0}}}))}function Ot(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(mt.lineString(i[a],t.properties),r,n,a))return!1}}}))}dt.coordAll=function(t){var e=[];return vt(t,(function(t){e.push(t)})),e},dt.coordEach=vt,dt.coordReduce=function(t,e,r,n){var o=r;return vt(t,(function(t,n,i,a,s){o=0===n&&void 0===r?t:e(o,t,n,i,a,s)}),n),o},dt.featureEach=wt,dt.featureReduce=function(t,e,r){var n=r;return wt(t,(function(t,o){n=0===o&&void 0===r?t:e(n,t,o)})),n},dt.findPoint=function(t,e){if(e=e||{},!mt.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 mt.point(u,s,e);case"MultiPoint":return o<0&&(o=u.length+o),mt.point(u[o],s,e);case"LineString":return a<0&&(a=u.length+a),mt.point(u[a],s,e);case"Polygon":return i<0&&(i=u.length+i),a<0&&(a=u[i].length+a),mt.point(u[i][a],s,e);case"MultiLineString":return o<0&&(o=u.length+o),a<0&&(a=u[o].length+a),mt.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),mt.point(u[o][i][a],s,e)}throw new Error("geojson is invalid")},dt.findSegment=function(t,e){if(e=e||{},!mt.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),mt.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),mt.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),mt.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),mt.lineString([u[o][i][a],u[o][i][a+1]],s,e)}throw new Error("geojson is invalid")},dt.flattenEach=Pt,dt.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},dt.geomEach=bt,dt.geomReduce=function(t,e,r){var n=r;return bt(t,(function(t,o,i,a,s){n=0===o&&void 0===r?t:e(n,t,o,i,a,s)})),n},dt.lineEach=Ot,dt.lineReduce=function(t,e,r){var n=r;return Ot(t,(function(t,o,i,a){n=0===o&&void 0===r?t:e(n,t,o,i,a)})),n},dt.propEach=_t,dt.propReduce=function(t,e,r){var n=r;return _t(t,(function(t,o){n=0===o&&void 0===r?t:e(n,t,o)})),n},dt.segmentEach=Et,dt.segmentReduce=function(t,e,r){var n=r,o=!1;return Et(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 xt={};Object.defineProperty(xt,"__esModule",{value:!0});var Ct=dt;function St(t){var e=[1/0,1/0,-1/0,-1/0];return Ct.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}St.default=St,xt.default=St;var At=m.default,jt=yt,Mt=dt,Gt=xt.default,kt=Mt.featureEach;Mt.coordEach;var Tt=jt.featureCollection;function Lt(t){var e=new At(t);return e.insert=function(t){if("Feature"!==t.type)throw new Error("invalid feature");return t.bbox=t.bbox?t.bbox:Gt(t),At.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:Gt(t),e.push(t)})):kt(t,(function(t){if("Feature"!==t.type)throw new Error("invalid features");t.bbox=t.bbox?t.bbox:Gt(t),e.push(t)})),At.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:Gt(t),At.prototype.remove.call(this,t,e)},e.clear=function(){return At.prototype.clear.call(this)},e.search=function(t){var e=At.prototype.search.call(this,this.toBBox(t));return Tt(e)},e.collides=function(t){return At.prototype.collides.call(this,this.toBBox(t))},e.all=function(){var t=At.prototype.all.call(this);return Tt(t)},e.toJSON=function(){return At.prototype.toJSON.call(this)},e.fromJSON=function(json){return At.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=Gt(t);else{if("FeatureCollection"!==t.type)throw new Error("invalid geojson");e=Gt(t)}return{minX:e[0],minY:e[1],maxX:e[2],maxY:e[3]}},e}function Rt(t,e){var r={},n=[];if("LineString"===t.type&&(t=nt(t)),"LineString"===e.type&&(e=nt(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=Ft(t,e);return o&&n.push(o),it(n)}var i=gt.exports();return i.load(ht(e)),ft(ht(t),(function(t){ft(i.search(t),(function(e){var o=Ft(t,e);if(o){var key=st(o).join(",");r[key]||(r[key]=!0,n.push(o))}}))})),it(n)}function Ft(t,e){var r=st(t),n=st(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(!at(t[0])||!at(t[1]))throw new Error("coordinates must contain numbers");return nt({type:"Point",coordinates:t},e,r)}([o+y*(a-o),i+y*(s-i)]):null}function Nt(t,e){void 0===e&&(e={});var r=ut(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=ut(t).coordinates,n=e.properties?e.properties:"Feature"===t.type?t.properties:{};return It(r,n)}(r,e);case"MultiPolygon":return function(t,e){void 0===e&&(e={});var r=ut(t).coordinates,n=e.properties?e.properties:"Feature"===t.type?t.properties:{},o=[];return r.forEach((function(t){o.push(It(t,n))})),it(o)}(r,e);default:throw new Error("invalid poly")}}function It(t,e){return t.length>1?function(t,e,r){return void 0===r&&(r={}),nt({type:"MultiLineString",coordinates:t},e,r)}(t,e):ot(t[0],e)}function qt(t,e){var r=!0;return pt(t,(function(t){pt(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!Dt(e,t);case"Polygon":return!ct(t,e)}break;case"LineString":switch(e.type){case"Point":return!Dt(t,e);case"LineString":return!function(t,e){if(Rt(t,e).features.length>0)return!0;return!1}(t,e);case"Polygon":return!Jt(e,t)}break;case"Polygon":switch(e.type){case"Point":return!ct(e,t);case"LineString":return!Jt(t,e);case"Polygon":return!function(t,e){for(var r=0,n=t.coordinates[0];r<n.length;r++){if(ct(n[r],e))return!0}for(var o=0,i=e.coordinates[0];o<i.length;o++){if(ct(i[o],t))return!0}if(Rt(Nt(t),Nt(e)).features.length>0)return!0;return!1}(e,t)}}var r,n;return!1}(t.geometry,e.geometry)}))})),r}function Dt(t,e){for(var r=0;r<t.coordinates.length-1;r++)if(Wt(t.coordinates[r],t.coordinates[r+1],e.coordinates))return!0;return!1}function Jt(t,e){for(var r=0,n=e.coordinates;r<n.length;r++){if(ct(n[r],t))return!0}return Rt(e,Nt(t)).features.length>0}function Wt(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 Vt(t){return t*Math.PI/180}gt.exports=Lt,gt.exports.default=Lt;var Ut=new w.default,Xt=new v.default,Yt=new _.default({featureNS:"https:/foo"}),Bt=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 A.default))return!1;var e=g.fromExtent(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=y.toLonLat(e,r),a=i[0],s=i[1],u=g.circular([a,s],n,o);return t.transform(u,t.WGS84_CODE,r)},t.prototype.assertValid=function(){if(!(this.getGeometry()instanceof P.default))throw new Error("Not a valid geometry");return this},t.prototype.getGeometry=function(){var t=this._feature.getGeometry();return t instanceof b.default?g.fromCircle(t):t},t.prototype.getGeometryAsArray=function(){var t=this.getGeometry();return t instanceof x.default?t.getPoints():t instanceof O.default?t.getLineStrings():t instanceof C.default?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 n.getCenter(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 Ut.writeGeometry(r,{decimals:e});case"json":return Xt.writeGeometry(r,{decimals:e});case"turf":return Xt.writeGeometryObject(r);case"gml":return Yt.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 S.default?n.intersectsCoordinate(e.getCoordinates()):n instanceof S.default?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,pt(o,(function(t){pt(i,(function(e){if(!0===a)return!0;a=!qt(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 S.default?t.intersectsCoordinate(e.getCoordinates()):e instanceof E.default?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,r,o,i){void 0===o&&(o=!0);var a=this.getGeometry(),s=e.getGeometry();if(a instanceof S.default&&s.intersectsCoordinate(a.getCoordinates()))return!0;if(s instanceof S.default&&a.intersectsCoordinate(s.getCoordinates()))return!0;if(!o){var u=s.getClosestPoint(n.getCenter(a.getExtent())),c=a.getClosestPoint(u);return new E.default([c,u]).getLength()<=r||this.intersects(e,i)}a=this.getGeometryTransformed(i,t.WGS84_CODE);var l=(s=e.getGeometryTransformed(i,t.WGS84_CODE)).getClosestPoint(n.getCenter(a.getExtent()));return function(t,e,r){r=r||6371008.8;const n=Vt(t[1]),o=Vt(e[1]),i=(o-n)/2,a=Vt(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(l),l)<=r||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 r.Feature)return new t(obj).assertValid();if(obj instanceof P.default)return new t(new r.Feature(obj)).assertValid();if(obj instanceof Array){if(obj.length>0&&obj.length%2==0){if(2==obj.length)return new t(new r.Feature(new S.default(obj,"XY")));if(4==obj.length)return new t(new r.Feature(g.fromExtent(obj)));if(6==obj.length)return new t(new r.Feature(new E.default(obj,"XY")));var e=obj.slice(0,2),n=e[0],o=e[1],i=obj.slice(-2),a=i[0],s=i[1];return new t(n===a&&o===s?new r.Feature(new A.default(obj,"XY",[obj.length])):new r.Feature(new E.default(obj,"XY")))}}else{if(obj instanceof Object){if(t.GEOMETRYNAME_HINT in obj){var u=obj[t.GEOMETRYNAME_HINT];return t.factory(obj[u])}var c=Object.entries(obj).find((function(t){return t[1]instanceof P.default}));if(c){var l=new r.Feature(obj),key=c[0],f=c[1];return l.setGeometryName(key),l.setGeometry(f),new t(l).assertValid()}return new t(Xt.readFeature(obj)).assertValid()}if("string"==typeof obj)return"{"===obj.trimStart().charAt(0)?new t(Xt.readFeature(obj)).assertValid():new t(Ut.readFeature(obj)).assertValid()}throw new Error("Unsupported geometry type")},t}(),zt=function(t){function e(value,opts){var e=this,r=Bt.factory(value);return opts.geometryName&&r.setGeometryName(opts.geometryName),(e=t.call(this,r.getGeometryName(),r.asWkt())||this)._feature=r,e._opts=G({geometryName:r.getGeometryName()},opts),e._reporter=new I("".concat(e.getAlias(),":").concat(e.key)),e}return M(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=Bt.factory(obj);this._reporter.start();var e=!1,r=this._opts.polygraphOpts.projCode;if(this instanceof Kt)e=this.feature.intersects(t,r);else if(this instanceof Ht)e=!this.feature.intersects(t,r);else if(this instanceof $t)e=t.contains(this.feature);else if(this instanceof Qt)e=this.feature.contains(t);else if(this instanceof te){var opts=this._opts;e=this.feature.dwithin(t,opts.distance,opts.greatCircle,r)}else if(this instanceof ee){opts=this._opts;e=!this.feature.dwithin(t,opts.distance,opts.greatCircle,r)}return this._reporter.stop(e),e},e}(q),Kt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="intersects",e}(zt),Ht=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="disjoint",e}(zt),$t=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="contains",e}(zt),Qt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="within",e}(zt),Zt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),Object.defineProperty(e.prototype,"opts",{get:function(){return this._opts},enumerable:!1,configurable:!0}),e}(zt),te=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="dwithin",e}(Zt),ee=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return M(e,t),e.alias="beyond",e}(Zt),re=function(){function t(){}return t.metersToUnit=function(t,e,r,o){var i=y.get(r);if("degrees"===i.getUnits()){var a=n.getCenter(Bt.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 zt){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=y.get(null!==(n=opts.projection)&&void 0!==n?n:t.opts.polygraphOpts.projCode);value="SRID=".concat(a.getCode().split(":").pop(),";").concat(value)}if(t instanceof Kt)return"INTERSECTS(".concat(i,", ").concat(value,")");if(t instanceof Ht)return"DISJOINT(".concat(i,", ").concat(value,")");if(t instanceof $t)return"CONTAINS(".concat(i,", ").concat(value,")");if(t instanceof Qt)return"WITHIN(".concat(i,", ").concat(value,")");if(t instanceof Zt){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=Bt.distanceSphere(t.feature.getCenter(),u,s);if(value=Bt.factory(l).asWkt(null==opts?void 0:opts.decimals,{sourceProj:u,targetProj:c}),t instanceof te)return"INTERSECTS(".concat(i,", ").concat(value,")");if(t instanceof ee)return"DISJOINT(".concat(i,", ").concat(value,")")}}if(t instanceof D){value=t.value instanceof Date?t.value.toISOString():"string"==typeof t.value?"'".concat(t.value,"'"):t.value;if(t instanceof J)return"".concat(t.key," = ").concat(value);if(t instanceof W)return"".concat(t.key," IS NULL");if(t instanceof V)return"".concat(t.key," > ").concat(value);if(t instanceof U)return"".concat(t.key," >= ").concat(value);if(t instanceof X)return"".concat(t.key," < ").concat(value);if(t instanceof Y)return"".concat(t.key," <= ").concat(value);if(t instanceof B){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 $){var p=t.getOperators();if(p.length>0){if(t instanceof Q)return"(".concat(p.map(e).join(" AND "),")");if(t instanceof Z)return"(".concat(p.map(e).join(" OR "),")");if(t instanceof tt)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 zt){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 Kt)return"<ogc:Intersects>".concat(o).concat(value,"</ogc:Intersects>");if(t instanceof Ht)return"<ogc:Disjoint>".concat(o).concat(value,"</ogc:Disjoint>");if(t instanceof $t)return"<ogc:Contains>".concat(o).concat(value,"</ogc:Contains>");if(t instanceof Qt)return"<ogc:Within>".concat(o).concat(value,"</ogc:Within>");if(t instanceof Zt){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=Bt.distanceSphere(t.feature.getCenter(),a,i);if(value=Bt.factory(u).asGml(null==opts?void 0:opts.decimals,{sourceProj:a,targetProj:s}),t instanceof te)return"<ogc:Intersects>".concat(o).concat(value,"</ogc:Intersects>");if(t instanceof ee)return"<ogc:Disjoint>".concat(o).concat(value,"</ogc:Disjoint>")}}if(t instanceof D){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 J)return'<ogc:PropertyIsEqualTo matchCase="true">'.concat(o).concat(value,"</ogc:PropertyIsEqualTo>");if(t instanceof W)return"<ogc:PropertyIsNull>".concat(o,"</ogc:PropertyIsNull>");if(t instanceof V)return"<ogc:PropertyIsGreaterThan>".concat(o).concat(value,"</ogc:PropertyIsGreaterThan>");if(t instanceof U)return"<ogc:PropertyIsGreaterThanOrEqualTo>".concat(o).concat(value,"</ogc:PropertyIsGreaterThanOrEqualTo>");if(t instanceof X)return"<ogc:PropertyIsLessThan>".concat(o).concat(value,"</ogc:PropertyIsLessThan>");if(t instanceof Y)return"<ogc:PropertyIsLessThanOrEqualTo>".concat(o).concat(value,"</ogc:PropertyIsLessThanOrEqualTo>");if(t instanceof B)return'<ogc:PropertyIsLike matchCase="'.concat(t.opts.matchCase,'" wildCard="').concat(t.opts.wildCard,'" escapeChar="\\" singleChar=".">').concat(o).concat(value,"</ogc:PropertyIsLike>")}if(t instanceof $){var c=t.getOperators();if(c.length>0){if(t instanceof Q)return"<ogc:And>".concat(c.map(e).join(""),"</ogc:And>");if(t instanceof Z)return"<ogc:Or>".concat(c.map(e).join(""),"</ogc:Or>");if(t instanceof tt)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}(),ne="EPSG:3857",oe=function(){this.projCode=ne},ie=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e._opts=new oe,e}return M(e,t),e.p