diff --git a/assets/demo-C9TpCBkC.js b/assets/demo-C9TpCBkC.js new file mode 100644 index 0000000..734badd --- /dev/null +++ b/assets/demo-C9TpCBkC.js @@ -0,0 +1,385 @@ +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const r of document.querySelectorAll('link[rel="modulepreload"]'))i(r);new MutationObserver(r=>{for(const s of r)if(s.type==="childList")for(const o of s.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&i(o)}).observe(document,{childList:!0,subtree:!0});function t(r){const s={};return r.integrity&&(s.integrity=r.integrity),r.referrerPolicy&&(s.referrerPolicy=r.referrerPolicy),r.crossOrigin==="use-credentials"?s.credentials="include":r.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function i(r){if(r.ep)return;r.ep=!0;const s=t(r);fetch(r.href,s)}})();class Jt{constructor(e){this.propagationStopped,this.defaultPrevented,this.type=e,this.target=null}preventDefault(){this.defaultPrevented=!0}stopPropagation(){this.propagationStopped=!0}}const bn={PROPERTYCHANGE:"propertychange"};class ka{constructor(){this.disposed=!1}dispose(){this.disposed||(this.disposed=!0,this.disposeInternal())}disposeInternal(){}}function Yd(n,e,t){let i,r;t=t||yi;let s=0,o=n.length,a=!1;for(;s>1),r=+t(n[i],e),r<0?s=i+1:(o=i,a=!r);return a?s:~s}function yi(n,e){return n>e?1:n0?r-1:r}return i-1}if(t>0){for(let r=1;r0||t&&o===0)})}function rr(){return!0}function Us(){return!1}function Tn(){}function qd(n){let e=!1,t,i,r;return function(){const s=Array.prototype.slice.call(arguments);return(!e||this!==r||!vi(s,i))&&(e=!0,r=this,i=s,t=n.apply(this,arguments)),t}}function ms(n){function e(){let t;try{t=n()}catch(i){return Promise.reject(i)}return t instanceof Promise?t:Promise.resolve(t)}return e()}function Cr(n){for(const e in n)delete n[e]}function ji(n){let e;for(e in n)return!1;return!e}class Vs extends ka{constructor(e){super(),this.eventTarget_=e,this.pendingRemovals_=null,this.dispatching_=null,this.listeners_=null}addEventListener(e,t){if(!e||!t)return;const i=this.listeners_||(this.listeners_={}),r=i[e]||(i[e]=[]);r.includes(t)||r.push(t)}dispatchEvent(e){const t=typeof e=="string",i=t?e:e.type,r=this.listeners_&&this.listeners_[i];if(!r)return;const s=t?new Jt(e):e;s.target||(s.target=this.eventTarget_||this);const o=this.dispatching_||(this.dispatching_={}),a=this.pendingRemovals_||(this.pendingRemovals_={});i in o||(o[i]=0,a[i]=0),++o[i];let l;for(let u=0,h=r.length;u0:!1}removeEventListener(e,t){const i=this.listeners_&&this.listeners_[e];if(i){const r=i.indexOf(t);r!==-1&&(this.pendingRemovals_&&e in this.pendingRemovals_?(i[r]=Tn,++this.pendingRemovals_[e]):(i.splice(r,1),i.length===0&&delete this.listeners_[e]))}}}const Y={CHANGE:"change",ERROR:"error",BLUR:"blur",CLEAR:"clear",CONTEXTMENU:"contextmenu",CLICK:"click",DBLCLICK:"dblclick",DRAGENTER:"dragenter",DRAGOVER:"dragover",DROP:"drop",FOCUS:"focus",KEYDOWN:"keydown",KEYPRESS:"keypress",LOAD:"load",RESIZE:"resize",TOUCHMOVE:"touchmove",WHEEL:"wheel"};function oe(n,e,t,i,r){if(i&&i!==n&&(t=t.bind(i)),r){const o=t;t=function(){n.removeEventListener(e,t),o.apply(this,arguments)}}const s={target:n,type:e,listener:t};return n.addEventListener(e,t),s}function ys(n,e,t,i){return oe(n,e,t,i,!0)}function xe(n){n&&n.target&&(n.target.removeEventListener(n.type,n.listener),Cr(n))}class br extends Vs{constructor(){super(),this.on=this.onInternal,this.once=this.onceInternal,this.un=this.unInternal,this.revision_=0}changed(){++this.revision_,this.dispatchEvent(Y.CHANGE)}getRevision(){return this.revision_}onInternal(e,t){if(Array.isArray(e)){const i=e.length,r=new Array(i);for(let s=0;s0&&n[1]>0}function Qd(n,e,t){return t===void 0&&(t=[0,0]),t[0]=n[0]*e+.5|0,t[1]=n[1]*e+.5|0,t}function Be(n,e){return Array.isArray(n)?n:(e===void 0?e=[n,n]:(e[0]=n,e[1]=n),e)}class Bs{constructor(e){this.opacity_=e.opacity,this.rotateWithView_=e.rotateWithView,this.rotation_=e.rotation,this.scale_=e.scale,this.scaleArray_=Be(e.scale),this.displacement_=e.displacement,this.declutterMode_=e.declutterMode}clone(){const e=this.getScale();return new Bs({opacity:this.getOpacity(),scale:Array.isArray(e)?e.slice():e,rotation:this.getRotation(),rotateWithView:this.getRotateWithView(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getOpacity(){return this.opacity_}getRotateWithView(){return this.rotateWithView_}getRotation(){return this.rotation_}getScale(){return this.scale_}getScaleArray(){return this.scaleArray_}getDisplacement(){return this.displacement_}getDeclutterMode(){return this.declutterMode_}getAnchor(){return W()}getImage(e){return W()}getHitDetectionImage(){return W()}getPixelRatio(e){return 1}getImageState(){return W()}getImageSize(){return W()}getOrigin(){return W()}getSize(){return W()}setDisplacement(e){this.displacement_=e}setOpacity(e){this.opacity_=e}setRotateWithView(e){this.rotateWithView_=e}setRotation(e){this.rotation_=e}setScale(e){this.scale_=e,this.scaleArray_=Be(e)}listenImageChange(e){W()}load(){W()}unlistenImageChange(e){W()}}function Me(n,e,t){return Math.min(Math.max(n,e),t)}function ef(n,e,t,i,r,s){const o=r-t,a=s-i;if(o!==0||a!==0){const l=((n-t)*o+(e-i)*a)/(o*o+a*a);l>1?(t=r,i=s):l>0&&(t+=o*l,i+=a*l)}return zi(n,e,t,i)}function zi(n,e,t,i){const r=t-n,s=i-e;return r*r+s*s}function tf(n){const e=n.length;for(let i=0;is&&(s=l,r=a)}if(s===0)return null;const o=n[r];n[r]=n[i],n[i]=o;for(let a=i+1;a=0;i--){t[i]=n[i][e]/n[i][i];for(let r=i-1;r>=0;r--)n[r][e]-=n[r][i]*t[i]}return t}function cs(n){return n*Math.PI/180}function Ni(n,e){const t=n%e;return t*e<0?t+e:t}function at(n,e,t){return n+t*(e-n)}function Da(n,e){const t=Math.pow(10,e);return Math.round(n*t)/t}function Yr(n,e){return Math.floor(Da(n,e))}function Br(n,e){return Math.ceil(Da(n,e))}const nf=/^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i,rf=/^([a-z]*)$|^hsla?\(.*\)$/i;function Mh(n){return typeof n=="string"?n:Ph(n)}function sf(n){const e=document.createElement("div");if(e.style.color=n,e.style.color!==""){document.body.appendChild(e);const t=getComputedStyle(e).color;return document.body.removeChild(e),t}return""}const of=function(){const e={};let t=0;return function(i){let r;if(e.hasOwnProperty(i))r=e[i];else{if(t>=1024){let s=0;for(const o in e)s++&3||(delete e[o],--t)}r=af(i),e[i]=r,++t}return r}}();function _s(n){return Array.isArray(n)?n:of(n)}function af(n){let e,t,i,r,s;if(rf.exec(n)&&(n=sf(n)),nf.exec(n)){const o=n.length-1;let a;o<=4?a=1:a=2;const l=o===4||o===8;e=parseInt(n.substr(1+0*a,a),16),t=parseInt(n.substr(1+1*a,a),16),i=parseInt(n.substr(1+2*a,a),16),l?r=parseInt(n.substr(1+3*a,a),16):r=255,a==1&&(e=(e<<4)+e,t=(t<<4)+t,i=(i<<4)+i,l&&(r=(r<<4)+r)),s=[e,t,i,r/255]}else if(n.startsWith("rgba("))s=n.slice(5,-1).split(",").map(Number),eu(s);else if(n.startsWith("rgb("))s=n.slice(4,-1).split(",").map(Number),s.push(1),eu(s);else throw new Error("Invalid color");return s}function eu(n){return n[0]=Me(n[0]+.5|0,0,255),n[1]=Me(n[1]+.5|0,0,255),n[2]=Me(n[2]+.5|0,0,255),n[3]=Me(n[3],0,1),n}function Ph(n){let e=n[0];e!=(e|0)&&(e=e+.5|0);let t=n[1];t!=(t|0)&&(t=t+.5|0);let i=n[2];i!=(i|0)&&(i=i+.5|0);const r=n[3]===void 0?1:Math.round(n[3]*100)/100;return"rgba("+e+","+t+","+i+","+r+")"}const _i=typeof navigator<"u"&&typeof navigator.userAgent<"u"?navigator.userAgent.toLowerCase():"",lf=_i.includes("firefox"),uf=_i.includes("safari")&&!_i.includes("chrom");uf&&(_i.includes("version/15.4")||/cpu (os|iphone os) 15_4 like mac os x/.test(_i));const hf=_i.includes("webkit")&&!_i.includes("edge"),Lh=_i.includes("macintosh"),za=typeof devicePixelRatio<"u"?devicePixelRatio:1,Na=typeof WorkerGlobalScope<"u"&&typeof OffscreenCanvas<"u"&&self instanceof WorkerGlobalScope,kh=typeof Image<"u"&&Image.prototype.decode,Oh=function(){let n=!1;try{const e=Object.defineProperty({},"passive",{get:function(){n=!0}});window.addEventListener("_",null,e),window.removeEventListener("_",null,e)}catch{}return n}();function $e(n,e,t,i){let r;return t&&t.length?r=t.shift():Na?r=new OffscreenCanvas(n||300,e||300):r=document.createElement("canvas"),n&&(r.width=n),e&&(r.height=e),r.getContext("2d",i)}function Tr(n){const e=n.canvas;e.width=1,e.height=1,n.clearRect(0,0,1,1)}function tu(n,e){const t=e.parentNode;t&&t.replaceChild(n,e)}function Qo(n){return n&&n.parentNode?n.parentNode.removeChild(n):null}function cf(n){for(;n.lastChild;)n.removeChild(n.lastChild)}function df(n,e){const t=n.childNodes;for(let i=0;;++i){const r=t[i],s=e[i];if(!r&&!s)break;if(r!==s){if(!r){n.appendChild(s);continue}if(!s){n.removeChild(r),--i;continue}n.insertBefore(s,r)}}}function ff(n,e,t){const i=n;let r=!0,s=!1,o=!1;const a=[ys(i,Y.LOAD,function(){o=!0,s||e()})];return i.src&&kh?(s=!0,i.decode().then(function(){r&&e()}).catch(function(l){r&&(o?e():t())})):a.push(ys(i,Y.ERROR,t)),function(){r=!1,a.forEach(xe)}}function gf(n,e){return new Promise((t,i)=>{function r(){o(),t(n)}function s(){o(),i(new Error("Image load error"))}function o(){n.removeEventListener("load",r),n.removeEventListener("error",s)}n.addEventListener("load",r),n.addEventListener("error",s),e&&(n.src=e)})}function pf(n,e){return e&&(n.src=e),kh?new Promise((t,i)=>n.decode().then(()=>t(n),i)):gf(n)}class mf{constructor(){this.cache_={},this.cacheSize_=0,this.maxCacheSize_=32}clear(){this.cache_={},this.cacheSize_=0}canExpireCache(){return this.cacheSize_>this.maxCacheSize_}expire(){if(this.canExpireCache()){let e=0;for(const t in this.cache_){const i=this.cache_[t];!(e++&3)&&!i.hasListener()&&(delete this.cache_[t],--this.cacheSize_)}}}get(e,t,i){const r=iu(e,t,i);return r in this.cache_?this.cache_[r]:null}set(e,t,i,r){const s=iu(e,t,i);this.cache_[s]=r,++this.cacheSize_}setSize(e){this.maxCacheSize_=e,this.expire()}}function iu(n,e,t){const i=t?Mh(t):"null";return e+":"+n+":"+i}const xs=new mf;let Wn=null;class yf extends Vs{constructor(e,t,i,r,s){super(),this.hitDetectionImage_=null,this.image_=e,this.crossOrigin_=i,this.canvas_={},this.color_=s,this.imageState_=r===void 0?ye.IDLE:r,this.size_=e&&e.width&&e.height?[e.width,e.height]:null,this.src_=t,this.tainted_}initializeImage_(){this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)}isTainted_(){if(this.tainted_===void 0&&this.imageState_===ye.LOADED){Wn||(Wn=$e(1,1,void 0,{willReadFrequently:!0})),Wn.drawImage(this.image_,0,0);try{Wn.getImageData(0,0,1,1),this.tainted_=!1}catch{Wn=null,this.tainted_=!0}}return this.tainted_===!0}dispatchChangeEvent_(){this.dispatchEvent(Y.CHANGE)}handleImageError_(){this.imageState_=ye.ERROR,this.dispatchChangeEvent_()}handleImageLoad_(){this.imageState_=ye.LOADED,this.size_=[this.image_.width,this.image_.height],this.dispatchChangeEvent_()}getImage(e){return this.image_||this.initializeImage_(),this.replaceColor_(e),this.canvas_[e]?this.canvas_[e]:this.image_}getPixelRatio(e){return this.replaceColor_(e),this.canvas_[e]?e:1}getImageState(){return this.imageState_}getHitDetectionImage(){if(this.image_||this.initializeImage_(),!this.hitDetectionImage_)if(this.isTainted_()){const e=this.size_[0],t=this.size_[1],i=$e(e,t);i.fillRect(0,0,e,t),this.hitDetectionImage_=i.canvas}else this.hitDetectionImage_=this.image_;return this.hitDetectionImage_}getSize(){return this.size_}getSrc(){return this.src_}load(){if(this.imageState_===ye.IDLE){this.image_||this.initializeImage_(),this.imageState_=ye.LOADING;try{this.src_!==void 0&&(this.image_.src=this.src_)}catch{this.handleImageError_()}this.image_ instanceof HTMLImageElement&&pf(this.image_,this.src_).then(e=>{this.image_=e,this.handleImageLoad_()}).catch(this.handleImageError_.bind(this))}}replaceColor_(e){if(!this.color_||this.canvas_[e]||this.imageState_!==ye.LOADED)return;const t=this.image_,i=document.createElement("canvas");i.width=Math.ceil(t.width*e),i.height=Math.ceil(t.height*e);const r=i.getContext("2d");r.scale(e,e),r.drawImage(t,0,0),r.globalCompositeOperation="multiply",r.fillStyle=Mh(this.color_),r.fillRect(0,0,i.width/e,i.height/e),r.globalCompositeOperation="destination-in",r.drawImage(t,0,0),this.canvas_[e]=i}}function _f(n,e,t,i,r){let s=e===void 0?void 0:xs.get(e,t,r);return s||(s=new yf(n,n instanceof HTMLImageElement?n.src||void 0:e,t,i,r),xs.set(e,t,r,s)),s}function nu(n,e,t,i){return t!==void 0&&i!==void 0?[t/n,i/e]:t!==void 0?t/n:i!==void 0?i/e:1}class Xi extends Bs{constructor(e){e=e||{};const t=e.opacity!==void 0?e.opacity:1,i=e.rotation!==void 0?e.rotation:0,r=e.scale!==void 0?e.scale:1,s=e.rotateWithView!==void 0?e.rotateWithView:!1;super({opacity:t,rotation:i,scale:r,displacement:e.displacement!==void 0?e.displacement:[0,0],rotateWithView:s,declutterMode:e.declutterMode}),this.anchor_=e.anchor!==void 0?e.anchor:[.5,.5],this.normalizedAnchor_=null,this.anchorOrigin_=e.anchorOrigin!==void 0?e.anchorOrigin:"top-left",this.anchorXUnits_=e.anchorXUnits!==void 0?e.anchorXUnits:"fraction",this.anchorYUnits_=e.anchorYUnits!==void 0?e.anchorYUnits:"fraction",this.crossOrigin_=e.crossOrigin!==void 0?e.crossOrigin:null;const o=e.img!==void 0?e.img:null;let a=e.src;te(!(a!==void 0&&o),"`image` and `src` cannot be provided at the same time"),(a===void 0||a.length===0)&&o&&(a=o.src||U(o)),te(a!==void 0&&a.length>0,"A defined and non-empty `src` or `image` must be provided"),te(!((e.width!==void 0||e.height!==void 0)&&e.scale!==void 0),"`width` or `height` cannot be provided together with `scale`");let l;if(e.src!==void 0?l=ye.IDLE:o!==void 0&&(o instanceof HTMLImageElement?o.complete?l=o.src?ye.LOADED:ye.IDLE:l=ye.LOADING:l=ye.LOADED),this.color_=e.color!==void 0?_s(e.color):null,this.iconImage_=_f(o,a,this.crossOrigin_,l,this.color_),this.offset_=e.offset!==void 0?e.offset:[0,0],this.offsetOrigin_=e.offsetOrigin!==void 0?e.offsetOrigin:"top-left",this.origin_=null,this.size_=e.size!==void 0?e.size:null,e.width!==void 0||e.height!==void 0){let u,h;if(e.size)[u,h]=e.size;else{const c=this.getImage(1);if(c.width&&c.height)u=c.width,h=c.height;else if(c instanceof HTMLImageElement){this.initialOptions_=e;const d=()=>{if(this.unlistenImageChange(d),!this.initialOptions_)return;const f=this.iconImage_.getSize();this.setScale(nu(f[0],f[1],e.width,e.height))};this.listenImageChange(d);return}}u!==void 0&&this.setScale(nu(u,h,e.width,e.height))}}clone(){let e,t,i;return this.initialOptions_?(t=this.initialOptions_.width,i=this.initialOptions_.height):(e=this.getScale(),e=Array.isArray(e)?e.slice():e),new Xi({anchor:this.anchor_.slice(),anchorOrigin:this.anchorOrigin_,anchorXUnits:this.anchorXUnits_,anchorYUnits:this.anchorYUnits_,color:this.color_&&this.color_.slice?this.color_.slice():this.color_||void 0,crossOrigin:this.crossOrigin_,offset:this.offset_.slice(),offsetOrigin:this.offsetOrigin_,opacity:this.getOpacity(),rotateWithView:this.getRotateWithView(),rotation:this.getRotation(),scale:e,width:t,height:i,size:this.size_!==null?this.size_.slice():void 0,src:this.getSrc(),displacement:this.getDisplacement().slice(),declutterMode:this.getDeclutterMode()})}getAnchor(){let e=this.normalizedAnchor_;if(!e){e=this.anchor_;const r=this.getSize();if(this.anchorXUnits_=="fraction"||this.anchorYUnits_=="fraction"){if(!r)return null;e=this.anchor_.slice(),this.anchorXUnits_=="fraction"&&(e[0]*=r[0]),this.anchorYUnits_=="fraction"&&(e[1]*=r[1])}if(this.anchorOrigin_!="top-left"){if(!r)return null;e===this.anchor_&&(e=this.anchor_.slice()),(this.anchorOrigin_=="top-right"||this.anchorOrigin_=="bottom-right")&&(e[0]=-e[0]+r[0]),(this.anchorOrigin_=="bottom-left"||this.anchorOrigin_=="bottom-right")&&(e[1]=-e[1]+r[1])}this.normalizedAnchor_=e}const t=this.getDisplacement(),i=this.getScaleArray();return[e[0]-t[0]/i[0],e[1]+t[1]/i[1]]}setAnchor(e){this.anchor_=e,this.normalizedAnchor_=null}getColor(){return this.color_}getImage(e){return this.iconImage_.getImage(e)}getPixelRatio(e){return this.iconImage_.getPixelRatio(e)}getImageSize(){return this.iconImage_.getSize()}getImageState(){return this.iconImage_.getImageState()}getHitDetectionImage(){return this.iconImage_.getHitDetectionImage()}getOrigin(){if(this.origin_)return this.origin_;let e=this.offset_;if(this.offsetOrigin_!="top-left"){const t=this.getSize(),i=this.iconImage_.getSize();if(!t||!i)return null;e=e.slice(),(this.offsetOrigin_=="top-right"||this.offsetOrigin_=="bottom-right")&&(e[0]=i[0]-t[0]-e[0]),(this.offsetOrigin_=="bottom-left"||this.offsetOrigin_=="bottom-right")&&(e[1]=i[1]-t[1]-e[1])}return this.origin_=e,this.origin_}getSrc(){return this.iconImage_.getSrc()}getSize(){return this.size_?this.size_:this.iconImage_.getSize()}getWidth(){const e=this.getScaleArray();if(this.size_)return this.size_[0]*e[0];if(this.iconImage_.getImageState()==ye.LOADED)return this.iconImage_.getSize()[0]*e[0]}getHeight(){const e=this.getScaleArray();if(this.size_)return this.size_[1]*e[1];if(this.iconImage_.getImageState()==ye.LOADED)return this.iconImage_.getSize()[1]*e[1]}setScale(e){delete this.initialOptions_,super.setScale(e)}listenImageChange(e){this.iconImage_.addEventListener(Y.CHANGE,e)}load(){this.iconImage_.load()}unlistenImageChange(e){this.iconImage_.removeEventListener(Y.CHANGE,e)}}const Rn={radians:6370997/(2*Math.PI),degrees:2*Math.PI*6370997/360,ft:.3048,m:1,"us-ft":1200/3937};class Ga{constructor(e){this.code_=e.code,this.units_=e.units,this.extent_=e.extent!==void 0?e.extent:null,this.worldExtent_=e.worldExtent!==void 0?e.worldExtent:null,this.axisOrientation_=e.axisOrientation!==void 0?e.axisOrientation:"enu",this.global_=e.global!==void 0?e.global:!1,this.canWrapX_=!!(this.global_&&this.extent_),this.getPointResolutionFunc_=e.getPointResolution,this.defaultTileGrid_=null,this.metersPerUnit_=e.metersPerUnit}canWrapX(){return this.canWrapX_}getCode(){return this.code_}getExtent(){return this.extent_}getUnits(){return this.units_}getMetersPerUnit(){return this.metersPerUnit_||Rn[this.units_]}getWorldExtent(){return this.worldExtent_}getAxisOrientation(){return this.axisOrientation_}isGlobal(){return this.global_}setGlobal(e){this.global_=e,this.canWrapX_=!!(e&&this.extent_)}getDefaultTileGrid(){return this.defaultTileGrid_}setDefaultTileGrid(e){this.defaultTileGrid_=e}setExtent(e){this.extent_=e,this.canWrapX_=!!(this.global_&&e)}setWorldExtent(e){this.worldExtent_=e}setGetPointResolution(e){this.getPointResolutionFunc_=e}getPointResolutionFunc(){return this.getPointResolutionFunc_}}const Rr=6378137,gn=Math.PI*Rr,xf=[-gn,-gn,gn,gn],vf=[-180,-85,180,85],Zr=Rr*Math.log(Math.tan(Math.PI/2));class Qi extends Ga{constructor(e){super({code:e,units:"m",extent:xf,global:!0,worldExtent:vf,getPointResolution:function(t,i){return t/Math.cosh(i[1]/Rr)}})}}const ru=[new Qi("EPSG:3857"),new Qi("EPSG:102100"),new Qi("EPSG:102113"),new Qi("EPSG:900913"),new Qi("http://www.opengis.net/def/crs/EPSG/0/3857"),new Qi("http://www.opengis.net/gml/srs/epsg.xml#3857")];function Ef(n,e,t){const i=n.length;t=t>1?t:2,e===void 0&&(t>2?e=n.slice():e=new Array(i));for(let r=0;rZr?s=Zr:s<-Zr&&(s=-Zr),e[r+1]=s}return e}function wf(n,e,t){const i=n.length;t=t>1?t:2,e===void 0&&(t>2?e=n.slice():e=new Array(i));for(let r=0;rr&&(l=l|De.RIGHT),as&&(l=l|De.ABOVE),l===De.UNKNOWN&&(l=De.INTERSECTING),l}function mt(){return[1/0,1/0,-1/0,-1/0]}function Zt(n,e,t,i,r){return r?(r[0]=n,r[1]=e,r[2]=t,r[3]=i,r):[n,e,t,i]}function On(n){return Zt(1/0,1/0,-1/0,-1/0,n)}function zh(n,e){const t=n[0],i=n[1];return Zt(t,i,t,i,e)}function ja(n,e,t,i,r){const s=On(r);return Gh(s,n,e,t,i)}function Sn(n,e){return n[0]==e[0]&&n[2]==e[2]&&n[1]==e[1]&&n[3]==e[3]}function Nh(n,e){return e[0]n[2]&&(n[2]=e[2]),e[1]n[3]&&(n[3]=e[3]),n}function Kn(n,e){e[0]n[2]&&(n[2]=e[0]),e[1]n[3]&&(n[3]=e[1])}function Gh(n,e,t,i,r){for(;te[0]?i[0]=n[0]:i[0]=e[0],n[1]>e[1]?i[1]=n[1]:i[1]=e[1],n[2]=e[0]&&n[1]<=e[3]&&n[3]>=e[1]}function Ir(n){return n[2]=o&&p<=l),!i&&s&De.RIGHT&&!(r&De.RIGHT)&&(m=f-(d-l)*g,i=m>=a&&m<=u),!i&&s&De.BELOW&&!(r&De.BELOW)&&(p=d-(f-a)/g,i=p>=o&&p<=l),!i&&s&De.LEFT&&!(r&De.LEFT)&&(m=f-(d-o)*g,i=m>=a&&m<=u)}return i}function Lf(n,e,t,i){if(Ir(n))return On(t);let r=[];if(i>1){const a=n[2]-n[0],l=n[3]-n[1];for(let u=0;u=t[2])){const r=ge(t),o=Math.floor((i[0]-t[0])/r)*r;n[0]-=o,n[2]-=o}return n}function kf(n,e){if(e.canWrapX()){const t=e.getExtent();if(!isFinite(n[0])||!isFinite(n[2]))return[[t[0],n[1],t[2],n[3]]];jh(n,e);const i=ge(t);if(ge(n)>i)return[[t[0],n[1],t[2],n[3]]];if(n[0]t[2])return[[n[0],n[1],t[2],n[3]],[t[0],n[1],n[2]-i,n[3]]]}return[n]}function Of(n,e){return n[0]+=+e[0],n[1]+=+e[1],n}function Es(n,e){let t=!0;for(let i=n.length-1;i>=0;--i)if(n[i]!=e[i]){t=!1;break}return t}function Xa(n,e){const t=Math.cos(e),i=Math.sin(e),r=n[0]*t-n[1]*i,s=n[1]*t+n[0]*i;return n[0]=r,n[1]=s,n}function Df(n,e){return n[0]*=e,n[1]*=e,n}function Wa(n,e){if(e.canWrapX()){const t=ge(e.getExtent()),i=zf(n,e,t);i&&(n[0]-=i*t)}return n}function zf(n,e,t){const i=e.getExtent();let r=0;return e.canWrapX()&&(n[0]i[2])&&(t=t||ge(i),r=Math.floor((n[0]-i[0])/t)),r}const Nf=63710088e-1;function au(n,e,t){t=t||Nf;const i=cs(n[1]),r=cs(e[1]),s=(r-i)/2,o=cs(e[0]-n[0])/2,a=Math.sin(s)*Math.sin(s)+Math.sin(o)*Math.sin(o)*Math.cos(i)*Math.cos(r);return 2*t*Math.atan2(Math.sqrt(a),Math.sqrt(1-a))}function Xh(...n){console.warn(...n)}let oa=!0;function Wh(n){oa=!(n===void 0?!0:n)}function Ua(n,e){if(e!==void 0){for(let t=0,i=n.length;t180)&&(t[0]=Ni(i+180,360)-180),t}function ui(n,e){if(n===e)return!0;const t=n.getUnits()===e.getUnits();return(n.getCode()===e.getCode()||Hs(n,e)===Ua)&&t}function Hs(n,e){const t=n.getCode(),i=e.getCode();let r=Sf(t,i);return r||(r=Uh),r}function Cs(n,e){const t=pe(n),i=pe(e);return Hs(t,i)}function Ya(n,e,t){return Cs(e,t)(n,void 0,n.length)}function aa(n,e){return n}function $t(n,e){return oa&&!Es(n,[0,0])&&n[0]>=-180&&n[0]<=180&&n[1]>=-90&&n[1]<=90&&(oa=!1,Xh("Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.")),n}function Vh(n,e){return n}function Pi(n,e){return n}function Xf(){uu(ru),uu(ou),jf(ou,ru,Ef,wf)}Xf();class Yh{constructor(){this.dataProjection=void 0,this.defaultFeatureProjection=void 0,this.supportedMediaTypes=null}getReadOptions(e,t){if(t){let i=t.dataProjection?pe(t.dataProjection):this.readProjection(e);t.extent&&i&&i.getUnits()==="tile-pixels"&&(i=pe(i),i.setWorldExtent(t.extent)),t={dataProjection:i,featureProjection:t.featureProjection}}return this.adaptOptions(t)}adaptOptions(e){return Object.assign({dataProjection:this.dataProjection,featureProjection:this.defaultFeatureProjection},e)}getType(){return W()}readFeature(e,t){return W()}readFeatures(e,t){return W()}readGeometry(e,t){return W()}readProjection(e){return W()}writeFeature(e,t){return W()}writeFeatures(e,t){return W()}writeGeometry(e,t){return W()}}function Ba(n,e,t){const i=t?pe(t.featureProjection):null,r=t?pe(t.dataProjection):null;let s;if(i&&r&&!ui(i,r)?s=(e?n.clone():n).transform(e?i:r,e?r:i):s=n,e&&t&&t.decimals!==void 0){const o=Math.pow(10,t.decimals),a=function(l){for(let u=0,h=l.length;u1)c=t;else if(d>0){for(let f=0;fr&&(r=u),s=a,o=l}return r}function Ha(n,e,t,i,r){for(let s=0,o=t.length;s0;){const c=u.pop(),d=u.pop();let f=0;const g=n[d],p=n[d+1],m=n[c],y=n[c+1];for(let _=d+i;_f&&(h=_,f=E)}f>r&&(l[(h-e)/i]=1,d+i0&&p>f)&&(g<0&&m0&&m>g)){u=c,h=d;continue}s[o++]=u,s[o++]=h,a=u,l=h,u=c,h=d}return s[o++]=u,s[o++]=h,o}function Hh(n,e,t,i,r,s,o,a){for(let l=0,u=t.length;l1?o:2,s=s||new Array(o);for(let h=0;h>1;rs&&(u-a)*(s-l)-(r-a)*(h-l)>0&&o++:h<=s&&(u-a)*(s-l)-(r-a)*(h-l)<0&&o--,a=u,l=h}return o!==0}function il(n,e,t,i,r,s){if(t.length===0||!Li(n,e,t[0],i,r,s))return!1;for(let o=1,a=t.length;o=r[0]&&s[2]<=r[2]||s[1]>=r[1]&&s[3]<=r[3]?!0:Jh(n,e,t,i,function(o,a){return Pf(r,o,a)}):!1}function og(n,e,t,i,r){for(let s=0,o=t.length;sy&&(u=(h+c)/2,il(n,e,t,i,u,g)&&(m=u,y=_)),h=c}return isNaN(m)&&(m=r[s]),o?(o.push(m,g,y),o):[m,g,y]}function rc(n,e,t,i,r){let s=[];for(let o=0,a=t.length;o0}function sc(n,e,t,i,r){r=r!==void 0?r:!1;for(let s=0,o=t.length;s */sl.read=function(n,e,t,i,r){var s,o,a=r*8-i-1,l=(1<>1,h=-7,c=t?r-1:0,d=t?-1:1,f=n[e+c];for(c+=d,s=f&(1<<-h)-1,f>>=-h,h+=a;h>0;s=s*256+n[e+c],c+=d,h-=8);for(o=s&(1<<-h)-1,s>>=-h,h+=i;h>0;o=o*256+n[e+c],c+=d,h-=8);if(s===0)s=1-u;else{if(s===l)return o?NaN:(f?-1:1)*(1/0);o=o+Math.pow(2,i),s=s-u}return(f?-1:1)*o*Math.pow(2,s-i)};sl.write=function(n,e,t,i,r,s){var o,a,l,u=s*8-r-1,h=(1<>1,d=r===23?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:s-1,g=i?1:-1,p=e<0||e===0&&1/e<0?1:0;for(e=Math.abs(e),isNaN(e)||e===1/0?(a=isNaN(e)?1:0,o=h):(o=Math.floor(Math.log(e)/Math.LN2),e*(l=Math.pow(2,-o))<1&&(o--,l*=2),o+c>=1?e+=d/l:e+=d*Math.pow(2,1-c),e*l>=2&&(o++,l/=2),o+c>=h?(a=0,o=h):o+c>=1?(a=(e*l-1)*Math.pow(2,r),o=o+c):(a=e*Math.pow(2,c-1)*Math.pow(2,r),o=0));r>=8;n[t+f]=a&255,f+=g,a/=256,r-=8);for(o=o<0;n[t+f]=o&255,f+=g,o/=256,u-=8);n[t+f-g]|=p*128};var fg=le,qr=sl;function le(n){this.buf=ArrayBuffer.isView&&ArrayBuffer.isView(n)?n:new Uint8Array(n||0),this.pos=0,this.type=0,this.length=this.buf.length}le.Varint=0;le.Fixed64=1;le.Bytes=2;le.Fixed32=5;var fa=65536*65536,yu=1/fa,gg=12,ac=typeof TextDecoder>"u"?null:new TextDecoder("utf8");le.prototype={destroy:function(){this.buf=null},readFields:function(n,e,t){for(t=t||this.length;this.pos>3,s=this.pos;this.type=i&7,n(r,e,this),this.pos===s&&this.skip(i)}return e},readMessage:function(n,e){return this.readFields(n,e,this.readVarint()+this.pos)},readFixed32:function(){var n=Kr(this.buf,this.pos);return this.pos+=4,n},readSFixed32:function(){var n=xu(this.buf,this.pos);return this.pos+=4,n},readFixed64:function(){var n=Kr(this.buf,this.pos)+Kr(this.buf,this.pos+4)*fa;return this.pos+=8,n},readSFixed64:function(){var n=Kr(this.buf,this.pos)+xu(this.buf,this.pos+4)*fa;return this.pos+=8,n},readFloat:function(){var n=qr.read(this.buf,this.pos,!0,23,4);return this.pos+=4,n},readDouble:function(){var n=qr.read(this.buf,this.pos,!0,52,8);return this.pos+=8,n},readVarint:function(n){var e=this.buf,t,i;return i=e[this.pos++],t=i&127,i<128||(i=e[this.pos++],t|=(i&127)<<7,i<128)||(i=e[this.pos++],t|=(i&127)<<14,i<128)||(i=e[this.pos++],t|=(i&127)<<21,i<128)?t:(i=e[this.pos],t|=(i&15)<<28,pg(t,n,this))},readVarint64:function(){return this.readVarint(!0)},readSVarint:function(){var n=this.readVarint();return n%2===1?(n+1)/-2:n/2},readBoolean:function(){return!!this.readVarint()},readString:function(){var n=this.readVarint()+this.pos,e=this.pos;return this.pos=n,n-e>=gg&&ac?Ag(this.buf,e,n):Ig(this.buf,e,n)},readBytes:function(){var n=this.readVarint()+this.pos,e=this.buf.subarray(this.pos,n);return this.pos=n,e},readPackedVarint:function(n,e){if(this.type!==le.Bytes)return n.push(this.readVarint(e));var t=zt(this);for(n=n||[];this.pos127;);else if(e===le.Bytes)this.pos=this.readVarint()+this.pos;else if(e===le.Fixed32)this.pos+=4;else if(e===le.Fixed64)this.pos+=8;else throw new Error("Unimplemented type: "+e)},writeTag:function(n,e){this.writeVarint(n<<3|e)},realloc:function(n){for(var e=this.length||16;e268435455||n<0){mg(n,this);return}this.realloc(4),this.buf[this.pos++]=n&127|(n>127?128:0),!(n<=127)&&(this.buf[this.pos++]=(n>>>=7)&127|(n>127?128:0),!(n<=127)&&(this.buf[this.pos++]=(n>>>=7)&127|(n>127?128:0),!(n<=127)&&(this.buf[this.pos++]=n>>>7&127)))},writeSVarint:function(n){this.writeVarint(n<0?-n*2-1:n*2)},writeBoolean:function(n){this.writeVarint(!!n)},writeString:function(n){n=String(n),this.realloc(n.length*4),this.pos++;var e=this.pos;this.pos=Fg(this.buf,n,this.pos);var t=this.pos-e;t>=128&&_u(e,t,this),this.pos=e-1,this.writeVarint(t),this.pos+=t},writeFloat:function(n){this.realloc(4),qr.write(this.buf,n,this.pos,!0,23,4),this.pos+=4},writeDouble:function(n){this.realloc(8),qr.write(this.buf,n,this.pos,!0,52,8),this.pos+=8},writeBytes:function(n){var e=n.length;this.writeVarint(e),this.realloc(e);for(var t=0;t=128&&_u(t,i,this),this.pos=t-1,this.writeVarint(i),this.pos+=i},writeMessage:function(n,e,t){this.writeTag(n,le.Bytes),this.writeRawMessage(e,t)},writePackedVarint:function(n,e){e.length&&this.writeMessage(n,xg,e)},writePackedSVarint:function(n,e){e.length&&this.writeMessage(n,vg,e)},writePackedBoolean:function(n,e){e.length&&this.writeMessage(n,Cg,e)},writePackedFloat:function(n,e){e.length&&this.writeMessage(n,Eg,e)},writePackedDouble:function(n,e){e.length&&this.writeMessage(n,wg,e)},writePackedFixed32:function(n,e){e.length&&this.writeMessage(n,bg,e)},writePackedSFixed32:function(n,e){e.length&&this.writeMessage(n,Tg,e)},writePackedFixed64:function(n,e){e.length&&this.writeMessage(n,Rg,e)},writePackedSFixed64:function(n,e){e.length&&this.writeMessage(n,Sg,e)},writeBytesField:function(n,e){this.writeTag(n,le.Bytes),this.writeBytes(e)},writeFixed32Field:function(n,e){this.writeTag(n,le.Fixed32),this.writeFixed32(e)},writeSFixed32Field:function(n,e){this.writeTag(n,le.Fixed32),this.writeSFixed32(e)},writeFixed64Field:function(n,e){this.writeTag(n,le.Fixed64),this.writeFixed64(e)},writeSFixed64Field:function(n,e){this.writeTag(n,le.Fixed64),this.writeSFixed64(e)},writeVarintField:function(n,e){this.writeTag(n,le.Varint),this.writeVarint(e)},writeSVarintField:function(n,e){this.writeTag(n,le.Varint),this.writeSVarint(e)},writeStringField:function(n,e){this.writeTag(n,le.Bytes),this.writeString(e)},writeFloatField:function(n,e){this.writeTag(n,le.Fixed32),this.writeFloat(e)},writeDoubleField:function(n,e){this.writeTag(n,le.Fixed64),this.writeDouble(e)},writeBooleanField:function(n,e){this.writeVarintField(n,!!e)}};function pg(n,e,t){var i=t.buf,r,s;if(s=i[t.pos++],r=(s&112)>>4,s<128||(s=i[t.pos++],r|=(s&127)<<3,s<128)||(s=i[t.pos++],r|=(s&127)<<10,s<128)||(s=i[t.pos++],r|=(s&127)<<17,s<128)||(s=i[t.pos++],r|=(s&127)<<24,s<128)||(s=i[t.pos++],r|=(s&1)<<31,s<128))return en(n,r,e);throw new Error("Expected varint not more than 10 bytes")}function zt(n){return n.type===le.Bytes?n.readVarint()+n.pos:n.pos+1}function en(n,e,t){return t?e*4294967296+(n>>>0):(e>>>0)*4294967296+(n>>>0)}function mg(n,e){var t,i;if(n>=0?(t=n%4294967296|0,i=n/4294967296|0):(t=~(-n%4294967296),i=~(-n/4294967296),t^4294967295?t=t+1|0:(t=0,i=i+1|0)),n>=18446744073709552e3||n<-18446744073709552e3)throw new Error("Given varint doesn't fit into 10 bytes");e.realloc(10),yg(t,i,e),_g(i,e)}function yg(n,e,t){t.buf[t.pos++]=n&127|128,n>>>=7,t.buf[t.pos++]=n&127|128,n>>>=7,t.buf[t.pos++]=n&127|128,n>>>=7,t.buf[t.pos++]=n&127|128,n>>>=7,t.buf[t.pos]=n&127}function _g(n,e){var t=(n&7)<<4;e.buf[e.pos++]|=t|((n>>>=3)?128:0),n&&(e.buf[e.pos++]=n&127|((n>>>=7)?128:0),n&&(e.buf[e.pos++]=n&127|((n>>>=7)?128:0),n&&(e.buf[e.pos++]=n&127|((n>>>=7)?128:0),n&&(e.buf[e.pos++]=n&127|((n>>>=7)?128:0),n&&(e.buf[e.pos++]=n&127)))))}function _u(n,e,t){var i=e<=16383?1:e<=2097151?2:e<=268435455?3:Math.floor(Math.log(e)/(Math.LN2*7));t.realloc(i);for(var r=t.pos-1;r>=n;r--)t.buf[r+i]=t.buf[r]}function xg(n,e){for(var t=0;t>>8,n[t+2]=e>>>16,n[t+3]=e>>>24}function xu(n,e){return(n[e]|n[e+1]<<8|n[e+2]<<16)+(n[e+3]<<24)}function Ig(n,e,t){for(var i="",r=e;r239?4:s>223?3:s>191?2:1;if(r+a>t)break;var l,u,h;a===1?s<128&&(o=s):a===2?(l=n[r+1],(l&192)===128&&(o=(s&31)<<6|l&63,o<=127&&(o=null))):a===3?(l=n[r+1],u=n[r+2],(l&192)===128&&(u&192)===128&&(o=(s&15)<<12|(l&63)<<6|u&63,(o<=2047||o>=55296&&o<=57343)&&(o=null))):a===4&&(l=n[r+1],u=n[r+2],h=n[r+3],(l&192)===128&&(u&192)===128&&(h&192)===128&&(o=(s&15)<<18|(l&63)<<12|(u&63)<<6|h&63,(o<=65535||o>=1114112)&&(o=null))),o===null?(o=65533,a=1):o>65535&&(o-=65536,i+=String.fromCharCode(o>>>10&1023|55296),o=56320|o&1023),i+=String.fromCharCode(o),r+=a}return i}function Ag(n,e,t){return ac.decode(n.subarray(e,t))}function Fg(n,e,t){for(var i=0,r,s;i55295&&r<57344)if(s)if(r<56320){n[t++]=239,n[t++]=191,n[t++]=189,s=r;continue}else r=s-55296<<10|r-56320|65536,s=null;else{r>56319||i+1===e.length?(n[t++]=239,n[t++]=191,n[t++]=189):s=r;continue}else s&&(n[t++]=239,n[t++]=191,n[t++]=189,s=null);r<128?n[t++]=r:(r<2048?n[t++]=r>>6|192:(r<65536?n[t++]=r>>12|224:(n[t++]=r>>18|240,n[t++]=r>>12&63|128),n[t++]=r>>6&63|128),n[t++]=r&63|128)}return t}const Mg=dg(fg);class Ts extends Kh{constructor(e){super(),this.geometries_=e||null,this.changeEventsKeys_=[],this.listenGeometriesChange_()}unlistenGeometriesChange_(){this.changeEventsKeys_.forEach(xe),this.changeEventsKeys_.length=0}listenGeometriesChange_(){if(this.geometries_)for(let e=0,t=this.geometries_.length;e>3}if(a--,o===1||o===2)l+=e.readSVarint(),u+=e.readSVarint(),o===1&&h>c&&(r.push(h),c=h),i.push(l,u),h+=2;else if(o===7)h>c&&(i.push(i[c],i[c+1]),h+=2);else throw new Error("Invalid command found in the PBF")}h>c&&(r.push(h),c=h)}createFeature_(e,t,i){const r=t.type;if(r===0)return null;let s;const o=t.properties;let a;this.idProperty_?(a=o[this.idProperty_],delete o[this.idProperty_]):a=t.id,o[this.layerName_]=t.layer.name;const l=[],u=[];this.readRawGeometry_(e,t,l,u);const h=zg(r,u.length);if(this.featureClass_===Vi)s=new this.featureClass_(h,l,u,o,a),s.transform(i.dataProjection);else{let c;if(h=="Polygon"){const g=cg(l,u);c=g.length>1?new lr(l,"XY",g):new Kt(l,"XY",u)}else c=h==="Point"?new Ui(l,"XY"):h==="LineString"?new Wi(l,"XY"):h==="MultiPoint"?new Ar(l,"XY"):h==="MultiLineString"?new or(l,"XY",u):null;const d=this.featureClass_;s=new d,this.geometryName_&&s.setGeometryName(this.geometryName_);const f=Ba(c,!1,i);s.setGeometry(f),a!==void 0&&s.setId(a),s.setProperties(o,!0)}return s}getType(){return"arraybuffer"}readFeatures(e,t){const i=this.layers_;t=this.adaptOptions(t);const r=pe(t.dataProjection);r.setWorldExtent(t.extent),t.dataProjection=r;const s=new Mg(e),o=s.readFields(Lg,{}),a=[];for(const l in o){if(i&&!i.includes(l))continue;const u=o[l],h=u?[0,0,u.extent,u.extent]:null;r.setExtent(h);for(let c=0,d=u.length;c>3,i=n===1?t.readString():n===2?t.readFloat():n===3?t.readDouble():n===4?t.readVarint64():n===5?t.readVarint():n===6?t.readSVarint():n===7?t.readBoolean():null;e.values.push(i)}}function Og(n,e,t){if(n==1)e.id=t.readVarint();else if(n==2){const i=t.readVarint()+t.pos;for(;t.posMath.max(r,Ss(n,s)),0);return t[e]=i,i}function ip(n,e){const t=[],i=[],r=[];let s=0,o=0,a=0,l=0;for(let u=0,h=e.length;u<=h;u+=2){const c=e[u];if(c===` +`||u===h){s=Math.max(s,o),r.push(o),o=0,a+=l;continue}const d=e[u+1]||n.font,f=Ss(d,c);t.push(f),o+=f;const g=tp(d);i.push(g),l=Math.max(l,g)}return{width:s,height:a,widths:t,heights:i,lineWidths:r}}function np(n,e,t,i,r,s,o,a,l,u,h){n.save(),t!==1&&(n.globalAlpha*=t),e&&n.transform.apply(n,e),i.contextInstructions?(n.translate(l,u),n.scale(h[0],h[1]),rp(i,n)):h[0]<0||h[1]<0?(n.translate(l,u),n.scale(h[0],h[1]),n.drawImage(i,r,s,o,a,0,0,o,a)):n.drawImage(i,r,s,o,a,l,u,o*h[0],a*h[1]),n.restore()}function rp(n,e){const t=n.contextInstructions;for(let i=0,r=t.length;i{const o=t.getTileCoordExtent(s);r.push({coord:s,extent:o})}),r}let Eo;function hp(n,e){if(e===1)return n;Eo||(Eo=document.createElement("canvas"));const t=Eo;t.width=n.width,t.height=n.height;const i=t.getContext("2d");return i.globalAlpha=e,i.drawImage(n,0,0),t}function cp(n,e){return n.map(t=>t*e/72)}const dp=.5,dc={Point:vp,LineString:yp,Polygon:wp,MultiPoint:Ep,MultiLineString:_p,MultiPolygon:xp,GeometryCollection:mp,Circle:gp};function fp(n,e){return parseInt(U(n),10)-parseInt(U(e),10)}function fc(n,e){const t=_a(n,e);return t*t}function _a(n,e){return dp*n/e}function gp(n,e,t,i,r){const s=t.getFill(),o=t.getStroke();if(s||o){const l=n.getBuilder(t.getZIndex(),"Circle");l.setFillStrokeStyle(s,o),l.drawCircle(e,i)}const a=t.getText();if(a&&a.getText()){const l=(r||n).getBuilder(t.getZIndex(),"Text");l.setTextStyle(a),l.drawText(e,i)}}function fr(n,e,t,i,r,s,o){let a=!1;const l=t.getImage();if(l){const u=l.getImageState();u==ye.LOADED||u==ye.ERROR?l.unlistenImageChange(r):(u==ye.IDLE&&l.load(),l.listenImageChange(r),a=!0)}return pp(n,e,t,i,s,o),a}function pp(n,e,t,i,r,s){const o=t.getGeometryFunction()(e);if(!o)return;const a=o.simplifyTransformed(i,r);if(t.getRenderer())gc(n,a,t,e);else{const u=dc[a.getType()];u(n,a,t,e,s)}}function gc(n,e,t,i){if(e.getType()=="GeometryCollection"){const s=e.getGeometries();for(let o=0,a=s.length;oc*this.pixelRatio_),lineDashOffset:(o||Yt)*this.pixelRatio_,lineJoin:a!==void 0?a:An,lineWidth:(l!==void 0?l:dr)*this.pixelRatio_,miterLimit:u!==void 0?u:ur,strokeStyle:At(i||hr)}}}setImageStyle(e){let t;if(!e||!(t=e.getSize())){this.image_=null;return}const i=e.getPixelRatio(this.pixelRatio_),r=e.getAnchor(),s=e.getOrigin();this.image_=e.getImage(this.pixelRatio_),this.imageAnchorX_=r[0]*i,this.imageAnchorY_=r[1]*i,this.imageHeight_=t[1]*i,this.imageOpacity_=e.getOpacity(),this.imageOriginX_=s[0],this.imageOriginY_=s[1],this.imageRotateWithView_=e.getRotateWithView(),this.imageRotation_=e.getRotation();const o=e.getScaleArray();this.imageScale_=[o[0]*this.pixelRatio_/i,o[1]*this.pixelRatio_/i],this.imageWidth_=t[0]*i}setTextStyle(e){if(!e)this.text_="";else{const t=e.getFill();if(!t)this.textFillState_=null;else{const f=t.getColor();this.textFillState_={fillStyle:At(f||Qe)}}const i=e.getStroke();if(!i)this.textStrokeState_=null;else{const f=i.getColor(),g=i.getLineCap(),p=i.getLineDash(),m=i.getLineDashOffset(),y=i.getLineJoin(),_=i.getWidth(),v=i.getMiterLimit();this.textStrokeState_={lineCap:g!==void 0?g:In,lineDash:p||Vt,lineDashOffset:m||Yt,lineJoin:y!==void 0?y:An,lineWidth:_!==void 0?_:dr,miterLimit:v!==void 0?v:ur,strokeStyle:At(f||hr)}}const r=e.getFont(),s=e.getOffsetX(),o=e.getOffsetY(),a=e.getRotateWithView(),l=e.getRotation(),u=e.getScaleArray(),h=e.getText(),c=e.getTextAlign(),d=e.getTextBaseline();this.textState_={font:r!==void 0?r:uc,textAlign:c!==void 0?c:cr,textBaseline:d!==void 0?d:Rs},this.text_=h!==void 0?Array.isArray(h)?h.reduce((f,g,p)=>f+=p%2?" ":g,""):h:"",this.textOffsetX_=s!==void 0?this.pixelRatio_*s:0,this.textOffsetY_=o!==void 0?this.pixelRatio_*o:0,this.textRotateWithView_=a!==void 0?a:!1,this.textRotation_=l!==void 0?l:0,this.textScale_=[this.pixelRatio_*u[0],this.pixelRatio_*u[1]]}}}const mc=Cp;function bp(n,e){const t=n.canvas;e=e||{};const i=e.pixelRatio||za,r=e.size;r&&(t.width=r[0]*i,t.height=r[1]*i,t.style.width=r[0]+"px",t.style.height=r[1]+"px");const s=[0,0,t.width,t.height],o=Hn(it(),i,i);return new mc(n,i,s,o,0)}const $={BEGIN_GEOMETRY:0,BEGIN_PATH:1,CIRCLE:2,CLOSE_PATH:3,CUSTOM:4,DRAW_CHARS:5,DRAW_IMAGE:6,END_GEOMETRY:7,FILL:8,MOVE_TO_LINE_TO:9,SET_FILL_STYLE:10,SET_STROKE_STYLE:11,STROKE:12},Qr=[$.FILL],di=[$.STROKE],Oi=[$.BEGIN_PATH],Su=[$.CLOSE_PATH];class Pr extends pc{constructor(e,t,i,r){super(),this.tolerance=e,this.maxExtent=t,this.pixelRatio=r,this.maxLineWidth=0,this.resolution=i,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_=null,this.bufferedMaxExtent_=null,this.instructions=[],this.coordinates=[],this.tmpCoordinate_=[],this.hitDetectionInstructions=[],this.state={}}applyPixelRatio(e){const t=this.pixelRatio;return t==1?e:e.map(function(i){return i*t})}appendFlatPointCoordinates(e,t){const i=this.getBufferedMaxExtent(),r=this.tmpCoordinate_,s=this.coordinates;let o=s.length;for(let a=0,l=e.length;aa&&(this.instructions.push([$.CUSTOM,a,u,e,i,ci]),this.hitDetectionInstructions.push([$.CUSTOM,a,u,e,r||i,ci]));break;case"Point":l=e.getFlatCoordinates(),this.coordinates.push(l[0],l[1]),u=this.coordinates.length,this.instructions.push([$.CUSTOM,a,u,e,i]),this.hitDetectionInstructions.push([$.CUSTOM,a,u,e,r||i]);break}this.endGeometry(t)}beginGeometry(e,t){this.beginGeometryInstruction1_=[$.BEGIN_GEOMETRY,t,0,e],this.instructions.push(this.beginGeometryInstruction1_),this.beginGeometryInstruction2_=[$.BEGIN_GEOMETRY,t,0,e],this.hitDetectionInstructions.push(this.beginGeometryInstruction2_)}finish(){return{instructions:this.instructions,hitDetectionInstructions:this.hitDetectionInstructions,coordinates:this.coordinates}}reverseHitDetectionInstructions(){const e=this.hitDetectionInstructions;e.reverse();let t;const i=e.length;let r,s,o=-1;for(t=0;tthis.maxLineWidth&&(this.maxLineWidth=i.lineWidth,this.bufferedMaxExtent_=null)}else i.strokeStyle=void 0,i.lineCap=void 0,i.lineDash=null,i.lineDashOffset=void 0,i.lineJoin=void 0,i.lineWidth=void 0,i.miterLimit=void 0}createFill(e){const t=e.fillStyle,i=[$.SET_FILL_STYLE,t];return typeof t!="string"&&i.push(!0),i}applyStroke(e){this.instructions.push(this.createStroke(e))}createStroke(e){return[$.SET_STROKE_STYLE,e.strokeStyle,e.lineWidth*this.pixelRatio,e.lineCap,e.lineJoin,e.miterLimit,this.applyPixelRatio(e.lineDash),e.lineDashOffset*this.pixelRatio]}updateFillStyle(e,t){const i=e.fillStyle;(typeof i!="string"||e.currentFillStyle!=i)&&(i!==void 0&&this.instructions.push(t.call(this,e)),e.currentFillStyle=i)}updateStrokeStyle(e,t){const i=e.strokeStyle,r=e.lineCap,s=e.lineDash,o=e.lineDashOffset,a=e.lineJoin,l=e.lineWidth,u=e.miterLimit;(e.currentStrokeStyle!=i||e.currentLineCap!=r||s!=e.currentLineDash&&!vi(e.currentLineDash,s)||e.currentLineDashOffset!=o||e.currentLineJoin!=a||e.currentLineWidth!=l||e.currentMiterLimit!=u)&&(i!==void 0&&t.call(this,e),e.currentStrokeStyle=i,e.currentLineCap=r,e.currentLineDash=s,e.currentLineDashOffset=o,e.currentLineJoin=a,e.currentLineWidth=l,e.currentMiterLimit=u)}endGeometry(e){this.beginGeometryInstruction1_[2]=this.instructions.length,this.beginGeometryInstruction1_=null,this.beginGeometryInstruction2_[2]=this.hitDetectionInstructions.length,this.beginGeometryInstruction2_=null;const t=[$.END_GEOMETRY,e];this.instructions.push(t),this.hitDetectionInstructions.push(t)}getBufferedMaxExtent(){if(!this.bufferedMaxExtent_&&(this.bufferedMaxExtent_=Dh(this.maxExtent),this.maxLineWidth>0)){const e=this.resolution*(this.maxLineWidth+1)/2;pi(this.bufferedMaxExtent_,e,this.bufferedMaxExtent_)}return this.bufferedMaxExtent_}}class Tp extends Pr{constructor(e,t,i,r){super(e,t,i,r),this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.anchorX_=void 0,this.anchorY_=void 0,this.height_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.scale_=void 0,this.width_=void 0,this.declutterMode_=void 0,this.declutterImageWithText_=void 0}drawPoint(e,t){if(!this.image_)return;this.beginGeometry(e,t);const i=e.getFlatCoordinates(),r=e.getStride(),s=this.coordinates.length,o=this.appendFlatPointCoordinates(i,r);this.instructions.push([$.DRAW_IMAGE,s,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([$.DRAW_IMAGE,s,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}drawMultiPoint(e,t){if(!this.image_)return;this.beginGeometry(e,t);const i=e.getFlatCoordinates(),r=e.getStride(),s=this.coordinates.length,o=this.appendFlatPointCoordinates(i,r);this.instructions.push([$.DRAW_IMAGE,s,o,this.image_,this.anchorX_*this.imagePixelRatio_,this.anchorY_*this.imagePixelRatio_,Math.ceil(this.height_*this.imagePixelRatio_),this.opacity_,this.originX_*this.imagePixelRatio_,this.originY_*this.imagePixelRatio_,this.rotateWithView_,this.rotation_,[this.scale_[0]*this.pixelRatio/this.imagePixelRatio_,this.scale_[1]*this.pixelRatio/this.imagePixelRatio_],Math.ceil(this.width_*this.imagePixelRatio_),this.declutterMode_,this.declutterImageWithText_]),this.hitDetectionInstructions.push([$.DRAW_IMAGE,s,o,this.hitDetectionImage_,this.anchorX_,this.anchorY_,this.height_,1,this.originX_,this.originY_,this.rotateWithView_,this.rotation_,this.scale_,this.width_,this.declutterMode_,this.declutterImageWithText_]),this.endGeometry(t)}finish(){return this.reverseHitDetectionInstructions(),this.anchorX_=void 0,this.anchorY_=void 0,this.hitDetectionImage_=null,this.image_=null,this.imagePixelRatio_=void 0,this.height_=void 0,this.scale_=void 0,this.opacity_=void 0,this.originX_=void 0,this.originY_=void 0,this.rotateWithView_=void 0,this.rotation_=void 0,this.width_=void 0,super.finish()}setImageStyle(e,t){const i=e.getAnchor(),r=e.getSize(),s=e.getOrigin();this.imagePixelRatio_=e.getPixelRatio(this.pixelRatio),this.anchorX_=i[0],this.anchorY_=i[1],this.hitDetectionImage_=e.getHitDetectionImage(),this.image_=e.getImage(this.pixelRatio),this.height_=r[1],this.opacity_=e.getOpacity(),this.originX_=s[0],this.originY_=s[1],this.rotateWithView_=e.getRotateWithView(),this.rotation_=e.getRotation(),this.scale_=e.getScaleArray(),this.width_=r[0],this.declutterMode_=e.getDeclutterMode(),this.declutterImageWithText_=t}}const Rp=Tp;class Sp extends Pr{constructor(e,t,i,r){super(e,t,i,r)}drawFlatCoordinates_(e,t,i,r){const s=this.coordinates.length,o=this.appendFlatLineCoordinates(e,t,i,r,!1,!1),a=[$.MOVE_TO_LINE_TO,s,o];return this.instructions.push(a),this.hitDetectionInstructions.push(a),i}drawLineString(e,t){const i=this.state,r=i.strokeStyle,s=i.lineWidth;if(r===void 0||s===void 0)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(e,t),this.hitDetectionInstructions.push([$.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Vt,Yt],Oi);const o=e.getFlatCoordinates(),a=e.getStride();this.drawFlatCoordinates_(o,0,o.length,a),this.hitDetectionInstructions.push(di),this.endGeometry(t)}drawMultiLineString(e,t){const i=this.state,r=i.strokeStyle,s=i.lineWidth;if(r===void 0||s===void 0)return;this.updateStrokeStyle(i,this.applyStroke),this.beginGeometry(e,t),this.hitDetectionInstructions.push([$.SET_STROKE_STYLE,i.strokeStyle,i.lineWidth,i.lineCap,i.lineJoin,i.miterLimit,Vt,Yt],Oi);const o=e.getEnds(),a=e.getFlatCoordinates(),l=e.getStride();let u=0;for(let h=0,c=o.length;h=n){const g=(n-a+f)/f,p=at(u,c,g),m=at(h,d,g);l.push(p,m),s.push(l),l=[p,m],a==n&&(o+=r),a=0}else if(a0&&s.push(l),s}function Mp(n,e,t,i,r){let s=t,o=t,a=0,l=0,u=t,h,c,d,f,g,p,m,y,_,v;for(c=t;cn&&(l>a&&(a=l,s=u,o=c),l=0,u=c-r)),d=f,m=_,y=v),g=x,p=E}return l+=f,l>a?[u,c]:[s,o]}const Is={left:0,center:.5,right:1,top:0,middle:.5,hanging:.2,alphabetic:.8,ideographic:.8,bottom:1};class Pp extends Pr{constructor(e,t,i,r){super(e,t,i,r),this.labels_=null,this.text_="",this.textOffsetX_=0,this.textOffsetY_=0,this.textRotateWithView_=void 0,this.textRotation_=0,this.textFillState_=null,this.fillStates={},this.fillStates[Qe]={fillStyle:Qe},this.textStrokeState_=null,this.strokeStates={},this.textState_={},this.textStates={},this.textKey_="",this.fillKey_="",this.strokeKey_="",this.declutterImageWithText_=void 0}finish(){const e=super.finish();return e.textStates=this.textStates,e.fillStates=this.fillStates,e.strokeStates=this.strokeStates,e}drawText(e,t){const i=this.textFillState_,r=this.textStrokeState_,s=this.textState_;if(this.text_===""||!s||!i&&!r)return;const o=this.coordinates;let a=o.length;const l=e.getType();let u=null,h=e.getStride();if(s.placement==="line"&&(l=="LineString"||l=="MultiLineString"||l=="Polygon"||l=="MultiPolygon")){if(!Se(this.getBufferedMaxExtent(),e.getExtent()))return;let c;if(u=e.getFlatCoordinates(),l=="LineString")c=[u.length];else if(l=="MultiLineString")c=e.getEnds();else if(l=="Polygon")c=e.getEnds().slice(0,1);else if(l=="MultiPolygon"){const p=e.getEndss();c=[];for(let m=0,y=p.length;m{const x=o[(y+v)*2]===u[v*h]&&o[(y+v)*2+1]===u[v*h+1];return x||--y,x})}this.saveTextStates_(),(s.backgroundFill||s.backgroundStroke)&&(this.setFillStrokeStyle(s.backgroundFill,s.backgroundStroke),s.backgroundFill&&this.updateFillStyle(this.state,this.createFill),s.backgroundStroke&&(this.updateStrokeStyle(this.state,this.applyStroke),this.hitDetectionInstructions.push(this.createStroke(this.state)))),this.beginGeometry(e,t);let f=s.padding;if(f!=ki&&(s.scale[0]<0||s.scale[1]<0)){let y=s.padding[0],_=s.padding[1],v=s.padding[2],x=s.padding[3];s.scale[0]<0&&(_=-_,x=-x),s.scale[1]<0&&(y=-y,v=-v),f=[y,_,v,x]}const g=this.pixelRatio;this.instructions.push([$.DRAW_IMAGE,a,d,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[1,1],NaN,void 0,this.declutterImageWithText_,f==ki?ki:f.map(function(y){return y*g}),!!s.backgroundFill,!!s.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_,this.textOffsetX_,this.textOffsetY_,c]);const p=1/g,m=this.state.fillStyle;s.backgroundFill&&(this.state.fillStyle=Qe,this.hitDetectionInstructions.push(this.createFill(this.state))),this.hitDetectionInstructions.push([$.DRAW_IMAGE,a,d,null,NaN,NaN,NaN,1,0,0,this.textRotateWithView_,this.textRotation_,[p,p],NaN,void 0,this.declutterImageWithText_,f,!!s.backgroundFill,!!s.backgroundStroke,this.text_,this.textKey_,this.strokeKey_,this.fillKey_?Qe:this.fillKey_,this.textOffsetX_,this.textOffsetY_,c]),s.backgroundFill&&(this.state.fillStyle=m,this.hitDetectionInstructions.push(this.createFill(this.state))),this.endGeometry(t)}}saveTextStates_(){const e=this.textStrokeState_,t=this.textState_,i=this.textFillState_,r=this.strokeKey_;e&&(r in this.strokeStates||(this.strokeStates[r]={strokeStyle:e.strokeStyle,lineCap:e.lineCap,lineDashOffset:e.lineDashOffset,lineWidth:e.lineWidth,lineJoin:e.lineJoin,miterLimit:e.miterLimit,lineDash:e.lineDash}));const s=this.textKey_;s in this.textStates||(this.textStates[s]={font:t.font,textAlign:t.textAlign||cr,justify:t.justify,textBaseline:t.textBaseline||Rs,scale:t.scale});const o=this.fillKey_;i&&(o in this.fillStates||(this.fillStates[o]={fillStyle:i.fillStyle}))}drawChars_(e,t){const i=this.textStrokeState_,r=this.textState_,s=this.strokeKey_,o=this.textKey_,a=this.fillKey_;this.saveTextStates_();const l=this.pixelRatio,u=Is[r.textBaseline],h=this.textOffsetY_*l,c=this.text_,d=i?i.lineWidth*Math.abs(r.scale[0])/2:0;this.instructions.push([$.DRAW_CHARS,e,t,u,r.overflow,a,r.maxAngle,l,h,s,d*l,c,o,1]),this.hitDetectionInstructions.push([$.DRAW_CHARS,e,t,u,r.overflow,a&&Qe,r.maxAngle,l,h,s,d*l,c,o,1/l])}setTextStyle(e,t){let i,r,s;if(!e)this.text_="";else{const o=e.getFill();o?(r=this.textFillState_,r||(r={},this.textFillState_=r),r.fillStyle=At(o.getColor()||Qe)):(r=null,this.textFillState_=r);const a=e.getStroke();if(!a)s=null,this.textStrokeState_=s;else{s=this.textStrokeState_,s||(s={},this.textStrokeState_=s);const g=a.getLineDash(),p=a.getLineDashOffset(),m=a.getWidth(),y=a.getMiterLimit();s.lineCap=a.getLineCap()||In,s.lineDash=g?g.slice():Vt,s.lineDashOffset=p===void 0?Yt:p,s.lineJoin=a.getLineJoin()||An,s.lineWidth=m===void 0?dr:m,s.miterLimit=y===void 0?ur:y,s.strokeStyle=At(a.getColor()||hr)}i=this.textState_;const l=e.getFont()||uc;hc(l);const u=e.getScaleArray();i.overflow=e.getOverflow(),i.font=l,i.maxAngle=e.getMaxAngle(),i.placement=e.getPlacement(),i.textAlign=e.getTextAlign(),i.repeat=e.getRepeat(),i.justify=e.getJustify(),i.textBaseline=e.getTextBaseline()||Rs,i.backgroundFill=e.getBackgroundFill(),i.backgroundStroke=e.getBackgroundStroke(),i.padding=e.getPadding()||ki,i.scale=u===void 0?[1,1]:u;const h=e.getOffsetX(),c=e.getOffsetY(),d=e.getRotateWithView(),f=e.getRotation();this.text_=e.getText()||"",this.textOffsetX_=h===void 0?0:h,this.textOffsetY_=c===void 0?0:c,this.textRotateWithView_=d===void 0?!1:d,this.textRotation_=f===void 0?0:f,this.strokeKey_=s?(typeof s.strokeStyle=="string"?s.strokeStyle:U(s.strokeStyle))+s.lineCap+s.lineDashOffset+"|"+s.lineWidth+s.lineJoin+s.miterLimit+"["+s.lineDash.join()+"]":"",this.textKey_=i.font+i.scale+(i.textAlign||"?")+(i.repeat||"?")+(i.justify||"?")+(i.textBaseline||"?"),this.fillKey_=r?typeof r.fillStyle=="string"?r.fillStyle:"|"+U(r.fillStyle):""}this.declutterImageWithText_=t}}const Lp={Circle:Iu,Default:Pr,Image:Rp,LineString:Ip,Polygon:Iu,Text:Pp};class Fn{constructor(e,t,i,r){this.tolerance_=e,this.maxExtent_=t,this.pixelRatio_=r,this.resolution_=i,this.buildersByZIndex_={}}finish(){const e={};for(const t in this.buildersByZIndex_){e[t]=e[t]||{};const i=this.buildersByZIndex_[t];for(const r in i){const s=i[r].finish();e[t][r]=s}}return e}getBuilder(e,t){const i=e!==void 0?e.toString():"0";let r=this.buildersByZIndex_[i];r===void 0&&(r={},this.buildersByZIndex_[i]=r);let s=r[t];if(s===void 0){const o=Lp[t];s=new o(this.tolerance_,this.maxExtent_,this.resolution_,this.pixelRatio_),r[t]=s}return s}}function kp(n,e,t,i,r,s,o,a,l,u,h,c){let d=n[e],f=n[e+1],g=0,p=0,m=0,y=0;function _(){g=d,p=f,e+=i,d=n[e],f=n[e+1],y+=m,m=Math.sqrt((d-g)*(d-g)+(f-p)*(f-p))}do _();while(ek[2]}else N=x>I;const R=Math.PI,G=[],L=b+i===e;e=b,m=0,y=w,d=n[e],f=n[e+1];let T;if(L){_(),T=Math.atan2(f-p,d-g),N&&(T+=T>0?-R:R);const k=(I+x)/2,O=(z+E)/2;return G[0]=[k,O,(C-s)/2,T,r],G}r=r.replace(/\n/g," ");for(let k=0,O=r.length;k0?-R:R),T!==void 0){let re=X-T;if(re+=re>R?-2*R:re<-R?2*R:0,Math.abs(re)>o)return null}T=X;const ne=k;let S=0;for(;k0&&n.push(` +`,""),n.push(e,""),n}class Dp{constructor(e,t,i,r){this.overlaps=i,this.pixelRatio=t,this.resolution=e,this.alignFill_,this.instructions=r.instructions,this.coordinates=r.coordinates,this.coordinateCache_={},this.renderedTransform_=it(),this.hitDetectionInstructions=r.hitDetectionInstructions,this.pixelCoordinates_=null,this.viewRotation_=0,this.fillStates=r.fillStates||{},this.strokeStates=r.strokeStates||{},this.textStates=r.textStates||{},this.widths_={},this.labels_={}}createLabel(e,t,i,r){const s=e+t+i+r;if(this.labels_[s])return this.labels_[s];const o=r?this.strokeStates[r]:null,a=i?this.fillStates[i]:null,l=this.textStates[t],u=this.pixelRatio,h=[l.scale[0]*u,l.scale[1]*u],c=Array.isArray(e),d=l.justify?Is[l.justify]:wo(Array.isArray(e)?e[0]:e,l.textAlign||cr),f=r&&o.lineWidth?o.lineWidth:0,g=c?e:e.split(` +`).reduce(Op,[]),{width:p,height:m,widths:y,heights:_,lineWidths:v}=ip(l,g),x=p+f,E=[],b=(x+2)*h[0],w=(m+f)*h[1],C={width:b<0?Math.floor(b):Math.ceil(b),height:w<0?Math.floor(w):Math.ceil(w),contextInstructions:E};(h[0]!=1||h[1]!=1)&&E.push("scale",h),r&&(E.push("strokeStyle",o.strokeStyle),E.push("lineWidth",f),E.push("lineCap",o.lineCap),E.push("lineJoin",o.lineJoin),E.push("miterLimit",o.miterLimit),E.push("setLineDash",[o.lineDash]),E.push("lineDashOffset",o.lineDashOffset)),i&&E.push("fillStyle",a.fillStyle),E.push("textBaseline","middle"),E.push("textAlign","center");const I=.5-d;let z=d*x+I*f;const N=[],R=[];let G=0,L=0,T=0,k=0,O;for(let X=0,ne=g.length;Xe?e-u:s,x=o+h>t?t-h:o,E=g[3]+v*d[0]+g[1],b=g[0]+x*d[1]+g[2],w=y-g[3],C=_-g[0];(p||c!==0)&&(ti[0]=w,ii[0]=w,ti[1]=C,Nt[1]=C,Nt[0]=w+E,Gt[0]=Nt[0],Gt[1]=C+b,ii[1]=Gt[1]);let I;return c!==0?(I=qt(it(),i,r,1,1,c,-i,-r),Le(I,ti),Le(I,Nt),Le(I,Gt),Le(I,ii),Zt(Math.min(ti[0],Nt[0],Gt[0],ii[0]),Math.min(ti[1],Nt[1],Gt[1],ii[1]),Math.max(ti[0],Nt[0],Gt[0],ii[0]),Math.max(ti[1],Nt[1],Gt[1],ii[1]),nn)):Zt(Math.min(w,w+E),Math.min(C,C+b),Math.max(w,w+E),Math.max(C,C+b),nn),f&&(y=Math.round(y),_=Math.round(_)),{drawImageX:y,drawImageY:_,drawImageW:v,drawImageH:x,originX:u,originY:h,declutterBox:{minX:nn[0],minY:nn[1],maxX:nn[2],maxY:nn[3],value:m},canvasTransform:I,scale:d}}replayImageOrLabel_(e,t,i,r,s,o,a){const l=!!(o||a),u=r.declutterBox,h=e.canvas,c=a?a[2]*r.scale[0]/2:0;return u.minX-c<=h.width/t&&u.maxX+c>=0&&u.minY-c<=h.height/t&&u.maxY+c>=0&&(l&&this.replayTextBackground_(e,ti,Nt,Gt,ii,o,a),np(e,r.canvasTransform,s,i,r.originX,r.originY,r.drawImageW,r.drawImageH,r.drawImageX,r.drawImageY,r.scale)),!0}fill_(e){if(this.alignFill_){const t=Le(this.renderedTransform_,[0,0]),i=512*this.pixelRatio;e.save(),e.translate(t[0]%i,t[1]%i),e.rotate(this.viewRotation_)}e.fill(),this.alignFill_&&e.restore()}setStrokeStyle_(e,t){e.strokeStyle=t[1],e.lineWidth=t[2],e.lineCap=t[3],e.lineJoin=t[4],e.miterLimit=t[5],e.lineDashOffset=t[7],e.setLineDash(t[6])}drawLabelWithPointPlacement_(e,t,i,r){const s=this.textStates[t],o=this.createLabel(e,t,r,i),a=this.strokeStates[i],l=this.pixelRatio,u=wo(Array.isArray(e)?e[0]:e,s.textAlign||cr),h=Is[s.textBaseline||Rs],c=a&&a.lineWidth?a.lineWidth:0,d=o.width/l-2*s.scale[0],f=u*d+2*(.5-u)*c,g=h*o.height/l+2*(.5-h)*c;return{label:o,anchorX:f,anchorY:g}}execute_(e,t,i,r,s,o,a,l){let u;this.pixelCoordinates_&&vi(i,this.renderedTransform_)?u=this.pixelCoordinates_:(this.pixelCoordinates_||(this.pixelCoordinates_=[]),u=Ut(this.coordinates,0,this.coordinates.length,2,i,this.pixelCoordinates_),Wf(this.renderedTransform_,i));let h=0;const c=r.length;let d=0,f,g,p,m,y,_,v,x,E,b,w,C,I=0,z=0,N=null,R=null;const G=this.coordinateCache_,L=this.viewRotation_,T=Math.round(Math.atan2(-i[1],i[0])*1e12)/1e12,k={context:e,pixelRatio:this.pixelRatio,resolution:this.resolution,rotation:L},O=this.instructions!=r||this.overlaps?0:200;let X,ne,S,Re;for(;hO&&(this.fill_(e),I=0),z>O&&(e.stroke(),z=0),!I&&!z&&(e.beginPath(),m=NaN,y=NaN),++h;break;case $.CIRCLE:d=A[1];const re=u[d],q=u[d+1],Oe=u[d+2],Ze=u[d+3],de=Oe-re,Pe=Ze-q,D=Math.sqrt(de*de+Pe*Pe);e.moveTo(re+D,q),e.arc(re,q,D,0,2*Math.PI,!0),++h;break;case $.CLOSE_PATH:e.closePath(),++h;break;case $.CUSTOM:d=A[1],f=A[2];const yt=A[3],_t=A[4],ie=A.length==6?A[5]:void 0;k.geometry=yt,k.feature=X,h in G||(G[h]=[]);const xt=G[h];ie?ie(u,d,f,2,xt):(xt[0]=u[d],xt[1]=u[d+1],xt.length=2),_t(xt,k),++h;break;case $.DRAW_IMAGE:d=A[1],f=A[2],x=A[3],g=A[4],p=A[5];let vt=A[6];const ve=A[7],ei=A[8],we=A[9],Tt=A[10];let ct=A[11];const dt=A[12];let Ae=A[13];const je=A[14],ee=A[15];if(!x&&A.length>=20){E=A[19],b=A[20],w=A[21],C=A[22];const st=this.drawLabelWithPointPlacement_(E,b,w,C);x=st.label,A[3]=x;const Ji=A[23];g=(st.anchorX-Ji)*this.pixelRatio,A[4]=g;const ft=A[24];p=(st.anchorY-ft)*this.pixelRatio,A[5]=p,vt=x.height,A[6]=vt,Ae=x.width,A[13]=Ae}let se;A.length>25&&(se=A[25]);let ae,ue,V;A.length>17?(ae=A[16],ue=A[17],V=A[18]):(ae=ki,ue=!1,V=!1),Tt&&T?ct+=L:!Tt&&!T&&(ct-=L);let H=0;for(;d0){if(!o||f!=="Image"&&f!=="Text"||o.includes(E)){const z=(d[C]-3)/4,N=r-z%a,R=r-(z/a|0),G=s(E,b,N*N+R*R);if(G)return G}h.clearRect(0,0,a,a);break}}const p=Object.keys(this.executorsByZIndex_).map(Number);p.sort(yi);let m,y,_,v,x;for(m=p.length-1;m>=0;--m){const E=p[m].toString();for(_=this.executorsByZIndex_[E],y=Co.length-1;y>=0;--y)if(f=Co[y],v=_[f],v!==void 0&&(x=v.executeHitDetection(h,l,i,g,c),x))return x}}getClipCoords(e){const t=this.maxExtent_;if(!t)return null;const i=t[0],r=t[1],s=t[2],o=t[3],a=[i,r,i,o,s,o,s,r];return Ut(a,0,8,2,e,a),a}isEmpty(){return ji(this.executorsByZIndex_)}execute(e,t,i,r,s,o,a){const l=Object.keys(this.executorsByZIndex_).map(Number);l.sort(yi),this.maxExtent_&&(e.save(),this.clip(e,i)),o=o||Co;let u,h,c,d,f,g;for(a&&l.reverse(),u=0,h=l.length;ut)break;let l=i[a];l||(l=[],i[a]=l),l.push(((n+s)*e+(n+o))*4+3),s>0&&l.push(((n-s)*e+(n+o))*4+3),o>0&&(l.push(((n+s)*e+(n-o))*4+3),s>0&&l.push(((n-s)*e+(n-o))*4+3))}const r=[];for(let s=0,o=i.length;st;){if(i-t>600){var s=i-t+1,o=e-t+1,a=Math.log(s),l=.5*Math.exp(2*a/3),u=.5*Math.sqrt(a*l*(s-l)/s)*(o-s/2<0?-1:1),h=Math.max(t,Math.floor(e-o*l/s+u)),c=Math.min(i,Math.floor(e+(s-o)*l/s+u));yc(n,e,h,c,r)}var d=n[e],f=t,g=i;for(Un(n,t,e),r(n[i],d)>0&&Un(n,t,i);f0;)g--}r(n[t],d)===0?Un(n,t,g):(g++,Un(n,g,i)),g<=e&&(t=g+1),e<=g&&(i=g-1)}}function Un(n,e,t){var i=n[e];n[e]=n[t],n[t]=i}function Gp(n,e){return ne?1:0}let ll=class{constructor(e=9){this._maxEntries=Math.max(4,e),this._minEntries=Math.max(2,Math.ceil(this._maxEntries*.4)),this.clear()}all(){return this._all(this.data,[])}search(e){let t=this.data;const i=[];if(!ts(e,t))return i;const r=this.toBBox,s=[];for(;t;){for(let o=0;o=0&&s[t].children.length>this._maxEntries;)this._split(s,t),t--;this._adjustParentBBoxes(r,s,t)}_split(e,t){const i=e[t],r=i.children.length,s=this._minEntries;this._chooseSplitAxis(i,s,r);const o=this._chooseSplitIndex(i,s,r),a=un(i.children.splice(o,i.children.length-o));a.height=i.height,a.leaf=i.leaf,rn(i,this.toBBox),rn(a,this.toBBox),t?e[t-1].children.push(a):this._splitRoot(i,a)}_splitRoot(e,t){this.data=un([e,t]),this.data.height=e.height+1,this.data.leaf=!1,rn(this.data,this.toBBox)}_chooseSplitIndex(e,t,i){let r,s=1/0,o=1/0;for(let a=t;a<=i-t;a++){const l=Zn(e,0,a,this.toBBox),u=Zn(e,a,i,this.toBBox),h=Up(l,u),c=To(l)+To(u);h=t;u--){const h=e.children[u];qn(a,e.leaf?s(h):h),l+=es(a)}return l}_adjustParentBBoxes(e,t,i){for(let r=i;r>=0;r--)qn(t[r],e)}_condense(e){for(let t=e.length-1,i;t>=0;t--)e[t].children.length===0?t>0?(i=e[t-1].children,i.splice(i.indexOf(e[t]),1)):this.clear():rn(e[t],this.toBBox)}};function $p(n,e,t){if(!t)return e.indexOf(n);for(let i=0;i=n.minX&&e.maxY>=n.minY}function un(n){return{children:n,height:1,leaf:!0,minX:1/0,minY:1/0,maxX:-1/0,maxY:-1/0}}function Mu(n,e,t,i,r){const s=[e,t];for(;s.length;){if(t=s.pop(),e=s.pop(),t-e<=i)continue;const o=e+Math.ceil((t-e)/i/2)*i;Np(n,o,e,t,r),s.push(e,o,o,t)}}class Vp{fetch(e,t){return typeof fetch<"u"?fetch(e,t):Promise.reject("no Fetch")}}const Yp=new Vp,Bp=new ol;class As{static{this.useImmediateAPI=!1}drawFeaturesToContextUsingRenderAPI_(e,t,i,r,s,o,a){const u=new Fn(0,e.extent,i,1);let h;a&&(h=new Fn(0,e.extent,i,1));function c(){console.log("FIXME: some resource is now available, we should regenerate the image")}const d=function(E){let b;const w=E.getStyleFunction()||t;w&&(b=w(E,i));let C=!1;if(b){Array.isArray(b)||(b=[b]);const I=0;for(const z of b)C=fr(u,E,z,I,c,void 0,h)||C}return C};let f=!1;e.features.forEach(E=>{f=d(E)||f}),f&&console.log("FIXME: some styles are still loading");const g=!0,p=u.finish(),m=new Mn(e.extent,i,1,g,p,o),y=1,_=r,v=0,x=!0;m.execute(s,y,_,v,x,void 0,null),h&&new Mn(e.extent,i,1,g,h.finish(),o).execute(s,y,_,v,x,void 0,a)}drawFeaturesToContextUsingImmediateAPI_(e,t,i,r,s){const o=[];let a=0;e.forEach(l=>{const u=t(l,i);u&&(Array.isArray(u)?u.forEach((h,c)=>{o.push({zIndex:h.getZIndex(),feature:l,naturalOrder:++a,styleIdx:c})}):o.push({zIndex:u.getZIndex(),feature:l,naturalOrder:++a,styleIdx:-1}))}),o.sort((l,u)=>(l.zIndex||0)-(u.zIndex||0)||l.naturalOrder-u.naturalOrder);for(const l of o){const u=t(l.feature,i),h=l.styleIdx===-1?u:u[l.styleIdx];s.setStyle(h);let c=h.getGeometry();typeof c=="function"&&(c=c()),c||(c=l.feature.getGeometry()),c=Object.assign(Object.create(Object.getPrototypeOf(c)),c);const d=c.flatCoordinates_,f=c.flatCoordinates_=new Array(d.length),g=c.getStride();Ut(d,0,d.length,g,r,f),s.drawGeometry(c)}}snapTileResolution(e,t){const i=e.getResolutions();let r=i[i.length-2];for(let s=i.length-2;s>=0;s--){const o=i[s];if(o<=t)r=o;else break}return r}assertCanvasSize(e,t){const i=ge(e)/nt(e),r=t[0]/t[1];if(Math.abs(i/r-1)>.02){const s=`The print extent ratio ${i} and the canvas ratio ${r} mismatch: ${Math.abs(i/r-1)*100} %`;throw new Error(s)}}async allFullfilled(e){const t=[];for(const i of e)await i.then(r=>t.push(r),()=>{});return t}async fetchFeatures(e,t){const i=t.getTileUrlFunction(),r=t.getProjection(),s=e.map(o=>{const a=i(o.coord,1,r);return a?Yp.fetch(a).then(l=>l.arrayBuffer()).then(l=>({features:Bp.readFeatures(l,{extent:o.extent,featureProjection:r}),extent:o.extent,url:a})):Promise.reject("Could not create URL")});return this.allFullfilled(s)}async encodeMVTLayer(e){const t=e.layer,i=e.outputFormat||"png",r=t.getRenderBuffer()||100,s=t.getSource(),o=s.getTileGrid(),a=this.snapTileResolution(o,e.tileResolution);a!==e.tileResolution&&(console.warn(`snapped and tile resolution mismatch: ${a} != ${e.tileResolution}`),e.tileResolution=a);const l=e.printExtent,u=up(l,a,o),h=await this.fetchFeatures(u,s),c=e.canvasSize;this.assertCanvasSize(l,c);const d=[{printExtent:l,canvasSize:c}],f=e.styleResolution||a,g=t.getStyleFunction(),p=t.get("opacity"),m=t.getDeclutter()?new ll(9):void 0;return d.map(_=>this.renderTile(h,_.printExtent,_.canvasSize,f,g,p,r,m,i))}renderTile(e,t,i,r,s,o,a,l,u){const h=document.createElement("canvas"),c=h.getContext("2d");console.assert(c,`Could not get the context ${h.width}x${h.height}`);const d=bp(c,{size:i,pixelRatio:1});e.forEach(g=>{const p=lp(t,h.width,h.height);As.useImmediateAPI?this.drawFeaturesToContextUsingImmediateAPI_(g.features,s,r,p,d):this.drawFeaturesToContextUsingRenderAPI_(g,s,r,p,c,a,l)});const f=(o===1?h:hp(h,o)).toDataURL(u);return{extent:t,baseURL:f}}}const et={ADD:"add",REMOVE:"remove"},Pu={LENGTH:"length"};class is extends Jt{constructor(e,t,i){super(e),this.element=t,this.index=i}}class Ft extends kt{constructor(e,t){if(super(),this.on,this.once,this.un,t=t||{},this.unique_=!!t.unique,this.array_=e||[],this.unique_)for(let i=0,r=this.array_.length;i0;)this.pop()}extend(e){for(let t=0,i=e.length;tthis.getLength())throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t),this.array_.splice(e,0,t),this.updateLength_(),this.dispatchEvent(new is(et.ADD,t,e))}pop(){return this.removeAt(this.getLength()-1)}push(e){this.unique_&&this.assertUnique_(e);const t=this.getLength();return this.insertAt(t,e),this.getLength()}remove(e){const t=this.array_;for(let i=0,r=t.length;i=this.getLength())return;const t=this.array_[e];return this.array_.splice(e,1),this.updateLength_(),this.dispatchEvent(new is(et.REMOVE,t,e)),t}setAt(e,t){const i=this.getLength();if(e>=i){this.insertAt(e,t);return}if(e<0)throw new Error("Index out of bounds: "+e);this.unique_&&this.assertUnique_(t,e);const r=this.array_[e];this.array_[e]=t,this.dispatchEvent(new is(et.REMOVE,r,e)),this.dispatchEvent(new is(et.ADD,t,e))}updateLength_(){this.set(Pu.LENGTH,this.array_.length)}assertUnique_(e,t){for(let i=0,r=this.array_.length;if&&(d=(f+d)/2,f=d),g>p&&(g=(p+g)/2,p=g);let m=Me(i[0],d,f),y=Me(i[1],g,p);if(o&&t&&r){const _=30*r;m+=-_*Math.log(1+Math.max(0,d-i[0])/_)+_*Math.log(1+Math.max(0,i[0]-f)/_),y+=-_*Math.log(1+Math.max(0,g-i[1])/_)+_*Math.log(1+Math.max(0,i[1]-p)/_)}return[m,y]}}function Zp(n){return n}function hl(n,e,t,i){const r=ge(e)/t[0],s=nt(e)/t[1];return i?Math.min(n,Math.max(r,s)):Math.min(n,Math.min(r,s))}function cl(n,e,t){let i=Math.min(n,e);const r=50;return i*=Math.log(1+r*Math.max(0,n/e-1))/r+1,t&&(i=Math.max(i,t),i/=Math.log(1+r*Math.max(0,t/n-1))/r+1),Me(i,t/2,e*2)}function qp(n,e,t,i){return e=e!==void 0?e:!0,function(r,s,o,a){if(r!==void 0){const l=n[0],u=n[n.length-1],h=t?hl(l,t,o,i):l;if(a)return e?cl(r,h,u):Me(r,u,h);const c=Math.min(h,r),d=Math.floor(Oa(n,c,s));return n[d]>h&&d1&&typeof arguments[t-1]=="function"&&(i=arguments[t-1],--t);let r=0;for(;r0}getInteracting(){return this.hints_[Te.INTERACTING]>0}cancelAnimations(){this.setHint(Te.ANIMATING,-this.hints_[Te.ANIMATING]);let e;for(let t=0,i=this.animations_.length;t=0;--i){const r=this.animations_[i];let s=!0;for(let o=0,a=r.length;o0?u/l.duration:1;h>=1?(l.complete=!0,h=1):s=!1;const c=l.easing(h);if(l.sourceCenter){const d=l.sourceCenter[0],f=l.sourceCenter[1],g=l.targetCenter[0],p=l.targetCenter[1];this.nextCenter_=l.targetCenter;const m=d+c*(g-d),y=f+c*(p-f);this.targetCenter_=[m,y]}if(l.sourceResolution&&l.targetResolution){const d=c===1?l.targetResolution:l.sourceResolution+c*(l.targetResolution-l.sourceResolution);if(l.anchor){const f=this.getViewportSize_(this.getRotation()),g=this.constraints_.resolution(d,0,f,!0);this.targetCenter_=this.calculateCenterZoom(g,l.anchor)}this.nextResolution_=l.targetResolution,this.targetResolution_=d,this.applyTargetState_(!0)}if(l.sourceRotation!==void 0&&l.targetRotation!==void 0){const d=c===1?Ni(l.targetRotation+Math.PI,2*Math.PI)-Math.PI:l.sourceRotation+c*(l.targetRotation-l.sourceRotation);if(l.anchor){const f=this.constraints_.rotation(d,!0);this.targetCenter_=this.calculateCenterRotate(f,l.anchor)}this.nextRotation_=l.targetRotation,this.targetRotation_=d}if(this.applyTargetState_(!0),t=!0,!l.complete)break}if(s){this.animations_[i]=null,this.setHint(Te.ANIMATING,-1),this.nextCenter_=null,this.nextResolution_=NaN,this.nextRotation_=NaN;const o=r[0].callback;o&&ns(o,!0)}}this.animations_=this.animations_.filter(Boolean),t&&this.updateAnimationKey_===void 0&&(this.updateAnimationKey_=requestAnimationFrame(this.updateAnimations_.bind(this)))}calculateCenterRotate(e,t){let i;const r=this.getCenterInternal();return r!==void 0&&(i=[r[0]-t[0],r[1]-t[1]],Xa(i,e-this.getRotation()),Of(i,t)),i}calculateCenterZoom(e,t){let i;const r=this.getCenterInternal(),s=this.getResolution();if(r!==void 0&&s!==void 0){const o=t[0]-e*(t[0]-r[0])/s,a=t[1]-e*(t[1]-r[1])/s;i=[o,a]}return i}getViewportSize_(e){const t=this.viewportSize_;if(e){const i=t[0],r=t[1];return[Math.abs(i*Math.cos(e))+Math.abs(r*Math.sin(e)),Math.abs(i*Math.sin(e))+Math.abs(r*Math.cos(e))]}return t}setViewportSize(e){this.viewportSize_=Array.isArray(e)?e.slice():[100,100],this.getAnimating()||this.resolveConstraints(0)}getCenter(){const e=this.getCenterInternal();return e&&aa(e,this.getProjection())}getCenterInternal(){return this.get(wt.CENTER)}getConstraints(){return this.constraints_}getConstrainResolution(){return this.get("constrainResolution")}getHints(e){return e!==void 0?(e[0]=this.hints_[0],e[1]=this.hints_[1],e):this.hints_.slice()}calculateExtent(e){const t=this.calculateExtentInternal(e);return Vh(t,this.getProjection())}calculateExtentInternal(e){e=e||this.getViewportSizeMinusPadding_();const t=this.getCenterInternal();te(t,"The view center is not defined");const i=this.getResolution();te(i!==void 0,"The view resolution is not defined");const r=this.getRotation();return te(r!==void 0,"The view rotation is not defined"),ra(t,i,r,e)}getMaxResolution(){return this.maxResolution_}getMinResolution(){return this.minResolution_}getMaxZoom(){return this.getZoomForResolution(this.minResolution_)}setMaxZoom(e){this.applyOptions_(this.getUpdatedOptions_({maxZoom:e}))}getMinZoom(){return this.getZoomForResolution(this.maxResolution_)}setMinZoom(e){this.applyOptions_(this.getUpdatedOptions_({minZoom:e}))}setConstrainResolution(e){this.applyOptions_(this.getUpdatedOptions_({constrainResolution:e}))}getProjection(){return this.projection_}getResolution(){return this.get(wt.RESOLUTION)}getResolutions(){return this.resolutions_}getResolutionForExtent(e,t){return this.getResolutionForExtentInternal(Pi(e,this.getProjection()),t)}getResolutionForExtentInternal(e,t){t=t||this.getViewportSizeMinusPadding_();const i=ge(e)/t[0],r=nt(e)/t[1];return Math.max(i,r)}getResolutionForValueFunction(e){e=e||2;const t=this.getConstrainedResolution(this.maxResolution_),i=this.minResolution_,r=Math.log(t/i)/Math.log(e);return function(s){return t/Math.pow(e,s*r)}}getRotation(){return this.get(wt.ROTATION)}getValueForResolutionFunction(e){const t=Math.log(e||2),i=this.getConstrainedResolution(this.maxResolution_),r=this.minResolution_,s=Math.log(i/r)/t;return function(o){return Math.log(i/o)/t/s}}getViewportSizeMinusPadding_(e){let t=this.getViewportSize_(e);const i=this.padding_;return i&&(t=[t[0]-i[1]-i[3],t[1]-i[0]-i[2]]),t}getState(){const e=this.getProjection(),t=this.getResolution(),i=this.getRotation();let r=this.getCenterInternal();const s=this.padding_;if(s){const o=this.getViewportSizeMinusPadding_();r=Io(r,this.getViewportSize_(),[o[0]/2+s[3],o[1]/2+s[0]],t,i)}return{center:r.slice(0),projection:e!==void 0?e:null,resolution:t,nextCenter:this.nextCenter_,nextResolution:this.nextResolution_,nextRotation:this.nextRotation_,rotation:i,zoom:this.getZoom()}}getViewStateAndExtent(){return{viewState:this.getState(),extent:this.calculateExtent()}}getZoom(){let e;const t=this.getResolution();return t!==void 0&&(e=this.getZoomForResolution(t)),e}getZoomForResolution(e){let t=this.minZoom_||0,i,r;if(this.resolutions_){const s=Oa(this.resolutions_,e,1);t=s,i=this.resolutions_[s],s==this.resolutions_.length-1?r=2:r=i/this.resolutions_[s+1]}else i=this.maxResolution_,r=this.zoomFactor_;return t+Math.log(i/e)/Math.log(r)}getResolutionForZoom(e){if(this.resolutions_){if(this.resolutions_.length<=1)return 0;const t=Me(Math.floor(e),0,this.resolutions_.length-2),i=this.resolutions_[t]/this.resolutions_[t+1];return this.resolutions_[t]/Math.pow(i,Me(e-t,0,1))}return this.maxResolution_/Math.pow(this.zoomFactor_,e-this.minZoom_)}fit(e,t){let i;if(te(Array.isArray(e)||typeof e.getSimplifiedGeometry=="function","Invalid extent or geometry provided as `geometry`"),Array.isArray(e)){te(!Ir(e),"Cannot fit empty extent provided as `geometry`");const r=Pi(e,this.getProjection());i=da(r)}else if(e.getType()==="Circle"){const r=Pi(e.getExtent(),this.getProjection());i=da(r),i.rotate(this.getRotation(),xi(r))}else i=e;this.fitInternal(i,t)}rotatedExtentForGeometry(e){const t=this.getRotation(),i=Math.cos(t),r=Math.sin(-t),s=e.getFlatCoordinates(),o=e.getStride();let a=1/0,l=1/0,u=-1/0,h=-1/0;for(let c=0,d=s.length;c{this.dispatchEvent("sourceready")},0))),this.changed()}getFeatures(e){return this.renderer_?this.renderer_.getFeatures(e):Promise.resolve([])}getData(e){return!this.renderer_||!this.rendered?null:this.renderer_.getData(e)}isVisible(e){let t;const i=this.getMapInternal();!e&&i&&(e=i.getView()),e instanceof St?t={viewState:e.getState(),extent:e.calculateExtent()}:t=e,!t.layerStatesArray&&i&&(t.layerStatesArray=i.getLayerGroup().getLayerStatesArray());let r;t.layerStatesArray?r=t.layerStatesArray.find(o=>o.layer===this):r=this.getLayerState();const s=this.getExtent();return fl(r,t.viewState)&&(!s||Se(s,t.extent))}getAttributions(e){if(!this.isVisible(e))return[];let t;const i=this.getSource();if(i&&(t=i.getAttributions()),!t)return[];const r=e instanceof St?e.getViewStateAndExtent():e;let s=t(r);return Array.isArray(s)||(s=[s]),s}render(e,t){const i=this.getRenderer();return i.prepareFrame(e)?(this.rendered=!0,i.renderFrame(e,t)):null}unrender(){this.rendered=!1}setMapInternal(e){e||this.unrender(),this.set(ce.MAP,e)}getMapInternal(){return this.get(ce.MAP)}setMap(e){this.mapPrecomposeKey_&&(xe(this.mapPrecomposeKey_),this.mapPrecomposeKey_=null),e||this.changed(),this.mapRenderKey_&&(xe(this.mapRenderKey_),this.mapRenderKey_=null),e&&(this.mapPrecomposeKey_=oe(e,Pt.PRECOMPOSE,function(t){const r=t.frameState.layerStatesArray,s=this.getLayerState(!1);te(!r.some(function(o){return o.layer===s.layer}),"A layer can only be added to the map once. Use either `layer.setMap()` or `map.addLayer()`, not both."),r.push(s)},this),this.mapRenderKey_=oe(this,Y.CHANGE,e.render,e),this.changed())}setSource(e){this.set(ce.SOURCE,e)}getRenderer(){return this.renderer_||(this.renderer_=this.createRenderer()),this.renderer_}hasRenderer(){return!!this.renderer_}createRenderer(){return null}disposeInternal(){this.renderer_&&(this.renderer_.dispose(),delete this.renderer_),this.setSource(null),super.disposeInternal()}}function fl(n,e){if(!n.visible)return!1;const t=e.resolution;if(t=n.maxResolution)return!1;const i=e.zoom;return i>n.minZoom&&i<=n.maxZoom}const no=sm;class om extends ka{constructor(e){super(),this.map_=e}dispatchRenderEvent(e,t){W()}calculateMatrices2D(e){const t=e.viewState,i=e.coordinateToPixelTransform,r=e.pixelToCoordinateTransform;qt(i,e.size[0]/2,e.size[1]/2,1/t.resolution,-1/t.resolution,-t.rotation,-t.center[0],-t.center[1]),qa(r,i)}forEachFeatureAtCoordinate(e,t,i,r,s,o,a,l){let u;const h=t.viewState;function c(x,E,b,w){return s.call(o,E,x?b:null,w)}const d=h.projection,f=Wa(e.slice(),d),g=[[0,0]];if(d.canWrapX()&&r){const x=d.getExtent(),E=ge(x);g.push([-E,0],[E,0])}const p=t.layerStatesArray,m=p.length,y=[],_=[];for(let x=0;x=0;--E){const b=p[E],w=b.layer;if(w.hasRenderer()&&fl(b,h)&&a.call(l,w)){const C=w.getRenderer(),I=w.getSource();if(C&&I){const z=I.getWrapX()?f:e,N=c.bind(null,b.managed);_[0]=z[0]+g[x][0],_[1]=z[1]+g[x][1],u=C.forEachFeatureAtCoordinate(_,t,i,N,y)}if(u)return u}}if(y.length===0)return;const v=1/y.length;return y.forEach((x,E)=>x.distanceSq+=E*v),y.sort((x,E)=>x.distanceSq-E.distanceSq),y.some(x=>u=x.callback(x.feature,x.layer,x.geometry)),u}hasFeatureAtCoordinate(e,t,i,r,s,o){return this.forEachFeatureAtCoordinate(e,t,i,r,rr,this,s,o)!==void 0}getMap(){return this.map_}renderFrame(e){W()}flushDeclutterItems(e){}scheduleExpireIconCache(e){xs.canExpireCache()&&e.postRenderFunctions.push(am)}}function am(n,e){xs.expire()}class Ec extends Jt{constructor(e,t,i,r){super(e),this.inversePixelTransform=t,this.frameState=i,this.context=r}}class lm extends om{constructor(e){super(e),this.fontChangeListenerKey_=oe(Rt,bn.PROPERTYCHANGE,e.redrawText.bind(e)),this.element_=document.createElement("div");const t=this.element_.style;t.position="absolute",t.width="100%",t.height="100%",t.zIndex="0",this.element_.className=to+" ol-layers";const i=e.getViewport();i.insertBefore(this.element_,i.firstChild||null),this.children_=[],this.renderedVisible_=!0,this.declutterLayers_=[]}dispatchRenderEvent(e,t){const i=this.getMap();if(i.hasListener(e)){const r=new Ec(e,void 0,t);i.dispatchEvent(r)}}disposeInternal(){xe(this.fontChangeListenerKey_),this.element_.parentNode.removeChild(this.element_),super.disposeInternal()}renderFrame(e){if(!e){this.renderedVisible_&&(this.element_.style.display="none",this.renderedVisible_=!1);return}this.calculateMatrices2D(e),this.dispatchRenderEvent(Pt.PRECOMPOSE,e);const t=e.layerStatesArray.sort(function(o,a){return o.zIndex-a.zIndex}),i=e.viewState;this.children_.length=0;const r=this.declutterLayers_;r.length=0;let s=null;for(let o=0,a=t.length;o=0;--i)t[i].renderDeclutter(e);t.length=0}}class ai extends Jt{constructor(e,t){super(e),this.layer=t}}const Ao={LAYERS:"layers"};class zn extends _c{constructor(e){e=e||{};const t=Object.assign({},e);delete t.layers;let i=e.layers;super(t),this.on,this.once,this.un,this.layersListenerKeys_=[],this.listenerKeys_={},this.addChangeListener(Ao.LAYERS,this.handleLayersChanged_),i?Array.isArray(i)?i=new Ft(i.slice(),{unique:!0}):te(typeof i.getArray=="function","Expected `layers` to be an array or a `Collection`"):i=new Ft(void 0,{unique:!0}),this.setLayers(i)}handleLayerChange_(){this.changed()}handleLayersChanged_(){this.layersListenerKeys_.forEach(xe),this.layersListenerKeys_.length=0;const e=this.getLayers();this.layersListenerKeys_.push(oe(e,et.ADD,this.handleLayersAdd_,this),oe(e,et.REMOVE,this.handleLayersRemove_,this));for(const i in this.listenerKeys_)this.listenerKeys_[i].forEach(xe);Cr(this.listenerKeys_);const t=e.getArray();for(let i=0,r=t.length;i{this.clickTimeoutId_=void 0;const i=new si(be.SINGLECLICK,this.map_,e);this.dispatchEvent(i)},250)}updateActivePointers_(e){const t=e,i=t.pointerId;if(t.type==be.POINTERUP||t.type==be.POINTERCANCEL){delete this.trackedTouches_[i];for(const r in this.trackedTouches_)if(this.trackedTouches_[r].target!==t.target){delete this.trackedTouches_[r];break}}else(t.type==be.POINTERDOWN||t.type==be.POINTERMOVE)&&(this.trackedTouches_[i]=t);this.activePointers_=Object.values(this.trackedTouches_)}handlePointerUp_(e){this.updateActivePointers_(e);const t=new si(be.POINTERUP,this.map_,e,void 0,void 0,this.activePointers_);this.dispatchEvent(t),this.emulateClicks_&&!t.defaultPrevented&&!this.dragging_&&this.isMouseActionButton_(e)&&this.emulateClick_(this.down_),this.activePointers_.length===0&&(this.dragListenerKeys_.forEach(xe),this.dragListenerKeys_.length=0,this.dragging_=!1,this.down_=null)}isMouseActionButton_(e){return e.button===0}handlePointerDown_(e){this.emulateClicks_=this.activePointers_.length===0,this.updateActivePointers_(e);const t=new si(be.POINTERDOWN,this.map_,e,void 0,void 0,this.activePointers_);if(this.dispatchEvent(t),this.down_=new PointerEvent(e.type,e),Object.defineProperty(this.down_,"target",{writable:!1,value:e.target}),this.dragListenerKeys_.length===0){const i=this.map_.getOwnerDocument();this.dragListenerKeys_.push(oe(i,be.POINTERMOVE,this.handlePointerMove_,this),oe(i,be.POINTERUP,this.handlePointerUp_,this),oe(this.element_,be.POINTERCANCEL,this.handlePointerUp_,this)),this.element_.getRootNode&&this.element_.getRootNode()!==i&&this.dragListenerKeys_.push(oe(this.element_.getRootNode(),be.POINTERUP,this.handlePointerUp_,this))}}handlePointerMove_(e){if(this.isMoving_(e)){this.updateActivePointers_(e),this.dragging_=!0;const t=new si(be.POINTERDRAG,this.map_,e,this.dragging_,void 0,this.activePointers_);this.dispatchEvent(t)}}relayMoveEvent_(e){this.originalPointerMoveEvent_=e;const t=!!(this.down_&&this.isMoving_(e));this.dispatchEvent(new si(be.POINTERMOVE,this.map_,e,t))}handleTouchMove_(e){const t=this.originalPointerMoveEvent_;(!t||t.defaultPrevented)&&(typeof e.cancelable!="boolean"||e.cancelable===!0)&&e.preventDefault()}isMoving_(e){return this.dragging_||Math.abs(e.clientX-this.down_.clientX)>this.moveTolerance_||Math.abs(e.clientY-this.down_.clientY)>this.moveTolerance_}disposeInternal(){this.relayedListenerKey_&&(xe(this.relayedListenerKey_),this.relayedListenerKey_=null),this.element_.removeEventListener(Y.TOUCHMOVE,this.boundHandleTouchMove_),this.pointerdownListenerKey_&&(xe(this.pointerdownListenerKey_),this.pointerdownListenerKey_=null),this.dragListenerKeys_.forEach(xe),this.dragListenerKeys_.length=0,this.element_=null,super.disposeInternal()}}const oi={POSTRENDER:"postrender",MOVESTART:"movestart",MOVEEND:"moveend",LOADSTART:"loadstart",LOADEND:"loadend"},Ve={LAYERGROUP:"layergroup",SIZE:"size",TARGET:"target",VIEW:"view"},Fs=1/0;class hm{constructor(e,t){this.priorityFunction_=e,this.keyFunction_=t,this.elements_=[],this.priorities_=[],this.queuedElements_={}}clear(){this.elements_.length=0,this.priorities_.length=0,Cr(this.queuedElements_)}dequeue(){const e=this.elements_,t=this.priorities_,i=e[0];e.length==1?(e.length=0,t.length=0):(e[0]=e.pop(),t[0]=t.pop(),this.siftUp_(0));const r=this.keyFunction_(i);return delete this.queuedElements_[r],i}enqueue(e){te(!(this.keyFunction_(e)in this.queuedElements_),"Tried to enqueue an `element` that was already added to the queue");const t=this.priorityFunction_(e);return t!=Fs?(this.elements_.push(e),this.priorities_.push(t),this.queuedElements_[this.keyFunction_(e)]=!0,this.siftDown_(0,this.elements_.length-1),!0):!1}getCount(){return this.elements_.length}getLeftChildIndex_(e){return e*2+1}getRightChildIndex_(e){return e*2+2}getParentIndex_(e){return e-1>>1}heapify_(){let e;for(e=(this.elements_.length>>1)-1;e>=0;e--)this.siftUp_(e)}isEmpty(){return this.elements_.length===0}isKeyQueued(e){return e in this.queuedElements_}isQueued(e){return this.isKeyQueued(this.keyFunction_(e))}siftUp_(e){const t=this.elements_,i=this.priorities_,r=t.length,s=t[e],o=i[e],a=e;for(;e>1;){const l=this.getLeftChildIndex_(e),u=this.getRightChildIndex_(e),h=ue;){const a=this.getParentIndex_(t);if(r[a]>o)i[t]=i[a],r[t]=r[a],t=a;else break}i[t]=s,r[t]=o}reprioritize(){const e=this.priorityFunction_,t=this.elements_,i=this.priorities_;let r=0;const s=t.length;let o,a,l;for(a=0;a0;)s=this.dequeue()[0],o=s.getKey(),r=s.getState(),r===P.IDLE&&!(o in this.tilesLoadingKeys_)&&(this.tilesLoadingKeys_[o]=!0,++this.tilesLoading_,++i,s.load())}}function dm(n,e,t,i,r){if(!n||!(t in n.wantedTiles)||!n.wantedTiles[t][e.getKey()])return Fs;const s=n.viewState.center,o=i[0]-s[0],a=i[1]-s[1];return 65536*Math.log(r)+Math.sqrt(o*o+a*a)/r}class gl extends kt{constructor(e){super();const t=e.element;t&&!e.target&&!t.style.pointerEvents&&(t.style.pointerEvents="auto"),this.element=t||null,this.target_=null,this.map_=null,this.listenerKeys=[],e.render&&(this.render=e.render),e.target&&this.setTarget(e.target)}disposeInternal(){Qo(this.element),super.disposeInternal()}getMap(){return this.map_}setMap(e){this.map_&&Qo(this.element);for(let t=0,i=this.listenerKeys.length;tr.getAttributions(e)))),i=!this.getMap().getAllLayers().some(r=>r.getSource()&&r.getSource().getAttributionsCollapsible()===!1);return this.overrideCollapsible_||this.setCollapsible(i),t}updateElement_(e){if(!e){this.renderedVisible_&&(this.element.style.display="none",this.renderedVisible_=!1);return}const t=this.collectSourceAttributions_(e),i=t.length>0;if(this.renderedVisible_!=i&&(this.element.style.display=i?"":"none",this.renderedVisible_=i),!vi(t,this.renderedAttributions_)){cf(this.ulElement_);for(let r=0,s=t.length;r0&&i%(2*Math.PI)!==0?t.animate({rotation:0,duration:this.duration_,easing:Dn}):t.setRotation(0))}render(e){const t=e.frameState;if(!t)return;const i=t.viewState.rotation;if(i!=this.rotation_){const r="rotate("+i+"rad)";if(this.autoHide_){const s=this.element.classList.contains(Jr);!s&&i===0?this.element.classList.add(Jr):s&&i!==0&&this.element.classList.remove(Jr)}this.label_.style.transform=r}this.rotation_=i}}const mm=pm;class ym extends gl{constructor(e){e=e||{},super({element:document.createElement("div"),target:e.target});const t=e.className!==void 0?e.className:"ol-zoom",i=e.delta!==void 0?e.delta:1,r=e.zoomInClassName!==void 0?e.zoomInClassName:t+"-in",s=e.zoomOutClassName!==void 0?e.zoomOutClassName:t+"-out",o=e.zoomInLabel!==void 0?e.zoomInLabel:"+",a=e.zoomOutLabel!==void 0?e.zoomOutLabel:"–",l=e.zoomInTipLabel!==void 0?e.zoomInTipLabel:"Zoom in",u=e.zoomOutTipLabel!==void 0?e.zoomOutTipLabel:"Zoom out",h=document.createElement("button");h.className=r,h.setAttribute("type","button"),h.title=l,h.appendChild(typeof o=="string"?document.createTextNode(o):o),h.addEventListener(Y.CLICK,this.handleClick_.bind(this,i),!1);const c=document.createElement("button");c.className=s,c.setAttribute("type","button"),c.title=u,c.appendChild(typeof a=="string"?document.createTextNode(a):a),c.addEventListener(Y.CLICK,this.handleClick_.bind(this,-i),!1);const d=t+" "+to+" "+al,f=this.element;f.className=d,f.appendChild(h),f.appendChild(c),this.duration_=e.duration!==void 0?e.duration:250}handleClick_(e,t){t.preventDefault(),this.zoomByDelta_(e)}zoomByDelta_(e){const i=this.getMap().getView();if(!i)return;const r=i.getZoom();if(r!==void 0){const s=i.getConstrainedZoom(r+e);this.duration_>0?(i.getAnimating()&&i.cancelAnimations(),i.animate({zoom:s,duration:this.duration_,easing:Dn})):i.setZoom(s)}}}const _m=ym;function xm(n){n=n||{};const e=new Ft;return(n.zoom!==void 0?n.zoom:!0)&&e.push(new _m(n.zoomOptions)),(n.rotate!==void 0?n.rotate:!0)&&e.push(new mm(n.rotateOptions)),(n.attribution!==void 0?n.attribution:!0)&&e.push(new gm(n.attributionOptions)),e}const Du={ACTIVE:"active"};class Lr extends kt{constructor(e){super(),this.on,this.once,this.un,e&&e.handleEvent&&(this.handleEvent=e.handleEvent),this.map_=null,this.setActive(!0)}getActive(){return this.get(Du.ACTIVE)}getMap(){return this.map_}handleEvent(e){return!0}setActive(e){this.set(Du.ACTIVE,e)}setMap(e){this.map_=e}}function vm(n,e,t){const i=n.getCenterInternal();if(i){const r=[i[0]+e[0],i[1]+e[1]];n.animateInternal({duration:t!==void 0?t:250,easing:em,center:n.getConstrainedCenter(r)})}}function pl(n,e,t,i){const r=n.getZoom();if(r===void 0)return;const s=n.getConstrainedZoom(r+e),o=n.getResolutionForZoom(s);n.getAnimating()&&n.cancelAnimations(),n.animate({resolution:o,anchor:t,duration:i!==void 0?i:250,easing:Dn})}class Em extends Lr{constructor(e){super(),e=e||{},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:250}handleEvent(e){let t=!1;if(e.type==be.DBLCLICK){const i=e.originalEvent,r=e.map,s=e.coordinate,o=i.shiftKey?-this.delta_:this.delta_,a=r.getView();pl(a,o,s,this.duration_),i.preventDefault(),t=!0}return!t}}const wm=Em;class kr extends Lr{constructor(e){e=e||{},super(e),e.handleDownEvent&&(this.handleDownEvent=e.handleDownEvent),e.handleDragEvent&&(this.handleDragEvent=e.handleDragEvent),e.handleMoveEvent&&(this.handleMoveEvent=e.handleMoveEvent),e.handleUpEvent&&(this.handleUpEvent=e.handleUpEvent),e.stopDown&&(this.stopDown=e.stopDown),this.handlingDownUpSequence=!1,this.targetPointers=[]}getPointerCount(){return this.targetPointers.length}handleDownEvent(e){return!1}handleDragEvent(e){}handleEvent(e){if(!e.originalEvent)return!0;let t=!1;if(this.updateTrackedPointers_(e),this.handlingDownUpSequence){if(e.type==be.POINTERDRAG)this.handleDragEvent(e),e.originalEvent.preventDefault();else if(e.type==be.POINTERUP){const i=this.handleUpEvent(e);this.handlingDownUpSequence=i&&this.targetPointers.length>0}}else if(e.type==be.POINTERDOWN){const i=this.handleDownEvent(e);this.handlingDownUpSequence=i,t=this.stopDown(i)}else e.type==be.POINTERMOVE&&this.handleMoveEvent(e);return!t}handleMoveEvent(e){}handleUpEvent(e){return!1}stopDown(e){return e}updateTrackedPointers_(e){e.activePointers&&(this.targetPointers=e.activePointers)}}function ml(n){const e=n.length;let t=0,i=0;for(let r=0;r0&&this.condition_(e)){const i=e.map.getView();return this.lastCentroid=null,i.getAnimating()&&i.cancelAnimations(),this.kinetic_&&this.kinetic_.begin(),this.noKinetic_=this.targetPointers.length>1,!0}return!1}}const Fm=Am;class Mm extends kr{constructor(e){e=e||{},super({stopDown:Us}),this.condition_=e.condition?e.condition:Cm,this.lastAngle_=void 0,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){if(!Fo(e))return;const t=e.map,i=t.getView();if(i.getConstraints().rotation===dl)return;const r=t.getSize(),s=e.pixel,o=Math.atan2(r[1]/2-s[1],s[0]-r[0]/2);if(this.lastAngle_!==void 0){const a=o-this.lastAngle_;i.adjustRotationInternal(-a)}this.lastAngle_=o}handleUpEvent(e){return Fo(e)?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){return Fo(e)&&Cc(e)&&this.condition_(e)?(e.map.getView().beginInteraction(),this.lastAngle_=void 0,!0):!1}}class Pm extends ka{constructor(e){super(),this.geometry_=null,this.element_=document.createElement("div"),this.element_.style.position="absolute",this.element_.style.pointerEvents="auto",this.element_.className="ol-box "+e,this.map_=null,this.startPixel_=null,this.endPixel_=null}disposeInternal(){this.setMap(null)}render_(){const e=this.startPixel_,t=this.endPixel_,i="px",r=this.element_.style;r.left=Math.min(e[0],t[0])+i,r.top=Math.min(e[1],t[1])+i,r.width=Math.abs(t[0]-e[0])+i,r.height=Math.abs(t[1]-e[1])+i}setMap(e){if(this.map_){this.map_.getOverlayContainer().removeChild(this.element_);const t=this.element_.style;t.left="inherit",t.top="inherit",t.width="inherit",t.height="inherit"}this.map_=e,this.map_&&this.map_.getOverlayContainer().appendChild(this.element_)}setPixels(e,t){this.startPixel_=e,this.endPixel_=t,this.createOrUpdateGeometry(),this.render_()}createOrUpdateGeometry(){const e=this.startPixel_,t=this.endPixel_,r=[e,[e[0],t[1]],t,[t[0],e[1]]].map(this.map_.getCoordinateFromPixelInternal,this.map_);r[4]=r[0].slice(),this.geometry_?this.geometry_.setCoordinates([r]):this.geometry_=new Kt([r])}getGeometry(){return this.geometry_}}const rs={BOXSTART:"boxstart",BOXDRAG:"boxdrag",BOXEND:"boxend",BOXCANCEL:"boxcancel"};class Mo extends Jt{constructor(e,t,i){super(e),this.coordinate=t,this.mapBrowserEvent=i}}class Lm extends kr{constructor(e){super(),this.on,this.once,this.un,e=e||{},this.box_=new Pm(e.className||"ol-dragbox"),this.minArea_=e.minArea!==void 0?e.minArea:64,e.onBoxEnd&&(this.onBoxEnd=e.onBoxEnd),this.startPixel_=null,this.condition_=e.condition?e.condition:Cc,this.boxEndCondition_=e.boxEndCondition?e.boxEndCondition:this.defaultBoxEndCondition}defaultBoxEndCondition(e,t,i){const r=i[0]-t[0],s=i[1]-t[1];return r*r+s*s>=this.minArea_}getGeometry(){return this.box_.getGeometry()}handleDragEvent(e){this.box_.setPixels(this.startPixel_,e.pixel),this.dispatchEvent(new Mo(rs.BOXDRAG,e.coordinate,e))}handleUpEvent(e){this.box_.setMap(null);const t=this.boxEndCondition_(e,this.startPixel_,e.pixel);return t&&this.onBoxEnd(e),this.dispatchEvent(new Mo(t?rs.BOXEND:rs.BOXCANCEL,e.coordinate,e)),!1}handleDownEvent(e){return this.condition_(e)?(this.startPixel_=e.pixel,this.box_.setMap(e.map),this.box_.setPixels(this.startPixel_,this.startPixel_),this.dispatchEvent(new Mo(rs.BOXSTART,e.coordinate,e)),!0):!1}onBoxEnd(e){}}class km extends Lm{constructor(e){e=e||{};const t=e.condition?e.condition:Sm;super({condition:t,className:e.className||"ol-dragzoom",minArea:e.minArea}),this.duration_=e.duration!==void 0?e.duration:200,this.out_=e.out!==void 0?e.out:!1}onBoxEnd(e){const i=this.getMap().getView();let r=this.getGeometry();if(this.out_){const s=i.rotatedExtentForGeometry(r),o=i.getResolutionForExtentInternal(s),a=i.getResolution()/o;r=r.clone(),r.scale(a*a)}i.fitInternal(r,{duration:this.duration_,easing:Dn})}}const Om=km,Ti={LEFT:"ArrowLeft",UP:"ArrowUp",RIGHT:"ArrowRight",DOWN:"ArrowDown"};class Dm extends Lr{constructor(e){super(),e=e||{},this.defaultCondition_=function(t){return bc(t)&&Tc(t)},this.condition_=e.condition!==void 0?e.condition:this.defaultCondition_,this.duration_=e.duration!==void 0?e.duration:100,this.pixelDelta_=e.pixelDelta!==void 0?e.pixelDelta:128}handleEvent(e){let t=!1;if(e.type==Y.KEYDOWN){const i=e.originalEvent,r=i.key;if(this.condition_(e)&&(r==Ti.DOWN||r==Ti.LEFT||r==Ti.RIGHT||r==Ti.UP)){const o=e.map.getView(),a=o.getResolution()*this.pixelDelta_;let l=0,u=0;r==Ti.DOWN?u=-a:r==Ti.LEFT?l=-a:r==Ti.RIGHT?l=a:u=a;const h=[l,u];Xa(h,o.getRotation()),vm(o,h,this.duration_),i.preventDefault(),t=!0}}return!t}}class zm extends Lr{constructor(e){super(),e=e||{},this.condition_=e.condition?e.condition:function(t){return!Rm(t)&&Tc(t)},this.delta_=e.delta?e.delta:1,this.duration_=e.duration!==void 0?e.duration:100}handleEvent(e){let t=!1;if(e.type==Y.KEYDOWN||e.type==Y.KEYPRESS){const i=e.originalEvent,r=i.key;if(this.condition_(e)&&(r==="+"||r==="-")){const s=e.map,o=r==="+"?this.delta_:-this.delta_,a=s.getView();pl(a,o,void 0,this.duration_),i.preventDefault(),t=!0}}return!t}}const Nm=zm;class Gm{constructor(e,t,i){this.decay_=e,this.minVelocity_=t,this.delay_=i,this.points_=[],this.angle_=0,this.initialVelocity_=0}begin(){this.points_.length=0,this.angle_=0,this.initialVelocity_=0}update(e,t){this.points_.push(e,t,Date.now())}end(){if(this.points_.length<6)return!1;const e=Date.now()-this.delay_,t=this.points_.length-3;if(this.points_[t+2]0&&this.points_[i+2]>e;)i-=3;const r=this.points_[t+2]-this.points_[i+2];if(r<1e3/60)return!1;const s=this.points_[t]-this.points_[i],o=this.points_[t+1]-this.points_[i+1];return this.angle_=Math.atan2(o,s),this.initialVelocity_=Math.sqrt(s*s+o*o)/r,this.initialVelocity_>this.minVelocity_}getDistance(){return(this.minVelocity_-this.initialVelocity_)/this.decay_}getAngle(){return this.angle_}}class $m extends Lr{constructor(e){e=e||{},super(e),this.totalDelta_=0,this.lastDelta_=0,this.maxDelta_=e.maxDelta!==void 0?e.maxDelta:1,this.duration_=e.duration!==void 0?e.duration:250,this.timeout_=e.timeout!==void 0?e.timeout:80,this.useAnchor_=e.useAnchor!==void 0?e.useAnchor:!0,this.constrainResolution_=e.constrainResolution!==void 0?e.constrainResolution:!1;const t=e.condition?e.condition:Tm;this.condition_=e.onFocusOnly?va(wc,t):t,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_,this.mode_=void 0,this.trackpadEventGap_=400,this.trackpadTimeoutId_,this.deltaPerZoom_=300}endInteraction_(){this.trackpadTimeoutId_=void 0;const e=this.getMap();if(!e)return;e.getView().endInteraction(void 0,this.lastDelta_?this.lastDelta_>0?1:-1:0,this.lastAnchor_)}handleEvent(e){if(!this.condition_(e)||e.type!==Y.WHEEL)return!0;const i=e.map,r=e.originalEvent;r.preventDefault(),this.useAnchor_&&(this.lastAnchor_=e.coordinate);let s;if(e.type==Y.WHEEL&&(s=r.deltaY,lf&&r.deltaMode===WheelEvent.DOM_DELTA_PIXEL&&(s/=za),r.deltaMode===WheelEvent.DOM_DELTA_LINE&&(s*=40)),s===0)return!1;this.lastDelta_=s;const o=Date.now();this.startTime_===void 0&&(this.startTime_=o),(!this.mode_||o-this.startTime_>this.trackpadEventGap_)&&(this.mode_=Math.abs(s)<4?"trackpad":"wheel");const a=i.getView();if(this.mode_==="trackpad"&&!(a.getConstrainResolution()||this.constrainResolution_))return this.trackpadTimeoutId_?clearTimeout(this.trackpadTimeoutId_):(a.getAnimating()&&a.cancelAnimations(),a.beginInteraction()),this.trackpadTimeoutId_=setTimeout(this.endInteraction_.bind(this),this.timeout_),a.adjustZoom(-s/this.deltaPerZoom_,this.lastAnchor_),this.startTime_=o,!1;this.totalDelta_+=s;const l=Math.max(this.timeout_-(o-this.startTime_),0);return clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(this.handleWheelZoom_.bind(this,i),l),!1}handleWheelZoom_(e){const t=e.getView();t.getAnimating()&&t.cancelAnimations();let i=-Me(this.totalDelta_,-this.maxDelta_*this.deltaPerZoom_,this.maxDelta_*this.deltaPerZoom_)/this.deltaPerZoom_;(t.getConstrainResolution()||this.constrainResolution_)&&(i=i?i>0?1:-1:0),pl(t,i,this.lastAnchor_,this.duration_),this.mode_=void 0,this.totalDelta_=0,this.lastAnchor_=null,this.startTime_=void 0,this.timeoutId_=void 0}setMouseAnchor(e){this.useAnchor_=e,e||(this.lastAnchor_=null)}}const jm=$m;class Xm extends kr{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Us),super(t),this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.threshold_=e.threshold!==void 0?e.threshold:.3,this.duration_=e.duration!==void 0?e.duration:250}handleDragEvent(e){let t=0;const i=this.targetPointers[0],r=this.targetPointers[1],s=Math.atan2(r.clientY-i.clientY,r.clientX-i.clientX);if(this.lastAngle_!==void 0){const l=s-this.lastAngle_;this.rotationDelta_+=l,!this.rotating_&&Math.abs(this.rotationDelta_)>this.threshold_&&(this.rotating_=!0),t=l}this.lastAngle_=s;const o=e.map,a=o.getView();a.getConstraints().rotation!==dl&&(this.anchor_=o.getCoordinateFromPixelInternal(o.getEventPixel(ml(this.targetPointers))),this.rotating_&&(o.render(),a.adjustRotationInternal(t,this.anchor_)))}handleUpEvent(e){return this.targetPointers.length<2?(e.map.getView().endInteraction(this.duration_),!1):!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastAngle_=void 0,this.rotating_=!1,this.rotationDelta_=0,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}class Wm extends kr{constructor(e){e=e||{};const t=e;t.stopDown||(t.stopDown=Us),super(t),this.anchor_=null,this.duration_=e.duration!==void 0?e.duration:400,this.lastDistance_=void 0,this.lastScaleDelta_=1}handleDragEvent(e){let t=1;const i=this.targetPointers[0],r=this.targetPointers[1],s=i.clientX-r.clientX,o=i.clientY-r.clientY,a=Math.sqrt(s*s+o*o);this.lastDistance_!==void 0&&(t=this.lastDistance_/a),this.lastDistance_=a;const l=e.map,u=l.getView();t!=1&&(this.lastScaleDelta_=t),this.anchor_=l.getCoordinateFromPixelInternal(l.getEventPixel(ml(this.targetPointers))),l.render(),u.adjustResolutionInternal(t,this.anchor_)}handleUpEvent(e){if(this.targetPointers.length<2){const i=e.map.getView(),r=this.lastScaleDelta_>1?1:-1;return i.endInteraction(this.duration_,r),!1}return!0}handleDownEvent(e){if(this.targetPointers.length>=2){const t=e.map;return this.anchor_=null,this.lastDistance_=void 0,this.lastScaleDelta_=1,this.handlingDownUpSequence||t.getView().beginInteraction(),!0}return!1}}const Um=Wm;function Vm(n){n=n||{};const e=new Ft,t=new Gm(-.005,.05,100);return(n.altShiftDragRotate!==void 0?n.altShiftDragRotate:!0)&&e.push(new Mm),(n.doubleClickZoom!==void 0?n.doubleClickZoom:!0)&&e.push(new wm({delta:n.zoomDelta,duration:n.zoomDuration})),(n.dragPan!==void 0?n.dragPan:!0)&&e.push(new Fm({onFocusOnly:n.onFocusOnly,kinetic:t})),(n.pinchRotate!==void 0?n.pinchRotate:!0)&&e.push(new Xm),(n.pinchZoom!==void 0?n.pinchZoom:!0)&&e.push(new Um({duration:n.zoomDuration})),(n.keyboard!==void 0?n.keyboard:!0)&&(e.push(new Dm),e.push(new Nm({delta:n.zoomDelta,duration:n.zoomDuration}))),(n.mouseWheelZoom!==void 0?n.mouseWheelZoom:!0)&&e.push(new jm({onFocusOnly:n.onFocusOnly,duration:n.zoomDuration})),(n.shiftDragZoom!==void 0?n.shiftDragZoom:!0)&&e.push(new Om({duration:n.zoomDuration})),e}function Rc(n){if(n instanceof no){n.setMapInternal(null);return}n instanceof zn&&n.getLayers().forEach(Rc)}function Sc(n,e){if(n instanceof no){n.setMapInternal(e);return}if(n instanceof zn){const t=n.getLayers().getArray();for(let i=0,r=t.length;ithis.updateSize()),this.controls=t.controls||xm(),this.interactions=t.interactions||Vm({onFocusOnly:!0}),this.overlays_=t.overlays,this.overlayIdIndex_={},this.renderer_=null,this.postRenderFunctions_=[],this.tileQueue_=new cm(this.getTilePriority.bind(this),this.handleTileChange_.bind(this)),this.addChangeListener(Ve.LAYERGROUP,this.handleLayerGroupChanged_),this.addChangeListener(Ve.VIEW,this.handleViewChanged_),this.addChangeListener(Ve.SIZE,this.handleSizeChanged_),this.addChangeListener(Ve.TARGET,this.handleTargetChanged_),this.setProperties(t.values);const i=this;e.view&&!(e.view instanceof St)&&e.view.then(function(r){i.setView(new St(r))}),this.controls.addEventListener(et.ADD,r=>{r.element.setMap(this)}),this.controls.addEventListener(et.REMOVE,r=>{r.element.setMap(null)}),this.interactions.addEventListener(et.ADD,r=>{r.element.setMap(this)}),this.interactions.addEventListener(et.REMOVE,r=>{r.element.setMap(null)}),this.overlays_.addEventListener(et.ADD,r=>{this.addOverlayInternal_(r.element)}),this.overlays_.addEventListener(et.REMOVE,r=>{const s=r.element.getId();s!==void 0&&delete this.overlayIdIndex_[s.toString()],r.element.setMap(null)}),this.controls.forEach(r=>{r.setMap(this)}),this.interactions.forEach(r=>{r.setMap(this)}),this.overlays_.forEach(this.addOverlayInternal_.bind(this))}addControl(e){this.getControls().push(e)}addInteraction(e){this.getInteractions().push(e)}addLayer(e){this.getLayerGroup().getLayers().push(e)}handleLayerAdd_(e){Sc(e.layer,this)}addOverlay(e){this.getOverlays().push(e)}addOverlayInternal_(e){const t=e.getId();t!==void 0&&(this.overlayIdIndex_[t.toString()]=e),e.setMap(this)}disposeInternal(){this.controls.clear(),this.interactions.clear(),this.overlays_.clear(),this.resizeObserver_.disconnect(),this.setTarget(null),super.disposeInternal()}forEachFeatureAtPixel(e,t,i){if(!this.frameState_||!this.renderer_)return;const r=this.getCoordinateFromPixelInternal(e);i=i!==void 0?i:{};const s=i.hitTolerance!==void 0?i.hitTolerance:0,o=i.layerFilter!==void 0?i.layerFilter:rr,a=i.checkWrapped!==!1;return this.renderer_.forEachFeatureAtCoordinate(r,this.frameState_,s,a,t,null,o,null)}getFeaturesAtPixel(e,t){const i=[];return this.forEachFeatureAtPixel(e,function(r){i.push(r)},t),i}getAllLayers(){const e=[];function t(i){i.forEach(function(r){r instanceof zn?t(r.getLayers()):e.push(r)})}return t(this.getLayers()),e}hasFeatureAtPixel(e,t){if(!this.frameState_||!this.renderer_)return!1;const i=this.getCoordinateFromPixelInternal(e);t=t!==void 0?t:{};const r=t.layerFilter!==void 0?t.layerFilter:rr,s=t.hitTolerance!==void 0?t.hitTolerance:0,o=t.checkWrapped!==!1;return this.renderer_.hasFeatureAtCoordinate(i,this.frameState_,s,o,r,null)}getEventCoordinate(e){return this.getCoordinateFromPixel(this.getEventPixel(e))}getEventCoordinateInternal(e){return this.getCoordinateFromPixelInternal(this.getEventPixel(e))}getEventPixel(e){const i=this.viewport_.getBoundingClientRect(),r=this.getSize(),s=i.width/r[0],o=i.height/r[1],a="changedTouches"in e?e.changedTouches[0]:e;return[(a.clientX-i.left)/s,(a.clientY-i.top)/o]}getTarget(){return this.get(Ve.TARGET)}getTargetElement(){return this.targetElement_}getCoordinateFromPixel(e){return aa(this.getCoordinateFromPixelInternal(e),this.getView().getProjection())}getCoordinateFromPixelInternal(e){const t=this.frameState_;return t?Le(t.pixelToCoordinateTransform,e.slice()):null}getControls(){return this.controls}getOverlays(){return this.overlays_}getOverlayById(e){const t=this.overlayIdIndex_[e.toString()];return t!==void 0?t:null}getInteractions(){return this.interactions}getLayerGroup(){return this.get(Ve.LAYERGROUP)}setLayers(e){const t=this.getLayerGroup();if(e instanceof Ft){t.setLayers(e);return}const i=t.getLayers();i.clear(),i.extend(e)}getLayers(){return this.getLayerGroup().getLayers()}getLoadingOrNotReady(){const e=this.getLayerGroup().getLayerStatesArray();for(let t=0,i=e.length;t=0;s--){const o=r[s];if(o.getMap()!==this||!o.getActive()||!this.getTargetElement())continue;if(!o.handleEvent(e)||e.propagationStopped)break}}}handlePostRender(){const e=this.frameState_,t=this.tileQueue_;if(!t.isEmpty()){let r=this.maxTilesLoading_,s=r;if(e){const o=e.viewHints;if(o[Te.ANIMATING]||o[Te.INTERACTING]){const a=Date.now()-e.time>8;r=a?0:8,s=a?0:2}}t.getTilesLoading(){this.postRenderTimeoutHandle_=void 0,this.handlePostRender()},0))}setLayerGroup(e){const t=this.getLayerGroup();t&&this.handleLayerRemove_(new ai("removelayer",t)),this.set(Ve.LAYERGROUP,e)}setSize(e){this.set(Ve.SIZE,e)}setTarget(e){this.set(Ve.TARGET,e)}setView(e){if(!e||e instanceof St){this.set(Ve.VIEW,e);return}this.set(Ve.VIEW,new St);const t=this;e.then(function(i){t.setView(new St(i))})}updateSize(){const e=this.getTargetElement();let t;if(e){const r=getComputedStyle(e),s=e.offsetWidth-parseFloat(r.borderLeftWidth)-parseFloat(r.paddingLeft)-parseFloat(r.paddingRight)-parseFloat(r.borderRightWidth),o=e.offsetHeight-parseFloat(r.borderTopWidth)-parseFloat(r.paddingTop)-parseFloat(r.paddingBottom)-parseFloat(r.borderBottomWidth);!isNaN(s)&&!isNaN(o)&&(t=[s,o],!Ql(t)&&(e.offsetWidth||e.offsetHeight||e.getClientRects().length)&&Xh("No map visible because the map container's width or height are 0."))}const i=this.getSize();t&&(!i||!vi(t,i))&&(this.setSize(t),this.updateViewportSize_())}updateViewportSize_(){const e=this.getView();if(e){let t;const i=getComputedStyle(this.viewport_);i.width&&i.height&&(t=[parseInt(i.width,10),parseInt(i.height,10)]),e.setViewportSize(t)}}};function Bm(n){let e=null;n.keyboardEventTarget!==void 0&&(e=typeof n.keyboardEventTarget=="string"?document.getElementById(n.keyboardEventTarget):n.keyboardEventTarget);const t={},i=n.layers&&typeof n.layers.getLayers=="function"?n.layers:new zn({layers:n.layers});t[Ve.LAYERGROUP]=i,t[Ve.TARGET]=n.target,t[Ve.VIEW]=n.view instanceof St?n.view:new St;let r;n.controls!==void 0&&(Array.isArray(n.controls)?r=new Ft(n.controls.slice()):(te(typeof n.controls.getArray=="function","Expected `controls` to be an array or an `ol/Collection.js`"),r=n.controls));let s;n.interactions!==void 0&&(Array.isArray(n.interactions)?s=new Ft(n.interactions.slice()):(te(typeof n.interactions.getArray=="function","Expected `interactions` to be an array or an `ol/Collection.js`"),s=n.interactions));let o;return n.overlays!==void 0?Array.isArray(n.overlays)?o=new Ft(n.overlays.slice()):(te(typeof n.overlays.getArray=="function","Expected `overlays` to be an array or an `ol/Collection.js`"),o=n.overlays):o=new Ft,{controls:r,interactions:s,keyboardEventTarget:e,overlays:o,values:t}}class ro extends Vs{constructor(e,t,i){super(),i=i||{},this.tileCoord=e,this.state=t,this.interimTile=null,this.key="",this.transition_=i.transition===void 0?250:i.transition,this.transitionStarts_={},this.interpolate=!!i.interpolate}changed(){this.dispatchEvent(Y.CHANGE)}release(){this.state===P.ERROR&&this.setState(P.EMPTY)}getKey(){return this.key+"/"+this.tileCoord}getInterimTile(){if(!this.interimTile)return this;let e=this.interimTile;do{if(e.getState()==P.LOADED)return this.transition_=0,e;e=e.interimTile}while(e);return this}refreshInterimChain(){if(!this.interimTile)return;let e=this.interimTile,t=this;do{if(e.getState()==P.LOADED){e.interimTile=null;break}else e.getState()==P.LOADING?t=e:e.getState()==P.IDLE?t.interimTile=e.interimTile:t=e;e=t.interimTile}while(e)}getTileCoord(){return this.tileCoord}getState(){return this.state}setState(e){if(this.state!==P.ERROR&&this.state>e)throw new Error("Tile load sequence violation");this.state=e,this.changed()}load(){W()}getAlpha(e,t){if(!this.transition_)return 1;let i=this.transitionStarts_[e];if(!i)i=t,this.transitionStarts_[e]=i;else if(i===-1)return 1;const r=t-i+1e3/60;return r>=this.transition_?1:vc(r/this.transition_)}inTransition(e){return this.transition_?this.transitionStarts_[e]!==-1:!1}endTransition(e){this.transition_&&(this.transitionStarts_[e]=-1)}}class Ic extends ro{constructor(e,t,i,r,s,o){super(e,t,o),this.crossOrigin_=r,this.src_=i,this.key=i,this.image_=new Image,r!==null&&(this.image_.crossOrigin=r),this.unlisten_=null,this.tileLoadFunction_=s}getImage(){return this.image_}setImage(e){this.image_=e,this.state=P.LOADED,this.unlistenImage_(),this.changed()}handleImageError_(){this.state=P.ERROR,this.unlistenImage_(),this.image_=Zm(),this.changed()}handleImageLoad_(){const e=this.image_;e.naturalWidth&&e.naturalHeight?this.state=P.LOADED:this.state=P.EMPTY,this.unlistenImage_(),this.changed()}load(){this.state==P.ERROR&&(this.state=P.IDLE,this.image_=new Image,this.crossOrigin_!==null&&(this.image_.crossOrigin=this.crossOrigin_)),this.state==P.IDLE&&(this.state=P.LOADING,this.changed(),this.tileLoadFunction_(this,this.src_),this.unlisten_=ff(this.image_,this.handleImageLoad_.bind(this),this.handleImageError_.bind(this)))}unlistenImage_(){this.unlisten_&&(this.unlisten_(),this.unlisten_=null)}}function Zm(){const n=$e(1,1);return n.fillStyle="rgba(0,0,0,0)",n.fillRect(0,0,1,1),n.canvas}const qm=.5,Km=10,zu=.25;class Hm{constructor(e,t,i,r,s,o){this.sourceProj_=e,this.targetProj_=t;let a={};const l=Cs(this.targetProj_,this.sourceProj_);this.transformInv_=function(_){const v=_[0]+"/"+_[1];return a[v]||(a[v]=l(_)),a[v]},this.maxSourceExtent_=r,this.errorThresholdSquared_=s*s,this.triangles_=[],this.wrapsXInSource_=!1,this.canWrapXInSource_=this.sourceProj_.canWrapX()&&!!r&&!!this.sourceProj_.getExtent()&&ge(r)>=ge(this.sourceProj_.getExtent()),this.sourceWorldWidth_=this.sourceProj_.getExtent()?ge(this.sourceProj_.getExtent()):null,this.targetWorldWidth_=this.targetProj_.getExtent()?ge(this.targetProj_.getExtent()):null;const u=Qt(i),h=Ks(i),c=qs(i),d=Sr(i),f=this.transformInv_(u),g=this.transformInv_(h),p=this.transformInv_(c),m=this.transformInv_(d),y=Km+(o?Math.max(0,Math.ceil(Math.log2(na(i)/(o*o*256*256)))):0);if(this.addQuad_(u,h,c,d,f,g,p,m,y),this.wrapsXInSource_){let _=1/0;this.triangles_.forEach(function(v,x,E){_=Math.min(_,v.source[0][0],v.source[1][0],v.source[2][0])}),this.triangles_.forEach(v=>{if(Math.max(v.source[0][0],v.source[1][0],v.source[2][0])-_>this.sourceWorldWidth_/2){const x=[[v.source[0][0],v.source[0][1]],[v.source[1][0],v.source[1][1]],[v.source[2][0],v.source[2][1]]];x[0][0]-_>this.sourceWorldWidth_/2&&(x[0][0]-=this.sourceWorldWidth_),x[1][0]-_>this.sourceWorldWidth_/2&&(x[1][0]-=this.sourceWorldWidth_),x[2][0]-_>this.sourceWorldWidth_/2&&(x[2][0]-=this.sourceWorldWidth_);const E=Math.min(x[0][0],x[1][0],x[2][0]);Math.max(x[0][0],x[1][0],x[2][0])-E.5&&c<1;let g=!1;if(u>0){if(this.targetProj_.isGlobal()&&this.targetWorldWidth_){const m=ta([e,t,i,r]);g=ge(m)/this.targetWorldWidth_>zu||g}!f&&this.sourceProj_.isGlobal()&&c&&(g=c>zu||g)}if(!g&&this.maxSourceExtent_&&isFinite(h[0])&&isFinite(h[1])&&isFinite(h[2])&&isFinite(h[3])&&!Se(h,this.maxSourceExtent_))return;let p=0;if(!g&&(!isFinite(s[0])||!isFinite(s[1])||!isFinite(o[0])||!isFinite(o[1])||!isFinite(a[0])||!isFinite(a[1])||!isFinite(l[0])||!isFinite(l[1]))){if(u>0)g=!0;else if(p=(!isFinite(s[0])||!isFinite(s[1])?8:0)+(!isFinite(o[0])||!isFinite(o[1])?4:0)+(!isFinite(a[0])||!isFinite(a[1])?2:0)+(!isFinite(l[0])||!isFinite(l[1])?1:0),p!=1&&p!=2&&p!=4&&p!=8)return}if(u>0){if(!g){const m=[(e[0]+i[0])/2,(e[1]+i[1])/2],y=this.transformInv_(m);let _;f?_=(Ni(s[0],d)+Ni(a[0],d))/2-Ni(y[0],d):_=(s[0]+a[0])/2-y[0];const v=(s[1]+a[1])/2-y[1];g=_*_+v*v>this.errorThresholdSquared_}if(g){if(Math.abs(e[0]-i[0])<=Math.abs(e[1]-i[1])){const m=[(t[0]+i[0])/2,(t[1]+i[1])/2],y=this.transformInv_(m),_=[(r[0]+e[0])/2,(r[1]+e[1])/2],v=this.transformInv_(_);this.addQuad_(e,t,m,_,s,o,y,v,u-1),this.addQuad_(_,m,i,r,v,y,a,l,u-1)}else{const m=[(e[0]+t[0])/2,(e[1]+t[1])/2],y=this.transformInv_(m),_=[(i[0]+r[0])/2,(i[1]+r[1])/2],v=this.transformInv_(_);this.addQuad_(e,m,_,r,s,y,v,l,u-1),this.addQuad_(m,t,i,_,y,o,a,v,u-1)}return}}if(f){if(!this.canWrapXInSource_)return;this.wrapsXInSource_=!0}p&11||this.addTriangle_(e,i,r,s,a,l),p&14||this.addTriangle_(e,i,t,s,a,o),p&&(p&13||this.addTriangle_(t,r,e,o,l,s),p&7||this.addTriangle_(t,r,i,o,l,a))}calculateSourceExtent(){const e=mt();return this.triangles_.forEach(function(t,i,r){const s=t.source;Kn(e,s[0]),Kn(e,s[1]),Kn(e,s[2])}),e}getTriangles(){return this.triangles_}}let Po;const xn=[];function Nu(n,e,t,i,r){n.beginPath(),n.moveTo(0,0),n.lineTo(e,t),n.lineTo(i,r),n.closePath(),n.save(),n.clip(),n.fillRect(0,0,Math.max(e,i)+1,Math.max(t,r)),n.restore()}function Lo(n,e){return Math.abs(n[e*4]-210)>2||Math.abs(n[e*4+3]-.75*255)>2}function Jm(){if(Po===void 0){const n=$e(6,6,xn);n.globalCompositeOperation="lighter",n.fillStyle="rgba(210, 0, 0, 0.75)",Nu(n,4,5,4,0),Nu(n,4,5,0,5);const e=n.getImageData(0,0,3,3).data;Po=Lo(e,0)||Lo(e,4)||Lo(e,8),Tr(n),xn.push(n.canvas)}return Po}function Gu(n,e,t,i){const r=Ya(t,e,n);let s=lu(e,i,t);const o=e.getMetersPerUnit();o!==void 0&&(s*=o);const a=n.getMetersPerUnit();a!==void 0&&(s/=a);const l=n.getExtent();if(!l||Zs(l,r)){const u=lu(n,s,r)/s;isFinite(u)&&u>0&&(s/=u)}return s}function Qm(n,e,t,i){const r=xi(t);let s=Gu(n,e,r,i);return(!isFinite(s)||s<=0)&&$h(t,function(o){return s=Gu(n,e,o,i),isFinite(s)&&s>0}),s}function ey(n,e,t,i,r,s,o,a,l,u,h,c){const d=$e(Math.round(t*n),Math.round(t*e),xn);if(c||(d.imageSmoothingEnabled=!1),l.length===0)return d.canvas;d.scale(t,t);function f(x){return Math.round(x*t)/t}d.globalCompositeOperation="lighter";const g=mt();l.forEach(function(x,E,b){Nh(g,x.extent)});const p=ge(g),m=nt(g),y=$e(Math.round(t*p/i),Math.round(t*m/i),xn);c||(y.imageSmoothingEnabled=!1);const _=t/i;l.forEach(function(x,E,b){const w=x.extent[0]-g[0],C=-(x.extent[3]-g[3]),I=ge(x.extent),z=nt(x.extent);x.image.width>0&&x.image.height>0&&y.drawImage(x.image,u,u,x.image.width-2*u,x.image.height-2*u,w*_,C*_,I*_,z*_)});const v=Qt(o);return a.getTriangles().forEach(function(x,E,b){const w=x.source,C=x.target;let I=w[0][0],z=w[0][1],N=w[1][0],R=w[1][1],G=w[2][0],L=w[2][1];const T=f((C[0][0]-v[0])/s),k=f(-(C[0][1]-v[1])/s),O=f((C[1][0]-v[0])/s),X=f(-(C[1][1]-v[1])/s),ne=f((C[2][0]-v[0])/s),S=f(-(C[2][1]-v[1])/s),Re=I,A=z;I=0,z=0,N-=Re,R-=A,G-=Re,L-=A;const Ie=[[N,R,0,0,O-T],[G,L,0,0,ne-T],[0,0,N,R,X-k],[0,0,G,L,S-k]],re=tf(Ie);if(re){if(d.save(),d.beginPath(),Jm()||!c){d.moveTo(O,X);const q=4,Oe=T-O,Ze=k-X;for(let de=0;de{t&&t.getState()==P.LOADED&&e.push({extent:this.sourceTileGrid_.getTileCoordExtent(t.tileCoord),image:t.getImage()})}),this.sourceTiles_.length=0,e.length===0)this.state=P.ERROR;else{const t=this.wrappedTileCoord_[0],i=this.targetTileGrid_.getTileSize(t),r=typeof i=="number"?i:i[0],s=typeof i=="number"?i:i[1],o=this.targetTileGrid_.getResolution(t),a=this.sourceTileGrid_.getResolution(this.sourceZ_),l=this.targetTileGrid_.getTileCoordExtent(this.wrappedTileCoord_);this.canvas_=ey(r,s,this.pixelRatio_,a,this.sourceTileGrid_.getExtent(),o,l,this.triangulation_,e,this.gutter_,this.renderEdges_,this.interpolate),this.state=P.LOADED}this.changed()}load(){if(this.state==P.IDLE){this.state=P.LOADING,this.changed();let e=0;this.sourcesListenerKeys_=[],this.sourceTiles_.forEach(t=>{const i=t.getState();if(i==P.IDLE||i==P.LOADING){e++;const r=oe(t,Y.CHANGE,function(s){const o=t.getState();(o==P.LOADED||o==P.ERROR||o==P.EMPTY)&&(xe(r),e--,e===0&&(this.unlistenSources_(),this.reproject_()))},this);this.sourcesListenerKeys_.push(r)}}),e===0?setTimeout(this.reproject_.bind(this),0):this.sourceTiles_.forEach(function(t,i,r){t.getState()==P.IDLE&&t.load()})}}unlistenSources_(){this.sourcesListenerKeys_.forEach(xe),this.sourcesListenerKeys_=null}release(){this.canvas_&&(Tr(this.canvas_.getContext("2d")),xn.push(this.canvas_),this.canvas_=null),super.release()}}class ty{constructor(e){this.highWaterMark=e!==void 0?e:2048,this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}canExpireCache(){return this.highWaterMark>0&&this.getCount()>this.highWaterMark}expireCache(e){for(;this.canExpireCache();)this.pop()}clear(){this.count_=0,this.entries_={},this.oldest_=null,this.newest_=null}containsKey(e){return this.entries_.hasOwnProperty(e)}forEach(e){let t=this.oldest_;for(;t;)e(t.value_,t.key_,this),t=t.newer}get(e,t){const i=this.entries_[e];return te(i!==void 0,"Tried to get a value for a key that does not exist in the cache"),i===this.newest_||(i===this.oldest_?(this.oldest_=this.oldest_.newer,this.oldest_.older=null):(i.newer.older=i.older,i.older.newer=i.newer),i.newer=null,i.older=this.newest_,this.newest_.newer=i,this.newest_=i),i.value_}remove(e){const t=this.entries_[e];return te(t!==void 0,"Tried to get a value for a key that does not exist in the cache"),t===this.newest_?(this.newest_=t.older,this.newest_&&(this.newest_.newer=null)):t===this.oldest_?(this.oldest_=t.newer,this.oldest_&&(this.oldest_.older=null)):(t.newer.older=t.older,t.older.newer=t.newer),delete this.entries_[e],--this.count_,t.value_}getCount(){return this.count_}getKeys(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.key_;return e}getValues(){const e=new Array(this.count_);let t=0,i;for(i=this.newest_;i;i=i.older)e[t++]=i.value_;return e}peekLast(){return this.oldest_.value_}peekLastKey(){return this.oldest_.key_}peekFirstKey(){return this.newest_.key_}peek(e){if(this.containsKey(e))return this.entries_[e].value_}pop(){const e=this.oldest_;return delete this.entries_[e.key_],e.newer&&(e.newer.older=null),this.oldest_=e.newer,this.oldest_||(this.newest_=null),--this.count_,e.value_}replace(e,t){this.get(e),this.entries_[e].value_=t}set(e,t){te(!(e in this.entries_),"Tried to set a value for a key that is used already");const i={key_:e,newer:null,older:this.newest_,value_:t};this.newest_?this.newest_.newer=i:this.oldest_=i,this.newest_=i,this.entries_[e]=i,++this.count_}setSize(e){this.highWaterMark=e}}function $u(n,e,t,i){return i!==void 0?(i[0]=n,i[1]=e,i[2]=t,i):[n,e,t]}function Nn(n,e,t){return n+"/"+e+"/"+t}function Ac(n){return Nn(n[0],n[1],n[2])}function iy(n){const[e,t,i]=n.substring(n.lastIndexOf("/")+1,n.length).split(",").map(Number);return Nn(e,t,i)}function Fc(n){return n.split("/").map(Number)}function ny(n){return(n[1]<t||t>e.getMaxZoom())return!1;const s=e.getFullTileRange(t);return s?s.containsXY(i,r):!0}class yl extends ty{clear(){for(;this.getCount()>0;)this.pop().release();super.clear()}expireCache(e){for(;this.canExpireCache()&&!(this.peekLast().getKey()in e);)this.pop().release()}pruneExceptNewestZ(){if(this.getCount()===0)return;const e=this.peekFirstKey(),i=Fc(e)[0];this.forEach(r=>{r.tileCoord[0]!==i&&(this.remove(Ac(r.tileCoord)),r.release())})}}const ko={TILELOADSTART:"tileloadstart",TILELOADEND:"tileloadend",TILELOADERROR:"tileloaderror"};class Mc extends kt{constructor(e){super(),this.projection=pe(e.projection),this.attributions_=ju(e.attributions),this.attributionsCollapsible_=e.attributionsCollapsible!==void 0?e.attributionsCollapsible:!0,this.loading=!1,this.state_=e.state!==void 0?e.state:"ready",this.wrapX_=e.wrapX!==void 0?e.wrapX:!1,this.interpolate_=!!e.interpolate,this.viewResolver=null,this.viewRejector=null;const t=this;this.viewPromise_=new Promise(function(i,r){t.viewResolver=i,t.viewRejector=r})}getAttributions(){return this.attributions_}getAttributionsCollapsible(){return this.attributionsCollapsible_}getProjection(){return this.projection}getResolutions(e){return null}getView(){return this.viewPromise_}getState(){return this.state_}getWrapX(){return this.wrapX_}getInterpolate(){return this.interpolate_}refresh(){this.changed()}setAttributions(e){this.attributions_=ju(e),this.changed()}setState(e){this.state_=e,this.changed()}}function ju(n){return n?Array.isArray(n)?function(e){return n}:typeof n=="function"?n:function(e){return[n]}:null}class _l{constructor(e,t,i,r){this.minX=e,this.maxX=t,this.minY=i,this.maxY=r}contains(e){return this.containsXY(e[1],e[2])}containsTileRange(e){return this.minX<=e.minX&&e.maxX<=this.maxX&&this.minY<=e.minY&&e.maxY<=this.maxY}containsXY(e,t){return this.minX<=e&&e<=this.maxX&&this.minY<=t&&t<=this.maxY}equals(e){return this.minX==e.minX&&this.minY==e.minY&&this.maxX==e.maxX&&this.maxY==e.maxY}extend(e){e.minXthis.maxX&&(this.maxX=e.maxX),e.minYthis.maxY&&(this.maxY=e.maxY)}getHeight(){return this.maxY-this.minY+1}getSize(){return[this.getWidth(),this.getHeight()]}getWidth(){return this.maxX-this.minX+1}intersects(e){return this.minX<=e.maxX&&this.maxX>=e.minX&&this.minY<=e.maxY&&this.maxY>=e.minY}}function sn(n,e,t,i,r){return r!==void 0?(r.minX=n,r.maxX=e,r.minY=t,r.maxY=i,r):new _l(n,e,t,i)}const on=[0,0,0],ni=5;class sy{constructor(e){this.minZoom=e.minZoom!==void 0?e.minZoom:0,this.resolutions_=e.resolutions,te(Zd(this.resolutions_,function(r,s){return s-r},!0),"`resolutions` must be sorted in descending order");let t;if(!e.origins){for(let r=0,s=this.resolutions_.length-1;r=this.minZoom;){if(this.zoomFactor_===2?(o=Math.floor(o/2),a=Math.floor(a/2),s=sn(o,o,a,a,i)):s=this.getTileRangeForExtentAndZ(l,u,i),t(u,s))return!0;--u}return!1}getExtent(){return this.extent_}getMaxZoom(){return this.maxZoom}getMinZoom(){return this.minZoom}getOrigin(e){return this.origin_?this.origin_:this.origins_[e]}getResolution(e){return this.resolutions_[e]}getResolutions(){return this.resolutions_}getTileCoordChildTileRange(e,t,i){if(e[0]this.maxZoom||t0?i:Math.max(s/t[0],r/t[1]);const o=e+1,a=new Array(o);for(let l=0;li.highWaterMark&&(i.highWaterMark=e)}useTile(e,t,i,r){}}class hy extends Jt{constructor(e,t){super(e),this.tile=t}}function cy(n,e){const t=/\{z\}/g,i=/\{x\}/g,r=/\{y\}/g,s=/\{-y\}/g;return function(o,a,l){if(o)return n.replace(t,o[0].toString()).replace(i,o[1].toString()).replace(r,o[2].toString()).replace(s,function(){const u=o[0],h=e.getFullTileRange(u);return te(h,"The {-y} placeholder requires a tile grid with extent"),(h.getHeight()-o[2]-1).toString()})}}function kc(n,e){const t=n.length,i=new Array(t);for(let r=0;rthis.getTileInternal(m,y,_,v,o),this.reprojectionErrorThreshold_,this.renderReprojectionEdges_,this.getInterpolate());return p.key=c,u?(p.interimTile=u,p.refreshInterimChain(),a.replace(h,p)):a.set(h,p),p}getTileInternal(e,t,i,r,s){let o=null;const a=Nn(e,t,i),l=this.getKey();if(!this.tileCache.containsKey(a))o=this.createTile_(e,t,i,r,s,l),this.tileCache.set(a,o);else if(o=this.tileCache.get(a),o.key!=l){const u=o;o=this.createTile_(e,t,i,r,s,l),u.getState()==P.IDLE?o.interimTile=u.interimTile:o.interimTile=u,o.refreshInterimChain(),this.tileCache.replace(a,o)}return o}setRenderReprojectionEdges(e){if(this.renderReprojectionEdges_!=e){this.renderReprojectionEdges_=e;for(const t in this.tileCacheForProjection)this.tileCacheForProjection[t].clear();this.changed()}}setTileGridForProjection(e,t){const i=pe(e);if(i){const r=U(i);r in this.tileGridForProjection||(this.tileGridForProjection[r]=t)}}clear(){super.clear();for(const e in this.tileCacheForProjection)this.tileCacheForProjection[e].clear()}}function fy(n,e){n.getImage().src=e}class zc extends Dc{constructor(e){e=e||{};const t=e.projection!==void 0?e.projection:"EPSG:3857",i=e.tileGrid!==void 0?e.tileGrid:so({extent:Dr(t),maxResolution:e.maxResolution,maxZoom:e.maxZoom,minZoom:e.minZoom,tileSize:e.tileSize});super({attributions:e.attributions,cacheSize:e.cacheSize,crossOrigin:e.crossOrigin,interpolate:e.interpolate,opaque:e.opaque,projection:t,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileGrid:i,tileLoadFunction:e.tileLoadFunction,tilePixelRatio:e.tilePixelRatio,tileUrlFunction:e.tileUrlFunction,url:e.url,urls:e.urls,wrapX:e.wrapX!==void 0?e.wrapX:!0,transition:e.transition,attributionsCollapsible:e.attributionsCollapsible,zDirection:e.zDirection}),this.gutter_=e.gutter!==void 0?e.gutter:0}getGutter(){return this.gutter_}}const gy='© OpenStreetMap contributors.';class py extends zc{constructor(e){e=e||{};let t;e.attributions!==void 0?t=e.attributions:t=[gy];const i=e.crossOrigin!==void 0?e.crossOrigin:"anonymous",r=e.url!==void 0?e.url:"https://tile.openstreetmap.org/{z}/{x}/{y}.png";super({attributions:t,attributionsCollapsible:!1,cacheSize:e.cacheSize,crossOrigin:i,interpolate:e.interpolate,maxZoom:e.maxZoom!==void 0?e.maxZoom:19,opaque:e.opaque!==void 0?e.opaque:!0,reprojectionErrorThreshold:e.reprojectionErrorThreshold,tileLoadFunction:e.tileLoadFunction,transition:e.transition,url:r,wrapX:e.wrapX,zDirection:e.zDirection})}}class Xu extends zc{constructor(e){e=e||{},super({opaque:!1,projection:e.projection,tileGrid:e.tileGrid,wrapX:e.wrapX!==void 0?e.wrapX:!0,zDirection:e.zDirection,url:e.template||"z:{z} x:{x} y:{y}",tileLoadFunction:(t,i)=>{const r=t.getTileCoord()[0],s=Be(this.tileGrid.getTileSize(r)),o=$e(s[0],s[1]);o.strokeStyle="grey",o.strokeRect(.5,.5,s[0]+.5,s[1]+.5),o.fillStyle="grey",o.strokeStyle="white",o.textAlign="center",o.textBaseline="middle",o.font="24px sans-serif",o.lineWidth=4,o.strokeText(i,s[0]/2,s[1]/2,s[0]),o.fillText(i,s[0]/2,s[1]/2,s[0]),t.setImage(o.canvas)}})}}const fi={PRELOAD:"preload",USE_INTERIM_TILES_ON_ERROR:"useInterimTilesOnError"};class my extends no{constructor(e){e=e||{};const t=Object.assign({},e);delete t.preload,delete t.useInterimTilesOnError,super(t),this.on,this.once,this.un,this.setPreload(e.preload!==void 0?e.preload:0),this.setUseInterimTilesOnError(e.useInterimTilesOnError!==void 0?e.useInterimTilesOnError:!0)}getPreload(){return this.get(fi.PRELOAD)}setPreload(e){this.set(fi.PRELOAD,e)}getUseInterimTilesOnError(){return this.get(fi.USE_INTERIM_TILES_ON_ERROR)}setUseInterimTilesOnError(e){this.set(fi.USE_INTERIM_TILES_ON_ERROR,e)}getData(e){return super.getData(e)}}class yy extends br{constructor(e){super(),this.ready=!0,this.boundHandleImageChange_=this.handleImageChange_.bind(this),this.layer_=e,this.declutterExecutorGroup=null}getFeatures(e){return W()}getData(e){return null}prepareFrame(e){return W()}renderFrame(e,t){return W()}loadedTileCallback(e,t,i){e[t]||(e[t]={}),e[t][i.tileCoord.toString()]=i}createLoadedTileFinder(e,t,i){return(r,s)=>{const o=this.loadedTileCallback.bind(this,i,r);return e.forEachLoadedTile(t,r,s,o)}}forEachFeatureAtCoordinate(e,t,i,r,s){}getLayer(){return this.layer_}handleFontsChanged(){}handleImageChange_(e){const t=e.target;(t.getState()===ye.LOADED||t.getState()===ye.ERROR)&&this.renderIfReadyAndVisible()}loadImage(e){let t=e.getState();return t!=ye.LOADED&&t!=ye.ERROR&&e.addEventListener(Y.CHANGE,this.boundHandleImageChange_),t==ye.IDLE&&(e.load(),t=e.getState()),t==ye.LOADED}renderIfReadyAndVisible(){const e=this.getLayer();e&&e.getVisible()&&e.getSourceState()==="ready"&&e.changed()}disposeInternal(){delete this.layer_,super.disposeInternal()}}const Wu=[];let cn=null;function _y(){cn=$e(1,1,void 0,{willReadFrequently:!0})}class Nc extends yy{constructor(e){super(e),this.container=null,this.renderedResolution,this.tempTransform=it(),this.pixelTransform=it(),this.inversePixelTransform=it(),this.context=null,this.containerReused=!1,this.pixelContext_=null,this.frameState=null}getImageData(e,t,i){cn||_y(),cn.clearRect(0,0,1,1);let r;try{cn.drawImage(e,t,i,1,1,0,0,1,1),r=cn.getImageData(0,0,1,1).data}catch{return cn=null,null}return r}getBackground(e){let i=this.getLayer().getBackground();return typeof i=="function"&&(i=i(e.viewState.resolution)),i||void 0}useContainer(e,t,i){const r=this.getLayer().getClassName();let s,o;if(e&&e.className===r&&(!i||e&&e.style.backgroundColor&&vi(_s(e.style.backgroundColor),_s(i)))){const a=e.firstElementChild;a instanceof HTMLCanvasElement&&(o=a.getContext("2d"))}if(o&&o.canvas.style.transform===t?(this.container=e,this.context=o,this.containerReused=!0):this.containerReused?(this.container=null,this.context=null,this.containerReused=!1):this.container&&(this.container.style.backgroundColor=null),!this.container){s=document.createElement("div"),s.className=r;let a=s.style;a.position="absolute",a.width="100%",a.height="100%",o=$e();const l=o.canvas;s.appendChild(l),a=l.style,a.position="absolute",a.left="0",a.transformOrigin="top left",this.container=s,this.context=o}!this.containerReused&&i&&!this.container.style.backgroundColor&&(this.container.style.backgroundColor=i)}clipUnrotated(e,t,i){const r=Qt(i),s=Ks(i),o=qs(i),a=Sr(i);Le(t.coordinateToPixelTransform,r),Le(t.coordinateToPixelTransform,s),Le(t.coordinateToPixelTransform,o),Le(t.coordinateToPixelTransform,a);const l=this.inversePixelTransform;Le(l,r),Le(l,s),Le(l,o),Le(l,a),e.save(),e.beginPath(),e.moveTo(Math.round(r[0]),Math.round(r[1])),e.lineTo(Math.round(s[0]),Math.round(s[1])),e.lineTo(Math.round(o[0]),Math.round(o[1])),e.lineTo(Math.round(a[0]),Math.round(a[1])),e.clip()}dispatchRenderEvent_(e,t,i){const r=this.getLayer();if(r.hasListener(e)){const s=new Ec(e,this.inversePixelTransform,i,t);r.dispatchEvent(s)}}preRender(e,t){this.frameState=t,this.dispatchRenderEvent_(Pt.PRERENDER,e,t)}postRender(e,t){this.dispatchRenderEvent_(Pt.POSTRENDER,e,t)}getRenderTransform(e,t,i,r,s,o,a){const l=s/2,u=o/2,h=r/t,c=-h,d=-e[0]+a,f=-e[1];return qt(this.tempTransform,l,u,h,c,-i,d,f)}disposeInternal(){delete this.frameState,super.disposeInternal()}}class Gc extends Nc{constructor(e){super(e),this.extentChanged=!0,this.renderedExtent_=null,this.renderedPixelRatio,this.renderedProjection=null,this.renderedRevision,this.renderedTiles=[],this.newTiles_=!1,this.tmpExtent=mt(),this.tmpTileRange_=new _l(0,0,0,0)}isDrawableTile(e){const t=this.getLayer(),i=e.getState(),r=t.getUseInterimTilesOnError();return i==P.LOADED||i==P.EMPTY||i==P.ERROR&&!r}getTile(e,t,i,r){const s=r.pixelRatio,o=r.viewState.projection,a=this.getLayer();let u=a.getSource().getTile(e,t,i,s,o);return u.getState()==P.ERROR&&a.getUseInterimTilesOnError()&&a.getPreload()>0&&(this.newTiles_=!0),this.isDrawableTile(u)||(u=u.getInterimTile()),u}getData(e){const t=this.frameState;if(!t)return null;const i=this.getLayer(),r=Le(t.pixelToCoordinateTransform,e.slice()),s=i.getExtent();if(s&&!Zs(s,r))return null;const o=t.pixelRatio,a=t.viewState.projection,l=t.viewState,u=i.getRenderSource(),h=u.getTileGridForProjection(l.projection),c=u.getTilePixelRatio(t.pixelRatio);for(let d=h.getZForResolution(l.resolution);d>=h.getMinZoom();--d){const f=h.getTileCoordForCoordAndZ(r,d),g=u.getTile(d,f[1],f[2],o,a);if(!(g instanceof Ic||g instanceof Ea)||g instanceof Ea&&g.getState()===P.EMPTY)return null;if(g.getState()!==P.LOADED)continue;const p=h.getOrigin(d),m=Be(h.getTileSize(d)),y=h.getResolution(d),_=Math.floor(c*((r[0]-p[0])/y-f[1]*m[0])),v=Math.floor(c*((p[1]-r[1])/y-f[2]*m[1])),x=Math.round(c*u.getGutterForProjection(l.projection));return this.getImageData(g.getImage(),_+x,v+x)}return null}loadedTileCallback(e,t,i){return this.isDrawableTile(i)?super.loadedTileCallback(e,t,i):!1}prepareFrame(e){return!!this.getLayer().getSource()}renderFrame(e,t){const i=e.layerStatesArray[e.layerIndex],r=e.viewState,s=r.projection,o=r.resolution,a=r.center,l=r.rotation,u=e.pixelRatio,h=this.getLayer(),c=h.getSource(),d=c.getRevision(),f=c.getTileGridForProjection(s),g=f.getZForResolution(o,c.zDirection),p=f.getResolution(g);let m=e.extent;const y=e.viewState.resolution,_=c.getTilePixelRatio(u),v=Math.round(ge(m)/y*u),x=Math.round(nt(m)/y*u),E=i.extent&&Pi(i.extent);E&&(m=Gi(m,Pi(i.extent)));const b=p*v/2/_,w=p*x/2/_,C=[a[0]-b,a[1]-w,a[0]+b,a[1]+w],I=f.getTileRangeForExtentAndZ(m,g),z={};z[g]={};const N=this.createLoadedTileFinder(c,s,z),R=this.tmpExtent,G=this.tmpTileRange_;this.newTiles_=!1;const L=l?sa(r.center,y,l,e.size):void 0;for(let Ie=I.minX;Ie<=I.maxX;++Ie)for(let re=I.minY;re<=I.maxY;++re){if(l&&!f.tileCoordIntersectsViewport([g,Ie,re],L))continue;const q=this.getTile(g,Ie,re,e);if(this.isDrawableTile(q)){const de=U(this);if(q.getState()==P.LOADED){z[g][q.tileCoord.toString()]=q;let Pe=q.inTransition(de);Pe&&i.opacity!==1&&(q.endTransition(de),Pe=!1),!this.newTiles_&&(Pe||!this.renderedTiles.includes(q))&&(this.newTiles_=!0)}if(q.getAlpha(de,e.time)===1)continue}const Oe=f.getTileCoordChildTileRange(q.tileCoord,G,R);let Ze=!1;Oe&&(Ze=N(g+1,Oe)),Ze||f.forEachTileCoordParentTileRange(q.tileCoord,N,G,R)}const T=p/o*u/_;qt(this.pixelTransform,e.size[0]/2,e.size[1]/2,1/u,1/u,l,-v/2,-x/2);const k=Zh(this.pixelTransform);this.useContainer(t,k,this.getBackground(e));const O=this.context,X=O.canvas;qa(this.inversePixelTransform,this.pixelTransform),qt(this.tempTransform,v/2,x/2,T,T,0,-v/2,-x/2),X.width!=v||X.height!=x?(X.width=v,X.height=x):this.containerReused||O.clearRect(0,0,v,x),E&&this.clipUnrotated(O,e,E),c.getInterpolate()||(O.imageSmoothingEnabled=!1),this.preRender(O,e),this.renderedTiles.length=0;let ne=Object.keys(z).map(Number);ne.sort(yi);let S,Re,A;i.opacity===1&&(!this.containerReused||c.getOpaque(e.viewState.projection))?ne=ne.reverse():(S=[],Re=[]);for(let Ie=ne.length-1;Ie>=0;--Ie){const re=ne[Ie],q=c.getTilePixelSize(re,u,s),Ze=f.getResolution(re)/p,de=q[0]*Ze*T,Pe=q[1]*Ze*T,D=f.getTileCoordForCoordAndZ(Qt(C),re),yt=f.getTileCoordExtent(D),_t=Le(this.tempTransform,[_*(yt[0]-C[0])/p,_*(C[3]-yt[3])/p]),ie=_*c.getGutterForProjection(s),xt=z[re];for(const vt in xt){const ve=xt[vt],ei=ve.tileCoord,we=D[1]-ei[1],Tt=Math.round(_t[0]-(we-1)*de),ct=D[2]-ei[2],dt=Math.round(_t[1]-(ct-1)*Pe),Ae=Math.round(_t[0]-we*de),je=Math.round(_t[1]-ct*Pe),ee=Tt-Ae,se=dt-je,ae=g===re,ue=ae&&ve.getAlpha(U(this),e.time)!==1;let V=!1;if(!ue)if(S){A=[Ae,je,Ae+ee,je,Ae+ee,je+se,Ae,je+se];for(let H=0,me=S.length;H",GreaterThanOrEqualTo:">=",LessThan:"<",LessThanOrEqualTo:"<=",Multiply:"*",Divide:"/",Add:"+",Subtract:"-",Clamp:"clamp",Mod:"%",Pow:"^",Abs:"abs",Floor:"floor",Ceil:"ceil",Round:"round",Sin:"sin",Cos:"cos",Atan:"atan",Sqrt:"sqrt",Match:"match"},wy={[F.Number]:he(fe(1,1/0,Ct),Q),[F.String]:he(fe(1,1/0,Ct),Pn),[F.Get]:he(Cy,Ct),[F.Var]:he(by,Ct),[F.Resolution]:he(Ty,Q),[F.Any]:he(fe(2,1/0,Ye),Ye),[F.All]:he(fe(2,1/0,Ye),Ye),[F.Not]:he(fe(1,1,Ye),Ye),[F.Equal]:he(fe(2,2,Ct),Ye),[F.NotEqual]:he(fe(2,2,Ct),Ye),[F.GreaterThan]:he(fe(2,2,Ct),Ye),[F.GreaterThanOrEqualTo]:he(fe(2,2,Ct),Ye),[F.LessThan]:he(fe(2,2,Ct),Ye),[F.LessThanOrEqualTo]:he(fe(2,2,Ct),Ye),[F.Multiply]:he(fe(2,1/0,Q),Q),[F.Divide]:he(fe(2,2,Q),Q),[F.Add]:he(fe(2,1/0,Q),Q),[F.Subtract]:he(fe(2,2,Q),Q),[F.Clamp]:he(fe(3,3,Q),Q),[F.Mod]:he(fe(2,2,Q),Q),[F.Pow]:he(fe(2,2,Q),Q),[F.Abs]:he(fe(1,1,Q),Q),[F.Floor]:he(fe(1,1,Q),Q),[F.Ceil]:he(fe(1,1,Q),Q),[F.Round]:he(fe(1,1,Q),Q),[F.Sin]:he(fe(1,1,Q),Q),[F.Cos]:he(fe(1,1,Q),Q),[F.Atan]:he(fe(1,2,Q),Q),[F.Sqrt]:he(fe(1,1,Q),Q),[F.Match]:he(fe(4,1/0,Pn|Q),Ct)};function Cy(n,e){if(n.length!==2)throw new Error("Expected 1 argument for get operation");const t=ao(n[1],e);if(!(t instanceof gi))throw new Error("Expected a literal argument for get operation");if(typeof t.value!="string")throw new Error("Expected a string argument for get operation");return e.properties.add(t.value),[t]}function by(n,e){if(n.length!==2)throw new Error("Expected 1 argument for var operation");const t=ao(n[1],e);if(!(t instanceof gi))throw new Error("Expected a literal argument for var operation");if(typeof t.value!="string")throw new Error("Expected a string argument for get operation");return e.variables.add(t.value),[t]}function Ty(n,e){const t=n[0];if(n.length!==1)throw new Error(`Expected no arguments for ${t} operation`);return[]}function fe(n,e,t){return function(i,r){const s=i[0],o=i.length-1;if(n===e){if(o!==n){const l=n===1?"":"s";throw new Error(`Expected ${n} argument${l} for operation ${s}, got ${o}`)}}else if(oe)throw new Error(`Expected ${n} to ${e} arguments for operation ${s}, got ${o}`);const a=new Array(o);for(let l=0;li.resolution;case F.Any:case F.All:case F.Not:return Fy(n);case F.Equal:case F.NotEqual:case F.LessThan:case F.LessThanOrEqualTo:case F.GreaterThan:case F.GreaterThanOrEqualTo:return Ay(n);case F.Multiply:case F.Divide:case F.Add:case F.Subtract:case F.Clamp:case F.Mod:case F.Pow:case F.Abs:case F.Floor:case F.Ceil:case F.Round:case F.Sin:case F.Cos:case F.Atan:case F.Sqrt:return My(n);case F.Match:return Py(n);default:throw new Error(`Unsupported operator ${t}`)}}function Sy(n,e){const t=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s{for(let o=0;or.properties[i];case F.Var:return r=>r.variables[i];default:throw new Error(`Unsupported accessor operator ${n.operator}`)}}function Ay(n,e){const t=n.operator,i=Yi(n.args[0]),r=Yi(n.args[1]);switch(t){case F.Equal:return s=>i(s)===r(s);case F.NotEqual:return s=>i(s)!==r(s);case F.LessThan:return s=>i(s)i(s)<=r(s);case F.GreaterThan:return s=>i(s)>r(s);case F.GreaterThanOrEqualTo:return s=>i(s)>=r(s);default:throw new Error(`Unsupported comparison operator ${t}`)}}function Fy(n,e){const t=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s{for(let o=0;o{for(let o=0;o!r[0](s);default:throw new Error(`Unsupported logical operator ${t}`)}}function My(n,e){const t=n.operator,i=n.args.length,r=new Array(i);for(let s=0;s{let o=1;for(let a=0;ar[0](s)/r[1](s);case F.Add:return s=>{let o=0;for(let a=0;ar[0](s)-r[1](s);case F.Clamp:return s=>{const o=r[0](s),a=r[1](s);if(ol?l:o};case F.Mod:return s=>r[0](s)%r[1](s);case F.Pow:return s=>Math.pow(r[0](s),r[1](s));case F.Abs:return s=>Math.abs(r[0](s));case F.Floor:return s=>Math.floor(r[0](s));case F.Ceil:return s=>Math.ceil(r[0](s));case F.Round:return s=>Math.round(r[0](s));case F.Sin:return s=>Math.sin(r[0](s));case F.Cos:return s=>Math.cos(r[0](s));case F.Atan:return i===2?s=>Math.atan2(r[0](s),r[1](s)):s=>Math.atan(r[0](s));case F.Sqrt:return s=>Math.sqrt(r[0](s));default:throw new Error(`Unsupported numeric operator ${t}`)}}function Py(n,e){const t=n.args.length,i=new Array(t);for(let r=0;r{const s=i[0](r);for(let o=1;o4)throw new Error(`Expected a color with 3 or 4 values for ${e}`);return t}function Vy(n,e){if(typeof n=="number")return n;const t=Nr(n,e);if(t.length!==2)throw new Error(`Expected an array of two numbers for ${e}`);return t}const Bu={RENDER_ORDER:"renderOrder"};class qc extends no{constructor(e){e=e||{};const t=Object.assign({},e);delete t.style,delete t.renderBuffer,delete t.updateWhileAnimating,delete t.updateWhileInteracting,super(t),this.declutter_=e.declutter!==void 0?e.declutter:!1,this.renderBuffer_=e.renderBuffer!==void 0?e.renderBuffer:100,this.style_=null,this.styleFunction_=void 0,this.setStyle(e.style),this.updateWhileAnimating_=e.updateWhileAnimating!==void 0?e.updateWhileAnimating:!1,this.updateWhileInteracting_=e.updateWhileInteracting!==void 0?e.updateWhileInteracting:!1}getDeclutter(){return this.declutter_}getFeatures(e){return super.getFeatures(e)}getRenderBuffer(){return this.renderBuffer_}getRenderOrder(){return this.get(Bu.RENDER_ORDER)}getStyle(){return this.style_}getStyleFunction(){return this.styleFunction_}getUpdateWhileAnimating(){return this.updateWhileAnimating_}getUpdateWhileInteracting(){return this.updateWhileInteracting_}renderDeclutter(e){e.declutterTree||(e.declutterTree=new ll(9)),this.getRenderer().renderDeclutter(e)}setRenderOrder(e){this.set(Bu.RENDER_ORDER,e)}setStyle(e){this.style_=Yy(e),this.styleFunction_=e===null?void 0:sp(this.style_),this.changed()}}function Yy(n){if(n===void 0)return op;if(!n)return null;if(typeof n=="function"||n instanceof He)return n;if(!Array.isArray(n))return Uu([n]);if(n.length===0)return[];const e=n.length,t=n[0];if(t instanceof He){const r=new Array(e);for(let s=0;s{if(!this.hitDetectionImageData_&&!this.animatingOrInteracting_){const i=[this.context.canvas.width,this.context.canvas.height];Le(this.pixelTransform,i);const r=this.renderedCenter_,s=this.renderedResolution_,o=this.renderedRotation_,a=this.renderedProjection_,l=this.wrappedRenderedExtent_,u=this.getLayer(),h=[],c=i[0]*lt,d=i[1]*lt;h.push(this.getRenderTransform(r,s,o,lt,c,d,0).slice());const f=u.getSource(),g=a.getExtent();if(f.getWrapX()&&a.canWrapX()&&!Mi(g,l)){let p=l[0];const m=ge(g);let y=0,_;for(;pg[2];)++y,_=m*y,h.push(this.getRenderTransform(r,s,o,lt,c,d,_).slice()),p-=m}this.hitDetectionImageData_=Kc(i,h,this.renderedFeatures_,u.getStyleFunction(),l,s,o)}t(Hc(e,this.renderedFeatures_,this.hitDetectionImageData_))})}forEachFeatureAtCoordinate(e,t,i,r,s){if(!this.replayGroup_)return;const o=t.viewState.resolution,a=t.viewState.rotation,l=this.getLayer(),u={},h=function(f,g,p){const m=U(f),y=u[m];if(y){if(y!==!0&&pc=f.forEachFeatureAtCoordinate(e,o,a,i,h,f===this.declutterExecutorGroup&&t.declutterTree?t.declutterTree.all().map(g=>g.value):null)),c}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.replayGroup_&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}prepareFrame(e){const t=this.getLayer(),i=t.getSource();if(!i)return!1;const r=e.viewHints[Te.ANIMATING],s=e.viewHints[Te.INTERACTING],o=t.getUpdateWhileAnimating(),a=t.getUpdateWhileInteracting();if(this.ready&&!o&&r||!a&&s)return this.animatingOrInteracting_=!0,!0;this.animatingOrInteracting_=!1;const l=e.extent,u=e.viewState,h=u.projection,c=u.resolution,d=e.pixelRatio,f=t.getRevision(),g=t.getRenderBuffer();let p=t.getRenderOrder();p===void 0&&(p=fp);const m=u.center.slice(),y=pi(l,g*c),_=y.slice(),v=[y.slice()],x=h.getExtent();if(i.getWrapX()&&h.canWrapX()&&!Mi(x,e.extent)){const T=ge(x),k=Math.max(ge(y)/2,T);y[0]=x[0]-k,y[2]=x[2]+k,Wa(m,h);const O=jh(v[0],h);O[0]x[0]&&O[2]>x[2]&&v.push([O[0]-T,O[1],O[2]-T,O[3]])}if(this.ready&&this.renderedResolution_==c&&this.renderedRevision_==f&&this.renderedRenderOrder_==p&&Mi(this.wrappedRenderedExtent_,y))return vi(this.renderedExtent_,_)||(this.hitDetectionImageData_=null,this.renderedExtent_=_),this.renderedCenter_=m,this.replayGroupChanged=!1,!0;this.replayGroup_=null;const E=new Fn(_a(c,d),y,c,d);let b;this.getLayer().getDeclutter()&&(b=new Fn(_a(c,d),y,c,d));let w;for(let T=0,k=v.length;T{let k;const O=T.getStyleFunction()||t.getStyleFunction();if(O&&(k=O(T,c)),k){const X=this.renderFeature(T,C,k,E,w,b);I=I&&!X}},N=Vh(y),R=i.getFeaturesInExtent(N);p&&R.sort(p);for(let T=0,k=R.length;T=200&&a.status<300){const u=e.getType();let h;u=="json"||u=="text"?h=a.responseText:u=="xml"?(h=a.responseXML,h||(h=new DOMParser().parseFromString(a.responseText,"application/xml"))):u=="arraybuffer"&&(h=a.response),h?s(e.readFeatures(h,{extent:t,featureProjection:r}),e.readProjection(h)):o()}else o()},a.onerror=o,a.send()}function qu(n,e){return function(t,i,r,s,o){const a=this;Qc(n,e,t,i,r,function(l,u){a.addFeatures(l),s!==void 0&&s(l)},o||Tn)}}class ri extends Jt{constructor(e,t,i){super(e),this.feature=t,this.features=i}}class ds extends Mc{constructor(e){e=e||{},super({attributions:e.attributions,interpolate:!0,projection:void 0,state:"ready",wrapX:e.wrapX!==void 0?e.wrapX:!0}),this.on,this.once,this.un,this.loader_=Tn,this.format_=e.format,this.overlaps_=e.overlaps===void 0?!0:e.overlaps,this.url_=e.url,e.loader!==void 0?this.loader_=e.loader:this.url_!==void 0&&(te(this.format_,"`format` must be set when `url` is set"),this.loader_=qu(this.url_,this.format_)),this.strategy_=e.strategy!==void 0?e.strategy:Zy;const t=e.useSpatialIndex!==void 0?e.useSpatialIndex:!0;this.featuresRtree_=t?new Zu:null,this.loadedExtentsRtree_=new Zu,this.loadingExtentsCount_=0,this.nullGeometryFeatures_={},this.idIndex_={},this.uidIndex_={},this.featureChangeKeys_={},this.featuresCollection_=null;let i,r;Array.isArray(e.features)?r=e.features:e.features&&(i=e.features,r=i.getArray()),!t&&i===void 0&&(i=new Ft(r)),r!==void 0&&this.addFeaturesInternal(r),i!==void 0&&this.bindFeaturesCollection_(i)}addFeature(e){this.addFeatureInternal(e),this.changed()}addFeatureInternal(e){const t=U(e);if(!this.addToIndex_(t,e)){this.featuresCollection_&&this.featuresCollection_.remove(e);return}this.setupChangeEvents_(t,e);const i=e.getGeometry();if(i){const r=i.getExtent();this.featuresRtree_&&this.featuresRtree_.insert(r,e)}else this.nullGeometryFeatures_[t]=e;this.dispatchEvent(new ri(bt.ADDFEATURE,e))}setupChangeEvents_(e,t){this.featureChangeKeys_[e]=[oe(t,Y.CHANGE,this.handleFeatureChange_,this),oe(t,bn.PROPERTYCHANGE,this.handleFeatureChange_,this)]}addToIndex_(e,t){let i=!0;const r=t.getId();return r!==void 0&&(r.toString()in this.idIndex_?i=!1:this.idIndex_[r.toString()]=t),i&&(te(!(e in this.uidIndex_),"The passed `feature` was already added to the source"),this.uidIndex_[e]=t),i}addFeatures(e){this.addFeaturesInternal(e),this.changed()}addFeaturesInternal(e){const t=[],i=[],r=[];for(let s=0,o=e.length;s{t||(t=!0,this.addFeature(i.element),t=!1)}),e.addEventListener(et.REMOVE,i=>{t||(t=!0,this.removeFeature(i.element),t=!1)}),this.featuresCollection_=e}clear(e){if(e){for(const i in this.featureChangeKeys_)this.featureChangeKeys_[i].forEach(xe);this.featuresCollection_||(this.featureChangeKeys_={},this.idIndex_={},this.uidIndex_={})}else if(this.featuresRtree_){const i=r=>{this.removeFeatureInternal(r)};this.featuresRtree_.forEach(i);for(const r in this.nullGeometryFeatures_)this.removeFeatureInternal(this.nullGeometryFeatures_[r])}this.featuresCollection_&&this.featuresCollection_.clear(),this.featuresRtree_&&this.featuresRtree_.clear(),this.nullGeometryFeatures_={};const t=new ri(bt.CLEAR);this.dispatchEvent(t),this.changed()}forEachFeature(e){if(this.featuresRtree_)return this.featuresRtree_.forEach(e);this.featuresCollection_&&this.featuresCollection_.forEach(e)}forEachFeatureAtCoordinateDirect(e,t){const i=[e[0],e[1],e[0],e[1]];return this.forEachFeatureInExtent(i,function(r){if(r.getGeometry().intersectsCoordinate(e))return t(r)})}forEachFeatureInExtent(e,t){if(this.featuresRtree_)return this.featuresRtree_.forEachInExtent(e,t);this.featuresCollection_&&this.featuresCollection_.forEach(t)}forEachFeatureIntersectingExtent(e,t){return this.forEachFeatureInExtent(e,function(i){if(i.getGeometry().intersectsExtent(e)){const s=t(i);if(s)return s}})}getFeaturesCollection(){return this.featuresCollection_}getFeatures(){let e;return this.featuresCollection_?e=this.featuresCollection_.getArray().slice(0):this.featuresRtree_&&(e=this.featuresRtree_.getAll(),ji(this.nullGeometryFeatures_)||Mt(e,Object.values(this.nullGeometryFeatures_))),e}getFeaturesAtCoordinate(e){const t=[];return this.forEachFeatureAtCoordinateDirect(e,function(i){t.push(i)}),t}getFeaturesInExtent(e,t){if(this.featuresRtree_){if(!(t&&t.canWrapX()&&this.getWrapX()))return this.featuresRtree_.getInExtent(e);const r=kf(e,t);return[].concat(...r.map(s=>this.featuresRtree_.getInExtent(s)))}return this.featuresCollection_?this.featuresCollection_.getArray().slice(0):[]}getClosestFeatureToCoordinate(e,t){const i=e[0],r=e[1];let s=null;const o=[NaN,NaN];let a=1/0;const l=[-1/0,-1/0,1/0,1/0];return t=t||rr,this.featuresRtree_.forEachInExtent(l,function(u){if(t(u)){const h=u.getGeometry(),c=a;if(a=h.closestPointXY(i,r,o,a),a{--this.loadingExtentsCount_,this.dispatchEvent(new ri(bt.FEATURESLOADEND,void 0,h))},()=>{--this.loadingExtentsCount_,this.dispatchEvent(new ri(bt.FEATURESLOADERROR))}),r.insert(l,{extent:l.slice()}))}this.loading=this.loader_.length<4?!1:this.loadingExtentsCount_>0}refresh(){this.clear(!0),this.loadedExtentsRtree_.clear(),super.refresh()}removeLoadedExtent(e){const t=this.loadedExtentsRtree_;let i;t.forEachInExtent(e,function(r){if(Sn(r.extent,e))return i=r,!0}),i&&t.remove(i)}removeFeature(e){if(!e)return;const t=U(e);t in this.nullGeometryFeatures_?delete this.nullGeometryFeatures_[t]:this.featuresRtree_&&this.featuresRtree_.remove(e),this.removeFeatureInternal(e)&&this.changed()}removeFeatureInternal(e){const t=U(e),i=this.featureChangeKeys_[t];if(!i)return;i.forEach(xe),delete this.featureChangeKeys_[t];const r=e.getId();return r!==void 0&&delete this.idIndex_[r.toString()],delete this.uidIndex_[t],this.dispatchEvent(new ri(bt.REMOVEFEATURE,e)),e}removeFromIdIndex_(e){let t=!1;for(const i in this.idIndex_)if(this.idIndex_[i]===e){delete this.idIndex_[i],t=!0;break}return t}setLoader(e){this.loader_=e}setUrl(e){te(this.format_,"`format` must be set when `url` is set"),this.url_=e,this.setLoader(qu(e,this.format_))}}const Hy={image:["Polygon","Circle","LineString","Image","Text"],hybrid:["Polygon","LineString"],vector:[]},Jy={hybrid:["Image","Text","Default"],vector:["Polygon","Circle","LineString","Image","Text","Default"]};class Qy extends Gc{constructor(e){super(e),this.boundHandleStyleImageChange_=this.handleStyleImageChange_.bind(this),this.renderedLayerRevision_,this.renderedPixelToCoordinateTransform_=null,this.renderedRotation_,this.tmpTransform_=it()}prepareTile(e,t,i){let r;const s=e.getState();return(s===P.LOADED||s===P.ERROR)&&(this.updateExecutorGroup_(e,t,i),this.tileImageNeedsRender_(e)&&(r=!0)),r}getTile(e,t,i,r){const s=r.pixelRatio,o=r.viewState,a=o.resolution,l=o.projection,u=this.getLayer(),h=u.getSource().getTile(e,t,i,s,l),c=r.viewHints,d=!(c[Te.ANIMATING]||c[Te.INTERACTING]);return(d||!h.wantedResolution)&&(h.wantedResolution=a),this.prepareTile(h,s,l)&&(d||Date.now()-r.time<8)&&u.getRenderMode()!=="vector"&&this.renderTileImage_(h,r),super.getTile(e,t,i,r)}isDrawableTile(e){const t=this.getLayer();return super.isDrawableTile(e)&&(t.getRenderMode()==="vector"?U(t)in e.executorGroups:e.hasContext(t))}getTileImage(e){return e.getImage(this.getLayer())}prepareFrame(e){const t=this.getLayer().getRevision();return this.renderedLayerRevision_!==t&&(this.renderedLayerRevision_=t,this.renderedTiles.length=0),super.prepareFrame(e)}updateExecutorGroup_(e,t,i){const r=this.getLayer(),s=r.getRevision(),o=r.getRenderOrder()||null,a=e.wantedResolution,l=e.getReplayState(r);if(!l.dirty&&l.renderedResolution===a&&l.renderedRevision==s&&l.renderedRenderOrder==o)return;const u=r.getSource(),h=r.getDeclutter(),c=u.getTileGrid(),f=u.getTileGridForProjection(i).getTileCoordExtent(e.wrappedTileCoord),g=u.getSourceTiles(t,i,e),p=U(r);delete e.hitDetectionImageData[p],e.executorGroups[p]=[],h&&(e.declutterExecutorGroups[p]=[]),l.dirty=!1;for(let m=0,y=g.length;m{const C=w===b?t.declutterTree.all().map(I=>I.value):null;for(let I=0,z=w.length;I{const r=this.getLayer(),s=U(r),o=r.getSource(),a=this.renderedProjection,l=a.getExtent(),u=this.renderedResolution,h=o.getTileGridForProjection(a),c=Le(this.renderedPixelToCoordinateTransform_,e.slice()),d=h.getTileCoordForCoordAndResolution(c,u);let f;for(let v=0,x=this.renderedTiles.length;v0){t([]);return}const g=h.getTileCoordExtent(f.wrappedTileCoord),p=Qt(g),m=[(c[0]-p[0])/u,(p[1]-c[1])/u],y=f.getSourceTiles().reduce(function(v,x){return v.concat(x.getFeatures())},[]);let _=f.hitDetectionImageData[s];if(!_){const v=Be(h.getTileSize(h.getZForResolution(u,o.zDirection))),x=this.renderedRotation_,E=[this.getRenderTransform(h.getTileCoordCenter(f.wrappedTileCoord),u,0,lt,v[0]*lt,v[1]*lt,0)];_=Kc(v,E,y,r.getStyleFunction(),h.getTileCoordExtent(f.wrappedTileCoord),f.getReplayState(r).renderedResolution,x),f.hitDetectionImageData[s]=_}t(Hc(m,y,_))})}handleFontsChanged(){const e=this.getLayer();e.getVisible()&&this.renderedLayerRevision_!==void 0&&e.changed()}handleStyleImageChange_(e){this.renderIfReadyAndVisible()}renderDeclutter(e){const t=this.context,i=t.globalAlpha;t.globalAlpha=this.getLayer().getOpacity();const r=e.viewHints,s=!(r[Te.ANIMATING]||r[Te.INTERACTING]),o=this.renderedTiles;for(let a=0,l=o.length;a=0;--c)h[c].execute(this.context,1,this.getTileRenderTransform(u,e),e.viewState.rotation,s,void 0,e.declutterTree)}t.globalAlpha=i}getTileRenderTransform(e,t){const i=t.pixelRatio,r=t.viewState,s=r.center,o=r.resolution,a=r.rotation,l=t.size,u=Math.round(l[0]*i),h=Math.round(l[1]*i),d=this.getLayer().getSource().getTileGridForProjection(t.viewState.projection),f=e.tileCoord,g=d.getTileCoordExtent(e.wrappedTileCoord),p=d.getTileCoordExtent(f,this.tmpExtent)[0]-g[0];return Za(Hn(this.inversePixelTransform.slice(),1/i,1/i),this.getRenderTransform(s,o,a,i,u,h,p))}postRender(e,t){const i=t.viewHints,r=!(i[Te.ANIMATING]||i[Te.INTERACTING]);this.renderedPixelToCoordinateTransform_=t.pixelToCoordinateTransform.slice(),this.renderedRotation_=t.viewState.rotation;const s=this.getLayer(),o=s.getRenderMode(),a=e.globalAlpha;e.globalAlpha=s.getOpacity();const l=Jy[o],u=t.viewState,h=u.rotation,c=s.getSource(),f=c.getTileGridForProjection(u.projection).getZForResolution(u.resolution,c.zDirection),g=this.renderedTiles,p=[],m=[];let y=!0;for(let _=g.length-1;_>=0;--_){const v=g[_];y=y&&!v.getReplayState(s).dirty;const x=v.executorGroups[U(s)].filter(I=>I.hasExecutors(l));if(x.length===0)continue;const E=this.getTileRenderTransform(v,t),b=v.tileCoord[0];let w=!1;const C=x[0].getClipCoords(E);if(C){for(let I=0,z=p.length;I{const a=iy(o),l=i.peek(a);if(l){const u=l.sourceTiles;for(let h=0,c=u.length;h{const f=this.tileUrlFunction(d,e,t),g=this.sourceTileCache.containsKey(f)?this.sourceTileCache.get(f):new this.tileClass(d,f?P.IDLE:P.EMPTY,f,this.format_,this.tileLoadFunction);i.sourceTiles.push(g);const p=g.getState();if(p{this.handleTileChange(y);const _=g.getState();if(_===P.LOADED||_===P.ERROR){const v=g.getKey();v in i.errorTileKeys?g.getState()===P.LOADED&&delete i.errorTileKeys[v]:i.loadingSourceTiles--,_===P.ERROR?i.errorTileKeys[v]=!0:g.removeEventListener(Y.CHANGE,m),i.loadingSourceTiles===0&&i.setState(ji(i.errorTileKeys)?P.LOADED:P.ERROR)}};g.addEventListener(Y.CHANGE,m),i.loadingSourceTiles++}p===P.IDLE&&(g.extent=u.getTileCoordExtent(d),g.projection=t,g.resolution=u.getResolution(d[0]),this.sourceTileCache.set(f,g),g.load())}),i.loadingSourceTiles||i.setState(i.sourceTiles.some(d=>d.getState()===P.ERROR)?P.ERROR:P.LOADED)}return i.sourceTiles}getTile(e,t,i,r,s){const o=Nn(e,t,i),a=this.getKey();let l;if(this.tileCache.containsKey(o)&&(l=this.tileCache.get(o),l.key===a))return l;const u=[e,t,i];let h=this.getTileCoordForTileUrlFunction(u,s);const c=this.getTileGrid().getExtent(),d=this.getTileGridForProjection(s);if(h&&c){const p=d.getTileCoordExtent(h);pi(p,-d.getResolution(e),p),Se(c,p)||(h=null)}let f=!0;if(h!==null){const p=this.tileGrid,m=d.getResolution(e),y=p.getZForResolution(m,1),_=d.getTileCoordExtent(h);pi(_,-m,_),p.forEachTileCoord(_,y,v=>{f=f&&!this.tileUrlFunction(v,r,s)})}const g=new e_(u,f?P.EMPTY:P.IDLE,h,this.getSourceTiles.bind(this,r,s));return g.key=a,l?(g.interimTile=l,g.refreshInterimChain(),this.tileCache.replace(o,g)):this.tileCache.set(o,g),g}getTileGridForProjection(e){const t=e.getCode();let i=this.tileGrids_[t];if(!i){const r=this.tileGrid,s=r.getResolutions().slice(),o=s.map(function(u,h){return r.getOrigin(h)}),a=s.map(function(u,h){return r.getTileSize(h)}),l=xc+1;for(let u=s.length;u=200&&t.status<300){let i;try{i=JSON.parse(t.responseText)}catch{this.handleTileJSONError();return}this.handleTileJSONResponse(i)}else this.handleTileJSONError()}onXHRError_(e){this.handleTileJSONError()}getTileJSON(){return this.tileJSON_}handleTileJSONResponse(e){const t=pe("EPSG:4326"),i=this.getProjection();let r;if(e.bounds!==void 0){const u=Hs(t,i);r=Lf(e.bounds,u)}const s=Dr(i),o=e.minzoom||0,a=e.maxzoom||22,l=so({extent:s,maxZoom:a,minZoom:o,tileSize:this.tileSize_});if(this.tileGrid=l,this.tileUrlFunction=kc(e.tiles,l),e.attribution&&!this.getAttributions()){const u=r!==void 0?r:s;this.setAttributions(function(h){return Se(u,h.extent)?[e.attribution]:null})}this.tileJSON_=e,this.setState("ready")}handleTileJSONError(){this.setState("error")}}const n_=i_;function nd(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var r_={},rd,Hu={transparent:[0,0,0,0],aliceblue:[240,248,255,1],antiquewhite:[250,235,215,1],aqua:[0,255,255,1],aquamarine:[127,255,212,1],azure:[240,255,255,1],beige:[245,245,220,1],bisque:[255,228,196,1],black:[0,0,0,1],blanchedalmond:[255,235,205,1],blue:[0,0,255,1],blueviolet:[138,43,226,1],brown:[165,42,42,1],burlywood:[222,184,135,1],cadetblue:[95,158,160,1],chartreuse:[127,255,0,1],chocolate:[210,105,30,1],coral:[255,127,80,1],cornflowerblue:[100,149,237,1],cornsilk:[255,248,220,1],crimson:[220,20,60,1],cyan:[0,255,255,1],darkblue:[0,0,139,1],darkcyan:[0,139,139,1],darkgoldenrod:[184,134,11,1],darkgray:[169,169,169,1],darkgreen:[0,100,0,1],darkgrey:[169,169,169,1],darkkhaki:[189,183,107,1],darkmagenta:[139,0,139,1],darkolivegreen:[85,107,47,1],darkorange:[255,140,0,1],darkorchid:[153,50,204,1],darkred:[139,0,0,1],darksalmon:[233,150,122,1],darkseagreen:[143,188,143,1],darkslateblue:[72,61,139,1],darkslategray:[47,79,79,1],darkslategrey:[47,79,79,1],darkturquoise:[0,206,209,1],darkviolet:[148,0,211,1],deeppink:[255,20,147,1],deepskyblue:[0,191,255,1],dimgray:[105,105,105,1],dimgrey:[105,105,105,1],dodgerblue:[30,144,255,1],firebrick:[178,34,34,1],floralwhite:[255,250,240,1],forestgreen:[34,139,34,1],fuchsia:[255,0,255,1],gainsboro:[220,220,220,1],ghostwhite:[248,248,255,1],gold:[255,215,0,1],goldenrod:[218,165,32,1],gray:[128,128,128,1],green:[0,128,0,1],greenyellow:[173,255,47,1],grey:[128,128,128,1],honeydew:[240,255,240,1],hotpink:[255,105,180,1],indianred:[205,92,92,1],indigo:[75,0,130,1],ivory:[255,255,240,1],khaki:[240,230,140,1],lavender:[230,230,250,1],lavenderblush:[255,240,245,1],lawngreen:[124,252,0,1],lemonchiffon:[255,250,205,1],lightblue:[173,216,230,1],lightcoral:[240,128,128,1],lightcyan:[224,255,255,1],lightgoldenrodyellow:[250,250,210,1],lightgray:[211,211,211,1],lightgreen:[144,238,144,1],lightgrey:[211,211,211,1],lightpink:[255,182,193,1],lightsalmon:[255,160,122,1],lightseagreen:[32,178,170,1],lightskyblue:[135,206,250,1],lightslategray:[119,136,153,1],lightslategrey:[119,136,153,1],lightsteelblue:[176,196,222,1],lightyellow:[255,255,224,1],lime:[0,255,0,1],limegreen:[50,205,50,1],linen:[250,240,230,1],magenta:[255,0,255,1],maroon:[128,0,0,1],mediumaquamarine:[102,205,170,1],mediumblue:[0,0,205,1],mediumorchid:[186,85,211,1],mediumpurple:[147,112,219,1],mediumseagreen:[60,179,113,1],mediumslateblue:[123,104,238,1],mediumspringgreen:[0,250,154,1],mediumturquoise:[72,209,204,1],mediumvioletred:[199,21,133,1],midnightblue:[25,25,112,1],mintcream:[245,255,250,1],mistyrose:[255,228,225,1],moccasin:[255,228,181,1],navajowhite:[255,222,173,1],navy:[0,0,128,1],oldlace:[253,245,230,1],olive:[128,128,0,1],olivedrab:[107,142,35,1],orange:[255,165,0,1],orangered:[255,69,0,1],orchid:[218,112,214,1],palegoldenrod:[238,232,170,1],palegreen:[152,251,152,1],paleturquoise:[175,238,238,1],palevioletred:[219,112,147,1],papayawhip:[255,239,213,1],peachpuff:[255,218,185,1],peru:[205,133,63,1],pink:[255,192,203,1],plum:[221,160,221,1],powderblue:[176,224,230,1],purple:[128,0,128,1],rebeccapurple:[102,51,153,1],red:[255,0,0,1],rosybrown:[188,143,143,1],royalblue:[65,105,225,1],saddlebrown:[139,69,19,1],salmon:[250,128,114,1],sandybrown:[244,164,96,1],seagreen:[46,139,87,1],seashell:[255,245,238,1],sienna:[160,82,45,1],silver:[192,192,192,1],skyblue:[135,206,235,1],slateblue:[106,90,205,1],slategray:[112,128,144,1],slategrey:[112,128,144,1],snow:[255,250,250,1],springgreen:[0,255,127,1],steelblue:[70,130,180,1],tan:[210,180,140,1],teal:[0,128,128,1],thistle:[216,191,216,1],tomato:[255,99,71,1],turquoise:[64,224,208,1],violet:[238,130,238,1],wheat:[245,222,179,1],white:[255,255,255,1],whitesmoke:[245,245,245,1],yellow:[255,255,0,1],yellowgreen:[154,205,50,1]};function Qn(n){return n=Math.round(n),n<0?0:n>255?255:n}function Ju(n){return n<0?0:n>1?1:n}function Do(n){return n[n.length-1]==="%"?Qn(parseFloat(n)/100*255):Qn(parseInt(n))}function ss(n){return n[n.length-1]==="%"?Ju(parseFloat(n)/100):Ju(parseFloat(n))}function zo(n,e,t){return t<0?t+=1:t>1&&(t-=1),t*6<1?n+(e-n)*t*6:t*2<1?e:t*3<2?n+(e-n)*(2/3-t)*6:n}function s_(n){var e=n.replace(/ /g,"").toLowerCase();if(e in Hu)return Hu[e].slice();if(e[0]==="#"){if(e.length===4){var t=parseInt(e.substr(1),16);return t>=0&&t<=4095?[(t&3840)>>4|(t&3840)>>8,t&240|(t&240)>>4,t&15|(t&15)<<4,1]:null}else if(e.length===7){var t=parseInt(e.substr(1),16);return t>=0&&t<=16777215?[(t&16711680)>>16,(t&65280)>>8,t&255,1]:null}return null}var i=e.indexOf("("),r=e.indexOf(")");if(i!==-1&&r+1===e.length){var s=e.substr(0,i),o=e.substr(i+1,r-(i+1)).split(","),a=1;switch(s){case"rgba":if(o.length!==4)return null;a=ss(o.pop());case"rgb":return o.length!==3?null:[Do(o[0]),Do(o[1]),Do(o[2]),a];case"hsla":if(o.length!==4)return null;a=ss(o.pop());case"hsl":if(o.length!==3)return null;var l=(parseFloat(o[0])%360+360)%360/360,u=ss(o[1]),h=ss(o[2]),c=h<=.5?h*(u+1):h+u-h*u,d=h*2-c;return[Qn(zo(d,c,l+1/3)*255),Qn(zo(d,c,l)*255),Qn(zo(d,c,l-1/3)*255),a];default:return null}}return null}try{rd=r_.parseCSSColor=s_}catch{}class rt{constructor(e,t,i,r=1){this.r=e,this.g=t,this.b=i,this.a=r}static parse(e){if(!e)return;if(e instanceof rt)return e;if(typeof e!="string")return;const t=rd(e);if(t)return new rt(t[0]/255*t[3],t[1]/255*t[3],t[2]/255*t[3],t[3])}toString(){const[e,t,i,r]=this.toArray();return`rgba(${Math.round(e)},${Math.round(t)},${Math.round(i)},${r})`}toArray(){const{r:e,g:t,b:i,a:r}=this;return r===0?[0,0,0,0]:[e*255/r,t*255/r,i*255/r,r]}toArray01(){const{r:e,g:t,b:i,a:r}=this;return r===0?[0,0,0,0]:[e/r,t/r,i/r,r]}toArray01PremultipliedAlpha(){const{r:e,g:t,b:i,a:r}=this;return[e,t,i,r]}}rt.black=new rt(0,0,0,1);rt.white=new rt(1,1,1,1);rt.transparent=new rt(0,0,0,0);rt.red=new rt(1,0,0,1);rt.blue=new rt(0,0,1,1);var ht=rt;function yr(n){return typeof n=="object"?["literal",n]:n}function o_(n,e){let t=n.stops;if(!t)return a_(n,e);const i=t&&typeof t[0][0]=="object",r=i||n.property!==void 0,s=i||!r;return t=t.map(o=>!r&&e.tokens&&typeof o[1]=="string"?[o[0],c_(o[1])]:[o[0],yr(o[1])]),i?l_(n,e,t):s?h_(n,e,t):Ca(n,e,t)}function a_(n,e){const t=["get",n.property];if(n.default===void 0)return e.type==="string"?["string",t]:t;if(e.type==="enum")return["match",t,Object.keys(e.values),t,n.default];{const i=[e.type==="color"?"to-color":e.type,t,yr(n.default)];return e.type==="array"&&i.splice(1,0,e.value,e.length||null),i}}function El(n){switch(n.colorSpace){case"hcl":return"interpolate-hcl";case"lab":return"interpolate-lab";default:return"interpolate"}}function l_(n,e,t){const i={},r={},s=[];for(let a=0;a3&&e===n[n.length-2]||(i&&n.length===2||n.push(e),n.push(t))}function Cl(n,e){return n.type?n.type:e.expression.interpolated?"exponential":"interval"}function c_(n){const e=["concat"],t=/{([^{}]+)}/g;let i=0;for(let r=t.exec(n);r!==null;r=t.exec(n)){const s=n.slice(i,t.lastIndex-r[0].length);i=t.lastIndex,s.length>0&&e.push(s),e.push(["get",r[1]])}if(e.length===1)return n;if(i`:n.itemType.kind==="value"?"array":`array<${e}>`}else return n.kind}const p_=[uo,M,K,B,Bt,co,En,pt(Z),Gr];function _r(n,e){if(e.kind==="error")return null;if(n.kind==="array"){if(e.kind==="array"&&(e.N===0&&e.itemType.kind==="value"||!_r(n.itemType,e.itemType))&&(typeof n.N!="number"||n.N===e.N))return null}else{if(n.kind===e.kind)return null;if(n.kind==="value"){for(const t of p_)if(!_r(t,e))return null}}return`Expected ${Ee(n)} but found ${Ee(e)} instead.`}function Tl(n,e){return e.some(t=>t.kind===n.kind)}function xr(n,e){return e.some(t=>t==="null"?n===null:t==="array"?Array.isArray(n):t==="object"?n&&!Array.isArray(n)&&typeof n=="object":t===typeof n)}class Rl{constructor(e,t,i){e?this.sensitivity=t?"variant":"case":this.sensitivity=t?"accent":"base",this.locale=i,this.collator=new Intl.Collator(this.locale?this.locale:[],{sensitivity:this.sensitivity,usage:"search"})}compare(e,t){return this.collator.compare(e,t)}resolvedLocale(){return new Intl.Collator(this.locale?this.locale:[]).resolvedOptions().locale}}class ba{constructor(e,t,i,r,s){this.text=e.normalize?e.normalize():e,this.image=t,this.scale=i,this.fontStack=r,this.textColor=s}}class Lt{constructor(e){this.sections=e}static fromString(e){return new Lt([new ba(e,null,null,null,null)])}isEmpty(){return this.sections.length===0?!0:!this.sections.some(e=>e.text.length!==0||e.image&&e.image.name.length!==0)}static factory(e){return e instanceof Lt?e:Lt.fromString(e)}toString(){return this.sections.length===0?"":this.sections.map(e=>e.text).join("")}serialize(){const e=["format"];for(const t of this.sections){if(t.image){e.push(["image",t.image.name]);continue}e.push(t.text);const i={};t.fontStack&&(i["text-font"]=["literal",t.fontStack.split(",")]),t.scale&&(i["font-scale"]=t.scale),t.textColor&&(i["text-color"]=["rgba"].concat(t.textColor.toArray())),e.push(i)}return e}}class wi{constructor(e){this.name=e.name,this.available=e.available}toString(){return this.name}static fromString(e){return e?new wi({name:e,available:!1}):null}serialize(){return["image",this.name]}}function sd(n,e,t,i){return typeof n=="number"&&n>=0&&n<=255&&typeof e=="number"&&e>=0&&e<=255&&typeof t=="number"&&t>=0&&t<=255?typeof i>"u"||typeof i=="number"&&i>=0&&i<=1?null:`Invalid rgba value [${[n,e,t,i].join(", ")}]: 'a' must be between 0 and 1.`:`Invalid rgba value [${(typeof i=="number"?[n,e,t,i]:[n,e,t]).join(", ")}]: 'r', 'g', and 'b' must be between 0 and 255.`}function Ls(n){if(n===null)return!0;if(typeof n=="string")return!0;if(typeof n=="boolean")return!0;if(typeof n=="number")return!0;if(n instanceof ht)return!0;if(n instanceof Rl)return!0;if(n instanceof Lt)return!0;if(n instanceof wi)return!0;if(Array.isArray(n)){for(const e of n)if(!Ls(e))return!1;return!0}else if(typeof n=="object"){for(const e in n)if(!Ls(n[e]))return!1;return!0}else return!1}function ke(n){if(n===null)return uo;if(typeof n=="string")return K;if(typeof n=="boolean")return B;if(typeof n=="number")return M;if(n instanceof ht)return Bt;if(n instanceof Rl)return ho;if(n instanceof Lt)return co;if(n instanceof wi)return Gr;if(Array.isArray(n)){const e=n.length;let t;for(const i of n){const r=ke(i);if(!t)t=r;else{if(t===r)continue;t=Z;break}}return pt(t||Z,e)}else return En}function er(n){const e=typeof n;return n===null?"":e==="string"||e==="number"||e==="boolean"?String(n):n instanceof ht||n instanceof Lt||n instanceof wi?n.toString():JSON.stringify(n)}class Sl{constructor(e,t){this.type=e,this.value=t}static parse(e,t){if(e.length!==2)return t.error(`'literal' expression requires exactly one argument, but found ${e.length-1} instead.`);if(!Ls(e[1]))return t.error("invalid value");const i=e[1];let r=ke(i);const s=t.expectedType;return r.kind==="array"&&r.N===0&&s&&s.kind==="array"&&(typeof s.N!="number"||s.N===0)&&(r=s),new Sl(r,i)}evaluate(){return this.value}eachChild(){}outputDefined(){return!0}serialize(){return this.type.kind==="array"||this.type.kind==="object"?["literal",this.value]:this.value instanceof ht?["rgba"].concat(this.value.toArray()):this.value instanceof Lt?this.value.serialize():this.value}}var ks=Sl;class m_{constructor(e){this.name="ExpressionEvaluationError",this.message=e}toJSON(){return this.message}}var Ge=m_;const No={string:K,number:M,boolean:B,object:En};class Il{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");let i=1,r;const s=e[0];if(s==="array"){let a;if(e.length>2){const u=e[1];if(typeof u!="string"||!(u in No)||u==="object")return t.error('The item type argument of "array" must be one of string, number, boolean',1);a=No[u],i++}else a=Z;let l;if(e.length>3){if(e[2]!==null&&(typeof e[2]!="number"||e[2]<0||e[2]!==Math.floor(e[2])))return t.error('The length argument to "array" must be a positive integer literal',2);l=e[2],i++}r=pt(a,l)}else r=No[s];const o=[];for(;ie.outputDefined())}serialize(){const e=this.type,t=[e.kind];if(e.kind==="array"){const i=e.itemType;if(i.kind==="string"||i.kind==="number"||i.kind==="boolean"){t.push(i.kind);const r=e.N;(typeof r=="number"||this.args.length>1)&&t.push(r)}}return t.concat(this.args.map(i=>i.serialize()))}}var jt=Il;class fo{constructor(e){this.type=co,this.sections=e}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[1];if(!Array.isArray(i)&&typeof i=="object")return t.error("First argument must be an image or text section.");const r=[];let s=!1;for(let o=1;o<=e.length-1;++o){const a=e[o];if(s&&typeof a=="object"&&!Array.isArray(a)){s=!1;let l=null;if(a["font-scale"]&&(l=t.parse(a["font-scale"],1,M),!l))return null;let u=null;if(a["text-font"]&&(u=t.parse(a["text-font"],1,pt(K)),!u))return null;let h=null;if(a["text-color"]&&(h=t.parse(a["text-color"],1,Bt),!h))return null;const c=r[r.length-1];c.scale=l,c.font=u,c.textColor=h}else{const l=t.parse(e[o],1,Z);if(!l)return null;const u=l.type.kind;if(u!=="string"&&u!=="value"&&u!=="null"&&u!=="resolvedImage")return t.error("Formatted text type must be 'string', 'value', 'image' or 'null'.");s=!0,r.push({content:l,scale:null,font:null,textColor:null})}}return new fo(r)}evaluate(e){const t=i=>{const r=i.content.evaluate(e);return ke(r)===Gr?new ba("",r,null,null,null):new ba(er(r),null,i.scale?i.scale.evaluate(e):null,i.font?i.font.evaluate(e).join(","):null,i.textColor?i.textColor.evaluate(e):null)};return new Lt(this.sections.map(t))}eachChild(e){for(const t of this.sections)e(t.content),t.scale&&e(t.scale),t.font&&e(t.font),t.textColor&&e(t.textColor)}outputDefined(){return!1}serialize(){const e=["format"];for(const t of this.sections){e.push(t.content.serialize());const i={};t.scale&&(i["font-scale"]=t.scale.serialize()),t.font&&(i["text-font"]=t.font.serialize()),t.textColor&&(i["text-color"]=t.textColor.serialize()),e.push(i)}return e}}class go{constructor(e){this.type=Gr,this.input=e}static parse(e,t){if(e.length!==2)return t.error("Expected two arguments.");const i=t.parse(e[1],1,K);return i?new go(i):t.error("No image name provided.")}evaluate(e){const t=this.input.evaluate(e),i=wi.fromString(t);return i&&e.availableImages&&(i.available=e.availableImages.indexOf(t)>-1),i}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){return["image",this.input.serialize()]}}const y_={"to-boolean":B,"to-color":Bt,"to-number":M,"to-string":K};class Al{constructor(e,t){this.type=e,this.args=t}static parse(e,t){if(e.length<2)return t.error("Expected at least one argument.");const i=e[0];if((i==="to-boolean"||i==="to-string")&&e.length!==2)return t.error("Expected one argument.");const r=y_[i],s=[];for(let o=1;o4?i=`Invalid rbga value ${JSON.stringify(t)}: expected an array containing either three or four numeric values.`:i=sd(t[0],t[1],t[2],t[3]),!i))return new ht(t[0]/255,t[1]/255,t[2]/255,t[3])}throw new Ge(i||`Could not parse color from value '${typeof t=="string"?t:String(JSON.stringify(t))}'`)}else if(this.type.kind==="number"){let t=null;for(const i of this.args){if(t=i.evaluate(e),t===null)return 0;const r=Number(t);if(!isNaN(r))return r}throw new Ge(`Could not convert ${JSON.stringify(t)} to number.`)}else return this.type.kind==="formatted"?Lt.fromString(er(this.args[0].evaluate(e))):this.type.kind==="resolvedImage"?wi.fromString(er(this.args[0].evaluate(e))):er(this.args[0].evaluate(e))}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){if(this.type.kind==="formatted")return new fo([{content:this.args[0],scale:null,font:null,textColor:null}]).serialize();if(this.type.kind==="resolvedImage")return new go(this.args[0]).serialize();const e=[`to-${this.type.kind}`];return this.eachChild(t=>{e.push(t.serialize())}),e}}var mn=Al;const __=["Unknown","Point","LineString","Polygon"];class x_{constructor(){this.globals=null,this.feature=null,this.featureState=null,this.formattedSection=null,this._parseColorCache={},this.availableImages=null,this.canonical=null,this.featureTileCoord=null,this.featureDistanceData=null}id(){return this.feature&&this.feature.id!==void 0?this.feature.id:null}geometryType(){return this.feature?typeof this.feature.type=="number"?__[this.feature.type]:this.feature.type:null}geometry(){return this.feature&&"geometry"in this.feature?this.feature.geometry:null}canonicalID(){return this.canonical}properties(){return this.feature&&this.feature.properties||{}}distanceFromCenter(){if(this.featureTileCoord&&this.featureDistanceData){const e=this.featureDistanceData.center,t=this.featureDistanceData.scale,{x:i,y:r}=this.featureTileCoord,s=i*t-e[0],o=r*t-e[1],a=this.featureDistanceData.bearing[0],l=this.featureDistanceData.bearing[1];return a*s+l*o}return 0}parseColor(e){let t=this._parseColorCache[e];return t||(t=this._parseColorCache[e]=ht.parse(e)),t}}var od=x_;class yn{constructor(e,t,i,r){this.name=e,this.type=t,this._evaluate=i,this.args=r}evaluate(e){return this._evaluate(e,this.args)}eachChild(e){this.args.forEach(e)}outputDefined(){return!1}serialize(){return[this.name].concat(this.args.map(e=>e.serialize()))}static parse(e,t){const i=e[0],r=yn.definitions[i];if(!r)return t.error(`Unknown expression "${i}". If you wanted a literal array, use ["literal", [...]].`,0);const s=Array.isArray(r)?r[0]:r.type,o=Array.isArray(r)?[[r[1],r[2]]]:r.overloads,a=o.filter(([u])=>!Array.isArray(u)||u.length===e.length-1);let l=null;for(const[u,h]of a){l=new cd(t.registry,t.path,null,t.scope);const c=[];let d=!1;for(let f=1;fv_(d)).join(" | "),c=[];for(let d=1;d=e[2]||n[1]<=e[1]||n[3]>=e[3])}function C_(n,e){const t=E_(n[0]),i=w_(n[1]),r=Math.pow(2,e.z);return[Math.round(t*r*mi),Math.round(i*r*mi)]}function b_(n,e,t){const i=n[0]-e[0],r=n[1]-e[1],s=n[0]-t[0],o=n[1]-t[1];return i*o-s*r===0&&i*s<=0&&r*o<=0}function T_(n,e,t){return e[1]>n[1]!=t[1]>n[1]&&n[0]<(t[0]-e[0])*(n[1]-e[1])/(t[1]-e[1])+e[0]}function Ml(n,e){let t=!1;for(let i=0,r=e.length;i0&&c<0||h<0&&c>0}function I_(n,e,t,i){const r=[e[0]-n[0],e[1]-n[1]],s=[i[0]-t[0],i[1]-t[1]];return S_(s,r)===0?!1:!!(eh(n,e,t,i)&&eh(t,i,n,e))}function A_(n,e,t){for(const i of t)for(let r=0;rt[2]){const r=i*.5;let s=n[0]-t[0]>r?-i:t[0]-n[0]>r?i:0;s===0&&(s=n[0]-t[2]>r?-i:t[2]-n[0]>r?i:0),n[0]+=s}Fl(e,n)}function M_(n){n[0]=n[1]=1/0,n[2]=n[3]=-1/0}function th(n,e,t,i){const r=Math.pow(2,i.z)*mi,s=[i.x*mi,i.y*mi],o=[];if(!n)return o;for(const a of n)for(const l of a){const u=[l.x+s[0],l.y+s[1]];ud(u,e,t,r),o.push(u)}return o}function ih(n,e,t,i){const r=Math.pow(2,i.z)*mi,s=[i.x*mi,i.y*mi],o=[];if(!n)return o;for(const a of n){const l=[];for(const u of a){const h=[u.x+s[0],u.y+s[1]];Fl(e,h),l.push(h)}o.push(l)}if(e[2]-e[0]<=r/2){M_(e);for(const a of o)for(const l of a)ud(l,e,t,r)}return o}function P_(n,e){const t=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],r=n.canonicalID();if(!r)return!1;if(e.type==="Polygon"){const s=Pl(e.coordinates,i,r),o=th(n.geometry(),t,i,r);if(!Os(t,i))return!1;for(const a of o)if(!Ml(a,s))return!1}if(e.type==="MultiPolygon"){const s=ld(e.coordinates,i,r),o=th(n.geometry(),t,i,r);if(!Os(t,i))return!1;for(const a of o)if(!R_(a,s))return!1}return!0}function L_(n,e){const t=[1/0,1/0,-1/0,-1/0],i=[1/0,1/0,-1/0,-1/0],r=n.canonicalID();if(!r)return!1;if(e.type==="Polygon"){const s=Pl(e.coordinates,i,r),o=ih(n.geometry(),t,i,r);if(!Os(t,i))return!1;for(const a of o)if(!ad(a,s))return!1}if(e.type==="MultiPolygon"){const s=ld(e.coordinates,i,r),o=ih(n.geometry(),t,i,r);if(!Os(t,i))return!1;for(const a of o)if(!F_(a,s))return!1}return!0}class tr{constructor(e,t){this.type=B,this.geojson=e,this.geometries=t}static parse(e,t){if(e.length!==2)return t.error(`'within' expression requires exactly one argument, but found ${e.length-1} instead.`);if(Ls(e[1])){const i=e[1];if(i.type==="FeatureCollection")for(let r=0;r{e&&!mo(t)&&(e=!1)}),e}function kl(n){if(n instanceof $n&&n.name==="feature-state")return!1;let e=!0;return n.eachChild(t=>{e&&!kl(t)&&(e=!1)}),e}function Ol(n,e){if(n instanceof $n&&e.indexOf(n.name)>=0)return!1;let t=!0;return n.eachChild(i=>{t&&!Ol(i,e)&&(t=!1)}),t}class Dl{constructor(e,t){this.type=t.type,this.name=e,this.boundExpression=t}static parse(e,t){if(e.length!==2||typeof e[1]!="string")return t.error("'var' expression requires exactly one string literal argument.");const i=e[1];return t.scope.has(i)?new Dl(i,t.scope.get(i)):t.error(`Unknown variable "${i}". Make sure "${i}" has been bound in an enclosing "let" expression before using it.`,1)}evaluate(e){return this.boundExpression.evaluate(e)}eachChild(){}outputDefined(){return!1}serialize(){return["var",this.name]}}var hd=Dl;class zl{constructor(e,t=[],i,r=new f_,s=[]){this.registry=e,this.path=t,this.key=t.map(o=>`[${o}]`).join(""),this.scope=r,this.errors=s,this.expectedType=i}parse(e,t,i,r,s={}){return t?this.concat(t,i,r)._parse(e,s):this._parse(e,s)}_parse(e,t){(e===null||typeof e=="string"||typeof e=="boolean"||typeof e=="number")&&(e=["literal",e]);function i(r,s,o){return o==="assert"?new jt(s,[r]):o==="coerce"?new mn(s,[r]):r}if(Array.isArray(e)){if(e.length===0)return this.error('Expected an array with at least one element. If you wanted a literal array, use ["literal", []].');const r=e[0];if(typeof r!="string")return this.error(`Expression name must be a string, but found ${typeof r} instead. If you wanted a literal array, use ["literal", [...]].`,0),null;const s=this.registry[r];if(s){let o=s.parse(e,this);if(!o)return null;if(this.expectedType){const a=this.expectedType,l=o.type;if((a.kind==="string"||a.kind==="number"||a.kind==="boolean"||a.kind==="object"||a.kind==="array")&&l.kind==="value")o=i(o,a,t.typeAnnotation||"assert");else if((a.kind==="color"||a.kind==="formatted"||a.kind==="resolvedImage")&&(l.kind==="value"||l.kind==="string"))o=i(o,a,t.typeAnnotation||"coerce");else if(this.checkSubtype(a,l))return null}if(!(o instanceof ks)&&o.type.kind!=="resolvedImage"&&Ta(o)){const a=new od;try{o=new ks(o.type,o.evaluate(a))}catch(l){return this.error(l.message),null}}return o}return this.error(`Unknown expression "${r}". If you wanted a literal array, use ["literal", [...]].`,0)}else return typeof e>"u"?this.error("'undefined' value invalid. Use null instead."):typeof e=="object"?this.error('Bare objects invalid. Use ["literal", {...}] instead.'):this.error(`Expected an array, but found ${typeof e} instead.`)}concat(e,t,i){const r=typeof e=="number"?this.path.concat(e):this.path,s=i?this.scope.concat(i):this.scope;return new zl(this.registry,r,t||null,s,this.errors)}error(e,...t){const i=`${this.key}${t.map(r=>`[${r}]`).join("")}`;this.errors.push(new It(i,e))}checkSubtype(e,t){const i=_r(e,t);return i&&this.error(i),i}}var cd=zl;function Ta(n){if(n instanceof hd)return Ta(n.boundExpression);if(n instanceof $n&&n.name==="error")return!1;if(n instanceof po)return!1;if(n instanceof Ll)return!1;const e=n instanceof mn||n instanceof jt;let t=!0;return n.eachChild(i=>{e?t=t&&Ta(i):t=t&&i instanceof ks}),t?mo(n)&&Ol(n,["zoom","heatmap-density","line-progress","sky-radial-progress","accumulated","is-supported-script","pitch","distance-from-center"]):!1}function dd(n,e){const t=n.length-1;let i=0,r=t,s=0,o,a;for(;i<=r;)if(s=Math.floor((i+r)/2),o=n[s],a=n[s+1],o<=e){if(s===t||ee)r=s-1;else throw new Ge("Input is not a number.");return 0}class Nl{constructor(e,t,i){this.type=e,this.input=t,this.labels=[],this.outputs=[];for(const[r,s]of i)this.labels.push(r),this.outputs.push(s)}static parse(e,t){if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!==0)return t.error("Expected an even number of arguments.");const i=t.parse(e[1],1,M);if(!i)return null;const r=[];let s=null;t.expectedType&&t.expectedType.kind!=="value"&&(s=t.expectedType);for(let o=1;o=a)return t.error('Input/output pairs for "step" expressions must be arranged with input values in strictly ascending order.',u);const c=t.parse(l,h,s);if(!c)return null;s=s||c.type,r.push([a,c])}return new Nl(s,i,r)}evaluate(e){const t=this.labels,i=this.outputs;if(t.length===1)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const s=t.length;if(r>=t[s-1])return i[s-1].evaluate(e);const o=dd(t,r);return i[o].evaluate(e)}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){const e=["step",this.input.serialize()];for(let t=0;t0&&e.push(this.labels[t]),e.push(this.outputs[t].serialize());return e}}var fd=Nl,k_=jn;function jn(n,e,t,i){this.cx=3*n,this.bx=3*(t-n)-this.cx,this.ax=1-this.cx-this.bx,this.cy=3*e,this.by=3*(i-e)-this.cy,this.ay=1-this.cy-this.by,this.p1x=n,this.p1y=i,this.p2x=t,this.p2y=i}jn.prototype.sampleCurveX=function(n){return((this.ax*n+this.bx)*n+this.cx)*n};jn.prototype.sampleCurveY=function(n){return((this.ay*n+this.by)*n+this.cy)*n};jn.prototype.sampleCurveDerivativeX=function(n){return(3*this.ax*n+2*this.bx)*n+this.cx};jn.prototype.solveCurveX=function(n,e){typeof e>"u"&&(e=1e-6);var t,i,r,s,o;for(r=n,o=0;o<8;o++){if(s=this.sampleCurveX(r)-n,Math.abs(s)i)return i;for(;ts?t=r:i=r,r=(i-t)*.5+t}return r};jn.prototype.solve=function(n,e){return this.sampleCurveY(this.solveCurveX(n,e))};var O_=nd(k_);function ut(n,e,t){return n*(1-t)+e*t}function D_(n,e,t){return new ht(ut(n.r,e.r,t),ut(n.g,e.g,t),ut(n.b,e.b,t),ut(n.a,e.a,t))}function z_(n,e,t){return n.map((i,r)=>ut(i,e[r],t))}var N_=Object.freeze({__proto__:null,number:ut,color:D_,array:z_});const gd=.95047,pd=1,md=1.08883,yd=4/29,wn=6/29,_d=3*wn*wn,G_=wn*wn*wn,$_=Math.PI/180,j_=180/Math.PI;function Go(n){return n>G_?Math.pow(n,1/3):n/_d+yd}function $o(n){return n>wn?n*n*n:_d*(n-yd)}function jo(n){return 255*(n<=.0031308?12.92*n:1.055*Math.pow(n,1/2.4)-.055)}function Xo(n){return n/=255,n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function xd(n){const e=Xo(n.r),t=Xo(n.g),i=Xo(n.b),r=Go((.4124564*e+.3575761*t+.1804375*i)/gd),s=Go((.2126729*e+.7151522*t+.072175*i)/pd),o=Go((.0193339*e+.119192*t+.9503041*i)/md);return{l:116*s-16,a:500*(r-s),b:200*(s-o),alpha:n.a}}function vd(n){let e=(n.l+16)/116,t=isNaN(n.a)?e:e+n.a/500,i=isNaN(n.b)?e:e-n.b/200;return e=pd*$o(e),t=gd*$o(t),i=md*$o(i),new ht(jo(3.2404542*t-1.5371385*e-.4985314*i),jo(-.969266*t+1.8760108*e+.041556*i),jo(.0556434*t-.2040259*e+1.0572252*i),n.alpha)}function X_(n,e,t){return{l:ut(n.l,e.l,t),a:ut(n.a,e.a,t),b:ut(n.b,e.b,t),alpha:ut(n.alpha,e.alpha,t)}}function W_(n){const{l:e,a:t,b:i}=xd(n),r=Math.atan2(i,t)*j_;return{h:r<0?r+360:r,c:Math.sqrt(t*t+i*i),l:e,alpha:n.a}}function U_(n){const e=n.h*$_,t=n.c,i=n.l;return vd({l:i,a:Math.cos(e)*t,b:Math.sin(e)*t,alpha:n.alpha})}function V_(n,e,t){const i=e-n;return n+t*(i>180||i<-180?i-360*Math.round(i/360):i)}function Y_(n,e,t){return{h:V_(n.h,e.h,t),c:ut(n.c,e.c,t),l:ut(n.l,e.l,t),alpha:ut(n.alpha,e.alpha,t)}}const os={forward:xd,reverse:vd,interpolate:X_},as={forward:W_,reverse:U_,interpolate:Y_};class Ds{constructor(e,t,i,r,s){this.type=e,this.operator=t,this.interpolation=i,this.input=r,this.labels=[],this.outputs=[];for(const[o,a]of s)this.labels.push(o),this.outputs.push(a)}static interpolationFactor(e,t,i,r){let s=0;if(e.name==="exponential")s=Wo(t,e.base,i,r);else if(e.name==="linear")s=Wo(t,1,i,r);else if(e.name==="cubic-bezier"){const o=e.controlPoints;s=new O_(o[0],o[1],o[2],o[3]).solve(Wo(t,1,i,r))}return s}static parse(e,t){let[i,r,s,...o]=e;if(!Array.isArray(r)||r.length===0)return t.error("Expected an interpolation type expression.",1);if(r[0]==="linear")r={name:"linear"};else if(r[0]==="exponential"){const u=r[1];if(typeof u!="number")return t.error("Exponential interpolation requires a numeric base.",1,1);r={name:"exponential",base:u}}else if(r[0]==="cubic-bezier"){const u=r.slice(1);if(u.length!==4||u.some(h=>typeof h!="number"||h<0||h>1))return t.error("Cubic bezier interpolation requires four numeric arguments with values between 0 and 1.",1);r={name:"cubic-bezier",controlPoints:u}}else return t.error(`Unknown interpolation type ${String(r[0])}`,1,0);if(e.length-1<4)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if((e.length-1)%2!==0)return t.error("Expected an even number of arguments.");if(s=t.parse(s,2,M),!s)return null;const a=[];let l=null;i==="interpolate-hcl"||i==="interpolate-lab"?l=Bt:t.expectedType&&t.expectedType.kind!=="value"&&(l=t.expectedType);for(let u=0;u=h)return t.error('Input/output pairs for "interpolate" expressions must be arranged with input values in strictly ascending order.',d);const g=t.parse(c,f,l);if(!g)return null;l=l||g.type,a.push([h,g])}return l.kind!=="number"&&l.kind!=="color"&&!(l.kind==="array"&&l.itemType.kind==="number"&&typeof l.N=="number")?t.error(`Type ${Ee(l)} is not interpolatable.`):new Ds(l,i,r,s,a)}evaluate(e){const t=this.labels,i=this.outputs;if(t.length===1)return i[0].evaluate(e);const r=this.input.evaluate(e);if(r<=t[0])return i[0].evaluate(e);const s=t.length;if(r>=t[s-1])return i[s-1].evaluate(e);const o=dd(t,r),a=t[o],l=t[o+1],u=Ds.interpolationFactor(this.interpolation,r,a,l),h=i[o].evaluate(e),c=i[o+1].evaluate(e);return this.operator==="interpolate"?N_[this.type.kind.toLowerCase()](h,c,u):this.operator==="interpolate-hcl"?as.reverse(as.interpolate(as.forward(h),as.forward(c),u)):os.reverse(os.interpolate(os.forward(h),os.forward(c),u))}eachChild(e){e(this.input);for(const t of this.outputs)e(t)}outputDefined(){return this.outputs.every(e=>e.outputDefined())}serialize(){let e;this.interpolation.name==="linear"?e=["linear"]:this.interpolation.name==="exponential"?this.interpolation.base===1?e=["linear"]:e=["exponential",this.interpolation.base]:e=["cubic-bezier"].concat(this.interpolation.controlPoints);const t=[this.operator,e,this.input.serialize()];for(let i=0;i_r(r,a.type))?new zs(Z,s):new zs(i,s)}evaluate(e){let t=null,i=0,r;for(const s of this.args){if(i++,t=s.evaluate(e),t&&t instanceof wi&&!t.available&&(r||(r=t),t=null,i===this.args.length))return r;if(t!==null)break}return t}eachChild(e){this.args.forEach(e)}outputDefined(){return this.args.every(e=>e.outputDefined())}serialize(){const e=["coalesce"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var Ed=zs;class Gl{constructor(e,t){this.type=t.type,this.bindings=[].concat(e),this.result=t}evaluate(e){return this.result.evaluate(e)}eachChild(e){for(const t of this.bindings)e(t[1]);e(this.result)}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found ${e.length-1} instead.`);const i=[];for(let s=1;s=i.length)throw new Ge(`Array index out of bounds: ${t} > ${i.length-1}.`);if(t!==Math.floor(t))throw new Ge(`Array index must be an integer, but found ${t} instead.`);return i[t]}eachChild(e){e(this.index),e(this.input)}outputDefined(){return!1}serialize(){return["at",this.index.serialize(),this.input.serialize()]}}var B_=$l;class jl{constructor(e,t){this.type=B,this.needle=e,this.haystack=t}static parse(e,t){if(e.length!==3)return t.error(`Expected 2 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Z),r=t.parse(e[2],2,Z);return!i||!r?null:Tl(i.type,[B,K,M,uo,Z])?new jl(i,r):t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ee(i.type)} instead`)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(i==null)return!1;if(!xr(t,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${Ee(ke(t))} instead.`);if(!xr(i,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${Ee(ke(i))} instead.`);return i.indexOf(t)>=0}eachChild(e){e(this.needle),e(this.haystack)}outputDefined(){return!0}serialize(){return["in",this.needle.serialize(),this.haystack.serialize()]}}var Z_=jl;class Ns{constructor(e,t,i){this.type=M,this.needle=e,this.haystack=t,this.fromIndex=i}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Z),r=t.parse(e[2],2,Z);if(!i||!r)return null;if(!Tl(i.type,[B,K,M,uo,Z]))return t.error(`Expected first argument to be of type boolean, string, number or null, but found ${Ee(i.type)} instead`);if(e.length===4){const s=t.parse(e[3],3,M);return s?new Ns(i,r,s):null}else return new Ns(i,r)}evaluate(e){const t=this.needle.evaluate(e),i=this.haystack.evaluate(e);if(!xr(t,["boolean","string","number","null"]))throw new Ge(`Expected first argument to be of type boolean, string, number or null, but found ${Ee(ke(t))} instead.`);if(!xr(i,["string","array"]))throw new Ge(`Expected second argument to be of type array or string, but found ${Ee(ke(i))} instead.`);if(this.fromIndex){const r=this.fromIndex.evaluate(e);return i.indexOf(t,r)}return i.indexOf(t)}eachChild(e){e(this.needle),e(this.haystack),this.fromIndex&&e(this.fromIndex)}outputDefined(){return!1}serialize(){if(this.fromIndex!=null&&this.fromIndex!==void 0){const e=this.fromIndex.serialize();return["index-of",this.needle.serialize(),this.haystack.serialize(),e]}return["index-of",this.needle.serialize(),this.haystack.serialize()]}}var q_=Ns;class Xl{constructor(e,t,i,r,s,o){this.inputType=e,this.type=t,this.input=i,this.cases=r,this.outputs=s,this.otherwise=o}static parse(e,t){if(e.length<5)return t.error(`Expected at least 4 arguments, but found only ${e.length-1}.`);if(e.length%2!==1)return t.error("Expected an even number of arguments.");let i,r;t.expectedType&&t.expectedType.kind!=="value"&&(r=t.expectedType);const s={},o=[];for(let u=2;uNumber.MAX_SAFE_INTEGER)return d.error(`Branch labels must be integers no larger than ${Number.MAX_SAFE_INTEGER}.`);if(typeof g=="number"&&Math.floor(g)!==g)return d.error("Numeric branch labels must be integer values.");if(!i)i=ke(g);else if(d.checkSubtype(i,ke(g)))return null;if(typeof s[String(g)]<"u")return d.error("Branch labels must be unique.");s[String(g)]=o.length}const f=t.parse(c,u,r);if(!f)return null;r=r||f.type,o.push(f)}const a=t.parse(e[1],1,Z);if(!a)return null;const l=t.parse(e[e.length-1],e.length-1,r);return!l||a.type.kind!=="value"&&t.concat(1).checkSubtype(i,a.type)?null:new Xl(i,r,a,s,o,l)}evaluate(e){const t=this.input.evaluate(e);return(ke(t)===this.inputType&&this.outputs[this.cases[t]]||this.otherwise).evaluate(e)}eachChild(e){e(this.input),this.outputs.forEach(e),e(this.otherwise)}outputDefined(){return this.outputs.every(e=>e.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["match",this.input.serialize()],t=Object.keys(this.cases).sort(),i=[],r={};for(const o of t){const a=r[this.cases[o]];a===void 0?(r[this.cases[o]]=i.length,i.push([this.cases[o],[o]])):i[a][1].push(o)}const s=o=>this.inputType.kind==="number"?Number(o):o;for(const[o,a]of i)a.length===1?e.push(s(a[0])):e.push(a.map(s)),e.push(this.outputs[o].serialize());return e.push(this.otherwise.serialize()),e}}var K_=Xl;class Wl{constructor(e,t,i){this.type=e,this.branches=t,this.otherwise=i}static parse(e,t){if(e.length<4)return t.error(`Expected at least 3 arguments, but found only ${e.length-1}.`);if(e.length%2!==0)return t.error("Expected an odd number of arguments.");let i;t.expectedType&&t.expectedType.kind!=="value"&&(i=t.expectedType);const r=[];for(let o=1;ot.outputDefined())&&this.otherwise.outputDefined()}serialize(){const e=["case"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var H_=Wl;class Gs{constructor(e,t,i,r){this.type=e,this.input=t,this.beginIndex=i,this.endIndex=r}static parse(e,t){if(e.length<=2||e.length>=5)return t.error(`Expected 3 or 4 arguments, but found ${e.length-1} instead.`);const i=t.parse(e[1],1,Z),r=t.parse(e[2],2,M);if(!i||!r)return null;if(!Tl(i.type,[pt(Z),K,Z]))return t.error(`Expected first argument to be of type array or string, but found ${Ee(i.type)} instead`);if(e.length===4){const s=t.parse(e[3],3,M);return s?new Gs(i.type,i,r,s):null}else return new Gs(i.type,i,r)}evaluate(e){const t=this.input.evaluate(e),i=this.beginIndex.evaluate(e);if(!xr(t,["string","array"]))throw new Ge(`Expected first argument to be of type array or string, but found ${Ee(ke(t))} instead.`);if(this.endIndex){const r=this.endIndex.evaluate(e);return t.slice(i,r)}return t.slice(i)}eachChild(e){e(this.input),e(this.beginIndex),this.endIndex&&e(this.endIndex)}outputDefined(){return!1}serialize(){if(this.endIndex!=null&&this.endIndex!==void 0){const e=this.endIndex.serialize();return["slice",this.input.serialize(),this.beginIndex.serialize(),e]}return["slice",this.input.serialize(),this.beginIndex.serialize()]}}var J_=Gs;function nh(n,e){return n==="=="||n==="!="?e.kind==="boolean"||e.kind==="string"||e.kind==="number"||e.kind==="null"||e.kind==="value":e.kind==="string"||e.kind==="number"||e.kind==="value"}function Q_(n,e,t){return e===t}function e0(n,e,t){return e!==t}function t0(n,e,t){return et}function n0(n,e,t){return e<=t}function r0(n,e,t){return e>=t}function Cd(n,e,t,i){return i.compare(e,t)===0}function s0(n,e,t,i){return!Cd(n,e,t,i)}function o0(n,e,t,i){return i.compare(e,t)<0}function a0(n,e,t,i){return i.compare(e,t)>0}function l0(n,e,t,i){return i.compare(e,t)<=0}function u0(n,e,t,i){return i.compare(e,t)>=0}function Xn(n,e,t){const i=n!=="=="&&n!=="!=";return class bd{constructor(s,o,a){this.type=B,this.lhs=s,this.rhs=o,this.collator=a,this.hasUntypedArgument=s.type.kind==="value"||o.type.kind==="value"}static parse(s,o){if(s.length!==3&&s.length!==4)return o.error("Expected two or three arguments.");const a=s[0];let l=o.parse(s[1],1,Z);if(!l)return null;if(!nh(a,l.type))return o.concat(1).error(`"${a}" comparisons are not supported for type '${Ee(l.type)}'.`);let u=o.parse(s[2],2,Z);if(!u)return null;if(!nh(a,u.type))return o.concat(2).error(`"${a}" comparisons are not supported for type '${Ee(u.type)}'.`);if(l.type.kind!==u.type.kind&&l.type.kind!=="value"&&u.type.kind!=="value")return o.error(`Cannot compare types '${Ee(l.type)}' and '${Ee(u.type)}'.`);i&&(l.type.kind==="value"&&u.type.kind!=="value"?l=new jt(u.type,[l]):l.type.kind!=="value"&&u.type.kind==="value"&&(u=new jt(l.type,[u])));let h=null;if(s.length===4){if(l.type.kind!=="string"&&u.type.kind!=="string"&&l.type.kind!=="value"&&u.type.kind!=="value")return o.error("Cannot use collator to compare non-string types.");if(h=o.parse(s[3],3,ho),!h)return null}return new bd(l,u,h)}evaluate(s){const o=this.lhs.evaluate(s),a=this.rhs.evaluate(s);if(i&&this.hasUntypedArgument){const l=ke(o),u=ke(a);if(l.kind!==u.kind||!(l.kind==="string"||l.kind==="number"))throw new Ge(`Expected arguments for "${n}" to be (string, string) or (number, number), but found (${l.kind}, ${u.kind}) instead.`)}if(this.collator&&!i&&this.hasUntypedArgument){const l=ke(o),u=ke(a);if(l.kind!=="string"||u.kind!=="string")return e(s,o,a)}return this.collator?t(s,o,a,this.collator.evaluate(s)):e(s,o,a)}eachChild(s){s(this.lhs),s(this.rhs),this.collator&&s(this.collator)}outputDefined(){return!0}serialize(){const s=[n];return this.eachChild(o=>{s.push(o.serialize())}),s}}}const h0=Xn("==",Q_,Cd),c0=Xn("!=",e0,s0),d0=Xn("<",t0,o0),f0=Xn(">",i0,a0),g0=Xn("<=",n0,l0),p0=Xn(">=",r0,u0);class Ul{constructor(e,t,i,r,s,o){this.type=K,this.number=e,this.locale=t,this.currency=i,this.unit=r,this.minFractionDigits=s,this.maxFractionDigits=o}static parse(e,t){if(e.length!==3)return t.error("Expected two arguments.");const i=t.parse(e[1],1,M);if(!i)return null;const r=e[2];if(typeof r!="object"||Array.isArray(r))return t.error("NumberFormat options argument must be an object.");let s=null;if(r.locale&&(s=t.parse(r.locale,1,K),!s))return null;let o=null;if(r.currency&&(o=t.parse(r.currency,1,K),!o))return null;let a=null;if(r.unit&&(a=t.parse(r.unit,1,K),!a))return null;let l=null;if(r["min-fraction-digits"]&&(l=t.parse(r["min-fraction-digits"],1,M),!l))return null;let u=null;return r["max-fraction-digits"]&&(u=t.parse(r["max-fraction-digits"],1,M),!u)?null:new Ul(i,s,o,a,l,u)}evaluate(e){return new Intl.NumberFormat(this.locale?this.locale.evaluate(e):[],{style:this.currency&&"currency"||this.unit&&"unit"||"decimal",currency:this.currency?this.currency.evaluate(e):void 0,unit:this.unit?this.unit.evaluate(e):void 0,minimumFractionDigits:this.minFractionDigits?this.minFractionDigits.evaluate(e):void 0,maximumFractionDigits:this.maxFractionDigits?this.maxFractionDigits.evaluate(e):void 0}).format(this.number.evaluate(e))}eachChild(e){e(this.number),this.locale&&e(this.locale),this.currency&&e(this.currency),this.unit&&e(this.unit),this.minFractionDigits&&e(this.minFractionDigits),this.maxFractionDigits&&e(this.maxFractionDigits)}outputDefined(){return!1}serialize(){const e={};return this.locale&&(e.locale=this.locale.serialize()),this.currency&&(e.currency=this.currency.serialize()),this.unit&&(e.unit=this.unit.serialize()),this.minFractionDigits&&(e["min-fraction-digits"]=this.minFractionDigits.serialize()),this.maxFractionDigits&&(e["max-fraction-digits"]=this.maxFractionDigits.serialize()),["number-format",this.number.serialize(),e]}}class Vl{constructor(e){this.type=M,this.input=e}static parse(e,t){if(e.length!==2)return t.error(`Expected 1 argument, but found ${e.length-1} instead.`);const i=t.parse(e[1],1);return i?i.type.kind!=="array"&&i.type.kind!=="string"&&i.type.kind!=="value"?t.error(`Expected argument of type string or array, but found ${Ee(i.type)} instead.`):new Vl(i):null}evaluate(e){const t=this.input.evaluate(e);if(typeof t=="string")return t.length;if(Array.isArray(t))return t.length;throw new Ge(`Expected value to be of type string or array, but found ${Ee(ke(t))} instead.`)}eachChild(e){e(this.input)}outputDefined(){return!1}serialize(){const e=["length"];return this.eachChild(t=>{e.push(t.serialize())}),e}}var m0=Vl;const Td={"==":h0,"!=":c0,">":f0,"<":d0,">=":p0,"<=":g0,array:jt,at:B_,boolean:jt,case:H_,coalesce:Ed,collator:po,format:fo,image:go,in:Z_,"index-of":q_,interpolate:$i,"interpolate-hcl":$i,"interpolate-lab":$i,length:m0,let:wd,literal:ks,match:K_,number:jt,"number-format":Ul,object:jt,slice:J_,step:fd,string:jt,"to-boolean":mn,"to-color":mn,"to-number":mn,"to-string":mn,var:hd,within:Ll};function rh(n,[e,t,i,r]){e=e.evaluate(n),t=t.evaluate(n),i=i.evaluate(n);const s=r?r.evaluate(n):1,o=sd(e,t,i,s);if(o)throw new Ge(o);return new ht(e/255*s,t/255*s,i/255*s,s)}function sh(n,e){return n in e}function Uo(n,e){const t=e[n];return typeof t>"u"?null:t}function y0(n,e,t,i){for(;t<=i;){const r=t+i>>1;if(e[r]===n)return!0;e[r]>n?i=r-1:t=r+1}return!1}function Ri(n){return{type:n}}$n.register(Td,{error:[g_,[K],(n,[e])=>{throw new Ge(e.evaluate(n))}],typeof:[K,[Z],(n,[e])=>Ee(ke(e.evaluate(n)))],"to-rgba":[pt(M,4),[Bt],(n,[e])=>e.evaluate(n).toArray()],rgb:[Bt,[M,M,M],rh],rgba:[Bt,[M,M,M,M],rh],has:{type:B,overloads:[[[K],(n,[e])=>sh(e.evaluate(n),n.properties())],[[K,En],(n,[e,t])=>sh(e.evaluate(n),t.evaluate(n))]]},get:{type:Z,overloads:[[[K],(n,[e])=>Uo(e.evaluate(n),n.properties())],[[K,En],(n,[e,t])=>Uo(e.evaluate(n),t.evaluate(n))]]},"feature-state":[Z,[K],(n,[e])=>Uo(e.evaluate(n),n.featureState||{})],properties:[En,[],n=>n.properties()],"geometry-type":[K,[],n=>n.geometryType()],id:[Z,[],n=>n.id()],zoom:[M,[],n=>n.globals.zoom],pitch:[M,[],n=>n.globals.pitch||0],"distance-from-center":[M,[],n=>n.distanceFromCenter()],"heatmap-density":[M,[],n=>n.globals.heatmapDensity||0],"line-progress":[M,[],n=>n.globals.lineProgress||0],"sky-radial-progress":[M,[],n=>n.globals.skyRadialProgress||0],accumulated:[Z,[],n=>n.globals.accumulated===void 0?null:n.globals.accumulated],"+":[M,Ri(M),(n,e)=>{let t=0;for(const i of e)t+=i.evaluate(n);return t}],"*":[M,Ri(M),(n,e)=>{let t=1;for(const i of e)t*=i.evaluate(n);return t}],"-":{type:M,overloads:[[[M,M],(n,[e,t])=>e.evaluate(n)-t.evaluate(n)],[[M],(n,[e])=>-e.evaluate(n)]]},"/":[M,[M,M],(n,[e,t])=>e.evaluate(n)/t.evaluate(n)],"%":[M,[M,M],(n,[e,t])=>e.evaluate(n)%t.evaluate(n)],ln2:[M,[],()=>Math.LN2],pi:[M,[],()=>Math.PI],e:[M,[],()=>Math.E],"^":[M,[M,M],(n,[e,t])=>Math.pow(e.evaluate(n),t.evaluate(n))],sqrt:[M,[M],(n,[e])=>Math.sqrt(e.evaluate(n))],log10:[M,[M],(n,[e])=>Math.log(e.evaluate(n))/Math.LN10],ln:[M,[M],(n,[e])=>Math.log(e.evaluate(n))],log2:[M,[M],(n,[e])=>Math.log(e.evaluate(n))/Math.LN2],sin:[M,[M],(n,[e])=>Math.sin(e.evaluate(n))],cos:[M,[M],(n,[e])=>Math.cos(e.evaluate(n))],tan:[M,[M],(n,[e])=>Math.tan(e.evaluate(n))],asin:[M,[M],(n,[e])=>Math.asin(e.evaluate(n))],acos:[M,[M],(n,[e])=>Math.acos(e.evaluate(n))],atan:[M,[M],(n,[e])=>Math.atan(e.evaluate(n))],min:[M,Ri(M),(n,e)=>Math.min(...e.map(t=>t.evaluate(n)))],max:[M,Ri(M),(n,e)=>Math.max(...e.map(t=>t.evaluate(n)))],abs:[M,[M],(n,[e])=>Math.abs(e.evaluate(n))],round:[M,[M],(n,[e])=>{const t=e.evaluate(n);return t<0?-Math.round(-t):Math.round(t)}],floor:[M,[M],(n,[e])=>Math.floor(e.evaluate(n))],ceil:[M,[M],(n,[e])=>Math.ceil(e.evaluate(n))],"filter-==":[B,[K,Z],(n,[e,t])=>n.properties()[e.value]===t.value],"filter-id-==":[B,[Z],(n,[e])=>n.id()===e.value],"filter-type-==":[B,[K],(n,[e])=>n.geometryType()===e.value],"filter-<":[B,[K,Z],(n,[e,t])=>{const i=n.properties()[e.value],r=t.value;return typeof i==typeof r&&i{const t=n.id(),i=e.value;return typeof t==typeof i&&t":[B,[K,Z],(n,[e,t])=>{const i=n.properties()[e.value],r=t.value;return typeof i==typeof r&&i>r}],"filter-id->":[B,[Z],(n,[e])=>{const t=n.id(),i=e.value;return typeof t==typeof i&&t>i}],"filter-<=":[B,[K,Z],(n,[e,t])=>{const i=n.properties()[e.value],r=t.value;return typeof i==typeof r&&i<=r}],"filter-id-<=":[B,[Z],(n,[e])=>{const t=n.id(),i=e.value;return typeof t==typeof i&&t<=i}],"filter->=":[B,[K,Z],(n,[e,t])=>{const i=n.properties()[e.value],r=t.value;return typeof i==typeof r&&i>=r}],"filter-id->=":[B,[Z],(n,[e])=>{const t=n.id(),i=e.value;return typeof t==typeof i&&t>=i}],"filter-has":[B,[Z],(n,[e])=>e.value in n.properties()],"filter-has-id":[B,[],n=>n.id()!==null&&n.id()!==void 0],"filter-type-in":[B,[pt(K)],(n,[e])=>e.value.indexOf(n.geometryType())>=0],"filter-id-in":[B,[pt(Z)],(n,[e])=>e.value.indexOf(n.id())>=0],"filter-in-small":[B,[K,pt(Z)],(n,[e,t])=>t.value.indexOf(n.properties()[e.value])>=0],"filter-in-large":[B,[K,pt(Z)],(n,[e,t])=>y0(n.properties()[e.value],t.value,0,t.value.length-1)],all:{type:B,overloads:[[[B,B],(n,[e,t])=>e.evaluate(n)&&t.evaluate(n)],[Ri(B),(n,e)=>{for(const t of e)if(!t.evaluate(n))return!1;return!0}]]},any:{type:B,overloads:[[[B,B],(n,[e,t])=>e.evaluate(n)||t.evaluate(n)],[Ri(B),(n,e)=>{for(const t of e)if(t.evaluate(n))return!0;return!1}]]},"!":[B,[B],(n,[e])=>!e.evaluate(n)],"is-supported-script":[B,[K],(n,[e])=>{const t=n.globals&&n.globals.isSupportedScript;return t?t(e.evaluate(n)):!0}],upcase:[K,[K],(n,[e])=>e.evaluate(n).toUpperCase()],downcase:[K,[K],(n,[e])=>e.evaluate(n).toLowerCase()],concat:[K,Ri(Z),(n,e)=>e.map(t=>er(t.evaluate(n))).join("")],"resolved-locale":[K,[ho],(n,[e])=>e.evaluate(n).resolvedLocale()]});var Rd=Td;function Ra(n){return{result:"success",value:n}}function dn(n){return{result:"error",value:n}}function _0(n){return n["property-type"]==="data-driven"}function x0(n){return!!n.expression&&n.expression.parameters.indexOf("zoom")>-1}function v0(n){return!!n.expression&&n.expression.interpolated}function Sd(n){return typeof n=="object"&&n!==null&&!Array.isArray(n)}class E0{constructor(e,t){this.expression=e,this._warningHistory={},this._evaluator=new od,this._defaultValue=t?T0(t):null,this._enumValues=t&&t.type==="enum"?t.values:null}evaluateWithoutErrorHandling(e,t,i,r,s,o,a,l){return this._evaluator.globals=e,this._evaluator.feature=t,this._evaluator.featureState=i,this._evaluator.canonical=r||null,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=o,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=l||null,this.expression.evaluate(this._evaluator)}evaluate(e,t,i,r,s,o,a,l){this._evaluator.globals=e,this._evaluator.feature=t||null,this._evaluator.featureState=i||null,this._evaluator.canonical=r||null,this._evaluator.availableImages=s||null,this._evaluator.formattedSection=o||null,this._evaluator.featureTileCoord=a||null,this._evaluator.featureDistanceData=l||null;try{const u=this.expression.evaluate(this._evaluator);if(u==null||typeof u=="number"&&u!==u)return this._defaultValue;if(this._enumValues&&!(u in this._enumValues))throw new Ge(`Expected value to be one of ${Object.keys(this._enumValues).map(h=>JSON.stringify(h)).join(", ")}, but found ${JSON.stringify(u)} instead.`);return u}catch(u){return this._warningHistory[u.message]||(this._warningHistory[u.message]=!0,typeof console<"u"&&console.warn(u.message)),this._defaultValue}}}function w0(n){return Array.isArray(n)&&n.length>0&&typeof n[0]=="string"&&n[0]in Rd}function Sa(n,e){const t=new cd(Rd,[],e?b0(e):void 0),i=t.parse(n,void 0,void 0,void 0,e&&e.type==="string"?{typeAnnotation:"coerce"}:void 0);return i?Ra(new E0(i,e)):dn(t.errors)}class oh{constructor(e,t){this.kind=e,this._styleExpression=t,this.isStateDependent=e!=="constant"&&!kl(t.expression)}evaluateWithoutErrorHandling(e,t,i,r,s,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,s,o)}evaluate(e,t,i,r,s,o){return this._styleExpression.evaluate(e,t,i,r,s,o)}}class ah{constructor(e,t,i,r){this.kind=e,this.zoomStops=i,this._styleExpression=t,this.isStateDependent=e!=="camera"&&!kl(t.expression),this.interpolationType=r}evaluateWithoutErrorHandling(e,t,i,r,s,o){return this._styleExpression.evaluateWithoutErrorHandling(e,t,i,r,s,o)}evaluate(e,t,i,r,s,o){return this._styleExpression.evaluate(e,t,i,r,s,o)}interpolationFactor(e,t,i){return this.interpolationType?$i.interpolationFactor(this.interpolationType,e,t,i):0}}function C0(n,e){if(n=Sa(n,e),n.result==="error")return n;const t=n.value.expression,i=mo(t);if(!i&&!_0(e))return dn([new It("","data expressions not supported")]);const r=Ol(t,["zoom","pitch","distance-from-center"]);if(!r&&!x0(e))return dn([new It("","zoom expressions not supported")]);const s=fs(t);if(!s&&!r)return dn([new It("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.')]);if(s instanceof It)return dn([s]);if(s instanceof $i&&!v0(e))return dn([new It("",'"interpolate" expressions cannot be used with this property')]);if(!s)return Ra(i?new oh("constant",n.value):new oh("source",n.value));const o=s instanceof $i?s.interpolation:void 0;return Ra(i?new ah("camera",n.value,s.labels,o):new ah("composite",n.value,s.labels,o))}function fs(n){let e=null;if(n instanceof wd)e=fs(n.result);else if(n instanceof Ed){for(const t of n.args)if(e=fs(t),e)break}else(n instanceof fd||n instanceof $i)&&n.input instanceof $n&&n.input.name==="zoom"&&(e=n);return e instanceof It||n.eachChild(t=>{const i=fs(t);i instanceof It?e=i:!e&&i?e=new It("",'"zoom" expression may only be used as input to a top-level "step" or "interpolate" expression.'):e&&i&&e!==i&&(e=new It("",'Only one zoom-based "step" or "interpolate" subexpression may be used in an expression.'))}),e}function b0(n){const e={color:Bt,string:K,number:M,enum:K,boolean:B,formatted:co,resolvedImage:Gr};return n.type==="array"?pt(e[n.value]||Z,n.length):e[n.type]}function T0(n){return n.type==="color"&&(Sd(n.default)||Array.isArray(n.default))?new ht(0,0,0,0):n.type==="color"?ht.parse(n.default)||null:n.default===void 0?null:n.default}function R0(n){return n instanceof Number||n instanceof String||n instanceof Boolean?n.valueOf():n}function Ia(n){if(Array.isArray(n))return n.map(Ia);if(n instanceof Object&&!(n instanceof Number||n instanceof String||n instanceof Boolean)){const e={};for(const t in n)e[t]=Ia(n[t]);return e}return R0(n)}var Id={$version:8,$root:{version:{required:!0,type:"enum",values:[8]},name:{type:"string"},metadata:{type:"*"},center:{type:"array",value:"number"},zoom:{type:"number"},bearing:{type:"number",default:0,period:360,units:"degrees"},pitch:{type:"number",default:0,units:"degrees"},light:{type:"light"},terrain:{type:"terrain"},fog:{type:"fog"},sources:{required:!0,type:"sources"},sprite:{type:"string"},glyphs:{type:"string"},transition:{type:"transition"},projection:{type:"projection"},layers:{required:!0,type:"array",value:"layer"}},sources:{"*":{type:"source"}},source:["source_vector","source_raster","source_raster_dem","source_geojson","source_video","source_image"],source_vector:{type:{required:!0,type:"enum",values:{vector:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},attribution:{type:"string"},promoteId:{type:"promoteId"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster:{type:{required:!0,type:"enum",values:{raster:{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},scheme:{type:"enum",values:{xyz:{},tms:{}},default:"xyz"},attribution:{type:"string"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_raster_dem:{type:{required:!0,type:"enum",values:{"raster-dem":{}}},url:{type:"string"},tiles:{type:"array",value:"string"},bounds:{type:"array",value:"number",length:4,default:[-180,-85.051129,180,85.051129]},minzoom:{type:"number",default:0},maxzoom:{type:"number",default:22},tileSize:{type:"number",default:512,units:"pixels"},attribution:{type:"string"},encoding:{type:"enum",values:{terrarium:{},mapbox:{}},default:"mapbox"},volatile:{type:"boolean",default:!1},"*":{type:"*"}},source_geojson:{type:{required:!0,type:"enum",values:{geojson:{}}},data:{type:"*"},maxzoom:{type:"number",default:18},attribution:{type:"string"},buffer:{type:"number",default:128,maximum:512,minimum:0},filter:{type:"*"},tolerance:{type:"number",default:.375},cluster:{type:"boolean",default:!1},clusterRadius:{type:"number",default:50,minimum:0},clusterMaxZoom:{type:"number"},clusterMinPoints:{type:"number"},clusterProperties:{type:"*"},lineMetrics:{type:"boolean",default:!1},generateId:{type:"boolean",default:!1},promoteId:{type:"promoteId"}},source_video:{type:{required:!0,type:"enum",values:{video:{}}},urls:{required:!0,type:"array",value:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},source_image:{type:{required:!0,type:"enum",values:{image:{}}},url:{required:!0,type:"string"},coordinates:{required:!0,type:"array",length:4,value:{type:"array",length:2,value:"number"}}},layer:{id:{type:"string",required:!0},type:{type:"enum",values:{fill:{},line:{},symbol:{},circle:{},heatmap:{},"fill-extrusion":{},raster:{},hillshade:{},background:{},sky:{}},required:!0},metadata:{type:"*"},source:{type:"string"},"source-layer":{type:"string"},minzoom:{type:"number",minimum:0,maximum:24},maxzoom:{type:"number",minimum:0,maximum:24},filter:{type:"filter"},layout:{type:"layout"},paint:{type:"paint"}},layout:["layout_fill","layout_line","layout_circle","layout_heatmap","layout_fill-extrusion","layout_symbol","layout_raster","layout_hillshade","layout_background","layout_sky"],layout_background:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_sky:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_fill:{"fill-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_circle:{"circle-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_heatmap:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},"layout_fill-extrusion":{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"},"fill-extrusion-edge-radius":{type:"number",private:!0,default:0,minimum:0,maximum:1,"property-type":"constant"}},layout_line:{"line-cap":{type:"enum",values:{butt:{},round:{},square:{}},default:"butt",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-join":{type:"enum",values:{bevel:{},round:{},miter:{}},default:"miter",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-miter-limit":{type:"number",default:2,requires:[{"line-join":"miter"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-round-limit":{type:"number",default:1.05,requires:[{"line-join":"round"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_symbol:{"symbol-placement":{type:"enum",values:{point:{},line:{},"line-center":{}},default:"point",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-spacing":{type:"number",default:250,minimum:1,units:"pixels",requires:[{"symbol-placement":"line"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"symbol-avoid-edges":{type:"boolean",default:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"symbol-sort-key":{type:"number",expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"symbol-z-order":{type:"enum",values:{auto:{},"viewport-y":{},source:{}},default:"auto",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-allow-overlap":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-ignore-placement":{type:"boolean",default:!1,requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-optional":{type:"boolean",default:!1,requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-size":{type:"number",default:1,minimum:0,units:"factor of the original icon size",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-text-fit":{type:"enum",values:{none:{},width:{},height:{},both:{}},default:"none",requires:["icon-image","text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-text-fit-padding":{type:"array",value:"number",length:4,default:[0,0,0,0],units:"pixels",requires:["icon-image","text-field",{"icon-text-fit":["both","width","height"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-image":{type:"resolvedImage",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-keep-upright":{type:"boolean",default:!1,requires:["icon-image",{"icon-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"icon-offset":{type:"array",value:"number",length:2,default:[0,0],requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"icon-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-pitch-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotation-alignment":{type:"enum",values:{map:{},viewport:{},auto:{}},default:"auto",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-field":{type:"formatted",default:"",tokens:!0,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-font":{type:"array",value:"string",default:["Open Sans Regular","Arial Unicode MS Regular"],requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-size":{type:"number",default:16,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-width":{type:"number",default:10,minimum:0,units:"ems",requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-line-height":{type:"number",default:1.2,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-letter-spacing":{type:"number",default:0,units:"ems",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-justify":{type:"enum",values:{auto:{},left:{},center:{},right:{}},default:"center",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-radial-offset":{type:"number",units:"ems",default:0,requires:["text-field"],"property-type":"data-driven",expression:{interpolated:!0,parameters:["zoom","feature"]}},"text-variable-anchor":{type:"array",value:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},requires:["text-field",{"symbol-placement":["point"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-anchor":{type:"enum",values:{center:{},left:{},right:{},top:{},bottom:{},"top-left":{},"top-right":{},"bottom-left":{},"bottom-right":{}},default:"center",requires:["text-field",{"!":"text-variable-anchor"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-max-angle":{type:"number",default:45,units:"degrees",requires:["text-field",{"symbol-placement":["line","line-center"]}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-writing-mode":{type:"array",value:"enum",values:{horizontal:{},vertical:{}},requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-rotate":{type:"number",default:0,period:360,units:"degrees",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-padding":{type:"number",default:2,minimum:0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-keep-upright":{type:"boolean",default:!0,requires:["text-field",{"text-rotation-alignment":"map"},{"symbol-placement":["line","line-center"]}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-transform":{type:"enum",values:{none:{},uppercase:{},lowercase:{}},default:"none",requires:["text-field"],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-offset":{type:"array",value:"number",units:"ems",length:2,default:[0,0],requires:["text-field",{"!":"text-radial-offset"}],expression:{interpolated:!0,parameters:["zoom","feature"]},"property-type":"data-driven"},"text-allow-overlap":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-ignore-placement":{type:"boolean",default:!1,requires:["text-field"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-optional":{type:"boolean",default:!1,requires:["text-field","icon-image"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_raster:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},layout_hillshade:{visibility:{type:"enum",values:{visible:{},none:{}},default:"visible","property-type":"constant"}},filter:{type:"array",value:"*"},filter_symbol:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature","pitch","distance-from-center"]}},filter_fill:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},filter_line:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},filter_circle:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},"filter_fill-extrusion":{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},filter_heatmap:{type:"boolean",default:!1,transition:!1,"property-type":"data-driven",expression:{interpolated:!1,parameters:["zoom","feature"]}},filter_operator:{type:"enum",values:{"==":{},"!=":{},">":{},">=":{},"<":{},"<=":{},in:{},"!in":{},all:{},any:{},none:{},has:{},"!has":{},within:{}}},geometry_type:{type:"enum",values:{Point:{},LineString:{},Polygon:{}}},function:{expression:{type:"expression"},stops:{type:"array",value:"function_stop"},base:{type:"number",default:1,minimum:0},property:{type:"string",default:"$zoom"},type:{type:"enum",values:{identity:{},exponential:{},interval:{},categorical:{}},default:"exponential"},colorSpace:{type:"enum",values:{rgb:{},lab:{},hcl:{}},default:"rgb"},default:{type:"*",required:!1}},function_stop:{type:"array",minimum:0,maximum:24,value:["number","color"],length:2},expression:{type:"array",value:"*",minimum:1},expression_name:{type:"enum",values:{let:{group:"Variable binding"},var:{group:"Variable binding"},literal:{group:"Types"},array:{group:"Types"},at:{group:"Lookup"},in:{group:"Lookup"},"index-of":{group:"Lookup"},slice:{group:"Lookup"},case:{group:"Decision"},match:{group:"Decision"},coalesce:{group:"Decision"},step:{group:"Ramps, scales, curves"},interpolate:{group:"Ramps, scales, curves"},"interpolate-hcl":{group:"Ramps, scales, curves"},"interpolate-lab":{group:"Ramps, scales, curves"},ln2:{group:"Math"},pi:{group:"Math"},e:{group:"Math"},typeof:{group:"Types"},string:{group:"Types"},number:{group:"Types"},boolean:{group:"Types"},object:{group:"Types"},collator:{group:"Types"},format:{group:"Types"},image:{group:"Types"},"number-format":{group:"Types"},"to-string":{group:"Types"},"to-number":{group:"Types"},"to-boolean":{group:"Types"},"to-rgba":{group:"Color"},"to-color":{group:"Types"},rgb:{group:"Color"},rgba:{group:"Color"},get:{group:"Lookup"},has:{group:"Lookup"},length:{group:"Lookup"},properties:{group:"Feature data"},"feature-state":{group:"Feature data"},"geometry-type":{group:"Feature data"},id:{group:"Feature data"},zoom:{group:"Camera"},pitch:{group:"Camera"},"distance-from-center":{group:"Camera"},"heatmap-density":{group:"Heatmap"},"line-progress":{group:"Feature data"},"sky-radial-progress":{group:"sky"},accumulated:{group:"Feature data"},"+":{group:"Math"},"*":{group:"Math"},"-":{group:"Math"},"/":{group:"Math"},"%":{group:"Math"},"^":{group:"Math"},sqrt:{group:"Math"},log10:{group:"Math"},ln:{group:"Math"},log2:{group:"Math"},sin:{group:"Math"},cos:{group:"Math"},tan:{group:"Math"},asin:{group:"Math"},acos:{group:"Math"},atan:{group:"Math"},min:{group:"Math"},max:{group:"Math"},round:{group:"Math"},abs:{group:"Math"},ceil:{group:"Math"},floor:{group:"Math"},distance:{group:"Math"},"==":{group:"Decision"},"!=":{group:"Decision"},">":{group:"Decision"},"<":{group:"Decision"},">=":{group:"Decision"},"<=":{group:"Decision"},all:{group:"Decision"},any:{group:"Decision"},"!":{group:"Decision"},within:{group:"Decision"},"is-supported-script":{group:"String"},upcase:{group:"String"},downcase:{group:"String"},concat:{group:"String"},"resolved-locale":{group:"String"}}},fog:{range:{type:"array",default:[.5,10],minimum:-20,maximum:20,length:2,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"high-color":{type:"color","property-type":"data-constant",default:"#245cdf",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"space-color":{type:"color","property-type":"data-constant",default:["interpolate",["linear"],["zoom"],4,"#010b19",7,"#367ab9"],expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"horizon-blend":{type:"number","property-type":"data-constant",default:["interpolate",["linear"],["zoom"],4,.2,7,.1],minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"star-intensity":{type:"number","property-type":"data-constant",default:["interpolate",["linear"],["zoom"],5,.35,6,0],minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},light:{anchor:{type:"enum",default:"viewport",values:{map:{},viewport:{}},"property-type":"data-constant",transition:!1,expression:{interpolated:!1,parameters:["zoom"]}},position:{type:"array",default:[1.15,210,30],length:3,value:"number","property-type":"data-constant",transition:!0,expression:{interpolated:!0,parameters:["zoom"]}},color:{type:"color","property-type":"data-constant",default:"#ffffff",expression:{interpolated:!0,parameters:["zoom"]},transition:!0},intensity:{type:"number","property-type":"data-constant",default:.5,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0}},projection:{name:{type:"enum",values:{albers:{},equalEarth:{},equirectangular:{},lambertConformalConic:{},mercator:{},naturalEarth:{},winkelTripel:{},globe:{}},default:"mercator",required:!0},center:{type:"array",length:2,value:"number","property-type":"data-constant",minimum:[-180,-90],maximum:[180,90],transition:!1,requires:[{name:["albers","lambertConformalConic"]}]},parallels:{type:"array",length:2,value:"number","property-type":"data-constant",minimum:[-90,-90],maximum:[90,90],transition:!1,requires:[{name:["albers","lambertConformalConic"]}]}},terrain:{source:{type:"string",required:!0},exaggeration:{type:"number","property-type":"data-constant",default:1,minimum:0,maximum:1e3,expression:{interpolated:!0,parameters:["zoom"]},transition:!0,requires:["source"]}},paint:["paint_fill","paint_line","paint_circle","paint_heatmap","paint_fill-extrusion","paint_symbol","paint_raster","paint_hillshade","paint_background","paint_sky"],paint_fill:{"fill-antialias":{type:"boolean",default:!0,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-outline-color":{type:"color",transition:!0,requires:[{"!":"fill-pattern"},{"fill-antialias":!0}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-pattern":{type:"resolvedImage",transition:!1,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"}},"paint_fill-extrusion":{"fill-extrusion-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"fill-extrusion-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["fill-extrusion-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-pattern":{type:"resolvedImage",transition:!1,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"fill-extrusion-height":{type:"number",default:0,minimum:0,units:"meters",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-base":{type:"number",default:0,minimum:0,units:"meters",transition:!0,requires:["fill-extrusion-height"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"fill-extrusion-vertical-gradient":{type:"boolean",default:!0,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"fill-extrusion-ambient-occlusion-intensity":{"property-type":"data-constant",type:"number",private:!0,default:0,minimum:0,maximum:1,expression:{interpolated:!0,parameters:["zoom"]},transition:!0},"fill-extrusion-ambient-occlusion-radius":{"property-type":"data-constant",type:"number",private:!0,default:3,minimum:0,expression:{interpolated:!0,parameters:["zoom"]},transition:!0,requires:["fill-extrusion-edge-radius"]}},paint_line:{"line-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"line-pattern"}],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"line-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["line-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"line-width":{type:"number",default:1,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-gap-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-offset":{type:"number",default:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"line-dasharray":{type:"array",value:"number",minimum:0,transition:!1,units:"line widths",requires:[{"!":"line-pattern"}],expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-pattern":{type:"resolvedImage",transition:!1,expression:{interpolated:!1,parameters:["zoom","feature"]},"property-type":"data-driven"},"line-gradient":{type:"color",transition:!1,requires:[{"!":"line-pattern"},{source:"geojson",has:{lineMetrics:!0}}],expression:{interpolated:!0,parameters:["line-progress"]},"property-type":"color-ramp"},"line-trim-offset":{type:"array",value:"number",length:2,default:[0,0],minimum:[0,0],maximum:[1,1],transition:!1,requires:[{source:"geojson",has:{lineMetrics:!0}}],"property-type":"constant"}},paint_circle:{"circle-radius":{type:"number",default:5,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-blur":{type:"number",default:0,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"circle-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["circle-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-scale":{type:"enum",values:{map:{},viewport:{}},default:"map",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-pitch-alignment":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"circle-stroke-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"circle-stroke-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"}},paint_heatmap:{"heatmap-radius":{type:"number",default:30,minimum:1,transition:!0,units:"pixels",expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-weight":{type:"number",default:1,minimum:0,transition:!1,expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"heatmap-intensity":{type:"number",default:1,minimum:0,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"heatmap-color":{type:"color",default:["interpolate",["linear"],["heatmap-density"],0,"rgba(0, 0, 255, 0)",.1,"royalblue",.3,"cyan",.5,"lime",.7,"yellow",1,"red"],transition:!1,expression:{interpolated:!0,parameters:["heatmap-density"]},"property-type":"color-ramp"},"heatmap-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_symbol:{"icon-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-color":{type:"color",default:"#000000",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"icon-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["icon-image"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"icon-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["icon-image","icon-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"text-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-color":{type:"color",default:"#000000",transition:!0,overridable:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-color":{type:"color",default:"rgba(0, 0, 0, 0)",transition:!0,requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-width":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-halo-blur":{type:"number",default:0,minimum:0,transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom","feature","feature-state"]},"property-type":"data-driven"},"text-translate":{type:"array",value:"number",length:2,default:[0,0],transition:!0,units:"pixels",requires:["text-field"],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"text-translate-anchor":{type:"enum",values:{map:{},viewport:{}},default:"map",requires:["text-field","text-translate"],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"}},paint_raster:{"raster-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-hue-rotate":{type:"number",default:0,period:360,transition:!0,units:"degrees",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-min":{type:"number",default:0,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-brightness-max":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-saturation":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-contrast":{type:"number",default:0,minimum:-1,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"raster-resampling":{type:"enum",values:{linear:{},nearest:{}},default:"linear",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"raster-fade-duration":{type:"number",default:300,minimum:0,transition:!1,units:"milliseconds",expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_hillshade:{"hillshade-illumination-direction":{type:"number",default:335,minimum:0,maximum:359,transition:!1,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-illumination-anchor":{type:"enum",values:{map:{},viewport:{}},default:"viewport",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-exaggeration":{type:"number",default:.5,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-shadow-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-highlight-color":{type:"color",default:"#FFFFFF",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"hillshade-accent-color":{type:"color",default:"#000000",transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_background:{"background-color":{type:"color",default:"#000000",transition:!0,requires:[{"!":"background-pattern"}],expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"},"background-pattern":{type:"resolvedImage",transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"background-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},paint_sky:{"sky-type":{type:"enum",values:{gradient:{},atmosphere:{}},default:"atmosphere",expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun":{type:"array",value:"number",length:2,units:"degrees",minimum:[0,0],maximum:[360,180],transition:!1,requires:[{"sky-type":"atmosphere"}],expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-atmosphere-sun-intensity":{type:"number",requires:[{"sky-type":"atmosphere"}],default:10,minimum:0,maximum:100,transition:!1,"property-type":"data-constant"},"sky-gradient-center":{type:"array",requires:[{"sky-type":"gradient"}],value:"number",default:[0,0],length:2,units:"degrees",minimum:[0,0],maximum:[360,180],transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-gradient-radius":{type:"number",requires:[{"sky-type":"gradient"}],default:90,minimum:0,maximum:180,transition:!1,expression:{interpolated:!1,parameters:["zoom"]},"property-type":"data-constant"},"sky-gradient":{type:"color",default:["interpolate",["linear"],["sky-radial-progress"],.8,"#87ceeb",1,"white"],transition:!1,requires:[{"sky-type":"gradient"}],expression:{interpolated:!0,parameters:["sky-radial-progress"]},"property-type":"color-ramp"},"sky-atmosphere-halo-color":{type:"color",default:"white",transition:!1,requires:[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-atmosphere-color":{type:"color",default:"white",transition:!1,requires:[{"sky-type":"atmosphere"}],"property-type":"data-constant"},"sky-opacity":{type:"number",default:1,minimum:0,maximum:1,transition:!0,expression:{interpolated:!0,parameters:["zoom"]},"property-type":"data-constant"}},transition:{duration:{type:"number",default:300,minimum:0,units:"milliseconds"},delay:{type:"number",default:0,minimum:0,units:"milliseconds"}},"property-type":{"data-driven":{type:"property-type"},"color-ramp":{type:"property-type"},"data-constant":{type:"property-type"},constant:{type:"property-type"}},promoteId:{"*":{type:"string"}}};function Ad(n){if(n===!0||n===!1)return!0;if(!Array.isArray(n)||n.length===0)return!1;switch(n[0]){case"has":return n.length>=2&&n[1]!=="$id"&&n[1]!=="$type";case"in":return n.length>=3&&(typeof n[1]!="string"||Array.isArray(n[2]));case"!in":case"!has":case"none":return!1;case"==":case"!=":case">":case">=":case"<":case"<=":return n.length!==3||Array.isArray(n[1])||Array.isArray(n[2]);case"any":case"all":for(const e of n.slice(1))if(!Ad(e)&&typeof e!="boolean")return!1;return!0;default:return!0}}function S0(n,e="fill"){if(n==null)return{filter:()=>!0,needGeometry:!1,needFeature:!1};Ad(n)||(n=$s(n));const t=n;let i=!0;try{i=I0(t)}catch{console.warn(`Failed to extract static filter. Filter will continue working, but at higher memory usage and slower framerate. +This is most likely a bug, please report this via https://github.com/mapbox/mapbox-gl-js/issues/new?assignees=&labels=&template=Bug_report.md +and paste the contents of this message in the report. +Thank you! +Filter Expression: +${JSON.stringify(t,null,2)} + `)}const r=Id[`filter_${e}`],s=Sa(i,r);let o=null;if(s.result==="error")throw new Error(s.value.map(h=>`${h.key}: ${h.message}`).join(", "));o=(h,c,d)=>s.value.evaluate(h,c,{},d);let a=null,l=null;if(i!==t){const h=Sa(t,r);if(h.result==="error")throw new Error(h.value.map(c=>`${c.key}: ${c.message}`).join(", "));a=(c,d,f,g,p)=>h.value.evaluate(c,d,{},f,void 0,void 0,g,p),l=!mo(h.value.expression)}o=o;const u=Pd(i);return{filter:o,dynamicFilter:a||void 0,needGeometry:u,needFeature:!!l}}function I0(n){if(!Cn(n))return n;let e=Ia(n);return Md(e),e=Fd(e),e}function Fd(n){if(!Array.isArray(n))return n;const e=M0(n);return e===!0?e:e.map(t=>Fd(t))}function Md(n){let e=!1;const t=[];if(n[0]==="case"){for(let i=1;i",">=","<","<=","to-boolean"]);function M0(n){if(F0.has(n[0]))for(let e=1;ee?1:0}function Pd(n){if(!Array.isArray(n))return!1;if(n[0]==="within")return!0;for(let e=1;e"||e==="<="||e===">="?Vo(n[1],n[2],e):e==="any"?L0(n.slice(1)):e==="all"?["all"].concat(n.slice(1).map($s)):e==="none"?["all"].concat(n.slice(1).map($s).map(ls)):e==="in"?lh(n[1],n.slice(2)):e==="!in"?ls(lh(n[1],n.slice(2))):e==="has"?uh(n[1]):e==="!has"?ls(uh(n[1])):e==="within"?n:!0}function Vo(n,e,t){switch(n){case"$type":return[`filter-type-${t}`,e];case"$id":return[`filter-id-${t}`,e];default:return[`filter-${t}`,n,e]}}function L0(n){return["any"].concat(n.map($s))}function lh(n,e){if(e.length===0)return!1;switch(n){case"$type":return["filter-type-in",["literal",e]];case"$id":return["filter-id-in",["literal",e]];default:return e.length>200&&!e.some(t=>typeof t!=typeof e[0])?["filter-in-large",n,["literal",e.sort(P0)]]:["filter-in-small",n,["literal",e]]}}function uh(n){switch(n){case"$type":return!0;case"$id":return["filter-has-id"];default:return["filter-has",n]}}function ls(n){return["!",n]}var k0=["type","source","source-layer","minzoom","maxzoom","filter","layout"];function O0(n,e){const t={};for(const i in n)i!=="ref"&&(t[i]=n[i]);return k0.forEach(i=>{i in e&&(t[i]=e[i])}),t}function D0(n){n=n.slice();const e=Object.create(null);for(let t=0;t1?d[d.length-2].toLowerCase():"";if(f==g||f==g.replace("-","")||p+"-"+f==g){r=a?r:hh[g],d.pop(),p&&g.startsWith(p)&&d.pop();break}}!a&&typeof f=="number"&&(r=f);var m=d.join(Vn).replace("Klokantech Noto Sans","Noto Sans");m.indexOf(Vn)!==-1&&(m='"'+m+'"'),o.push(m)}i=dh[n]=[s,r,o]}return i[0]+Vn+i[1]+Vn+e+"px"+(t?"/"+t:"")+Vn+i[2]},Aa=nd(z0);const Ld="https://api.mapbox.com";function Yl(n){const e="mapbox://";return n.indexOf(e)!==0?"":n.slice(e.length)}function N0(n,e,t){const i=Yl(n);if(!i)return decodeURI(new URL(n,t).href);const r="sprites/";if(i.indexOf(r)!==0)throw new Error(`unexpected sprites url: ${n}`);const s=i.slice(r.length);return`${Ld}/styles/v1/${s}/sprite?access_token=${e}`}function kd(n,e){const t=Yl(n);if(!t)return decodeURI(new URL(n,location.href).href);const i="styles/";if(t.indexOf(i)!==0)throw new Error(`unexpected style url: ${n}`);const r=t.slice(i.length);return`${Ld}/styles/v1/${r}?&access_token=${e}`}function gs(n,e,t,i){const r=new URL(n,i),s=Yl(n);if(!s)return e&&(r.searchParams.has(t)||r.searchParams.set(t,e)),decodeURI(r.href);if(s==="mapbox.satellite"){const o=window.devicePixelRatio>=1.5?"@2x":"";return`https://api.mapbox.com/v4/${s}/{z}/{x}/{y}${o}.webp?access_token=${e}`}return`https://{a-d}.tiles.mapbox.com/v4/${s}/{z}/{x}/{y}.vector.pbf?access_token=${e}`}const fh={},gh={};let G0=0;function Bl(n){return n.id||(n.id=G0++),n.id}function $0(n,e){return Bl(n)+"."+U(e)}function j0(n){let e=fh[n.id];return e||(e={},fh[Bl(n)]=e),e}function X0(n){let e=gh[n.id];return e||(e={},gh[Bl(n)]=e),e}function Yo(n){return n*Math.PI/180}const yo=function(){const n=[];for(let e=78271.51696402048;n.length<=24;e/=2)n.push(e);return n}();new Or({extent:pe("EPSG:3857").getExtent(),resolutions:yo});function Od(n,e){if(typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope&&typeof OffscreenCanvas<"u")return new OffscreenCanvas(n,e);const t=document.createElement("canvas");return t.width=n,t.height=e,t}function W0(n,e){let t=0;const i=e.length;for(;tr).then(o=>(o instanceof Request||(o=new Request(o)),o.headers.get("Accept")||o.headers.set("Accept","application/json"),i&&(i.request=o),fetch(o).then(function(a){return delete an[e],a.ok?a.json():Promise.reject(new Error("Error fetching source "+e))}).catch(function(a){return delete an[e],Promise.reject(new Error("Error fetching source "+e))})));return an[e]=[r,s],s}function U0(n,e){if(typeof n=="string")if(n.trim().startsWith("{"))try{const t=JSON.parse(n);return Promise.resolve(t)}catch(t){return Promise.reject(t)}else return n=kd(n,e.accessToken),Ln("Style",n,e);else return Promise.resolve(n)}const ph={};function V0(n,e,t={}){const i=[e,JSON.stringify(n)].toString();let r=ph[i];if(!r||t.transformRequest){let s;t.transformRequest&&(s=(a,l)=>{const u=t.transformRequest&&t.transformRequest(l,"Tiles")||l;if(a instanceof ed)a.setLoader((h,c,d)=>{ms(()=>u).then(f=>{fetch(f).then(g=>g.arrayBuffer()).then(g=>{const m=a.getFormat().readFeatures(g,{extent:h,featureProjection:d});a.setFeatures(m)}).catch(g=>a.setState(P.ERROR))})});else{const h=a.getImage();ms(()=>u).then(c=>{c instanceof Request?fetch(c).then(d=>d.blob()).then(d=>{const f=URL.createObjectURL(d);h.addEventListener("load",()=>URL.revokeObjectURL(f)),h.addEventListener("error",()=>URL.revokeObjectURL(f)),h.src=f}).catch(d=>a.setState(P.ERROR)):h.src=c})}});const o=n.url;if(o&&!n.tiles){const a=gs(o,t.accessToken,t.accessTokenParam||"access_token",e||location.href);if(o.startsWith("mapbox://"))r=Promise.resolve({tileJson:Object.assign({},n,{url:void 0,tiles:Oc(a)}),tileLoadFunction:s});else{const l={};r=Ln("Source",a,t,l).then(function(u){return u.tiles=u.tiles.map(function(h){return u.scheme==="tms"&&(h=h.replace("{y}","{-y}")),gs(h,t.accessToken,t.accessTokenParam||"access_token",l.request.url)}),Promise.resolve({tileJson:u,tileLoadFunction:s})})}}else n=Object.assign({},n,{tiles:n.tiles.map(function(a){return n.scheme==="tms"&&(a=a.replace("{y}","{-y}")),gs(a,t.accessToken,t.accessTokenParam||"access_token",e||location.href)})}),r=Promise.resolve({tileJson:Object.assign({},n),tileLoadFunction:s});ph[i]=r}return r}function mh(n,e,t,i){const r=document.createElement("canvas"),s=[2*t*e.pixelRatio+e.width,2*t*e.pixelRatio+e.height];r.width=s[0],r.height=s[1];const o=r.getContext("2d");o.drawImage(n,e.x,e.y,e.width,e.height,t*e.pixelRatio,t*e.pixelRatio,e.width,e.height);const a=o.getImageData(0,0,s[0],s[1]);o.globalCompositeOperation="destination-over",o.fillStyle=`rgba(${i.r*255},${i.g*255},${i.b*255},${i.a})`;const l=a.data;for(let u=0,h=a.width;u0&&o.arc(u,c,t*e.pixelRatio,0,2*Math.PI)}return o.fill(),r}function Y0(n,e,t){const i=Math.max(0,Math.min(1,(t-n)/(e-n)));return i*i*(3-2*i)}function yh(n,e,t){const i=document.createElement("canvas");i.width=e.width,i.height=e.height;const r=i.getContext("2d");r.drawImage(n,e.x,e.y,e.width,e.height,0,0,e.width,e.height);const s=r.getImageData(0,0,e.width,e.height),o=s.data;for(let a=0,l=s.width;a0?(o[c+0]=Math.round(255*t.r*p),o[c+1]=Math.round(255*t.g*p),o[c+2]=Math.round(255*t.b*p),o[c+3]=Math.round(255*p)):o[c+3]=0}return r.putImageData(s,0,0),i}const B0=Array(256).join(" ");function Fa(n,e){if(e>=.05){let t="";const i=n.split(` +`),r=B0.slice(0,Math.round(e/.1));for(let s=0,o=i.length;s0&&(t+=` +`),t+=i[s].split("").join(r);return t}return n}let Bo;function Dd(){return Bo||(Bo=Od(1,1).getContext("2d")),Bo}function Si(n,e){return Dd().measureText(n).width+(n.length-1)*e}const _h={};function Ma(n,e,t,i){if(n.indexOf(` +`)!==-1){const o=n.split(` +`),a=[];for(let l=0,u=o.length;l1){const a=Dd();a.font=e;const u=a.measureText("M").width*t;let h="";const c=[];for(let d=0,f=o.length;d1;++d){const g=c[d];if(Si(g,i)0?Si(c[d-1],i):1/0,m=du*.7&&Si(p,i)`${i.key}: ${i.message}`).join(", "));return t.value},Pa={},js={zoom:0};let hs,qo;function j(n,e,t,i,r,s,o){const a=n.id;s||(s={},console.warn("No functionCache provided to getValue()")),s[a]||(s[a]={});const l=s[a];if(!l[t]){let u=(n[e]||Pa)[t];const h=Id[`${e}_${n.type}`][t];u===void 0&&(u=h.default);let c=w0(u);if(!c&&Sd(u)&&(u=o_(u,h),c=!0),c){const d=ex(u,h);l[t]=d.evaluate.bind(d)}else h.type=="color"&&(u=ht.parse(u)),l[t]=function(){return u}}return js.zoom=i,l[t](js,r,o)}function xh(n,e,t,i,r){return j(n,"layout",`${i}-allow-overlap`,e,t,r)?j(n,"layout",`${i}-ignore-placement`,e,t,r)?"none":"obstacle":"declutter"}function tx(n,e,t,i,r){return r||console.warn("No filterCache provided to evaluateFilter()"),n in r||(r[n]=S0(e).filter),js.zoom=i,r[n](js,t)}function Ii(n,e){if(n){if(n.a===0||e===0)return;const t=n.a;return e=e===void 0?1:e,t===0?"transparent":"rgba("+Math.round(n.r*255/t)+","+Math.round(n.g*255/t)+","+Math.round(n.b*255/t)+","+t*e+")"}return n}const ix=/\{[^{}}]*\}/g;function Ko(n,e){return n.replace(ix,function(t){return e[t.slice(1,-1)]||""})}const nx={};function rx(n,e,t,i=yo,r=void 0,s=void 0,o=void 0,a=void 0){if(typeof e=="string"&&(e=JSON.parse(e)),e.version!=8)throw new Error("glStyle version 8 required.");nx[$0(e,n)]=Array.from(arguments);let l,u,h;if(s){if(typeof Image<"u"){const w=new Image;let C;ms(()=>s).then(I=>{I instanceof Request?fetch(I).then(z=>z.blob()).then(z=>{C=URL.createObjectURL(z),w.src=C}).catch(()=>{}):(w.crossOrigin="anonymous",w.src=I,C&&URL.revokeObjectURL(C))}),w.onload=function(){l=w,u=[w.width,w.height],n.changed(),w.onload=null}}else if(typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope){const w=self;w.postMessage({action:"loadImage",src:s}),w.addEventListener("message",function(I){I.data.action==="imageLoaded"&&I.data.src===s&&(l=I.data.image,u=[l.width,l.height])})}}const c=D0(e.layers),d={},f=[],g={},p={},m=j0(e),y=X0(e);let _;for(let w=0,C=c.length;w=S.maxzoom)continue;const re=S.filter;if(!re||tx(Re,re,L,R,y)){let q,Oe,Ze,de,Pe,D;const yt=ne.index;if(G==3&&(S.type=="fill"||S.type=="fill-extrusion"))if(Oe=j(S,"paint",S.type+"-opacity",R,L,m,T),S.type+"-pattern"in Ie){const ee=j(S,"paint",S.type+"-pattern",R,L,m,T);if(ee){const se=typeof ee=="string"?Ko(ee,z):ee.toString();if(l&&r&&r[se]){++k,D=E[k],(!D||!D.getFill()||D.getStroke()||D.getText())&&(D=new He({fill:new Xt}),E[k]=D),Ze=D.getFill(),D.setZIndex(yt);const ae=se+"."+Oe;let ue=p[ae];if(!ue){const V=r[se],H=Od(V.width,V.height),me=H.getContext("2d");me.globalAlpha=Oe,me.drawImage(l,V.x,V.y,V.width,V.height,0,0,V.width,V.height),ue=me.createPattern(H,"repeat"),p[ae]=ue}Ze.setColor(ue)}}}else q=Ii(j(S,"paint",S.type+"-color",R,L,m,T),Oe),S.type+"-outline-color"in Ie&&(Pe=Ii(j(S,"paint",S.type+"-outline-color",R,L,m,T),Oe)),Pe||(Pe=q),(q||Pe)&&(++k,D=E[k],(!D||q&&!D.getFill()||!q&&D.getFill()||Pe&&!D.getStroke()||!Pe&&D.getStroke()||D.getText())&&(D=new He({fill:q?new Xt:void 0,stroke:Pe?new Wt:void 0}),E[k]=D),q&&(Ze=D.getFill(),Ze.setColor(q)),Pe&&(de=D.getStroke(),de.setColor(Pe),de.setWidth(.5)),D.setZIndex(yt));if(G!=1&&S.type=="line"){"line-pattern"in Ie?q=void 0:q=Ii(j(S,"paint","line-color",R,L,m,T),j(S,"paint","line-opacity",R,L,m,T));const ee=j(S,"paint","line-width",R,L,m,T);q&&ee>0&&(++k,D=E[k],(!D||!D.getStroke()||D.getFill()||D.getText())&&(D=new He({stroke:new Wt}),E[k]=D),de=D.getStroke(),de.setLineCap(j(S,"layout","line-cap",R,L,m,T)),de.setLineJoin(j(S,"layout","line-join",R,L,m,T)),de.setMiterLimit(j(S,"layout","line-miter-limit",R,L,m,T)),de.setColor(q),de.setWidth(ee),de.setLineDash(Ie["line-dasharray"]?j(S,"paint","line-dasharray",R,L,m,T).map(function(se){return se*ee}):null),D.setZIndex(yt))}let _t=!1,ie=null,xt=0,vt,ve,ei;if((G==1||G==2)&&"icon-image"in A){const ee=j(S,"layout","icon-image",R,L,m,T);if(ee){vt=typeof ee=="string"?Ko(ee,z):ee.toString();let se;const ae=a?a(n,vt):void 0;if(l&&r&&r[vt]||ae){const ue=j(S,"layout","icon-rotation-alignment",R,L,m,T);if(G==2){const V=w.getGeometry();if(V.getFlatMidpoint||V.getFlatMidpoints){const H=V.getExtent();if(Math.sqrt(Math.max(Math.pow((H[2]-H[0])/C,2),Math.pow((H[3]-H[1])/C,2)))>150){const J=V.getType()==="MultiLineString"?V.getFlatMidpoints():V.getFlatMidpoint();if(qo||(hs=[NaN,NaN],qo=new Vi("Point",hs,[],2,{},void 0)),se=qo,hs[0]=J[0],hs[1]=J[1],j(S,"layout","symbol-placement",R,L,m,T)==="line"&&ue==="map"){const qe=V.getStride(),ze=V.getFlatCoordinates();for(let Ne=0,_e=ze.length-qe;Ne<_e;Ne+=qe){const We=ze[Ne],Ke=ze[Ne+1],Ue=ze[Ne+qe],Ce=ze[Ne+qe+1],Et=Math.min(We,Ue),Ci=Math.min(Ke,Ce),Xr=Math.max(We,Ue),Wr=Math.max(Ke,Ce);if(J[0]>=Et&&J[0]<=Xr&&J[1]>=Ci&&J[1]<=Wr){xt=Math.atan2(Ke-Ce,Ue-We);break}}}}}}if(G!==2||se){const V=j(S,"layout","icon-size",R,L,m,T),H=Ie["icon-color"]!==void 0?j(S,"paint","icon-color",R,L,m,T):null;if(!H||H.a!==0){const me=j(S,"paint","icon-halo-color",R,L,m,T),J=j(S,"paint","icon-halo-width",R,L,m,T);let Xe=`${vt}.${V}.${J}.${me}`;if(H!==null&&(Xe+=`.${H}`),ve=g[Xe],!ve){const qe=xh(S,R,L,"icon",m);let ze;"icon-offset"in A&&(ze=j(S,"layout","icon-offset",R,L,m,T).slice(0),ze[0]*=V,ze[1]*=-V);let Ne=H?[H.r*255,H.g*255,H.b*255,H.a]:void 0;if(ae){const _e={color:Ne,rotateWithView:ue==="map",displacement:ze,declutterMode:qe,scale:V};typeof ae=="string"?_e.src=ae:(_e.img=ae,_e.imgSize=[ae.width,ae.height]),ve=new Xi(_e)}else{const _e=r[vt];let We,Ke,Ue;J?_e.sdf?(We=mh(yh(l,_e,H||[0,0,0,1]),{x:0,y:0,width:_e.width,height:_e.height,pixelRatio:_e.pixelRatio},J,me),Ne=void 0):We=mh(l,_e,J,me):(_e.sdf?(h||(h=yh(l,{x:0,y:0,width:u[0],height:u[1]},{r:1,g:1,b:1,a:1})),We=h):We=l,Ke=[_e.width,_e.height],Ue=[_e.x,_e.y]),ve=new Xi({color:Ne,img:We,imgSize:u,size:Ke,offset:Ue,rotateWithView:ue==="map",scale:V/_e.pixelRatio,displacement:ze,declutterMode:qe})}g[Xe]=ve}}ve&&(++k,D=E[k],(!D||!D.getImage()||D.getFill()||D.getStroke())&&(D=new He,E[k]=D),D.setGeometry(se),ve.setRotation(xt+Yo(j(S,"layout","icon-rotate",R,L,m,T))),ve.setOpacity(j(S,"paint","icon-opacity",R,L,m,T)),ve.setAnchor(Q0[j(S,"layout","icon-anchor",R,L,m,T)]),D.setImage(ve),ie=D.getText(),D.setText(void 0),D.setZIndex(yt),_t=!0,ei=!1)}else ei=!0}}}if(G==1&&S.type==="circle"){++k,D=E[k],(!D||!D.getImage()||D.getFill()||D.getStroke())&&(D=new He,E[k]=D);const ee="circle-radius"in Ie?j(S,"paint","circle-radius",R,L,m,T):5,se=Ii(j(S,"paint","circle-stroke-color",R,L,m,T),j(S,"paint","circle-stroke-opacity",R,L,m,T)),ae=j(S,"paint","circle-translate",R,L,m,T),ue=Ii(j(S,"paint","circle-color",R,L,m,T),j(S,"paint","circle-opacity",R,L,m,T)),V=j(S,"paint","circle-stroke-width",R,L,m,T),H=ee+"."+se+"."+ue+"."+V+"."+ae[0]+"."+ae[1];ve=g[H],ve||(ve=new Fr({radius:ee,displacement:[ae[0],-ae[1]],stroke:se&&V>0?new Wt({width:V,color:se}):void 0,fill:ue?new Xt({color:ue}):void 0,declutterMode:"none"}),g[H]=ve),D.setImage(ve),ie=D.getText(),D.setText(void 0),D.setGeometry(void 0),D.setZIndex(yt),_t=!0}let we,Tt,ct,dt,Ae,je;if("text-field"in A){dt=Math.round(j(S,"layout","text-size",R,L,m,T));const ee=j(S,"layout","text-font",R,L,m,T);ct=j(S,"layout","text-line-height",R,L,m,T),Tt=Aa(o?o(ee,e.metadata?e.metadata["ol:webfonts"]:void 0):ee,dt,ct),Tt.includes("sans-serif")||(Tt+=",sans-serif"),Ae=j(S,"layout","text-letter-spacing",R,L,m,T),je=j(S,"layout","text-max-width",R,L,m,T);const se=j(S,"layout","text-field",R,L,m,T);typeof se=="object"&&se.sections?se.sections.length===1?we=se.toString():we=se.sections.reduce((ae,ue,V)=>{const H=ue.fontStack?ue.fontStack.split(","):ee,me=Aa(o?o(H):H,dt*(ue.scale||1),ct);let J=ue.text;if(J===` +`)return ae.push(` +`,""),ae;if(G==2){ae.push(Fa(J,Ae),me);return}J=Ma(J,me,je,Ae).split(` +`);for(let Xe=0,qe=J.length;Xe0&&ae.push(` +`,""),ae.push(J[Xe],me);return ae},[]):we=Ko(se,z).trim(),Oe=j(S,"paint","text-opacity",R,L,m,T)}if(we&&Oe&&!ei){_t||(++k,D=E[k],(!D||!D.getText()||D.getFill()||D.getStroke())&&(D=new He,E[k]=D),D.setImage(void 0),D.setGeometry(void 0));const ee=xh(S,R,L,"text",m);D.getText()||D.setText(ie),ie=D.getText(),(!ie||"getDeclutterMode"in ie&&ie.getDeclutterMode()!==ee)&&(ie=new Mr({padding:[2,2,2,2],declutterMode:ee}),D.setText(ie));const se=j(S,"layout","text-transform",R,L,m,T);se=="uppercase"?we=Array.isArray(we)?we.map((Ce,Et)=>Et%2?Ce:Ce.toUpperCase()):we.toUpperCase():se=="lowercase"&&(we=Array.isArray(we)?we.map((Ce,Et)=>Et%2?Ce:Ce.toLowerCase()):we.toLowerCase());const ae=Array.isArray(we)?we:G==2?Fa(we,Ae):Ma(we,Tt,je,Ae);ie.setText(ae),ie.setFont(Tt),ie.setRotation(Yo(j(S,"layout","text-rotate",R,L,m,T)));const ue=j(S,"layout","text-anchor",R,L,m,T),V=_t||G==1?"point":j(S,"layout","symbol-placement",R,L,m,T);let H;if(V==="line-center"?(ie.setPlacement("line"),H="center"):ie.setPlacement(V),V==="line"&&typeof ie.setRepeat=="function"){const Ce=j(S,"layout","symbol-spacing",R,L,m,T);ie.setRepeat(Ce*2)}ie.setOverflow(V==="point");let me=j(S,"paint","text-halo-width",R,L,m,T);const J=j(S,"layout","text-offset",R,L,m,T),Xe=j(S,"paint","text-translate",R,L,m,T);let qe=0,ze=0;if(V=="point"){H="center",ue.indexOf("left")!==-1?(H="left",ze=me):ue.indexOf("right")!==-1&&(H="right",ze=-me);const Ce=j(S,"layout","text-rotation-alignment",R,L,m,T);ie.setRotateWithView(Ce=="map")}else ie.setMaxAngle(Yo(j(S,"layout","text-max-angle",R,L,m,T))*we.length/ae.length),ie.setRotateWithView(!1);ie.setTextAlign(H);let Ne="middle";ue.indexOf("bottom")==0?(Ne="bottom",qe=-me-.5*(ct-1)*dt):ue.indexOf("top")==0&&(Ne="top",qe=me+.5*(ct-1)*dt),ie.setTextBaseline(Ne);const _e=j(S,"layout","text-justify",R,L,m,T);ie.setJustify(_e==="auto"?void 0:_e),ie.setOffsetX(J[0]*dt+ze+Xe[0]),ie.setOffsetY(J[1]*dt+qe+Xe[1]),x.setColor(Ii(j(S,"paint","text-color",R,L,m,T),Oe)),ie.setFill(x);const We=Ii(j(S,"paint","text-halo-color",R,L,m,T),Oe);if(We&&me>0){v.setColor(We),me*=2;const Ce=.5*dt;v.setWidth(me<=Ce?me:Ce),ie.setStroke(v)}else ie.setStroke(void 0);const Ke=j(S,"layout","text-padding",R,L,m,T),Ue=ie.getPadding();Ke!==Ue[0]&&(Ue[0]=Ke,Ue[1]=Ke,Ue[2]=Ke,Ue[3]=Ke),D.setZIndex(yt)}}}if(k>-1)return E.length=k+1,E};return n.setStyle(b),n.set("mapbox-source",_),n.set("mapbox-layers",f),n.set("mapbox-featurestate",n.get("mapbox-featurestate")||{}),b}function sx(n,e=512){return n.getExtent()?so({extent:n.getExtent(),tileSize:e,maxZoom:22}).getResolutions():yo}function ox(n,e){return e.accessToken||(e=Object.assign({},e),new URL(n).searchParams.forEach((i,r)=>{e.accessToken=i,e.accessTokenParam=r})),e}function ax(n,e,t="",i={},r=void 0){let s,o,a,l,u=!0;return typeof t!="string"&&!Array.isArray(t)?(a=t,l=a.source||a.layers,i=a):l=t,typeof i=="string"?(s=i,a={}):(s=i.styleUrl,a=i),a.updateSource===!1&&(u=!1),r||(r=a.resolutions),!s&&typeof e=="string"&&!e.trim().startsWith("{")&&(s=e),s&&(s=s.startsWith("data:")?location.href:kd(s,a.accessToken),a=ox(s,a)),new Promise(function(h,c){U0(e,a).then(function(d){if(d.version!=8)return c(new Error("glStyle version 8 required."));if(!(n instanceof Jc||n instanceof Jn))return c(new Error("Can only apply to VectorLayer or VectorTileLayer"));const f=n instanceof Jn?"vector":"geojson";if(l?Array.isArray(l)?o=d.layers.find(function(x){return x.id===l[0]}).source:o=l:(o=Object.keys(d.sources).find(function(x){return d.sources[x].type===f}),l=o),!o)return c(new Error(`No ${f} source found in the glStyle.`));function g(){if(!u)return Promise.resolve();if(n instanceof Jn)return hx(d.sources[o],s,a).then(function(w){const C=n.getSource();if(C?w!==C&&(C.setTileUrlFunction(w.getTileUrlFunction()),typeof C.setUrls=="function"&&typeof w.getUrls=="function"&&C.setUrls(w.getUrls()),C.format_||(C.format_=w.format_),C.getAttributions()||C.setAttributions(w.getAttributions()),C.getTileLoadFunction()===id&&C.setTileLoadFunction(w.getTileLoadFunction()),ui(C.getProjection(),w.getProjection())&&(C.tileGrid=w.getTileGrid())):n.setSource(w),!isFinite(n.getMaxResolution())&&!isFinite(n.getMinZoom())){const I=n.getSource().getTileGrid();n.setMaxResolution(I.getResolution(I.getMinZoom()))}});const x=d.sources[o];let E=n.getSource();(!E||E.get("mapbox-source")!==x)&&(E=dx(x,s,a));const b=n.getSource();return b?E!==b&&(b.getAttributions()||b.setAttributions(E.getAttributions()),b.format_||(b.format_=E.getFormat()),b.url_=E.getUrl()):n.setSource(E),Promise.resolve()}let p,m,y,_;function v(){if(!_&&(!d.sprite||m)){if(a.projection&&!r){const E=pe(a.projection).getUnits();E!=="m"&&(r=yo.map(b=>b/Rn[E]))}_=rx(n,d,l,r,m,y,H0,a.getImage),n.getStyle()?g().then(h).catch(c):c(new Error(`Nothing to show for source [${o}]`))}else _?(n.setStyle(_),g().then(h).catch(c)):c(new Error("Something went wrong trying to apply style."))}if(d.sprite){const x=new URL(N0(d.sprite,a.accessToken,s||location.href));p=window.devicePixelRatio>=1.5?.5:1;const E=p==.5?"@2x":"";let b=x.origin+x.pathname+E+".json"+x.search;new Promise(function(w,C){Ln("Sprite",b,a).then(w).catch(function(I){b=x.origin+x.pathname+".json"+x.search,Ln("Sprite",b,a).then(w).catch(C)})}).then(function(w){if(w===void 0&&c(new Error("No sprites found.")),m=w,y=x.origin+x.pathname+E+".png"+x.search,a.transformRequest){const C=a.transformRequest(y,"SpriteImage")||y;(C instanceof Request||C instanceof Promise)&&(y=C)}v()}).catch(function(w){c(new Error(`Sprites cannot be loaded: ${b}: ${w.message}`))})}else v()}).catch(c)})}function lx(n,e){const t=n.bounds;if(t){const i=ws([t[0],t[1]],e),r=ws([t[2],t[3]],e);return[i[0],i[1],r[0],r[1]]}return pe(e).getExtent()}function ux(n,e,t){const i=new n_({tileJSON:e,tileSize:n.tileSize||e.tileSize||512}),r=i.getTileJSON(),s=i.getTileGrid(),o=pe(t.projection||"EPSG:3857"),a=lx(r,o),l=o.getExtent(),u=r.minzoom||0,h=r.maxzoom||22,c={attributions:i.getAttributions(),projection:o,tileGrid:new Or({origin:l?Qt(l):s.getOrigin(0),extent:a||s.getExtent(),minZoom:u,resolutions:sx(o,e.tileSize).slice(0,h+1),tileSize:s.getTileSize(0)})};return Array.isArray(r.tiles)?c.urls=r.tiles:c.url=r.tiles,c}function hx(n,e,t){return new Promise(function(i,r){V0(n,e,t).then(function({tileJson:s,tileLoadFunction:o}){const a=ux(n,s,t);a.tileLoadFunction=o,a.format=new ol,i(new td(a))}).catch(r)})}function cx(n){return`{bbox-${(n?n.getCode():"EPSG:3857").toLowerCase().replace(/[^a-z0-9]/g,"-")}}`}function dx(n,e,t){const i=t.projection?new wu({dataProjection:t.projection}):new wu,r=n.data,s={};if(typeof r=="string"){const a=gs(r,t.accessToken,t.accessTokenParam||"access_token",e||location.href);if(/\{bbox-[0-9a-z-]+\}/.test(a)){const u=(c,d,f)=>{const g=cx(f);return a.replace(g,`${c.join(",")}`)},h=new ds({attributions:n.attribution,format:i,loader:(c,d,f,g,p)=>{const m=typeof u=="function"?u(c,d,f):u;Ln("GeoJSON",m,t).then(y=>{const _=h.getFormat().readFeatures(y,{featureProjection:f});h.addFeatures(_),g(_)}).catch(y=>{h.removeLoadedExtent(c),p()})},strategy:qy});return h.set("mapbox-source",n),h}const l=new ds({attributions:n.attribution,format:i,url:a,loader:(u,h,c,d,f)=>{Ln("GeoJSON",a,t).then(g=>{const p=l.getFormat().readFeatures(g,{featureProjection:c});l.addFeatures(p),d(p)}).catch(g=>{l.removeLoadedExtent(u),f()})}});return l}s.features=i.readFeatures(r,{featureProjection:"EPSG:3857"});const o=new ds(Object.assign({attributions:n.attribution,format:i},s));return o.set("mapbox-source",n),o}/** + * @license + * Copyright 2019 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const ps=globalThis,Zl=ps.ShadowRoot&&(ps.ShadyCSS===void 0||ps.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,ql=Symbol(),vh=new WeakMap;let zd=class{constructor(e,t,i){if(this._$cssResult$=!0,i!==ql)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=e,this.t=t}get styleSheet(){let e=this.o;const t=this.t;if(Zl&&e===void 0){const i=t!==void 0&&t.length===1;i&&(e=vh.get(t)),e===void 0&&((this.o=e=new CSSStyleSheet).replaceSync(this.cssText),i&&vh.set(t,e))}return e}toString(){return this.cssText}};const fx=n=>new zd(typeof n=="string"?n:n+"",void 0,ql),Nd=(n,...e)=>{const t=n.length===1?n[0]:e.reduce((i,r,s)=>i+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(r)+n[s+1],n[0]);return new zd(t,n,ql)},gx=(n,e)=>{if(Zl)n.adoptedStyleSheets=e.map(t=>t instanceof CSSStyleSheet?t:t.styleSheet);else for(const t of e){const i=document.createElement("style"),r=ps.litNonce;r!==void 0&&i.setAttribute("nonce",r),i.textContent=t.cssText,n.appendChild(i)}},Eh=Zl?n=>n:n=>n instanceof CSSStyleSheet?(e=>{let t="";for(const i of e.cssRules)t+=i.cssText;return fx(t)})(n):n;/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const{is:px,defineProperty:mx,getOwnPropertyDescriptor:yx,getOwnPropertyNames:_x,getOwnPropertySymbols:xx,getPrototypeOf:vx}=Object,_o=globalThis,wh=_o.trustedTypes,Ex=wh?wh.emptyScript:"",wx=_o.reactiveElementPolyfillSupport,ir=(n,e)=>n,Xs={toAttribute(n,e){switch(e){case Boolean:n=n?Ex:null;break;case Object:case Array:n=n==null?n:JSON.stringify(n)}return n},fromAttribute(n,e){let t=n;switch(e){case Boolean:t=n!==null;break;case Number:t=n===null?null:Number(n);break;case Object:case Array:try{t=JSON.parse(n)}catch{t=null}}return t}},Kl=(n,e)=>!px(n,e),Ch={attribute:!0,type:String,converter:Xs,reflect:!1,hasChanged:Kl};Symbol.metadata??=Symbol("metadata"),_o.litPropertyMetadata??=new WeakMap;class fn extends HTMLElement{static addInitializer(e){this._$Ei(),(this.l??=[]).push(e)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(e,t=Ch){if(t.state&&(t.attribute=!1),this._$Ei(),this.elementProperties.set(e,t),!t.noAccessor){const i=Symbol(),r=this.getPropertyDescriptor(e,i,t);r!==void 0&&mx(this.prototype,e,r)}}static getPropertyDescriptor(e,t,i){const{get:r,set:s}=yx(this.prototype,e)??{get(){return this[t]},set(o){this[t]=o}};return{get(){return r?.call(this)},set(o){const a=r?.call(this);s.call(this,o),this.requestUpdate(e,a,i)},configurable:!0,enumerable:!0}}static getPropertyOptions(e){return this.elementProperties.get(e)??Ch}static _$Ei(){if(this.hasOwnProperty(ir("elementProperties")))return;const e=vx(this);e.finalize(),e.l!==void 0&&(this.l=[...e.l]),this.elementProperties=new Map(e.elementProperties)}static finalize(){if(this.hasOwnProperty(ir("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(ir("properties"))){const t=this.properties,i=[..._x(t),...xx(t)];for(const r of i)this.createProperty(r,t[r])}const e=this[Symbol.metadata];if(e!==null){const t=litPropertyMetadata.get(e);if(t!==void 0)for(const[i,r]of t)this.elementProperties.set(i,r)}this._$Eh=new Map;for(const[t,i]of this.elementProperties){const r=this._$Eu(t,i);r!==void 0&&this._$Eh.set(r,t)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(e){const t=[];if(Array.isArray(e)){const i=new Set(e.flat(1/0).reverse());for(const r of i)t.unshift(Eh(r))}else e!==void 0&&t.push(Eh(e));return t}static _$Eu(e,t){const i=t.attribute;return i===!1?void 0:typeof i=="string"?i:typeof e=="string"?e.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),this.constructor.l?.forEach(e=>e(this))}addController(e){(this._$EO??=new Set).add(e),this.renderRoot!==void 0&&this.isConnected&&e.hostConnected?.()}removeController(e){this._$EO?.delete(e)}_$E_(){const e=new Map,t=this.constructor.elementProperties;for(const i of t.keys())this.hasOwnProperty(i)&&(e.set(i,this[i]),delete this[i]);e.size>0&&(this._$Ep=e)}createRenderRoot(){const e=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return gx(e,this.constructor.elementStyles),e}connectedCallback(){this.renderRoot??=this.createRenderRoot(),this.enableUpdating(!0),this._$EO?.forEach(e=>e.hostConnected?.())}enableUpdating(e){}disconnectedCallback(){this._$EO?.forEach(e=>e.hostDisconnected?.())}attributeChangedCallback(e,t,i){this._$AK(e,i)}_$EC(e,t){const i=this.constructor.elementProperties.get(e),r=this.constructor._$Eu(e,i);if(r!==void 0&&i.reflect===!0){const s=(i.converter?.toAttribute!==void 0?i.converter:Xs).toAttribute(t,i.type);this._$Em=e,s==null?this.removeAttribute(r):this.setAttribute(r,s),this._$Em=null}}_$AK(e,t){const i=this.constructor,r=i._$Eh.get(e);if(r!==void 0&&this._$Em!==r){const s=i.getPropertyOptions(r),o=typeof s.converter=="function"?{fromAttribute:s.converter}:s.converter?.fromAttribute!==void 0?s.converter:Xs;this._$Em=r,this[r]=o.fromAttribute(t,s.type),this._$Em=null}}requestUpdate(e,t,i){if(e!==void 0){if(i??=this.constructor.getPropertyOptions(e),!(i.hasChanged??Kl)(this[e],t))return;this.P(e,t,i)}this.isUpdatePending===!1&&(this._$ES=this._$ET())}P(e,t,i){this._$AL.has(e)||this._$AL.set(e,t),i.reflect===!0&&this._$Em!==e&&(this._$Ej??=new Set).add(e)}async _$ET(){this.isUpdatePending=!0;try{await this._$ES}catch(t){Promise.reject(t)}const e=this.scheduleUpdate();return e!=null&&await e,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??=this.createRenderRoot(),this._$Ep){for(const[r,s]of this._$Ep)this[r]=s;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[r,s]of i)s.wrapped!==!0||this._$AL.has(r)||this[r]===void 0||this.P(r,this[r],s)}let e=!1;const t=this._$AL;try{e=this.shouldUpdate(t),e?(this.willUpdate(t),this._$EO?.forEach(i=>i.hostUpdate?.()),this.update(t)):this._$EU()}catch(i){throw e=!1,this._$EU(),i}e&&this._$AE(t)}willUpdate(e){}_$AE(e){this._$EO?.forEach(t=>t.hostUpdated?.()),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(e)),this.updated(e)}_$EU(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(e){return!0}update(e){this._$Ej&&=this._$Ej.forEach(t=>this._$EC(t,this[t])),this._$EU()}updated(e){}firstUpdated(e){}}fn.elementStyles=[],fn.shadowRootOptions={mode:"open"},fn[ir("elementProperties")]=new Map,fn[ir("finalized")]=new Map,wx?.({ReactiveElement:fn}),(_o.reactiveElementVersions??=[]).push("2.0.4");/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Hl=globalThis,Ws=Hl.trustedTypes,bh=Ws?Ws.createPolicy("lit-html",{createHTML:n=>n}):void 0,Gd="$lit$",hi=`lit$${(Math.random()+"").slice(9)}$`,$d="?"+hi,Cx=`<${$d}>`,Bi=document,vr=()=>Bi.createComment(""),Er=n=>n===null||typeof n!="object"&&typeof n!="function",jd=Array.isArray,bx=n=>jd(n)||typeof n?.[Symbol.iterator]=="function",Ho=`[ +\f\r]`,Yn=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,Th=/-->/g,Rh=/>/g,Ai=RegExp(`>|${Ho}(?:([^\\s"'>=/]+)(${Ho}*=${Ho}*(?:[^ +\f\r"'\`<>=]|("|')|))|$)`,"g"),Sh=/'/g,Ih=/"/g,Xd=/^(?:script|style|textarea|title)$/i,Tx=n=>(e,...t)=>({_$litType$:n,strings:e,values:t}),Jo=Tx(1),Zi=Symbol.for("lit-noChange"),Fe=Symbol.for("lit-nothing"),Ah=new WeakMap,Di=Bi.createTreeWalker(Bi,129);function Wd(n,e){if(!Array.isArray(n)||!n.hasOwnProperty("raw"))throw Error("invalid template strings array");return bh!==void 0?bh.createHTML(e):e}const Rx=(n,e)=>{const t=n.length-1,i=[];let r,s=e===2?"":"",o=Yn;for(let a=0;a"?(o=r??Yn,c=-1):h[1]===void 0?c=-2:(c=o.lastIndex-h[2].length,u=h[1],o=h[3]===void 0?Ai:h[3]==='"'?Ih:Sh):o===Ih||o===Sh?o=Ai:o===Th||o===Rh?o=Yn:(o=Ai,r=void 0);const f=o===Ai&&n[a+1].startsWith("/>")?" ":"";s+=o===Yn?l+Cx:c>=0?(i.push(u),l.slice(0,c)+Gd+l.slice(c)+hi+f):l+hi+(c===-2?a:f)}return[Wd(n,s+(n[t]||"")+(e===2?"":"")),i]};class wr{constructor({strings:e,_$litType$:t},i){let r;this.parts=[];let s=0,o=0;const a=e.length-1,l=this.parts,[u,h]=Rx(e,t);if(this.el=wr.createElement(u,i),Di.currentNode=this.el.content,t===2){const c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(r=Di.nextNode())!==null&&l.length0){r.textContent=Ws?Ws.emptyScript:"";for(let f=0;f2||i[0]!==""||i[1]!==""?(this._$AH=Array(i.length-1).fill(new String),this.strings=i):this._$AH=Fe}_$AI(e,t=this,i,r){const s=this.strings;let o=!1;if(s===void 0)e=kn(this,e,t,0),o=!Er(e)||e!==this._$AH&&e!==Zi,o&&(this._$AH=e);else{const a=e;let l,u;for(e=s[0],l=0;l{const i=t?.renderBefore??e;let r=i._$litPart$;if(r===void 0){const s=t?.renderBefore??null;i._$litPart$=r=new $r(e.insertBefore(vr(),s),s,void 0,t??{})}return r._$AI(n),r};/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */class nr extends fn{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){const e=super.createRenderRoot();return this.renderOptions.renderBefore??=e.firstChild,e}update(e){const t=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(e),this._$Do=Lx(t,this.renderRoot,this.renderOptions)}connectedCallback(){super.connectedCallback(),this._$Do?.setConnected(!0)}disconnectedCallback(){super.disconnectedCallback(),this._$Do?.setConnected(!1)}render(){return Zi}}nr._$litElement$=!0,nr.finalized=!0,globalThis.litElementHydrateSupport?.({LitElement:nr});const kx=globalThis.litElementPolyfillSupport;kx?.({LitElement:nr});(globalThis.litElementVersions??=[]).push("4.0.4");const Ox=72,Dx=.0254,zx=Ox/Dx;function Ud(n,e,t){const i=e/2,r=t/2,[s,o]=n,a=i-s/2,l=r-o/2;return[a,l,a+s,l+o]}function Nx(n,e){const i=n.target.getViewport().getElementsByTagName("canvas"),r=n.frameState,s=Number((r.size[0]*r.pixelRatio).toFixed()),o=Number((r.size[1]*r.pixelRatio).toFixed()),a=Ud(e,s,o);for(let l=i.length-1;l>=0;l--){const u=i.item(l),h=u.getContext("2d");if(u.width===s&&u.height===o){h.beginPath(),h.rect(0,0,s,o),h.rect(a[0],a[1],e[0],e[1]),h.fillStyle="rgba(0, 5, 25, 0.15)",h.fill("evenodd");break}}}/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Gx=n=>(e,t)=>{t!==void 0?t.addInitializer(()=>{customElements.define(n,e)}):customElements.define(n,e)};/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const $x={attribute:!0,type:String,converter:Xs,reflect:!1,hasChanged:Kl},jx=(n=$x,e,t)=>{const{kind:i,metadata:r}=t;let s=globalThis.litPropertyMetadata.get(r);if(s===void 0&&globalThis.litPropertyMetadata.set(r,s=new Map),s.set(t.name,n),i==="accessor"){const{name:o}=t;return{set(a){const l=e.get.call(this);e.set.call(this,a),this.requestUpdate(o,l,n)},init(a){return a!==void 0&&this.P(o,void 0,n),a}}}if(i==="setter"){const{name:o}=t;return function(a){const l=this[o];e.call(this,a),this.requestUpdate(o,l,n)}}throw Error("Unsupported decorator location: "+i)};function Xx(n){return(e,t)=>typeof t=="object"?jx(n,e,t):((i,r,s)=>{const o=r.hasOwnProperty(s);return r.constructor.createProperty(s,o?{...i,wrapped:!0}:i),o?Object.getOwnPropertyDescriptor(r,s):void 0})(n,e,t)}/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */function jr(n){return Xx({...n,state:!0,attribute:!1})}/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Fh=(n,e,t)=>(t.configurable=!0,t.enumerable=!0,Reflect.decorate&&typeof e!="object"&&Object.defineProperty(n,e,t),t);/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */function Wx(n,e){return(t,i,r)=>{const s=o=>o.renderRoot?.querySelector(n)??null;if(e){const{get:o,set:a}=typeof i=="object"?t:r??(()=>{const l=Symbol();return{get(){return this[l]},set(u){this[l]=u}}})();return Fh(t,i,{get(){let l=o.call(this);return l===void 0&&(l=s(this),(l!==null||this.hasUpdated)&&a.call(this,l)),l}})}return Fh(t,i,{get(){return s(this)}})}}const Ux=Nd` + .ol-control { + position: absolute; + background-color: rgba(255, 255, 255, 0.4); + border-radius: 4px; + padding: 2px; + } + .ol-control:hover { + background-color: rgba(255, 255, 255, 0.6); + } + .ol-zoom { + top: 0.5em; + left: 0.5em; + } + .ol-control button { + display: block; + margin: 1px; + padding: 0; + color: white; + font-size: 1.14em; + font-weight: bold; + text-decoration: none; + text-align: center; + height: 1.375em; + width: 1.375em; + line-height: 0.4em; + background-color: rgba(0, 60, 136, 0.5); + border: none; + border-radius: 2px; + } + .ol-control button::-moz-focus-inner { + border: none; + padding: 0; + } + .ol-rotate { + top: 0.5em; + right: 0.5em; + transition: opacity 0.25s linear, visibility 0s linear; + } + .ol-rotate.ol-hidden { + opacity: 0; + visibility: hidden; + transition: opacity 0.25s linear, visibility 0s linear 0.25s; + } + .ol-attribution li { + display: inline; + list-style: none; + } + .ol-attribution li:not(:last-child):after { + content: ' '; + } + .ol-attribution img { + max-height: 2em; + max-width: inherit; + vertical-align: middle; + } + .ol-attribution button { + flex-shrink: 0; + } + .ol-attribution.ol-collapsed ul { + display: none; + } + .ol-attribution:not(.ol-collapsed) { + background: rgba(255, 255, 255, 0.8); + } + .ol-attribution.ol-uncollapsible { + bottom: 0; + right: 0; + border-radius: 4px 0 0; + } + .ol-attribution.ol-uncollapsible img { + margin-top: -0.2em; + max-height: 1.6em; + } + .ol-attribution.ol-uncollapsible button { + display: none; + } + .ol-viewport, + .ol-unselectable { + user-select: none; + } + .ol-selectable { + user-select: text; + } +`,Vx=` + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + Openclipart + + + Printer icon + 2006-12-26T00:00:00 + + https://openclipart.org/detail/24825/-by--24825 + + + Anonymous + + + + + + + + + + + +`;/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */const Yx={ATTRIBUTE:1,CHILD:2,PROPERTY:3,BOOLEAN_ATTRIBUTE:4,EVENT:5,ELEMENT:6},Bx=n=>(...e)=>({_$litDirective$:n,values:e});class Zx{constructor(e){}get _$AU(){return this._$AM._$AU}_$AT(e,t,i){this._$Ct=e,this._$AM=t,this._$Ci=i}_$AS(e,t){return this.update(e,t)}update(e,t){return this.render(...t)}}/** + * @license + * Copyright 2017 Google LLC + * SPDX-License-Identifier: BSD-3-Clause + */class La extends Zx{constructor(e){if(super(e),this.it=Fe,e.type!==Yx.CHILD)throw Error(this.constructor.directiveName+"() can only be used in child bindings")}render(e){if(e===Fe||e==null)return this._t=void 0,this.it=e;if(e===Zi)return e;if(typeof e!="string")throw Error(this.constructor.directiveName+"() called with a non-string value");if(e===this.it)return this._t;this.it=e;const t=[e];return t.raw=t,this._t={_$litType$:this.constructor.resultType,strings:t,values:[]}}}La.directiveName="unsafeHTML",La.resultType=1;const qx=Bx(La);var Kx=Object.defineProperty,Hx=Object.getOwnPropertyDescriptor,Hi=(n,e,t,i)=>{for(var r=i>1?void 0:i?Hx(e,t):e,s=n.length-1,o;s>=0;s--)(o=n[s])&&(r=(i?o(e,t,r):o(r))||r);return i&&r&&Kx(e,t,r),r};const Bn={demo:"mapbox1",declutter:!0,immediateApi:!1};let Ht=class extends nr{constructor(){super(...arguments),this.targetSizeInPdfPoints=[255,355],this.printScale=1/5e3,this.dpi=96,this.zoom=-1,this.currentDemo=Bn.demo,this.shouldDeclutter=Bn.declutter,this.useImmediateApi=Bn.immediateApi}async configureVTStyle(n,e,t){return fetch(e).then(i=>i.json()).then(i=>ax(n,i,t))}createMap(){this.printExtentLayer=new Jc({name:"printExtent",source:new ds({features:[]})}),this.map=new Ym({target:this.mapEl,layers:[],view:new St({zoom:15})}),this.shouldDeclutter=Bn.declutter,this.updateDemo(Bn.demo),this.map.on("postcompose",n=>{const e=n.frameState.viewState.resolution;Nx(n,this.getPrintExtentSizeForResolution(e,devicePixelRatio))}),this.map.getView().on("change:resolution",()=>{this.zoom=this.map?.getView().getZoom()||-1}),this.zoom=this.map?.getView().getZoom()||-1}getPrintExtentSizeForResolution(n,e){return this.targetSizeInPdfPoints.map(t=>{const i=t/zx/this.printScale;return e*i/n})}firstUpdated(){this.createMap()}async print(){As.useImmediateAPI=this.useImmediateApi;const n=new As,e=this.map.getView().getResolution(),t=this.map.getSize(),i=this.getPrintExtentSizeForResolution(e,window.devicePixelRatio),r=Ud(i,t[0],t[1]),s=[...this.map.getCoordinateFromPixel([r[0],r[3]]),...this.map.getCoordinateFromPixel([r[2],r[1]])];this.printExtentLayer?.getSource()?.clear(),this.printExtentLayer?.getSource()?.addFeature(new Ys({geometry:da(s)}));const o=cp(this.targetSizeInPdfPoints,this.dpi);console.log("Estimated size on screen",o.map(u=>u/96*2.54));const a={layer:this.mvtLayer,printExtent:s,tileResolution:e,styleResolution:e,canvasSize:o},l=await n.encodeMVTLayer(a);console.log(l),this.result0=l[0]}configureSimpleDemo(){this.mvtLayer=new Jn({declutter:this.shouldDeclutter,style(t){return t.getGeometry()?.getType()==="Point"?new He({text:new Mr({font:"bold 28px beach",text:"beach",offsetY:40}),image:new Xi({src:`${document.baseURI}/beach.svg`,opacity:.5,scale:.05})}):new He({stroke:new Wt({color:"red"})})},source:new td({format:new ol,url:document.baseURI+"tiles/{z}/{x}/{y}.pbf",maxZoom:14})});const n=this.map?.getLayers();n.clear();const e=[new Oo({source:new py}),this.mvtLayer,this.printExtentLayer,new Oo({zIndex:1e4,source:new Xu({tileGrid:this.mvtLayer.getSource().getTileGrid()})})];n.extend(e),this.map?.getView().setCenter(ws([6.5725,46.51339]))}configureMapboxDemo1(){this.configureMapboxDemo("https://vectortiles.geo.admin.ch/styles/ch.swisstopo.leichte-basiskarte.vt/style.json","leichtebasiskarte_v3.0.1")}async configureMapboxDemo(n,e){this.mvtLayer=new Jn({declutter:this.shouldDeclutter}),await this.configureVTStyle(this.mvtLayer,n,e);const t=this.map?.getLayers();t.clear();const i=[this.mvtLayer,this.printExtentLayer,new Oo({zIndex:1e4,source:new Xu({tileGrid:this.mvtLayer.getSource().getTileGrid()})})];t.extend(i),this.map?.getView().setCenter(ws([7.44835,46.94811]))}updateDemo(n){switch(this.currentDemo=n,n){case"simple":this.configureSimpleDemo();break;case"mapbox1":this.configureMapboxDemo1();break}}formatExtent(n){const e=[n[0],n[1]],t=[n[2],n[3]],i=hu(e,"EPSG:3857").map(s=>s.toFixed(3)).join(", "),r=hu(t,"EPSG:3857").map(s=>s.toFixed(3)).join(", ");return`[${i}, ${r}]`}render(){let n="",e="";if(this.result0){const t=this.result0.extent;n=Jo``,e=Jo`${this.formatExtent(t)}`}return Jo` + + + + + +
zoom: ${this.zoom.toFixed(1)}
+
+ printed extent: ${e||"Move around and click the print button..."} +
+
+
+ ${n} +
+ `}};Ht.styles=[Nd` + :host { + display: block; + border: solid 1px gray; + padding: 16px; + } + #side { + background-color: lightgray; + display: inline-block; + } + #print { + width: 30px; + height: 30px; + } + #map { + display: inline-block; + width: 45%; + height: calc(100vh - 32px - 20px - 40px); + } + `,Ux];Hi([Wx("#map")],Ht.prototype,"mapEl",2);Hi([jr()],Ht.prototype,"result0",2);Hi([jr()],Ht.prototype,"zoom",2);Hi([jr()],Ht.prototype,"currentDemo",2);Hi([jr()],Ht.prototype,"shouldDeclutter",2);Hi([jr()],Ht.prototype,"useImmediateApi",2);Ht=Hi([Gx("demo-app")],Ht); +//# sourceMappingURL=demo-C9TpCBkC.js.map diff --git a/assets/demo-C9TpCBkC.js.map b/assets/demo-C9TpCBkC.js.map new file mode 100644 index 0000000..6ca9b65 --- /dev/null +++ b/assets/demo-C9TpCBkC.js.map @@ -0,0 +1 @@ +{"version":3,"file":"demo-C9TpCBkC.js","sources":["../../node_modules/ol/events/Event.js","../../node_modules/ol/ObjectEventType.js","../../node_modules/ol/Disposable.js","../../node_modules/ol/array.js","../../node_modules/ol/functions.js","../../node_modules/ol/obj.js","../../node_modules/ol/events/Target.js","../../node_modules/ol/events/EventType.js","../../node_modules/ol/events.js","../../node_modules/ol/Observable.js","../../node_modules/ol/util.js","../../node_modules/ol/Object.js","../../node_modules/ol/asserts.js","../../node_modules/ol/Feature.js","../../node_modules/ol/ImageState.js","../../node_modules/ol/size.js","../../node_modules/ol/style/Image.js","../../node_modules/ol/math.js","../../node_modules/ol/color.js","../../node_modules/ol/has.js","../../node_modules/ol/dom.js","../../node_modules/ol/Image.js","../../node_modules/ol/style/IconImageCache.js","../../node_modules/ol/style/IconImage.js","../../node_modules/ol/style/Icon.js","../../node_modules/ol/proj/Units.js","../../node_modules/ol/proj/Projection.js","../../node_modules/ol/proj/epsg3857.js","../../node_modules/ol/proj/epsg4326.js","../../node_modules/ol/proj/projections.js","../../node_modules/ol/proj/transforms.js","../../node_modules/ol/extent/Relationship.js","../../node_modules/ol/extent.js","../../node_modules/ol/coordinate.js","../../node_modules/ol/sphere.js","../../node_modules/ol/console.js","../../node_modules/ol/proj.js","../../node_modules/ol/format/Feature.js","../../node_modules/ol/transform.js","../../node_modules/ol/geom/flat/transform.js","../../node_modules/ol/geom/Geometry.js","../../node_modules/ol/geom/SimpleGeometry.js","../../node_modules/ol/geom/flat/closest.js","../../node_modules/ol/geom/flat/deflate.js","../../node_modules/ol/geom/flat/simplify.js","../../node_modules/ol/geom/flat/segments.js","../../node_modules/ol/geom/flat/inflate.js","../../node_modules/ol/geom/flat/interpolate.js","../../node_modules/ol/geom/flat/contains.js","../../node_modules/ol/geom/flat/intersectsextent.js","../../node_modules/ol/geom/flat/length.js","../../node_modules/ol/geom/LineString.js","../../node_modules/ol/geom/MultiLineString.js","../../node_modules/ol/geom/Point.js","../../node_modules/ol/geom/MultiPoint.js","../../node_modules/ol/geom/flat/area.js","../../node_modules/ol/geom/LinearRing.js","../../node_modules/ol/geom/flat/interiorpoint.js","../../node_modules/ol/geom/flat/reverse.js","../../node_modules/ol/geom/flat/orient.js","../../node_modules/ol/geom/Polygon.js","../../node_modules/ol/geom/flat/center.js","../../node_modules/ol/geom/MultiPolygon.js","../../node_modules/ieee754/index.js","../../node_modules/pbf/index.js","../../node_modules/ol/geom/GeometryCollection.js","../../node_modules/ol/render/Feature.js","../../node_modules/ol/format/MVT.js","../../node_modules/ol/format/JSONFeature.js","../../node_modules/ol/format/GeoJSON.js","../../node_modules/ol/style/Fill.js","../../node_modules/ol/style/Stroke.js","../../node_modules/ol/colorlike.js","../../node_modules/ol/css.js","../../node_modules/ol/render/canvas.js","../../node_modules/ol/style/RegularShape.js","../../node_modules/ol/style/Circle.js","../../node_modules/ol/style/Style.js","../../node_modules/ol/style/Text.js","../../src/encodeutils.ts","../../src/canvasUtils.ts","../../node_modules/ol/renderer/vector.js","../../node_modules/ol/render/VectorContext.js","../../node_modules/ol/render/canvas/Immediate.js","../../node_modules/ol/render.js","../../node_modules/ol/render/canvas/Instruction.js","../../node_modules/ol/render/canvas/Builder.js","../../node_modules/ol/render/canvas/ImageBuilder.js","../../node_modules/ol/render/canvas/LineStringBuilder.js","../../node_modules/ol/render/canvas/PolygonBuilder.js","../../node_modules/ol/geom/flat/linechunk.js","../../node_modules/ol/geom/flat/straightchunk.js","../../node_modules/ol/render/canvas/TextBuilder.js","../../node_modules/ol/render/canvas/BuilderGroup.js","../../node_modules/ol/geom/flat/textpath.js","../../node_modules/ol/render/canvas/Executor.js","../../node_modules/ol/render/canvas/ExecutorGroup.js","../../node_modules/quickselect/index.js","../../node_modules/rbush/index.js","../../src/MVTEncoder.ts","../../node_modules/ol/CollectionEventType.js","../../node_modules/ol/Collection.js","../../node_modules/ol/layer/Property.js","../../node_modules/ol/layer/Base.js","../../node_modules/ol/render/EventType.js","../../node_modules/ol/ViewHint.js","../../node_modules/ol/ViewProperty.js","../../node_modules/ol/tilegrid/common.js","../../node_modules/ol/centerconstraint.js","../../node_modules/ol/resolutionconstraint.js","../../node_modules/ol/rotationconstraint.js","../../node_modules/ol/easing.js","../../node_modules/ol/View.js","../../node_modules/ol/layer/Layer.js","../../node_modules/ol/renderer/Map.js","../../node_modules/ol/render/Event.js","../../node_modules/ol/renderer/Composite.js","../../node_modules/ol/layer/Group.js","../../node_modules/ol/MapEvent.js","../../node_modules/ol/MapBrowserEvent.js","../../node_modules/ol/MapBrowserEventType.js","../../node_modules/ol/pointer/EventType.js","../../node_modules/ol/MapBrowserEventHandler.js","../../node_modules/ol/MapEventType.js","../../node_modules/ol/MapProperty.js","../../node_modules/ol/structs/PriorityQueue.js","../../node_modules/ol/TileState.js","../../node_modules/ol/TileQueue.js","../../node_modules/ol/control/Control.js","../../node_modules/ol/control/Attribution.js","../../node_modules/ol/control/Rotate.js","../../node_modules/ol/control/Zoom.js","../../node_modules/ol/control/defaults.js","../../node_modules/ol/interaction/Property.js","../../node_modules/ol/interaction/Interaction.js","../../node_modules/ol/interaction/DoubleClickZoom.js","../../node_modules/ol/interaction/Pointer.js","../../node_modules/ol/events/condition.js","../../node_modules/ol/interaction/DragPan.js","../../node_modules/ol/interaction/DragRotate.js","../../node_modules/ol/render/Box.js","../../node_modules/ol/interaction/DragBox.js","../../node_modules/ol/interaction/DragZoom.js","../../node_modules/ol/events/Key.js","../../node_modules/ol/interaction/KeyboardPan.js","../../node_modules/ol/interaction/KeyboardZoom.js","../../node_modules/ol/Kinetic.js","../../node_modules/ol/interaction/MouseWheelZoom.js","../../node_modules/ol/interaction/PinchRotate.js","../../node_modules/ol/interaction/PinchZoom.js","../../node_modules/ol/interaction/defaults.js","../../node_modules/ol/Map.js","../../node_modules/ol/Tile.js","../../node_modules/ol/ImageTile.js","../../node_modules/ol/reproj/common.js","../../node_modules/ol/reproj/Triangulation.js","../../node_modules/ol/reproj.js","../../node_modules/ol/reproj/Tile.js","../../node_modules/ol/structs/LRUCache.js","../../node_modules/ol/tilecoord.js","../../node_modules/ol/TileCache.js","../../node_modules/ol/source/TileEventType.js","../../node_modules/ol/source/Source.js","../../node_modules/ol/TileRange.js","../../node_modules/ol/tilegrid/TileGrid.js","../../node_modules/ol/tilegrid.js","../../node_modules/ol/source/Tile.js","../../node_modules/ol/tileurlfunction.js","../../node_modules/ol/source/UrlTile.js","../../node_modules/ol/source/TileImage.js","../../node_modules/ol/source/XYZ.js","../../node_modules/ol/source/OSM.js","../../node_modules/ol/source/TileDebug.js","../../node_modules/ol/layer/TileProperty.js","../../node_modules/ol/layer/BaseTile.js","../../node_modules/ol/renderer/Layer.js","../../node_modules/ol/renderer/canvas/Layer.js","../../node_modules/ol/renderer/canvas/TileLayer.js","../../node_modules/ol/layer/Tile.js","../../node_modules/ol/expr/expression.js","../../node_modules/ol/expr/cpu.js","../../node_modules/ol/render/canvas/style.js","../../node_modules/ol/layer/BaseVector.js","../../node_modules/ol/render/canvas/hitdetect.js","../../node_modules/ol/renderer/canvas/VectorLayer.js","../../node_modules/ol/layer/Vector.js","../../node_modules/ol/structs/RBush.js","../../node_modules/ol/source/VectorEventType.js","../../node_modules/ol/loadingstrategy.js","../../node_modules/ol/featureloader.js","../../node_modules/ol/source/Vector.js","../../node_modules/ol/renderer/canvas/VectorTileLayer.js","../../node_modules/ol/layer/VectorTile.js","../../node_modules/ol/VectorTile.js","../../node_modules/ol/VectorRenderTile.js","../../node_modules/ol/source/VectorTile.js","../../node_modules/ol/net.js","../../node_modules/ol/source/TileJSON.js","../../node_modules/ol-mapbox-style/dist/index.js","../../node_modules/@lit/reactive-element/css-tag.js","../../node_modules/@lit/reactive-element/reactive-element.js","../../node_modules/lit-html/lit-html.js","../../node_modules/lit-element/lit-element.js","../../src/constants.ts","../../src/postcompose.ts","../../node_modules/@lit/reactive-element/decorators/custom-element.js","../../node_modules/@lit/reactive-element/decorators/property.js","../../node_modules/@lit/reactive-element/decorators/state.js","../../node_modules/@lit/reactive-element/decorators/base.js","../../node_modules/@lit/reactive-element/decorators/query.js","../../src/demo/css.ts","../../src/printer.ts","../../node_modules/lit-html/directive.js","../../node_modules/lit-html/directives/unsafe-html.js","../../src/demo/demo-app.ts"],"sourcesContent":["/**\n * @module ol/events/Event\n */\n\n/**\n * @classdesc\n * Stripped down implementation of the W3C DOM Level 2 Event interface.\n * See https://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-interface.\n *\n * This implementation only provides `type` and `target` properties, and\n * `stopPropagation` and `preventDefault` methods. It is meant as base class\n * for higher level events defined in the library, and works with\n * {@link module:ol/events/Target~Target}.\n */\nclass BaseEvent {\n /**\n * @param {string} type Type.\n */\n constructor(type) {\n /**\n * @type {boolean}\n */\n this.propagationStopped;\n\n /**\n * @type {boolean}\n */\n this.defaultPrevented;\n\n /**\n * The event type.\n * @type {string}\n * @api\n */\n this.type = type;\n\n /**\n * The event target.\n * @type {Object}\n * @api\n */\n this.target = null;\n }\n\n /**\n * Prevent default. This means that no emulated `click`, `singleclick` or `doubleclick` events\n * will be fired.\n * @api\n */\n preventDefault() {\n this.defaultPrevented = true;\n }\n\n /**\n * Stop event propagation.\n * @api\n */\n stopPropagation() {\n this.propagationStopped = true;\n }\n}\n\n/**\n * @param {Event|import(\"./Event.js\").default} evt Event\n */\nexport function stopPropagation(evt) {\n evt.stopPropagation();\n}\n\n/**\n * @param {Event|import(\"./Event.js\").default} evt Event\n */\nexport function preventDefault(evt) {\n evt.preventDefault();\n}\n\nexport default BaseEvent;\n","/**\n * @module ol/ObjectEventType\n */\n\n/**\n * @enum {string}\n */\nexport default {\n /**\n * Triggered when a property is changed.\n * @event module:ol/Object.ObjectEvent#propertychange\n * @api\n */\n PROPERTYCHANGE: 'propertychange',\n};\n\n/**\n * @typedef {'propertychange'} Types\n */\n","/**\n * @module ol/Disposable\n */\n\n/**\n * @classdesc\n * Objects that need to clean up after themselves.\n */\nclass Disposable {\n constructor() {\n /**\n * The object has already been disposed.\n * @type {boolean}\n * @protected\n */\n this.disposed = false;\n }\n\n /**\n * Clean up.\n */\n dispose() {\n if (!this.disposed) {\n this.disposed = true;\n this.disposeInternal();\n }\n }\n\n /**\n * Extension point for disposable objects.\n * @protected\n */\n disposeInternal() {}\n}\n\nexport default Disposable;\n","/**\n * @module ol/array\n */\n\n/**\n * Performs a binary search on the provided sorted list and returns the index of the item if found. If it can't be found it'll return -1.\n * https://github.com/darkskyapp/binary-search\n *\n * @param {Array<*>} haystack Items to search through.\n * @param {*} needle The item to look for.\n * @param {Function} [comparator] Comparator function.\n * @return {number} The index of the item if found, -1 if not.\n */\nexport function binarySearch(haystack, needle, comparator) {\n let mid, cmp;\n comparator = comparator || ascending;\n let low = 0;\n let high = haystack.length;\n let found = false;\n\n while (low < high) {\n /* Note that \"(low + high) >>> 1\" may overflow, and results in a typecast\n * to double (which gives the wrong results). */\n mid = low + ((high - low) >> 1);\n cmp = +comparator(haystack[mid], needle);\n\n if (cmp < 0.0) {\n /* Too low. */\n low = mid + 1;\n } else {\n /* Key found or too high */\n high = mid;\n found = !cmp;\n }\n }\n\n /* Key not found. */\n return found ? low : ~low;\n}\n\n/**\n * Compare function sorting arrays in ascending order. Safe to use for numeric values.\n * @param {*} a The first object to be compared.\n * @param {*} b The second object to be compared.\n * @return {number} A negative number, zero, or a positive number as the first\n * argument is less than, equal to, or greater than the second.\n */\nexport function ascending(a, b) {\n return a > b ? 1 : a < b ? -1 : 0;\n}\n\n/**\n * Compare function sorting arrays in descending order. Safe to use for numeric values.\n * @param {*} a The first object to be compared.\n * @param {*} b The second object to be compared.\n * @return {number} A negative number, zero, or a positive number as the first\n * argument is greater than, equal to, or less than the second.\n */\nexport function descending(a, b) {\n return a < b ? 1 : a > b ? -1 : 0;\n}\n\n/**\n * {@link module:ol/tilegrid/TileGrid~TileGrid#getZForResolution} can use a function\n * of this type to determine which nearest resolution to use.\n *\n * This function takes a `{number}` representing a value between two array entries,\n * a `{number}` representing the value of the nearest higher entry and\n * a `{number}` representing the value of the nearest lower entry\n * as arguments and returns a `{number}`. If a negative number or zero is returned\n * the lower value will be used, if a positive number is returned the higher value\n * will be used.\n * @typedef {function(number, number, number): number} NearestDirectionFunction\n * @api\n */\n\n/**\n * @param {Array} arr Array in descending order.\n * @param {number} target Target.\n * @param {number|NearestDirectionFunction} direction\n * 0 means return the nearest,\n * > 0 means return the largest nearest,\n * < 0 means return the smallest nearest.\n * @return {number} Index.\n */\nexport function linearFindNearest(arr, target, direction) {\n if (arr[0] <= target) {\n return 0;\n }\n\n const n = arr.length;\n if (target <= arr[n - 1]) {\n return n - 1;\n }\n\n if (typeof direction === 'function') {\n for (let i = 1; i < n; ++i) {\n const candidate = arr[i];\n if (candidate === target) {\n return i;\n }\n if (candidate < target) {\n if (direction(target, arr[i - 1], candidate) > 0) {\n return i - 1;\n }\n return i;\n }\n }\n return n - 1;\n }\n\n if (direction > 0) {\n for (let i = 1; i < n; ++i) {\n if (arr[i] < target) {\n return i - 1;\n }\n }\n return n - 1;\n }\n\n if (direction < 0) {\n for (let i = 1; i < n; ++i) {\n if (arr[i] <= target) {\n return i;\n }\n }\n return n - 1;\n }\n\n for (let i = 1; i < n; ++i) {\n if (arr[i] == target) {\n return i;\n }\n if (arr[i] < target) {\n if (arr[i - 1] - target < target - arr[i]) {\n return i - 1;\n }\n return i;\n }\n }\n return n - 1;\n}\n\n/**\n * @param {Array<*>} arr Array.\n * @param {number} begin Begin index.\n * @param {number} end End index.\n */\nexport function reverseSubArray(arr, begin, end) {\n while (begin < end) {\n const tmp = arr[begin];\n arr[begin] = arr[end];\n arr[end] = tmp;\n ++begin;\n --end;\n }\n}\n\n/**\n * @param {Array} arr The array to modify.\n * @param {!Array|VALUE} data The elements or arrays of elements to add to arr.\n * @template VALUE\n */\nexport function extend(arr, data) {\n const extension = Array.isArray(data) ? data : [data];\n const length = extension.length;\n for (let i = 0; i < length; i++) {\n arr[arr.length] = extension[i];\n }\n}\n\n/**\n * @param {Array} arr The array to modify.\n * @param {VALUE} obj The element to remove.\n * @template VALUE\n * @return {boolean} If the element was removed.\n */\nexport function remove(arr, obj) {\n const i = arr.indexOf(obj);\n const found = i > -1;\n if (found) {\n arr.splice(i, 1);\n }\n return found;\n}\n\n/**\n * @param {Array|Uint8ClampedArray} arr1 The first array to compare.\n * @param {Array|Uint8ClampedArray} arr2 The second array to compare.\n * @return {boolean} Whether the two arrays are equal.\n */\nexport function equals(arr1, arr2) {\n const len1 = arr1.length;\n if (len1 !== arr2.length) {\n return false;\n }\n for (let i = 0; i < len1; i++) {\n if (arr1[i] !== arr2[i]) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * Sort the passed array such that the relative order of equal elements is preserved.\n * See https://en.wikipedia.org/wiki/Sorting_algorithm#Stability for details.\n * @param {Array<*>} arr The array to sort (modifies original).\n * @param {!function(*, *): number} compareFnc Comparison function.\n * @api\n */\nexport function stableSort(arr, compareFnc) {\n const length = arr.length;\n const tmp = Array(arr.length);\n let i;\n for (i = 0; i < length; i++) {\n tmp[i] = {index: i, value: arr[i]};\n }\n tmp.sort(function (a, b) {\n return compareFnc(a.value, b.value) || a.index - b.index;\n });\n for (i = 0; i < arr.length; i++) {\n arr[i] = tmp[i].value;\n }\n}\n\n/**\n * @param {Array<*>} arr The array to test.\n * @param {Function} [func] Comparison function.\n * @param {boolean} [strict] Strictly sorted (default false).\n * @return {boolean} Return index.\n */\nexport function isSorted(arr, func, strict) {\n const compare = func || ascending;\n return arr.every(function (currentVal, index) {\n if (index === 0) {\n return true;\n }\n const res = compare(arr[index - 1], currentVal);\n return !(res > 0 || (strict && res === 0));\n });\n}\n","/**\n * @module ol/functions\n */\n\nimport {equals as arrayEquals} from './array.js';\n\n/**\n * Always returns true.\n * @return {boolean} true.\n */\nexport function TRUE() {\n return true;\n}\n\n/**\n * Always returns false.\n * @return {boolean} false.\n */\nexport function FALSE() {\n return false;\n}\n\n/**\n * A reusable function, used e.g. as a default for callbacks.\n *\n * @return {void} Nothing.\n */\nexport function VOID() {}\n\n/**\n * Wrap a function in another function that remembers the last return. If the\n * returned function is called twice in a row with the same arguments and the same\n * this object, it will return the value from the first call in the second call.\n *\n * @param {function(...any): ReturnType} fn The function to memoize.\n * @return {function(...any): ReturnType} The memoized function.\n * @template ReturnType\n */\nexport function memoizeOne(fn) {\n let called = false;\n\n /** @type {ReturnType} */\n let lastResult;\n\n /** @type {Array} */\n let lastArgs;\n\n let lastThis;\n\n return function () {\n const nextArgs = Array.prototype.slice.call(arguments);\n if (!called || this !== lastThis || !arrayEquals(nextArgs, lastArgs)) {\n called = true;\n lastThis = this;\n lastArgs = nextArgs;\n lastResult = fn.apply(this, arguments);\n }\n return lastResult;\n };\n}\n\n/**\n * @template T\n * @param {function(): (T | Promise)} getter A function that returns a value or a promise for a value.\n * @return {Promise} A promise for the value.\n */\nexport function toPromise(getter) {\n function promiseGetter() {\n let value;\n try {\n value = getter();\n } catch (err) {\n return Promise.reject(err);\n }\n if (value instanceof Promise) {\n return value;\n }\n return Promise.resolve(value);\n }\n return promiseGetter();\n}\n","/**\n * @module ol/obj\n */\n\n/**\n * Removes all properties from an object.\n * @param {Object} object The object to clear.\n */\nexport function clear(object) {\n for (const property in object) {\n delete object[property];\n }\n}\n\n/**\n * Determine if an object has any properties.\n * @param {Object} object The object to check.\n * @return {boolean} The object is empty.\n */\nexport function isEmpty(object) {\n let property;\n for (property in object) {\n return false;\n }\n return !property;\n}\n","/**\n * @module ol/events/Target\n */\nimport Disposable from '../Disposable.js';\nimport Event from './Event.js';\nimport {VOID} from '../functions.js';\nimport {clear} from '../obj.js';\n\n/**\n * @typedef {EventTarget|Target} EventTargetLike\n */\n\n/**\n * @classdesc\n * A simplified implementation of the W3C DOM Level 2 EventTarget interface.\n * See https://www.w3.org/TR/2000/REC-DOM-Level-2-Events-20001113/events.html#Events-EventTarget.\n *\n * There are two important simplifications compared to the specification:\n *\n * 1. The handling of `useCapture` in `addEventListener` and\n * `removeEventListener`. There is no real capture model.\n * 2. The handling of `stopPropagation` and `preventDefault` on `dispatchEvent`.\n * There is no event target hierarchy. When a listener calls\n * `stopPropagation` or `preventDefault` on an event object, it means that no\n * more listeners after this one will be called. Same as when the listener\n * returns false.\n */\nclass Target extends Disposable {\n /**\n * @param {*} [target] Default event target for dispatched events.\n */\n constructor(target) {\n super();\n\n /**\n * @private\n * @type {*}\n */\n this.eventTarget_ = target;\n\n /**\n * @private\n * @type {Object}\n */\n this.pendingRemovals_ = null;\n\n /**\n * @private\n * @type {Object}\n */\n this.dispatching_ = null;\n\n /**\n * @private\n * @type {Object>}\n */\n this.listeners_ = null;\n }\n\n /**\n * @param {string} type Type.\n * @param {import(\"../events.js\").Listener} listener Listener.\n */\n addEventListener(type, listener) {\n if (!type || !listener) {\n return;\n }\n const listeners = this.listeners_ || (this.listeners_ = {});\n const listenersForType = listeners[type] || (listeners[type] = []);\n if (!listenersForType.includes(listener)) {\n listenersForType.push(listener);\n }\n }\n\n /**\n * Dispatches an event and calls all listeners listening for events\n * of this type. The event parameter can either be a string or an\n * Object with a `type` property.\n *\n * @param {import(\"./Event.js\").default|string} event Event object.\n * @return {boolean|undefined} `false` if anyone called preventDefault on the\n * event object or if any of the listeners returned false.\n * @api\n */\n dispatchEvent(event) {\n const isString = typeof event === 'string';\n const type = isString ? event : event.type;\n const listeners = this.listeners_ && this.listeners_[type];\n if (!listeners) {\n return;\n }\n\n const evt = isString ? new Event(event) : /** @type {Event} */ (event);\n if (!evt.target) {\n evt.target = this.eventTarget_ || this;\n }\n const dispatching = this.dispatching_ || (this.dispatching_ = {});\n const pendingRemovals =\n this.pendingRemovals_ || (this.pendingRemovals_ = {});\n if (!(type in dispatching)) {\n dispatching[type] = 0;\n pendingRemovals[type] = 0;\n }\n ++dispatching[type];\n let propagate;\n for (let i = 0, ii = listeners.length; i < ii; ++i) {\n if ('handleEvent' in listeners[i]) {\n propagate = /** @type {import(\"../events.js\").ListenerObject} */ (\n listeners[i]\n ).handleEvent(evt);\n } else {\n propagate = /** @type {import(\"../events.js\").ListenerFunction} */ (\n listeners[i]\n ).call(this, evt);\n }\n if (propagate === false || evt.propagationStopped) {\n propagate = false;\n break;\n }\n }\n if (--dispatching[type] === 0) {\n let pr = pendingRemovals[type];\n delete pendingRemovals[type];\n while (pr--) {\n this.removeEventListener(type, VOID);\n }\n delete dispatching[type];\n }\n return propagate;\n }\n\n /**\n * Clean up.\n */\n disposeInternal() {\n this.listeners_ && clear(this.listeners_);\n }\n\n /**\n * Get the listeners for a specified event type. Listeners are returned in the\n * order that they will be called in.\n *\n * @param {string} type Type.\n * @return {Array|undefined} Listeners.\n */\n getListeners(type) {\n return (this.listeners_ && this.listeners_[type]) || undefined;\n }\n\n /**\n * @param {string} [type] Type. If not provided,\n * `true` will be returned if this event target has any listeners.\n * @return {boolean} Has listeners.\n */\n hasListener(type) {\n if (!this.listeners_) {\n return false;\n }\n return type\n ? type in this.listeners_\n : Object.keys(this.listeners_).length > 0;\n }\n\n /**\n * @param {string} type Type.\n * @param {import(\"../events.js\").Listener} listener Listener.\n */\n removeEventListener(type, listener) {\n const listeners = this.listeners_ && this.listeners_[type];\n if (listeners) {\n const index = listeners.indexOf(listener);\n if (index !== -1) {\n if (this.pendingRemovals_ && type in this.pendingRemovals_) {\n // make listener a no-op, and remove later in #dispatchEvent()\n listeners[index] = VOID;\n ++this.pendingRemovals_[type];\n } else {\n listeners.splice(index, 1);\n if (listeners.length === 0) {\n delete this.listeners_[type];\n }\n }\n }\n }\n }\n}\n\nexport default Target;\n","/**\n * @module ol/events/EventType\n */\n\n/**\n * @enum {string}\n * @const\n */\nexport default {\n /**\n * Generic change event. Triggered when the revision counter is increased.\n * @event module:ol/events/Event~BaseEvent#change\n * @api\n */\n CHANGE: 'change',\n\n /**\n * Generic error event. Triggered when an error occurs.\n * @event module:ol/events/Event~BaseEvent#error\n * @api\n */\n ERROR: 'error',\n\n BLUR: 'blur',\n CLEAR: 'clear',\n CONTEXTMENU: 'contextmenu',\n CLICK: 'click',\n DBLCLICK: 'dblclick',\n DRAGENTER: 'dragenter',\n DRAGOVER: 'dragover',\n DROP: 'drop',\n FOCUS: 'focus',\n KEYDOWN: 'keydown',\n KEYPRESS: 'keypress',\n LOAD: 'load',\n RESIZE: 'resize',\n TOUCHMOVE: 'touchmove',\n WHEEL: 'wheel',\n};\n","/**\n * @module ol/events\n */\nimport {clear} from './obj.js';\n\n/**\n * Key to use with {@link module:ol/Observable.unByKey}.\n * @typedef {Object} EventsKey\n * @property {ListenerFunction} listener Listener.\n * @property {import(\"./events/Target.js\").EventTargetLike} target Target.\n * @property {string} type Type.\n * @api\n */\n\n/**\n * Listener function. This function is called with an event object as argument.\n * When the function returns `false`, event propagation will stop.\n *\n * @typedef {function((Event|import(\"./events/Event.js\").default)): (void|boolean)} ListenerFunction\n * @api\n */\n\n/**\n * @typedef {Object} ListenerObject\n * @property {ListenerFunction} handleEvent HandleEvent listener function.\n */\n\n/**\n * @typedef {ListenerFunction|ListenerObject} Listener\n */\n\n/**\n * Registers an event listener on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * This function efficiently binds a `listener` to a `this` object, and returns\n * a key for use with {@link module:ol/events.unlistenByKey}.\n *\n * @param {import(\"./events/Target.js\").EventTargetLike} target Event target.\n * @param {string} type Event type.\n * @param {ListenerFunction} listener Listener.\n * @param {Object} [thisArg] Object referenced by the `this` keyword in the\n * listener. Default is the `target`.\n * @param {boolean} [once] If true, add the listener as one-off listener.\n * @return {EventsKey} Unique key for the listener.\n */\nexport function listen(target, type, listener, thisArg, once) {\n if (thisArg && thisArg !== target) {\n listener = listener.bind(thisArg);\n }\n if (once) {\n const originalListener = listener;\n listener = function () {\n target.removeEventListener(type, listener);\n originalListener.apply(this, arguments);\n };\n }\n const eventsKey = {\n target: target,\n type: type,\n listener: listener,\n };\n target.addEventListener(type, listener);\n return eventsKey;\n}\n\n/**\n * Registers a one-off event listener on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * This function efficiently binds a `listener` as self-unregistering listener\n * to a `this` object, and returns a key for use with\n * {@link module:ol/events.unlistenByKey} in case the listener needs to be\n * unregistered before it is called.\n *\n * When {@link module:ol/events.listen} is called with the same arguments after this\n * function, the self-unregistering listener will be turned into a permanent\n * listener.\n *\n * @param {import(\"./events/Target.js\").EventTargetLike} target Event target.\n * @param {string} type Event type.\n * @param {ListenerFunction} listener Listener.\n * @param {Object} [thisArg] Object referenced by the `this` keyword in the\n * listener. Default is the `target`.\n * @return {EventsKey} Key for unlistenByKey.\n */\nexport function listenOnce(target, type, listener, thisArg) {\n return listen(target, type, listener, thisArg, true);\n}\n\n/**\n * Unregisters event listeners on an event target. Inspired by\n * https://google.github.io/closure-library/api/source/closure/goog/events/events.js.src.html\n *\n * The argument passed to this function is the key returned from\n * {@link module:ol/events.listen} or {@link module:ol/events.listenOnce}.\n *\n * @param {EventsKey} key The key.\n */\nexport function unlistenByKey(key) {\n if (key && key.target) {\n key.target.removeEventListener(key.type, key.listener);\n clear(key);\n }\n}\n","/**\n * @module ol/Observable\n */\nimport EventTarget from './events/Target.js';\nimport EventType from './events/EventType.js';\nimport {listen, listenOnce, unlistenByKey} from './events.js';\n\n/***\n * @template {string} Type\n * @template {Event|import(\"./events/Event.js\").default} EventClass\n * @template Return\n * @typedef {(type: Type, listener: (event: EventClass) => ?) => Return} OnSignature\n */\n\n/***\n * @template {string} Type\n * @template Return\n * @typedef {(type: Type[], listener: (event: Event|import(\"./events/Event\").default) => ?) => Return extends void ? void : Return[]} CombinedOnSignature\n */\n\n/**\n * @typedef {'change'|'error'} EventTypes\n */\n\n/***\n * @template Return\n * @typedef {OnSignature & CombinedOnSignature} ObservableOnSignature\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * An event target providing convenient methods for listener registration\n * and unregistration. A generic `change` event is always available through\n * {@link module:ol/Observable~Observable#changed}.\n *\n * @fires import(\"./events/Event.js\").default\n * @api\n */\nclass Observable extends EventTarget {\n constructor() {\n super();\n\n this.on =\n /** @type {ObservableOnSignature} */ (\n this.onInternal\n );\n\n this.once =\n /** @type {ObservableOnSignature} */ (\n this.onceInternal\n );\n\n this.un = /** @type {ObservableOnSignature} */ (this.unInternal);\n\n /**\n * @private\n * @type {number}\n */\n this.revision_ = 0;\n }\n\n /**\n * Increases the revision counter and dispatches a 'change' event.\n * @api\n */\n changed() {\n ++this.revision_;\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * Get the version number for this object. Each time the object is modified,\n * its version number will be incremented.\n * @return {number} Revision.\n * @api\n */\n getRevision() {\n return this.revision_;\n }\n\n /**\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener Listener.\n * @return {import(\"./events.js\").EventsKey|Array} Event key.\n * @protected\n */\n onInternal(type, listener) {\n if (Array.isArray(type)) {\n const len = type.length;\n const keys = new Array(len);\n for (let i = 0; i < len; ++i) {\n keys[i] = listen(this, type[i], listener);\n }\n return keys;\n }\n return listen(this, /** @type {string} */ (type), listener);\n }\n\n /**\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener Listener.\n * @return {import(\"./events.js\").EventsKey|Array} Event key.\n * @protected\n */\n onceInternal(type, listener) {\n let key;\n if (Array.isArray(type)) {\n const len = type.length;\n key = new Array(len);\n for (let i = 0; i < len; ++i) {\n key[i] = listenOnce(this, type[i], listener);\n }\n } else {\n key = listenOnce(this, /** @type {string} */ (type), listener);\n }\n /** @type {Object} */ (listener).ol_key = key;\n return key;\n }\n\n /**\n * Unlisten for a certain type of event.\n * @param {string|Array} type Type.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener Listener.\n * @protected\n */\n unInternal(type, listener) {\n const key = /** @type {Object} */ (listener).ol_key;\n if (key) {\n unByKey(key);\n } else if (Array.isArray(type)) {\n for (let i = 0, ii = type.length; i < ii; ++i) {\n this.removeEventListener(type[i], listener);\n }\n } else {\n this.removeEventListener(type, listener);\n }\n }\n}\n\n/**\n * Listen for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener The listener function.\n * @return {import(\"./events.js\").EventsKey|Array} Unique key for the listener. If\n * called with an array of event types as the first argument, the return\n * will be an array of keys.\n * @api\n */\nObservable.prototype.on;\n\n/**\n * Listen once for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener The listener function.\n * @return {import(\"./events.js\").EventsKey|Array} Unique key for the listener. If\n * called with an array of event types as the first argument, the return\n * will be an array of keys.\n * @api\n */\nObservable.prototype.once;\n\n/**\n * Unlisten for a certain type of event.\n * @function\n * @param {string|Array} type The event type or array of event types.\n * @param {function((Event|import(\"./events/Event\").default)): ?} listener The listener function.\n * @api\n */\nObservable.prototype.un;\n\n/**\n * Removes an event listener using the key returned by `on()` or `once()`.\n * @param {import(\"./events.js\").EventsKey|Array} key The key returned by `on()`\n * or `once()` (or an array of keys).\n * @api\n */\nexport function unByKey(key) {\n if (Array.isArray(key)) {\n for (let i = 0, ii = key.length; i < ii; ++i) {\n unlistenByKey(key[i]);\n }\n } else {\n unlistenByKey(/** @type {import(\"./events.js\").EventsKey} */ (key));\n }\n}\n\nexport default Observable;\n","/**\n * @module ol/util\n */\n\n/**\n * @return {never} Any return.\n */\nexport function abstract() {\n throw new Error('Unimplemented abstract method.');\n}\n\n/**\n * Counter for getUid.\n * @type {number}\n * @private\n */\nlet uidCounter_ = 0;\n\n/**\n * Gets a unique ID for an object. This mutates the object so that further calls\n * with the same object as a parameter returns the same value. Unique IDs are generated\n * as a strictly increasing sequence. Adapted from goog.getUid.\n *\n * @param {Object} obj The object to get the unique ID for.\n * @return {string} The unique ID for the object.\n * @api\n */\nexport function getUid(obj) {\n return obj.ol_uid || (obj.ol_uid = String(++uidCounter_));\n}\n\n/**\n * OpenLayers version.\n * @type {string}\n */\nexport const VERSION = '8.0.0';\n","/**\n * @module ol/Object\n */\nimport Event from './events/Event.js';\nimport ObjectEventType from './ObjectEventType.js';\nimport Observable from './Observable.js';\nimport {getUid} from './util.js';\nimport {isEmpty} from './obj.js';\n\n/**\n * @classdesc\n * Events emitted by {@link module:ol/Object~BaseObject} instances are instances of this type.\n */\nexport class ObjectEvent extends Event {\n /**\n * @param {string} type The event type.\n * @param {string} key The property name.\n * @param {*} oldValue The old value for `key`.\n */\n constructor(type, key, oldValue) {\n super(type);\n\n /**\n * The name of the property whose value is changing.\n * @type {string}\n * @api\n */\n this.key = key;\n\n /**\n * The old value. To get the new value use `e.target.get(e.key)` where\n * `e` is the event object.\n * @type {*}\n * @api\n */\n this.oldValue = oldValue;\n }\n}\n\n/***\n * @template Return\n * @typedef {import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature &\n * import(\"./Observable\").CombinedOnSignature} ObjectOnSignature\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Most non-trivial classes inherit from this.\n *\n * This extends {@link module:ol/Observable~Observable} with observable\n * properties, where each property is observable as well as the object as a\n * whole.\n *\n * Classes that inherit from this have pre-defined properties, to which you can\n * add your owns. The pre-defined properties are listed in this documentation as\n * 'Observable Properties', and have their own accessors; for example,\n * {@link module:ol/Map~Map} has a `target` property, accessed with\n * `getTarget()` and changed with `setTarget()`. Not all properties are however\n * settable. There are also general-purpose accessors `get()` and `set()`. For\n * example, `get('target')` is equivalent to `getTarget()`.\n *\n * The `set` accessors trigger a change event, and you can monitor this by\n * registering a listener. For example, {@link module:ol/View~View} has a\n * `center` property, so `view.on('change:center', function(evt) {...});` would\n * call the function whenever the value of the center property changes. Within\n * the function, `evt.target` would be the view, so `evt.target.getCenter()`\n * would return the new center.\n *\n * You can add your own observable properties with\n * `object.set('prop', 'value')`, and retrieve that with `object.get('prop')`.\n * You can listen for changes on that property value with\n * `object.on('change:prop', listener)`. You can get a list of all\n * properties with {@link module:ol/Object~BaseObject#getProperties}.\n *\n * Note that the observable properties are separate from standard JS properties.\n * You can, for example, give your map object a title with\n * `map.title='New title'` and with `map.set('title', 'Another title')`. The\n * first will be a `hasOwnProperty`; the second will appear in\n * `getProperties()`. Only the second is observable.\n *\n * Properties can be deleted by using the unset method. E.g.\n * object.unset('foo').\n *\n * @fires ObjectEvent\n * @api\n */\nclass BaseObject extends Observable {\n /**\n * @param {Object} [values] An object with key-value pairs.\n */\n constructor(values) {\n super();\n\n /***\n * @type {ObjectOnSignature}\n */\n this.on;\n\n /***\n * @type {ObjectOnSignature}\n */\n this.once;\n\n /***\n * @type {ObjectOnSignature}\n */\n this.un;\n\n // Call {@link module:ol/util.getUid} to ensure that the order of objects' ids is\n // the same as the order in which they were created. This also helps to\n // ensure that object properties are always added in the same order, which\n // helps many JavaScript engines generate faster code.\n getUid(this);\n\n /**\n * @private\n * @type {Object}\n */\n this.values_ = null;\n\n if (values !== undefined) {\n this.setProperties(values);\n }\n }\n\n /**\n * Gets a value.\n * @param {string} key Key name.\n * @return {*} Value.\n * @api\n */\n get(key) {\n let value;\n if (this.values_ && this.values_.hasOwnProperty(key)) {\n value = this.values_[key];\n }\n return value;\n }\n\n /**\n * Get a list of object property names.\n * @return {Array} List of property names.\n * @api\n */\n getKeys() {\n return (this.values_ && Object.keys(this.values_)) || [];\n }\n\n /**\n * Get an object of all property names and values.\n * @return {Object} Object.\n * @api\n */\n getProperties() {\n return (this.values_ && Object.assign({}, this.values_)) || {};\n }\n\n /**\n * Get an object of all property names and values.\n * @return {Object?} Object.\n */\n getPropertiesInternal() {\n return this.values_;\n }\n\n /**\n * @return {boolean} The object has properties.\n */\n hasProperties() {\n return !!this.values_;\n }\n\n /**\n * @param {string} key Key name.\n * @param {*} oldValue Old value.\n */\n notify(key, oldValue) {\n let eventType;\n eventType = `change:${key}`;\n if (this.hasListener(eventType)) {\n this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));\n }\n eventType = ObjectEventType.PROPERTYCHANGE;\n if (this.hasListener(eventType)) {\n this.dispatchEvent(new ObjectEvent(eventType, key, oldValue));\n }\n }\n\n /**\n * @param {string} key Key name.\n * @param {import(\"./events.js\").Listener} listener Listener.\n */\n addChangeListener(key, listener) {\n this.addEventListener(`change:${key}`, listener);\n }\n\n /**\n * @param {string} key Key name.\n * @param {import(\"./events.js\").Listener} listener Listener.\n */\n removeChangeListener(key, listener) {\n this.removeEventListener(`change:${key}`, listener);\n }\n\n /**\n * Sets a value.\n * @param {string} key Key name.\n * @param {*} value Value.\n * @param {boolean} [silent] Update without triggering an event.\n * @api\n */\n set(key, value, silent) {\n const values = this.values_ || (this.values_ = {});\n if (silent) {\n values[key] = value;\n } else {\n const oldValue = values[key];\n values[key] = value;\n if (oldValue !== value) {\n this.notify(key, oldValue);\n }\n }\n }\n\n /**\n * Sets a collection of key-value pairs. Note that this changes any existing\n * properties and adds new ones (it does not remove any existing properties).\n * @param {Object} values Values.\n * @param {boolean} [silent] Update without triggering an event.\n * @api\n */\n setProperties(values, silent) {\n for (const key in values) {\n this.set(key, values[key], silent);\n }\n }\n\n /**\n * Apply any properties from another object without triggering events.\n * @param {BaseObject} source The source object.\n * @protected\n */\n applyProperties(source) {\n if (!source.values_) {\n return;\n }\n Object.assign(this.values_ || (this.values_ = {}), source.values_);\n }\n\n /**\n * Unsets a property.\n * @param {string} key Key name.\n * @param {boolean} [silent] Unset without triggering an event.\n * @api\n */\n unset(key, silent) {\n if (this.values_ && key in this.values_) {\n const oldValue = this.values_[key];\n delete this.values_[key];\n if (isEmpty(this.values_)) {\n this.values_ = null;\n }\n if (!silent) {\n this.notify(key, oldValue);\n }\n }\n }\n}\n\nexport default BaseObject;\n","/**\n * @module ol/asserts\n */\n\n/**\n * @param {*} assertion Assertion we expected to be truthy.\n * @param {string} errorMessage Error message.\n */\nexport function assert(assertion, errorMessage) {\n if (!assertion) {\n throw new Error(errorMessage);\n }\n}\n","/**\n * @module ol/Feature\n */\nimport BaseObject from './Object.js';\nimport EventType from './events/EventType.js';\nimport {assert} from './asserts.js';\nimport {listen, unlistenByKey} from './events.js';\n\n/**\n * @typedef {typeof Feature|typeof import(\"./render/Feature.js\").default} FeatureClass\n */\n\n/**\n * @typedef {Feature|import(\"./render/Feature.js\").default} FeatureLike\n */\n\n/***\n * @template Return\n * @typedef {import(\"./Observable\").OnSignature &\n * import(\"./Observable\").OnSignature &\n * import(\"./Observable\").CombinedOnSignature} FeatureOnSignature\n */\n\n/***\n * @template Geometry\n * @typedef {Object & { geometry?: Geometry }} ObjectWithGeometry\n */\n\n/**\n * @classdesc\n * A vector object for geographic features with a geometry and other\n * attribute properties, similar to the features in vector file formats like\n * GeoJSON.\n *\n * Features can be styled individually with `setStyle`; otherwise they use the\n * style of their vector layer.\n *\n * Note that attribute properties are set as {@link module:ol/Object~BaseObject} properties on\n * the feature object, so they are observable, and have get/set accessors.\n *\n * Typically, a feature has a single geometry property. You can set the\n * geometry using the `setGeometry` method and get it with `getGeometry`.\n * It is possible to store more than one geometry on a feature using attribute\n * properties. By default, the geometry used for rendering is identified by\n * the property name `geometry`. If you want to use another geometry property\n * for rendering, use the `setGeometryName` method to change the attribute\n * property associated with the geometry for the feature. For example:\n *\n * ```js\n *\n * import Feature from 'ol/Feature.js';\n * import Polygon from 'ol/geom/Polygon.js';\n * import Point from 'ol/geom/Point.js';\n *\n * const feature = new Feature({\n * geometry: new Polygon(polyCoords),\n * labelPoint: new Point(labelCoords),\n * name: 'My Polygon',\n * });\n *\n * // get the polygon geometry\n * const poly = feature.getGeometry();\n *\n * // Render the feature as a point using the coordinates from labelPoint\n * feature.setGeometryName('labelPoint');\n *\n * // get the point geometry\n * const point = feature.getGeometry();\n * ```\n *\n * @api\n * @template {import(\"./geom/Geometry.js\").default} [Geometry=import(\"./geom/Geometry.js\").default]\n */\nclass Feature extends BaseObject {\n /**\n * @param {Geometry|ObjectWithGeometry} [geometryOrProperties]\n * You may pass a Geometry object directly, or an object literal containing\n * properties. If you pass an object literal, you may include a Geometry\n * associated with a `geometry` key.\n */\n constructor(geometryOrProperties) {\n super();\n\n /***\n * @type {FeatureOnSignature}\n */\n this.on;\n\n /***\n * @type {FeatureOnSignature}\n */\n this.once;\n\n /***\n * @type {FeatureOnSignature}\n */\n this.un;\n\n /**\n * @private\n * @type {number|string|undefined}\n */\n this.id_ = undefined;\n\n /**\n * @type {string}\n * @private\n */\n this.geometryName_ = 'geometry';\n\n /**\n * User provided style.\n * @private\n * @type {import(\"./style/Style.js\").StyleLike}\n */\n this.style_ = null;\n\n /**\n * @private\n * @type {import(\"./style/Style.js\").StyleFunction|undefined}\n */\n this.styleFunction_ = undefined;\n\n /**\n * @private\n * @type {?import(\"./events.js\").EventsKey}\n */\n this.geometryChangeKey_ = null;\n\n this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);\n\n if (geometryOrProperties) {\n if (\n typeof (\n /** @type {?} */ (geometryOrProperties).getSimplifiedGeometry\n ) === 'function'\n ) {\n const geometry = /** @type {Geometry} */ (geometryOrProperties);\n this.setGeometry(geometry);\n } else {\n /** @type {Object} */\n const properties = geometryOrProperties;\n this.setProperties(properties);\n }\n }\n }\n\n /**\n * Clone this feature. If the original feature has a geometry it\n * is also cloned. The feature id is not set in the clone.\n * @return {Feature} The clone.\n * @api\n */\n clone() {\n const clone = /** @type {Feature} */ (\n new Feature(this.hasProperties() ? this.getProperties() : null)\n );\n clone.setGeometryName(this.getGeometryName());\n const geometry = this.getGeometry();\n if (geometry) {\n clone.setGeometry(/** @type {Geometry} */ (geometry.clone()));\n }\n const style = this.getStyle();\n if (style) {\n clone.setStyle(style);\n }\n return clone;\n }\n\n /**\n * Get the feature's default geometry. A feature may have any number of named\n * geometries. The \"default\" geometry (the one that is rendered by default) is\n * set when calling {@link module:ol/Feature~Feature#setGeometry}.\n * @return {Geometry|undefined} The default geometry for the feature.\n * @api\n * @observable\n */\n getGeometry() {\n return /** @type {Geometry|undefined} */ (this.get(this.geometryName_));\n }\n\n /**\n * Get the feature identifier. This is a stable identifier for the feature and\n * is either set when reading data from a remote source or set explicitly by\n * calling {@link module:ol/Feature~Feature#setId}.\n * @return {number|string|undefined} Id.\n * @api\n */\n getId() {\n return this.id_;\n }\n\n /**\n * Get the name of the feature's default geometry. By default, the default\n * geometry is named `geometry`.\n * @return {string} Get the property name associated with the default geometry\n * for this feature.\n * @api\n */\n getGeometryName() {\n return this.geometryName_;\n }\n\n /**\n * Get the feature's style. Will return what was provided to the\n * {@link module:ol/Feature~Feature#setStyle} method.\n * @return {import(\"./style/Style.js\").StyleLike|undefined} The feature style.\n * @api\n */\n getStyle() {\n return this.style_;\n }\n\n /**\n * Get the feature's style function.\n * @return {import(\"./style/Style.js\").StyleFunction|undefined} Return a function\n * representing the current style of this feature.\n * @api\n */\n getStyleFunction() {\n return this.styleFunction_;\n }\n\n /**\n * @private\n */\n handleGeometryChange_() {\n this.changed();\n }\n\n /**\n * @private\n */\n handleGeometryChanged_() {\n if (this.geometryChangeKey_) {\n unlistenByKey(this.geometryChangeKey_);\n this.geometryChangeKey_ = null;\n }\n const geometry = this.getGeometry();\n if (geometry) {\n this.geometryChangeKey_ = listen(\n geometry,\n EventType.CHANGE,\n this.handleGeometryChange_,\n this\n );\n }\n this.changed();\n }\n\n /**\n * Set the default geometry for the feature. This will update the property\n * with the name returned by {@link module:ol/Feature~Feature#getGeometryName}.\n * @param {Geometry|undefined} geometry The new geometry.\n * @api\n * @observable\n */\n setGeometry(geometry) {\n this.set(this.geometryName_, geometry);\n }\n\n /**\n * Set the style for the feature to override the layer style. This can be a\n * single style object, an array of styles, or a function that takes a\n * resolution and returns an array of styles. To unset the feature style, call\n * `setStyle()` without arguments or a falsey value.\n * @param {import(\"./style/Style.js\").StyleLike} [style] Style for this feature.\n * @api\n * @fires module:ol/events/Event~BaseEvent#event:change\n */\n setStyle(style) {\n this.style_ = style;\n this.styleFunction_ = !style ? undefined : createStyleFunction(style);\n this.changed();\n }\n\n /**\n * Set the feature id. The feature id is considered stable and may be used when\n * requesting features or comparing identifiers returned from a remote source.\n * The feature id can be used with the\n * {@link module:ol/source/Vector~VectorSource#getFeatureById} method.\n * @param {number|string|undefined} id The feature id.\n * @api\n * @fires module:ol/events/Event~BaseEvent#event:change\n */\n setId(id) {\n this.id_ = id;\n this.changed();\n }\n\n /**\n * Set the property name to be used when getting the feature's default geometry.\n * When calling {@link module:ol/Feature~Feature#getGeometry}, the value of the property with\n * this name will be returned.\n * @param {string} name The property name of the default geometry.\n * @api\n */\n setGeometryName(name) {\n this.removeChangeListener(this.geometryName_, this.handleGeometryChanged_);\n this.geometryName_ = name;\n this.addChangeListener(this.geometryName_, this.handleGeometryChanged_);\n this.handleGeometryChanged_();\n }\n}\n\n/**\n * Convert the provided object into a feature style function. Functions passed\n * through unchanged. Arrays of Style or single style objects wrapped\n * in a new feature style function.\n * @param {!import(\"./style/Style.js\").StyleFunction|!Array|!import(\"./style/Style.js\").default} obj\n * A feature style function, a single style, or an array of styles.\n * @return {import(\"./style/Style.js\").StyleFunction} A style function.\n */\nexport function createStyleFunction(obj) {\n if (typeof obj === 'function') {\n return obj;\n }\n /**\n * @type {Array}\n */\n let styles;\n if (Array.isArray(obj)) {\n styles = obj;\n } else {\n assert(\n typeof (/** @type {?} */ (obj).getZIndex) === 'function',\n 'Expected an `ol/style/Style` or an array of `ol/style/Style.js`'\n );\n const style = /** @type {import(\"./style/Style.js\").default} */ (obj);\n styles = [style];\n }\n return function () {\n return styles;\n };\n}\nexport default Feature;\n","/**\n * @module ol/ImageState\n */\n\n/**\n * @enum {number}\n */\nexport default {\n IDLE: 0,\n LOADING: 1,\n LOADED: 2,\n ERROR: 3,\n EMPTY: 4,\n};\n","/**\n * @module ol/size\n */\n\n/**\n * An array of numbers representing a size: `[width, height]`.\n * @typedef {Array} Size\n * @api\n */\n\n/**\n * Returns a buffered size.\n * @param {Size} size Size.\n * @param {number} num The amount by which to buffer.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} The buffered size.\n */\nexport function buffer(size, num, dest) {\n if (dest === undefined) {\n dest = [0, 0];\n }\n dest[0] = size[0] + 2 * num;\n dest[1] = size[1] + 2 * num;\n return dest;\n}\n\n/**\n * Determines if a size has a positive area.\n * @param {Size} size The size to test.\n * @return {boolean} The size has a positive area.\n */\nexport function hasArea(size) {\n return size[0] > 0 && size[1] > 0;\n}\n\n/**\n * Returns a size scaled by a ratio. The result will be an array of integers.\n * @param {Size} size Size.\n * @param {number} ratio Ratio.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} The scaled size.\n */\nexport function scale(size, ratio, dest) {\n if (dest === undefined) {\n dest = [0, 0];\n }\n dest[0] = (size[0] * ratio + 0.5) | 0;\n dest[1] = (size[1] * ratio + 0.5) | 0;\n return dest;\n}\n\n/**\n * Returns an `Size` array for the passed in number (meaning: square) or\n * `Size` array.\n * (meaning: non-square),\n * @param {number|Size} size Width and height.\n * @param {Size} [dest] Optional reusable size array.\n * @return {Size} Size.\n * @api\n */\nexport function toSize(size, dest) {\n if (Array.isArray(size)) {\n return size;\n }\n if (dest === undefined) {\n dest = [size, size];\n } else {\n dest[0] = size;\n dest[1] = size;\n }\n return dest;\n}\n","/**\n * @module ol/style/Image\n */\nimport {abstract} from '../util.js';\nimport {toSize} from '../size.js';\n\n/**\n * @typedef {Object} Options\n * @property {number} opacity Opacity.\n * @property {boolean} rotateWithView If the image should get rotated with the view.\n * @property {number} rotation Rotation.\n * @property {number|import(\"../size.js\").Size} scale Scale.\n * @property {Array} displacement Displacement.\n * @property {\"declutter\"|\"obstacle\"|\"none\"|undefined} declutterMode Declutter mode: `declutter`, `obstacle`, 'none */\n\n/**\n * @classdesc\n * A base class used for creating subclasses and not instantiated in\n * apps. Base class for {@link module:ol/style/Icon~Icon}, {@link module:ol/style/Circle~CircleStyle} and\n * {@link module:ol/style/RegularShape~RegularShape}.\n * @abstract\n * @api\n */\nclass ImageStyle {\n /**\n * @param {Options} options Options.\n */\n constructor(options) {\n /**\n * @private\n * @type {number}\n */\n this.opacity_ = options.opacity;\n\n /**\n * @private\n * @type {boolean}\n */\n this.rotateWithView_ = options.rotateWithView;\n\n /**\n * @private\n * @type {number}\n */\n this.rotation_ = options.rotation;\n\n /**\n * @private\n * @type {number|import(\"../size.js\").Size}\n */\n this.scale_ = options.scale;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.scaleArray_ = toSize(options.scale);\n\n /**\n * @private\n * @type {Array}\n */\n this.displacement_ = options.displacement;\n\n /**\n * @private\n * @type {\"declutter\"|\"obstacle\"|\"none\"|undefined}\n */\n this.declutterMode_ = options.declutterMode;\n }\n\n /**\n * Clones the style.\n * @return {ImageStyle} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n return new ImageStyle({\n opacity: this.getOpacity(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n }\n\n /**\n * Get the symbolizer opacity.\n * @return {number} Opacity.\n * @api\n */\n getOpacity() {\n return this.opacity_;\n }\n\n /**\n * Determine whether the symbolizer rotates with the map.\n * @return {boolean} Rotate with map.\n * @api\n */\n getRotateWithView() {\n return this.rotateWithView_;\n }\n\n /**\n * Get the symoblizer rotation.\n * @return {number} Rotation.\n * @api\n */\n getRotation() {\n return this.rotation_;\n }\n\n /**\n * Get the symbolizer scale.\n * @return {number|import(\"../size.js\").Size} Scale.\n * @api\n */\n getScale() {\n return this.scale_;\n }\n\n /**\n * Get the symbolizer scale array.\n * @return {import(\"../size.js\").Size} Scale array.\n */\n getScaleArray() {\n return this.scaleArray_;\n }\n\n /**\n * Get the displacement of the shape\n * @return {Array} Shape's center displacement\n * @api\n */\n getDisplacement() {\n return this.displacement_;\n }\n\n /**\n * Get the declutter mode of the shape\n * @return {\"declutter\"|\"obstacle\"|\"none\"|undefined} Shape's declutter mode\n * @api\n */\n getDeclutterMode() {\n return this.declutterMode_;\n }\n\n /**\n * Get the anchor point in pixels. The anchor determines the center point for the\n * symbolizer.\n * @abstract\n * @return {Array} Anchor.\n */\n getAnchor() {\n return abstract();\n }\n\n /**\n * Get the image element for the symbolizer.\n * @abstract\n * @param {number} pixelRatio Pixel ratio.\n * @return {import('../DataTile.js').ImageLike} Image element.\n */\n getImage(pixelRatio) {\n return abstract();\n }\n\n /**\n * @abstract\n * @return {import('../DataTile.js').ImageLike} Image element.\n */\n getHitDetectionImage() {\n return abstract();\n }\n\n /**\n * Get the image pixel ratio.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Pixel ratio.\n */\n getPixelRatio(pixelRatio) {\n return 1;\n }\n\n /**\n * @abstract\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return abstract();\n }\n\n /**\n * @abstract\n * @return {import(\"../size.js\").Size} Image size.\n */\n getImageSize() {\n return abstract();\n }\n\n /**\n * Get the origin of the symbolizer.\n * @abstract\n * @return {Array} Origin.\n */\n getOrigin() {\n return abstract();\n }\n\n /**\n * Get the size of the symbolizer (in pixels).\n * @abstract\n * @return {import(\"../size.js\").Size} Size.\n */\n getSize() {\n return abstract();\n }\n\n /**\n * Set the displacement.\n *\n * @param {Array} displacement Displacement.\n * @api\n */\n setDisplacement(displacement) {\n this.displacement_ = displacement;\n }\n\n /**\n * Set the opacity.\n *\n * @param {number} opacity Opacity.\n * @api\n */\n setOpacity(opacity) {\n this.opacity_ = opacity;\n }\n\n /**\n * Set whether to rotate the style with the view.\n *\n * @param {boolean} rotateWithView Rotate with map.\n * @api\n */\n setRotateWithView(rotateWithView) {\n this.rotateWithView_ = rotateWithView;\n }\n\n /**\n * Set the rotation.\n *\n * @param {number} rotation Rotation.\n * @api\n */\n setRotation(rotation) {\n this.rotation_ = rotation;\n }\n\n /**\n * Set the scale.\n *\n * @param {number|import(\"../size.js\").Size} scale Scale.\n * @api\n */\n setScale(scale) {\n this.scale_ = scale;\n this.scaleArray_ = toSize(scale);\n }\n\n /**\n * @abstract\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n listenImageChange(listener) {\n abstract();\n }\n\n /**\n * Load not yet loaded URI.\n * @abstract\n */\n load() {\n abstract();\n }\n\n /**\n * @abstract\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n unlistenImageChange(listener) {\n abstract();\n }\n}\n\nexport default ImageStyle;\n","/**\n * @module ol/math\n */\n\n/**\n * Takes a number and clamps it to within the provided bounds.\n * @param {number} value The input number.\n * @param {number} min The minimum value to return.\n * @param {number} max The maximum value to return.\n * @return {number} The input number if it is within bounds, or the nearest\n * number within the bounds.\n */\nexport function clamp(value, min, max) {\n return Math.min(Math.max(value, min), max);\n}\n\n/**\n * Returns the square of the closest distance between the point (x, y) and the\n * line segment (x1, y1) to (x2, y2).\n * @param {number} x X.\n * @param {number} y Y.\n * @param {number} x1 X1.\n * @param {number} y1 Y1.\n * @param {number} x2 X2.\n * @param {number} y2 Y2.\n * @return {number} Squared distance.\n */\nexport function squaredSegmentDistance(x, y, x1, y1, x2, y2) {\n const dx = x2 - x1;\n const dy = y2 - y1;\n if (dx !== 0 || dy !== 0) {\n const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n x1 = x2;\n y1 = y2;\n } else if (t > 0) {\n x1 += dx * t;\n y1 += dy * t;\n }\n }\n return squaredDistance(x, y, x1, y1);\n}\n\n/**\n * Returns the square of the distance between the points (x1, y1) and (x2, y2).\n * @param {number} x1 X1.\n * @param {number} y1 Y1.\n * @param {number} x2 X2.\n * @param {number} y2 Y2.\n * @return {number} Squared distance.\n */\nexport function squaredDistance(x1, y1, x2, y2) {\n const dx = x2 - x1;\n const dy = y2 - y1;\n return dx * dx + dy * dy;\n}\n\n/**\n * Solves system of linear equations using Gaussian elimination method.\n *\n * @param {Array>} mat Augmented matrix (n x n + 1 column)\n * in row-major order.\n * @return {Array} The resulting vector.\n */\nexport function solveLinearSystem(mat) {\n const n = mat.length;\n\n for (let i = 0; i < n; i++) {\n // Find max in the i-th column (ignoring i - 1 first rows)\n let maxRow = i;\n let maxEl = Math.abs(mat[i][i]);\n for (let r = i + 1; r < n; r++) {\n const absValue = Math.abs(mat[r][i]);\n if (absValue > maxEl) {\n maxEl = absValue;\n maxRow = r;\n }\n }\n\n if (maxEl === 0) {\n return null; // matrix is singular\n }\n\n // Swap max row with i-th (current) row\n const tmp = mat[maxRow];\n mat[maxRow] = mat[i];\n mat[i] = tmp;\n\n // Subtract the i-th row to make all the remaining rows 0 in the i-th column\n for (let j = i + 1; j < n; j++) {\n const coef = -mat[j][i] / mat[i][i];\n for (let k = i; k < n + 1; k++) {\n if (i == k) {\n mat[j][k] = 0;\n } else {\n mat[j][k] += coef * mat[i][k];\n }\n }\n }\n }\n\n // Solve Ax=b for upper triangular matrix A (mat)\n const x = new Array(n);\n for (let l = n - 1; l >= 0; l--) {\n x[l] = mat[l][n] / mat[l][l];\n for (let m = l - 1; m >= 0; m--) {\n mat[m][n] -= mat[m][l] * x[l];\n }\n }\n return x;\n}\n\n/**\n * Converts radians to to degrees.\n *\n * @param {number} angleInRadians Angle in radians.\n * @return {number} Angle in degrees.\n */\nexport function toDegrees(angleInRadians) {\n return (angleInRadians * 180) / Math.PI;\n}\n\n/**\n * Converts degrees to radians.\n *\n * @param {number} angleInDegrees Angle in degrees.\n * @return {number} Angle in radians.\n */\nexport function toRadians(angleInDegrees) {\n return (angleInDegrees * Math.PI) / 180;\n}\n\n/**\n * Returns the modulo of a / b, depending on the sign of b.\n *\n * @param {number} a Dividend.\n * @param {number} b Divisor.\n * @return {number} Modulo.\n */\nexport function modulo(a, b) {\n const r = a % b;\n return r * b < 0 ? r + b : r;\n}\n\n/**\n * Calculates the linearly interpolated value of x between a and b.\n *\n * @param {number} a Number\n * @param {number} b Number\n * @param {number} x Value to be interpolated.\n * @return {number} Interpolated value.\n */\nexport function lerp(a, b, x) {\n return a + x * (b - a);\n}\n\n/**\n * Returns a number with a limited number of decimal digits.\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The input number with a limited number of decimal digits.\n */\nexport function toFixed(n, decimals) {\n const factor = Math.pow(10, decimals);\n return Math.round(n * factor) / factor;\n}\n\n/**\n * Rounds a number to the nearest integer value considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The nearest integer.\n */\nexport function round(n, decimals) {\n return Math.round(toFixed(n, decimals));\n}\n\n/**\n * Rounds a number to the next smaller integer considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The next smaller integer.\n */\nexport function floor(n, decimals) {\n return Math.floor(toFixed(n, decimals));\n}\n\n/**\n * Rounds a number to the next bigger integer considering only the given number\n * of decimal digits (with rounding on the final digit).\n * @param {number} n The input number.\n * @param {number} decimals The maximum number of decimal digits.\n * @return {number} The next bigger integer.\n */\nexport function ceil(n, decimals) {\n return Math.ceil(toFixed(n, decimals));\n}\n","/**\n * @module ol/color\n */\nimport {clamp} from './math.js';\n\n/**\n * A color represented as a short array [red, green, blue, alpha].\n * red, green, and blue should be integers in the range 0..255 inclusive.\n * alpha should be a float in the range 0..1 inclusive. If no alpha value is\n * given then `1` will be used.\n * @typedef {Array} Color\n * @api\n */\n\n/**\n * This RegExp matches # followed by 3, 4, 6, or 8 hex digits.\n * @const\n * @type {RegExp}\n * @private\n */\nconst HEX_COLOR_RE_ = /^#([a-f0-9]{3}|[a-f0-9]{4}(?:[a-f0-9]{2}){0,2})$/i;\n\n/**\n * Regular expression for matching potential named color style strings.\n * @const\n * @type {RegExp}\n * @private\n */\nconst NAMED_COLOR_RE_ = /^([a-z]*)$|^hsla?\\(.*\\)$/i;\n\n/**\n * Return the color as an rgba string.\n * @param {Color|string} color Color.\n * @return {string} Rgba string.\n * @api\n */\nexport function asString(color) {\n if (typeof color === 'string') {\n return color;\n }\n return toString(color);\n}\n\n/**\n * Return named color as an rgba string.\n * @param {string} color Named color.\n * @return {string} Rgb string.\n */\nfunction fromNamed(color) {\n const el = document.createElement('div');\n el.style.color = color;\n if (el.style.color !== '') {\n document.body.appendChild(el);\n const rgb = getComputedStyle(el).color;\n document.body.removeChild(el);\n return rgb;\n }\n return '';\n}\n\n/**\n * @param {string} s String.\n * @return {Color} Color.\n */\nexport const fromString = (function () {\n // We maintain a small cache of parsed strings. To provide cheap LRU-like\n // semantics, whenever the cache grows too large we simply delete an\n // arbitrary 25% of the entries.\n\n /**\n * @const\n * @type {number}\n */\n const MAX_CACHE_SIZE = 1024;\n\n /**\n * @type {Object}\n */\n const cache = {};\n\n /**\n * @type {number}\n */\n let cacheSize = 0;\n\n return (\n /**\n * @param {string} s String.\n * @return {Color} Color.\n */\n function (s) {\n let color;\n if (cache.hasOwnProperty(s)) {\n color = cache[s];\n } else {\n if (cacheSize >= MAX_CACHE_SIZE) {\n let i = 0;\n for (const key in cache) {\n if ((i++ & 3) === 0) {\n delete cache[key];\n --cacheSize;\n }\n }\n }\n color = fromStringInternal_(s);\n cache[s] = color;\n ++cacheSize;\n }\n return color;\n }\n );\n})();\n\n/**\n * Return the color as an array. This function maintains a cache of calculated\n * arrays which means the result should not be modified.\n * @param {Color|string} color Color.\n * @return {Color} Color.\n * @api\n */\nexport function asArray(color) {\n if (Array.isArray(color)) {\n return color;\n }\n return fromString(color);\n}\n\n/**\n * @param {string} s String.\n * @private\n * @return {Color} Color.\n */\nfunction fromStringInternal_(s) {\n let r, g, b, a, color;\n\n if (NAMED_COLOR_RE_.exec(s)) {\n s = fromNamed(s);\n }\n\n if (HEX_COLOR_RE_.exec(s)) {\n // hex\n const n = s.length - 1; // number of hex digits\n let d; // number of digits per channel\n if (n <= 4) {\n d = 1;\n } else {\n d = 2;\n }\n const hasAlpha = n === 4 || n === 8;\n r = parseInt(s.substr(1 + 0 * d, d), 16);\n g = parseInt(s.substr(1 + 1 * d, d), 16);\n b = parseInt(s.substr(1 + 2 * d, d), 16);\n if (hasAlpha) {\n a = parseInt(s.substr(1 + 3 * d, d), 16);\n } else {\n a = 255;\n }\n if (d == 1) {\n r = (r << 4) + r;\n g = (g << 4) + g;\n b = (b << 4) + b;\n if (hasAlpha) {\n a = (a << 4) + a;\n }\n }\n color = [r, g, b, a / 255];\n } else if (s.startsWith('rgba(')) {\n // rgba()\n color = s.slice(5, -1).split(',').map(Number);\n normalize(color);\n } else if (s.startsWith('rgb(')) {\n // rgb()\n color = s.slice(4, -1).split(',').map(Number);\n color.push(1);\n normalize(color);\n } else {\n throw new Error('Invalid color');\n }\n return color;\n}\n\n/**\n * TODO this function is only used in the test, we probably shouldn't export it\n * @param {Color} color Color.\n * @return {Color} Clamped color.\n */\nexport function normalize(color) {\n color[0] = clamp((color[0] + 0.5) | 0, 0, 255);\n color[1] = clamp((color[1] + 0.5) | 0, 0, 255);\n color[2] = clamp((color[2] + 0.5) | 0, 0, 255);\n color[3] = clamp(color[3], 0, 1);\n return color;\n}\n\n/**\n * @param {Color} color Color.\n * @return {string} String.\n */\nexport function toString(color) {\n let r = color[0];\n if (r != (r | 0)) {\n r = (r + 0.5) | 0;\n }\n let g = color[1];\n if (g != (g | 0)) {\n g = (g + 0.5) | 0;\n }\n let b = color[2];\n if (b != (b | 0)) {\n b = (b + 0.5) | 0;\n }\n const a = color[3] === undefined ? 1 : Math.round(color[3] * 100) / 100;\n return 'rgba(' + r + ',' + g + ',' + b + ',' + a + ')';\n}\n\n/**\n * @param {string} s String.\n * @return {boolean} Whether the string is actually a valid color\n */\nexport function isStringColor(s) {\n if (NAMED_COLOR_RE_.test(s)) {\n s = fromNamed(s);\n }\n return HEX_COLOR_RE_.test(s) || s.startsWith('rgba(') || s.startsWith('rgb(');\n}\n","/**\n * @module ol/has\n */\n\nconst ua =\n typeof navigator !== 'undefined' && typeof navigator.userAgent !== 'undefined'\n ? navigator.userAgent.toLowerCase()\n : '';\n\n/**\n * User agent string says we are dealing with Firefox as browser.\n * @type {boolean}\n */\nexport const FIREFOX = ua.includes('firefox');\n\n/**\n * User agent string says we are dealing with Safari as browser.\n * @type {boolean}\n */\nexport const SAFARI = ua.includes('safari') && !ua.includes('chrom');\n\n/**\n * https://bugs.webkit.org/show_bug.cgi?id=237906\n * @type {boolean}\n */\nexport const SAFARI_BUG_237906 =\n SAFARI &&\n (ua.includes('version/15.4') ||\n /cpu (os|iphone os) 15_4 like mac os x/.test(ua));\n\n/**\n * User agent string says we are dealing with a WebKit engine.\n * @type {boolean}\n */\nexport const WEBKIT = ua.includes('webkit') && !ua.includes('edge');\n\n/**\n * User agent string says we are dealing with a Mac as platform.\n * @type {boolean}\n */\nexport const MAC = ua.includes('macintosh');\n\n/**\n * The ratio between physical pixels and device-independent pixels\n * (dips) on the device (`window.devicePixelRatio`).\n * @const\n * @type {number}\n * @api\n */\nexport const DEVICE_PIXEL_RATIO =\n typeof devicePixelRatio !== 'undefined' ? devicePixelRatio : 1;\n\n/**\n * The execution context is a worker with OffscreenCanvas available.\n * @const\n * @type {boolean}\n */\nexport const WORKER_OFFSCREEN_CANVAS =\n typeof WorkerGlobalScope !== 'undefined' &&\n typeof OffscreenCanvas !== 'undefined' &&\n self instanceof WorkerGlobalScope; //eslint-disable-line\n\n/**\n * Image.prototype.decode() is supported.\n * @type {boolean}\n */\nexport const IMAGE_DECODE =\n typeof Image !== 'undefined' && Image.prototype.decode;\n\n/**\n * createImageBitmap() is supported.\n * @type {boolean}\n */\nexport const CREATE_IMAGE_BITMAP = typeof createImageBitmap === 'function';\n\n/**\n * @type {boolean}\n */\nexport const PASSIVE_EVENT_LISTENERS = (function () {\n let passive = false;\n try {\n const options = Object.defineProperty({}, 'passive', {\n get: function () {\n passive = true;\n },\n });\n\n window.addEventListener('_', null, options);\n window.removeEventListener('_', null, options);\n } catch (error) {\n // passive not supported\n }\n return passive;\n})();\n","import {WORKER_OFFSCREEN_CANVAS} from './has.js';\n\n/**\n * @module ol/dom\n */\n\n//FIXME Move this function to the canvas module\n/**\n * Create an html canvas element and returns its 2d context.\n * @param {number} [width] Canvas width.\n * @param {number} [height] Canvas height.\n * @param {Array} [canvasPool] Canvas pool to take existing canvas from.\n * @param {CanvasRenderingContext2DSettings} [settings] CanvasRenderingContext2DSettings\n * @return {CanvasRenderingContext2D} The context.\n */\nexport function createCanvasContext2D(width, height, canvasPool, settings) {\n /** @type {HTMLCanvasElement|OffscreenCanvas} */\n let canvas;\n if (canvasPool && canvasPool.length) {\n canvas = canvasPool.shift();\n } else if (WORKER_OFFSCREEN_CANVAS) {\n canvas = new OffscreenCanvas(width || 300, height || 300);\n } else {\n canvas = document.createElement('canvas');\n }\n if (width) {\n canvas.width = width;\n }\n if (height) {\n canvas.height = height;\n }\n //FIXME Allow OffscreenCanvasRenderingContext2D as return type\n return /** @type {CanvasRenderingContext2D} */ (\n canvas.getContext('2d', settings)\n );\n}\n\n/**\n * Releases canvas memory to avoid exceeding memory limits in Safari.\n * See https://pqina.nl/blog/total-canvas-memory-use-exceeds-the-maximum-limit/\n * @param {CanvasRenderingContext2D} context Context.\n */\nexport function releaseCanvas(context) {\n const canvas = context.canvas;\n canvas.width = 1;\n canvas.height = 1;\n context.clearRect(0, 0, 1, 1);\n}\n\n/**\n * Get the current computed width for the given element including margin,\n * padding and border.\n * Equivalent to jQuery's `$(el).outerWidth(true)`.\n * @param {!HTMLElement} element Element.\n * @return {number} The width.\n */\nexport function outerWidth(element) {\n let width = element.offsetWidth;\n const style = getComputedStyle(element);\n width += parseInt(style.marginLeft, 10) + parseInt(style.marginRight, 10);\n\n return width;\n}\n\n/**\n * Get the current computed height for the given element including margin,\n * padding and border.\n * Equivalent to jQuery's `$(el).outerHeight(true)`.\n * @param {!HTMLElement} element Element.\n * @return {number} The height.\n */\nexport function outerHeight(element) {\n let height = element.offsetHeight;\n const style = getComputedStyle(element);\n height += parseInt(style.marginTop, 10) + parseInt(style.marginBottom, 10);\n\n return height;\n}\n\n/**\n * @param {Node} newNode Node to replace old node\n * @param {Node} oldNode The node to be replaced\n */\nexport function replaceNode(newNode, oldNode) {\n const parent = oldNode.parentNode;\n if (parent) {\n parent.replaceChild(newNode, oldNode);\n }\n}\n\n/**\n * @param {Node} node The node to remove.\n * @return {Node|null} The node that was removed or null.\n */\nexport function removeNode(node) {\n return node && node.parentNode ? node.parentNode.removeChild(node) : null;\n}\n\n/**\n * @param {Node} node The node to remove the children from.\n */\nexport function removeChildren(node) {\n while (node.lastChild) {\n node.removeChild(node.lastChild);\n }\n}\n\n/**\n * Transform the children of a parent node so they match the\n * provided list of children. This function aims to efficiently\n * remove, add, and reorder child nodes while maintaining a simple\n * implementation (it is not guaranteed to minimize DOM operations).\n * @param {Node} node The parent node whose children need reworking.\n * @param {Array} children The desired children.\n */\nexport function replaceChildren(node, children) {\n const oldChildren = node.childNodes;\n\n for (let i = 0; true; ++i) {\n const oldChild = oldChildren[i];\n const newChild = children[i];\n\n // check if our work is done\n if (!oldChild && !newChild) {\n break;\n }\n\n // check if children match\n if (oldChild === newChild) {\n continue;\n }\n\n // check if a new child needs to be added\n if (!oldChild) {\n node.appendChild(newChild);\n continue;\n }\n\n // check if an old child needs to be removed\n if (!newChild) {\n node.removeChild(oldChild);\n --i;\n continue;\n }\n\n // reorder\n node.insertBefore(newChild, oldChild);\n }\n}\n","/**\n * @module ol/Image\n */\nimport EventTarget from './events/Target.js';\nimport EventType from './events/EventType.js';\nimport ImageState from './ImageState.js';\nimport {CREATE_IMAGE_BITMAP, IMAGE_DECODE} from './has.js';\nimport {listenOnce, unlistenByKey} from './events.js';\nimport {toPromise} from './functions.js';\n\n/**\n * A function that takes an {@link module:ol/Image~ImageWrapper} for the image and a\n * `{string}` for the src as arguments. It is supposed to make it so the\n * underlying image {@link module:ol/Image~ImageWrapper#getImage} is assigned the\n * content specified by the src. If not specified, the default is\n *\n * function(image, src) {\n * image.getImage().src = src;\n * }\n *\n * Providing a custom `imageLoadFunction` can be useful to load images with\n * post requests or - in general - through XHR requests, where the src of the\n * image element would be set to a data URI when the content is loaded.\n *\n * @typedef {function(import(\"./Image.js\").default, string): void} LoadFunction\n * @api\n */\n\n/**\n * @typedef {Object} ImageObject\n * @property {import(\"./extent.js\").Extent} [extent] Extent, if different from the requested one.\n * @property {import(\"./resolution.js\").ResolutionLike} [resolution] Resolution, if different from the requested one.\n * When x and y resolution are different, use the array type (`[xResolution, yResolution]`).\n * @property {number} [pixelRatio] Pixel ratio, if different from the requested one.\n * @property {import('./DataTile.js').ImageLike} image Image.\n */\n\n/**\n * Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.\n * For images that cover any extent and resolution (static images), the loader function should not accept\n * any arguments. The function returns an {@link import(\"./DataTile.js\").ImageLike image}, an\n * {@link import(\"./Image.js\").ImageObject image object}, or a promise for the same.\n * For loaders that generate images, the promise should not resolve until the image is loaded.\n * If the returned image does not match the extent, resolution or pixel ratio passed to the loader,\n * it has to return an {@link import(\"./Image.js\").ImageObject image object} with the `image` and the\n * correct `extent`, `resolution` and `pixelRatio`.\n *\n * @typedef {function(import(\"./extent.js\").Extent, number, number, (function(HTMLImageElement, string): void)=): import(\"./DataTile.js\").ImageLike|ImageObject|Promise} Loader\n * @api\n */\n\n/**\n * Loader function used for image sources. Receives extent, resolution and pixel ratio as arguments.\n * The function returns a promise for an {@link import(\"./Image.js\").ImageObject image object}.\n *\n * @typedef {function(import(\"./extent.js\").Extent, number, number, (function(HTMLImageElement, string): void)=): import(\"./DataTile.js\").ImageLike|ImageObject|Promise} ImageObjectPromiseLoader\n */\n\nclass ImageWrapper extends EventTarget {\n /**\n * @param {import(\"./extent.js\").Extent} extent Extent.\n * @param {number|Array|undefined} resolution Resolution. If provided as array, x and y\n * resolution will be assumed.\n * @param {number} pixelRatio Pixel ratio.\n * @param {import(\"./ImageState.js\").default|import(\"./Image.js\").Loader} stateOrLoader State.\n */\n constructor(extent, resolution, pixelRatio, stateOrLoader) {\n super();\n\n /**\n * @protected\n * @type {import(\"./extent.js\").Extent}\n */\n this.extent = extent;\n\n /**\n * @private\n * @type {number}\n */\n this.pixelRatio_ = pixelRatio;\n\n /**\n * @protected\n * @type {number|Array|undefined}\n */\n this.resolution = resolution;\n\n /**\n * @protected\n * @type {import(\"./ImageState.js\").default}\n */\n this.state =\n typeof stateOrLoader === 'function' ? ImageState.IDLE : stateOrLoader;\n\n /**\n * @private\n * @type {import('./DataTile.js').ImageLike|null}\n */\n this.image_ = null;\n\n /**\n * @protected\n * @type {import(\"./Image.js\").Loader}\n */\n this.loader = typeof stateOrLoader === 'function' ? stateOrLoader : null;\n }\n\n /**\n * @protected\n */\n changed() {\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * @return {import(\"./extent.js\").Extent} Extent.\n */\n getExtent() {\n return this.extent;\n }\n\n /**\n * @return {import('./DataTile.js').ImageLike} Image.\n */\n getImage() {\n return this.image_;\n }\n\n /**\n * @return {number} PixelRatio.\n */\n getPixelRatio() {\n return this.pixelRatio_;\n }\n\n /**\n * @return {number|Array} Resolution.\n */\n getResolution() {\n return /** @type {number} */ (this.resolution);\n }\n\n /**\n * @return {import(\"./ImageState.js\").default} State.\n */\n getState() {\n return this.state;\n }\n\n /**\n * Load not yet loaded URI.\n */\n load() {\n if (this.state == ImageState.IDLE) {\n if (this.loader) {\n this.state = ImageState.LOADING;\n this.changed();\n const resolution = this.getResolution();\n const requestResolution = Array.isArray(resolution)\n ? resolution[0]\n : resolution;\n toPromise(() =>\n this.loader(this.getExtent(), requestResolution, this.getPixelRatio())\n )\n .then((image) => {\n if ('image' in image) {\n this.image_ = image.image;\n }\n if ('extent' in image) {\n this.extent = image.extent;\n }\n if ('resolution' in image) {\n this.resolution = image.resolution;\n }\n if ('pixelRatio' in image) {\n this.pixelRatio_ = image.pixelRatio;\n }\n if (\n image instanceof HTMLImageElement ||\n image instanceof ImageBitmap ||\n image instanceof HTMLCanvasElement ||\n image instanceof HTMLVideoElement\n ) {\n this.image_ = image;\n }\n this.state = ImageState.LOADED;\n })\n .catch((error) => {\n this.state = ImageState.ERROR;\n console.error(error); // eslint-disable-line no-console\n })\n .finally(() => this.changed());\n }\n }\n }\n\n /**\n * @param {import('./DataTile.js').ImageLike} image The image.\n */\n setImage(image) {\n this.image_ = image;\n }\n\n /**\n * @param {number|Array} resolution Resolution.\n */\n setResolution(resolution) {\n this.resolution = resolution;\n }\n}\n\n/**\n * @param {import('./DataTile.js').ImageLike} image Image element.\n * @param {function():any} loadHandler Load callback function.\n * @param {function():any} errorHandler Error callback function.\n * @return {function():void} Callback to stop listening.\n */\nexport function listenImage(image, loadHandler, errorHandler) {\n const img = /** @type {HTMLImageElement} */ (image);\n let listening = true;\n let decoding = false;\n let loaded = false;\n\n const listenerKeys = [\n listenOnce(img, EventType.LOAD, function () {\n loaded = true;\n if (!decoding) {\n loadHandler();\n }\n }),\n ];\n\n if (img.src && IMAGE_DECODE) {\n decoding = true;\n img\n .decode()\n .then(function () {\n if (listening) {\n loadHandler();\n }\n })\n .catch(function (error) {\n if (listening) {\n if (loaded) {\n loadHandler();\n } else {\n errorHandler();\n }\n }\n });\n } else {\n listenerKeys.push(listenOnce(img, EventType.ERROR, errorHandler));\n }\n\n return function unlisten() {\n listening = false;\n listenerKeys.forEach(unlistenByKey);\n };\n}\n\n/**\n * Loads an image.\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `HTMLImageElement`.\n * @api\n */\nexport function load(image, src) {\n return new Promise((resolve, reject) => {\n function handleLoad() {\n unlisten();\n resolve(image);\n }\n function handleError() {\n unlisten();\n reject(new Error('Image load error'));\n }\n function unlisten() {\n image.removeEventListener('load', handleLoad);\n image.removeEventListener('error', handleError);\n }\n image.addEventListener('load', handleLoad);\n image.addEventListener('error', handleError);\n if (src) {\n image.src = src;\n }\n });\n}\n\n/**\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `HTMLImageElement`.\n */\nexport function decodeFallback(image, src) {\n if (src) {\n image.src = src;\n }\n return IMAGE_DECODE\n ? new Promise((resolve, reject) =>\n image.decode().then(() => resolve(image), reject)\n )\n : load(image);\n}\n\n/**\n * Loads an image and decodes it to an `ImageBitmap` if `createImageBitmap()` is supported. Returns\n * the loaded image otherwise.\n * @param {HTMLImageElement} image Image, not yet loaded.\n * @param {string} [src] `src` attribute of the image. Optional, not required if already present.\n * @return {Promise} Promise resolving to an `ImageBitmap` or an\n * `HTMLImageElement` if `createImageBitmap()` is not supported.\n * @api\n */\nexport function decode(image, src) {\n if (src) {\n image.src = src;\n }\n return IMAGE_DECODE && CREATE_IMAGE_BITMAP\n ? image.decode().then(() => createImageBitmap(image))\n : decodeFallback(image);\n}\n\nexport default ImageWrapper;\n","/**\n * @module ol/style/IconImageCache\n */\nimport {asString} from '../color.js';\n\n/**\n * @classdesc\n * Singleton class. Available through {@link module:ol/style/IconImageCache.shared}.\n */\nclass IconImageCache {\n constructor() {\n /**\n * @type {!Object}\n * @private\n */\n this.cache_ = {};\n\n /**\n * @type {number}\n * @private\n */\n this.cacheSize_ = 0;\n\n /**\n * @type {number}\n * @private\n */\n this.maxCacheSize_ = 32;\n }\n\n /**\n * FIXME empty description for jsdoc\n */\n clear() {\n this.cache_ = {};\n this.cacheSize_ = 0;\n }\n\n /**\n * @return {boolean} Can expire cache.\n */\n canExpireCache() {\n return this.cacheSize_ > this.maxCacheSize_;\n }\n\n /**\n * FIXME empty description for jsdoc\n */\n expire() {\n if (this.canExpireCache()) {\n let i = 0;\n for (const key in this.cache_) {\n const iconImage = this.cache_[key];\n if ((i++ & 3) === 0 && !iconImage.hasListener()) {\n delete this.cache_[key];\n --this.cacheSize_;\n }\n }\n }\n }\n\n /**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color} color Color.\n * @return {import(\"./IconImage.js\").default} Icon image.\n */\n get(src, crossOrigin, color) {\n const key = getKey(src, crossOrigin, color);\n return key in this.cache_ ? this.cache_[key] : null;\n }\n\n /**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color} color Color.\n * @param {import(\"./IconImage.js\").default} iconImage Icon image.\n */\n set(src, crossOrigin, color, iconImage) {\n const key = getKey(src, crossOrigin, color);\n this.cache_[key] = iconImage;\n ++this.cacheSize_;\n }\n\n /**\n * Set the cache size of the icon cache. Default is `32`. Change this value when\n * your map uses more than 32 different icon images and you are not caching icon\n * styles on the application level.\n * @param {number} maxCacheSize Cache max size.\n * @api\n */\n setSize(maxCacheSize) {\n this.maxCacheSize_ = maxCacheSize;\n this.expire();\n }\n}\n\n/**\n * @param {string} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../color.js\").Color} color Color.\n * @return {string} Cache key.\n */\nfunction getKey(src, crossOrigin, color) {\n const colorString = color ? asString(color) : 'null';\n return crossOrigin + ':' + src + ':' + colorString;\n}\n\nexport default IconImageCache;\n\n/**\n * The {@link module:ol/style/IconImageCache~IconImageCache} for\n * {@link module:ol/style/Icon~Icon} images.\n * @api\n */\nexport const shared = new IconImageCache();\n","/**\n * @module ol/style/IconImage\n */\n\nimport EventTarget from '../events/Target.js';\nimport EventType from '../events/EventType.js';\nimport ImageState from '../ImageState.js';\nimport {asString} from '../color.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {decodeFallback} from '../Image.js';\nimport {shared as iconImageCache} from './IconImageCache.js';\n\n/**\n * @type {CanvasRenderingContext2D}\n */\nlet taintedTestContext = null;\n\nclass IconImage extends EventTarget {\n /**\n * @param {HTMLImageElement|HTMLCanvasElement|ImageBitmap} image Image.\n * @param {string|undefined} src Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../ImageState.js\").default} imageState Image state.\n * @param {import(\"../color.js\").Color} color Color.\n */\n constructor(image, src, crossOrigin, imageState, color) {\n super();\n\n /**\n * @private\n * @type {HTMLImageElement|HTMLCanvasElement|ImageBitmap}\n */\n this.hitDetectionImage_ = null;\n\n /**\n * @private\n * @type {HTMLImageElement|HTMLCanvasElement|ImageBitmap}\n */\n this.image_ = image;\n\n /**\n * @private\n * @type {string|null}\n */\n this.crossOrigin_ = crossOrigin;\n\n /**\n * @private\n * @type {Object}\n */\n this.canvas_ = {};\n\n /**\n * @private\n * @type {import(\"../color.js\").Color}\n */\n this.color_ = color;\n\n /**\n * @private\n * @type {import(\"../ImageState.js\").default}\n */\n this.imageState_ = imageState === undefined ? ImageState.IDLE : imageState;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size|null}\n */\n this.size_ =\n image && image.width && image.height ? [image.width, image.height] : null;\n\n /**\n * @private\n * @type {string|undefined}\n */\n this.src_ = src;\n\n /**\n * @private\n */\n this.tainted_;\n }\n\n /**\n * @private\n */\n initializeImage_() {\n this.image_ = new Image();\n if (this.crossOrigin_ !== null) {\n this.image_.crossOrigin = this.crossOrigin_;\n }\n }\n\n /**\n * @private\n * @return {boolean} The image canvas is tainted.\n */\n isTainted_() {\n if (this.tainted_ === undefined && this.imageState_ === ImageState.LOADED) {\n if (!taintedTestContext) {\n taintedTestContext = createCanvasContext2D(1, 1, undefined, {\n willReadFrequently: true,\n });\n }\n taintedTestContext.drawImage(this.image_, 0, 0);\n try {\n taintedTestContext.getImageData(0, 0, 1, 1);\n this.tainted_ = false;\n } catch (e) {\n taintedTestContext = null;\n this.tainted_ = true;\n }\n }\n return this.tainted_ === true;\n }\n\n /**\n * @private\n */\n dispatchChangeEvent_() {\n this.dispatchEvent(EventType.CHANGE);\n }\n\n /**\n * @private\n */\n handleImageError_() {\n this.imageState_ = ImageState.ERROR;\n this.dispatchChangeEvent_();\n }\n\n /**\n * @private\n */\n handleImageLoad_() {\n this.imageState_ = ImageState.LOADED;\n this.size_ = [this.image_.width, this.image_.height];\n this.dispatchChangeEvent_();\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @return {HTMLImageElement|HTMLCanvasElement|ImageBitmap} Image or Canvas element or image bitmap.\n */\n getImage(pixelRatio) {\n if (!this.image_) {\n this.initializeImage_();\n }\n this.replaceColor_(pixelRatio);\n return this.canvas_[pixelRatio] ? this.canvas_[pixelRatio] : this.image_;\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Image or Canvas element.\n */\n getPixelRatio(pixelRatio) {\n this.replaceColor_(pixelRatio);\n return this.canvas_[pixelRatio] ? pixelRatio : 1;\n }\n\n /**\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return this.imageState_;\n }\n\n /**\n * @return {HTMLImageElement|HTMLCanvasElement|ImageBitmap} Image element.\n */\n getHitDetectionImage() {\n if (!this.image_) {\n this.initializeImage_();\n }\n if (!this.hitDetectionImage_) {\n if (this.isTainted_()) {\n const width = this.size_[0];\n const height = this.size_[1];\n const context = createCanvasContext2D(width, height);\n context.fillRect(0, 0, width, height);\n this.hitDetectionImage_ = context.canvas;\n } else {\n this.hitDetectionImage_ = this.image_;\n }\n }\n return this.hitDetectionImage_;\n }\n\n /**\n * Get the size of the icon (in pixels).\n * @return {import(\"../size.js\").Size} Image size.\n */\n getSize() {\n return this.size_;\n }\n\n /**\n * @return {string|undefined} Image src.\n */\n getSrc() {\n return this.src_;\n }\n\n /**\n * Load not yet loaded URI.\n */\n load() {\n if (this.imageState_ !== ImageState.IDLE) {\n return;\n }\n if (!this.image_) {\n this.initializeImage_();\n }\n\n this.imageState_ = ImageState.LOADING;\n try {\n if (this.src_ !== undefined) {\n /** @type {HTMLImageElement} */ (this.image_).src = this.src_;\n }\n } catch (e) {\n this.handleImageError_();\n }\n if (this.image_ instanceof HTMLImageElement) {\n decodeFallback(this.image_, this.src_)\n .then((image) => {\n this.image_ = image;\n this.handleImageLoad_();\n })\n .catch(this.handleImageError_.bind(this));\n }\n }\n\n /**\n * @param {number} pixelRatio Pixel ratio.\n * @private\n */\n replaceColor_(pixelRatio) {\n if (\n !this.color_ ||\n this.canvas_[pixelRatio] ||\n this.imageState_ !== ImageState.LOADED\n ) {\n return;\n }\n\n const image = this.image_;\n const canvas = document.createElement('canvas');\n canvas.width = Math.ceil(image.width * pixelRatio);\n canvas.height = Math.ceil(image.height * pixelRatio);\n\n const ctx = canvas.getContext('2d');\n ctx.scale(pixelRatio, pixelRatio);\n ctx.drawImage(image, 0, 0);\n\n ctx.globalCompositeOperation = 'multiply';\n ctx.fillStyle = asString(this.color_);\n ctx.fillRect(0, 0, canvas.width / pixelRatio, canvas.height / pixelRatio);\n\n ctx.globalCompositeOperation = 'destination-in';\n ctx.drawImage(image, 0, 0);\n\n this.canvas_[pixelRatio] = canvas;\n }\n}\n\n/**\n * @param {HTMLImageElement|HTMLCanvasElement|ImageBitmap} image Image.\n * @param {string} cacheKey Src.\n * @param {?string} crossOrigin Cross origin.\n * @param {import(\"../ImageState.js\").default} imageState Image state.\n * @param {import(\"../color.js\").Color} color Color.\n * @return {IconImage} Icon image.\n */\nexport function get(image, cacheKey, crossOrigin, imageState, color) {\n let iconImage =\n cacheKey === undefined\n ? undefined\n : iconImageCache.get(cacheKey, crossOrigin, color);\n if (!iconImage) {\n iconImage = new IconImage(\n image,\n image instanceof HTMLImageElement ? image.src || undefined : cacheKey,\n crossOrigin,\n imageState,\n color\n );\n iconImageCache.set(cacheKey, crossOrigin, color, iconImage);\n }\n return iconImage;\n}\n\nexport default IconImage;\n","/**\n * @module ol/style/Icon\n */\nimport EventType from '../events/EventType.js';\nimport ImageState from '../ImageState.js';\nimport ImageStyle from './Image.js';\nimport {asArray} from '../color.js';\nimport {assert} from '../asserts.js';\nimport {get as getIconImage} from './IconImage.js';\nimport {getUid} from '../util.js';\n\n/**\n * @typedef {'fraction' | 'pixels'} IconAnchorUnits\n * Anchor unit can be either a fraction of the icon size or in pixels.\n */\n\n/**\n * @typedef {'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'} IconOrigin\n * Icon origin. One of 'bottom-left', 'bottom-right', 'top-left', 'top-right'.\n */\n\n/**\n * @typedef {Object} Options\n * @property {Array} [anchor=[0.5, 0.5]] Anchor. Default value is the icon center.\n * @property {IconOrigin} [anchorOrigin='top-left'] Origin of the anchor: `bottom-left`, `bottom-right`,\n * `top-left` or `top-right`.\n * @property {IconAnchorUnits} [anchorXUnits='fraction'] Units in which the anchor x value is\n * specified. A value of `'fraction'` indicates the x value is a fraction of the icon. A value of `'pixels'` indicates\n * the x value in pixels.\n * @property {IconAnchorUnits} [anchorYUnits='fraction'] Units in which the anchor y value is\n * specified. A value of `'fraction'` indicates the y value is a fraction of the icon. A value of `'pixels'` indicates\n * the y value in pixels.\n * @property {import(\"../color.js\").Color|string} [color] Color to tint the icon. If not specified,\n * the icon will be left as is.\n * @property {null|string} [crossOrigin] The `crossOrigin` attribute for loaded images. Note that you must provide a\n * `crossOrigin` value if you want to access pixel data with the Canvas renderer.\n * See https://developer.mozilla.org/en-US/docs/Web/HTML/CORS_enabled_image for more detail.\n * @property {HTMLImageElement|HTMLCanvasElement|ImageBitmap} [img] Image object for the icon.\n * @property {Array} [displacement=[0, 0]] Displacement of the icon in pixels.\n * Positive values will shift the icon right and up.\n * @property {number} [opacity=1] Opacity of the icon.\n * @property {number} [width] The width of the icon in pixels. This can't be used together with `scale`.\n * @property {number} [height] The height of the icon in pixels. This can't be used together with `scale`.\n * @property {number|import(\"../size.js\").Size} [scale=1] Scale.\n * @property {boolean} [rotateWithView=false] Whether to rotate the icon with the view.\n * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).\n * @property {Array} [offset=[0, 0]] Offset which, together with `size` and `offsetOrigin`, defines the\n * sub-rectangle to use from the original (sprite) image.\n * @property {IconOrigin} [offsetOrigin='top-left'] Origin of the offset: `bottom-left`, `bottom-right`,\n * `top-left` or `top-right`.\n * @property {import(\"../size.js\").Size} [size] Icon size in pixels. Used together with `offset` to define the\n * sub-rectangle to use from the original (sprite) image.\n * @property {string} [src] Image source URI.\n * @property {\"declutter\"|\"obstacle\"|\"none\"|undefined} [declutterMode] Declutter mode.\n */\n\n/**\n * @param {number} width The width.\n * @param {number} height The height.\n * @param {number|undefined} wantedWidth The wanted width.\n * @param {number|undefined} wantedHeight The wanted height.\n * @return {number|Array} The scale.\n */\nfunction calculateScale(width, height, wantedWidth, wantedHeight) {\n if (wantedWidth !== undefined && wantedHeight !== undefined) {\n return [wantedWidth / width, wantedHeight / height];\n }\n if (wantedWidth !== undefined) {\n return wantedWidth / width;\n }\n if (wantedHeight !== undefined) {\n return wantedHeight / height;\n }\n return 1;\n}\n\n/**\n * @classdesc\n * Set icon style for vector features.\n * @api\n */\nclass Icon extends ImageStyle {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options || {};\n\n /**\n * @type {number}\n */\n const opacity = options.opacity !== undefined ? options.opacity : 1;\n\n /**\n * @type {number}\n */\n const rotation = options.rotation !== undefined ? options.rotation : 0;\n\n /**\n * @type {number|import(\"../size.js\").Size}\n */\n const scale = options.scale !== undefined ? options.scale : 1;\n\n /**\n * @type {boolean}\n */\n const rotateWithView =\n options.rotateWithView !== undefined ? options.rotateWithView : false;\n\n super({\n opacity: opacity,\n rotation: rotation,\n scale: scale,\n displacement:\n options.displacement !== undefined ? options.displacement : [0, 0],\n rotateWithView: rotateWithView,\n declutterMode: options.declutterMode,\n });\n\n /**\n * @private\n * @type {Array}\n */\n this.anchor_ = options.anchor !== undefined ? options.anchor : [0.5, 0.5];\n\n /**\n * @private\n * @type {Array}\n */\n this.normalizedAnchor_ = null;\n\n /**\n * @private\n * @type {IconOrigin}\n */\n this.anchorOrigin_ =\n options.anchorOrigin !== undefined ? options.anchorOrigin : 'top-left';\n\n /**\n * @private\n * @type {IconAnchorUnits}\n */\n this.anchorXUnits_ =\n options.anchorXUnits !== undefined ? options.anchorXUnits : 'fraction';\n\n /**\n * @private\n * @type {IconAnchorUnits}\n */\n this.anchorYUnits_ =\n options.anchorYUnits !== undefined ? options.anchorYUnits : 'fraction';\n\n /**\n * @private\n * @type {?string}\n */\n this.crossOrigin_ =\n options.crossOrigin !== undefined ? options.crossOrigin : null;\n\n const image = options.img !== undefined ? options.img : null;\n\n let cacheKey = options.src;\n\n assert(\n !(cacheKey !== undefined && image),\n '`image` and `src` cannot be provided at the same time'\n );\n\n if ((cacheKey === undefined || cacheKey.length === 0) && image) {\n cacheKey = /** @type {HTMLImageElement} */ (image).src || getUid(image);\n }\n assert(\n cacheKey !== undefined && cacheKey.length > 0,\n 'A defined and non-empty `src` or `image` must be provided'\n );\n\n assert(\n !(\n (options.width !== undefined || options.height !== undefined) &&\n options.scale !== undefined\n ),\n '`width` or `height` cannot be provided together with `scale`'\n );\n\n let imageState;\n if (options.src !== undefined) {\n imageState = ImageState.IDLE;\n } else if (image !== undefined) {\n if (image instanceof HTMLImageElement) {\n if (image.complete) {\n imageState = image.src ? ImageState.LOADED : ImageState.IDLE;\n } else {\n imageState = ImageState.LOADING;\n }\n } else {\n imageState = ImageState.LOADED;\n }\n }\n\n /**\n * @private\n * @type {import(\"../color.js\").Color}\n */\n this.color_ = options.color !== undefined ? asArray(options.color) : null;\n\n /**\n * @private\n * @type {import(\"./IconImage.js\").default}\n */\n this.iconImage_ = getIconImage(\n image,\n /** @type {string} */ (cacheKey),\n this.crossOrigin_,\n imageState,\n this.color_\n );\n\n /**\n * @private\n * @type {Array}\n */\n this.offset_ = options.offset !== undefined ? options.offset : [0, 0];\n /**\n * @private\n * @type {IconOrigin}\n */\n this.offsetOrigin_ =\n options.offsetOrigin !== undefined ? options.offsetOrigin : 'top-left';\n\n /**\n * @private\n * @type {Array}\n */\n this.origin_ = null;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.size_ = options.size !== undefined ? options.size : null;\n\n /**\n * Calculate the scale if width or height were given.\n */\n if (options.width !== undefined || options.height !== undefined) {\n let width, height;\n if (options.size) {\n [width, height] = options.size;\n } else {\n const image = this.getImage(1);\n if (image.width && image.height) {\n width = image.width;\n height = image.height;\n } else if (image instanceof HTMLImageElement) {\n this.initialOptions_ = options;\n const onload = () => {\n this.unlistenImageChange(onload);\n if (!this.initialOptions_) {\n return;\n }\n const imageSize = this.iconImage_.getSize();\n this.setScale(\n calculateScale(\n imageSize[0],\n imageSize[1],\n options.width,\n options.height\n )\n );\n };\n this.listenImageChange(onload);\n return;\n }\n }\n if (width !== undefined) {\n this.setScale(\n calculateScale(width, height, options.width, options.height)\n );\n }\n }\n }\n\n /**\n * Clones the style. The underlying Image/HTMLCanvasElement is not cloned.\n * @return {Icon} The cloned style.\n * @api\n */\n clone() {\n let scale, width, height;\n if (this.initialOptions_) {\n width = this.initialOptions_.width;\n height = this.initialOptions_.height;\n } else {\n scale = this.getScale();\n scale = Array.isArray(scale) ? scale.slice() : scale;\n }\n return new Icon({\n anchor: this.anchor_.slice(),\n anchorOrigin: this.anchorOrigin_,\n anchorXUnits: this.anchorXUnits_,\n anchorYUnits: this.anchorYUnits_,\n color:\n this.color_ && this.color_.slice\n ? this.color_.slice()\n : this.color_ || undefined,\n crossOrigin: this.crossOrigin_,\n offset: this.offset_.slice(),\n offsetOrigin: this.offsetOrigin_,\n opacity: this.getOpacity(),\n rotateWithView: this.getRotateWithView(),\n rotation: this.getRotation(),\n scale,\n width,\n height,\n size: this.size_ !== null ? this.size_.slice() : undefined,\n src: this.getSrc(),\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n }\n\n /**\n * Get the anchor point in pixels. The anchor determines the center point for the\n * symbolizer.\n * @return {Array} Anchor.\n * @api\n */\n getAnchor() {\n let anchor = this.normalizedAnchor_;\n if (!anchor) {\n anchor = this.anchor_;\n const size = this.getSize();\n if (\n this.anchorXUnits_ == 'fraction' ||\n this.anchorYUnits_ == 'fraction'\n ) {\n if (!size) {\n return null;\n }\n anchor = this.anchor_.slice();\n if (this.anchorXUnits_ == 'fraction') {\n anchor[0] *= size[0];\n }\n if (this.anchorYUnits_ == 'fraction') {\n anchor[1] *= size[1];\n }\n }\n\n if (this.anchorOrigin_ != 'top-left') {\n if (!size) {\n return null;\n }\n if (anchor === this.anchor_) {\n anchor = this.anchor_.slice();\n }\n if (\n this.anchorOrigin_ == 'top-right' ||\n this.anchorOrigin_ == 'bottom-right'\n ) {\n anchor[0] = -anchor[0] + size[0];\n }\n if (\n this.anchorOrigin_ == 'bottom-left' ||\n this.anchorOrigin_ == 'bottom-right'\n ) {\n anchor[1] = -anchor[1] + size[1];\n }\n }\n this.normalizedAnchor_ = anchor;\n }\n const displacement = this.getDisplacement();\n const scale = this.getScaleArray();\n // anchor is scaled by renderer but displacement should not be scaled\n // so divide by scale here\n return [\n anchor[0] - displacement[0] / scale[0],\n anchor[1] + displacement[1] / scale[1],\n ];\n }\n\n /**\n * Set the anchor point. The anchor determines the center point for the\n * symbolizer.\n *\n * @param {Array} anchor Anchor.\n * @api\n */\n setAnchor(anchor) {\n this.anchor_ = anchor;\n this.normalizedAnchor_ = null;\n }\n\n /**\n * Get the icon color.\n * @return {import(\"../color.js\").Color} Color.\n * @api\n */\n getColor() {\n return this.color_;\n }\n\n /**\n * Get the image icon.\n * @param {number} pixelRatio Pixel ratio.\n * @return {HTMLImageElement|HTMLCanvasElement|ImageBitmap} Image or Canvas element. If the Icon\n * style was configured with `src` or with a not let loaded `img`, an `ImageBitmap` will be returned.\n * @api\n */\n getImage(pixelRatio) {\n return this.iconImage_.getImage(pixelRatio);\n }\n\n /**\n * Get the pixel ratio.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} The pixel ratio of the image.\n * @api\n */\n getPixelRatio(pixelRatio) {\n return this.iconImage_.getPixelRatio(pixelRatio);\n }\n\n /**\n * @return {import(\"../size.js\").Size} Image size.\n */\n getImageSize() {\n return this.iconImage_.getSize();\n }\n\n /**\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return this.iconImage_.getImageState();\n }\n\n /**\n * @return {HTMLImageElement|HTMLCanvasElement|ImageBitmap} Image element.\n */\n getHitDetectionImage() {\n return this.iconImage_.getHitDetectionImage();\n }\n\n /**\n * Get the origin of the symbolizer.\n * @return {Array} Origin.\n * @api\n */\n getOrigin() {\n if (this.origin_) {\n return this.origin_;\n }\n let offset = this.offset_;\n\n if (this.offsetOrigin_ != 'top-left') {\n const size = this.getSize();\n const iconImageSize = this.iconImage_.getSize();\n if (!size || !iconImageSize) {\n return null;\n }\n offset = offset.slice();\n if (\n this.offsetOrigin_ == 'top-right' ||\n this.offsetOrigin_ == 'bottom-right'\n ) {\n offset[0] = iconImageSize[0] - size[0] - offset[0];\n }\n if (\n this.offsetOrigin_ == 'bottom-left' ||\n this.offsetOrigin_ == 'bottom-right'\n ) {\n offset[1] = iconImageSize[1] - size[1] - offset[1];\n }\n }\n this.origin_ = offset;\n return this.origin_;\n }\n\n /**\n * Get the image URL.\n * @return {string|undefined} Image src.\n * @api\n */\n getSrc() {\n return this.iconImage_.getSrc();\n }\n\n /**\n * Get the size of the icon (in pixels).\n * @return {import(\"../size.js\").Size} Image size.\n * @api\n */\n getSize() {\n return !this.size_ ? this.iconImage_.getSize() : this.size_;\n }\n\n /**\n * Get the width of the icon (in pixels). Will return undefined when the icon image is not yet loaded.\n * @return {number} Icon width (in pixels).\n * @api\n */\n getWidth() {\n const scale = this.getScaleArray();\n if (this.size_) {\n return this.size_[0] * scale[0];\n }\n if (this.iconImage_.getImageState() == ImageState.LOADED) {\n return this.iconImage_.getSize()[0] * scale[0];\n }\n return undefined;\n }\n\n /**\n * Get the height of the icon (in pixels). Will return undefined when the icon image is not yet loaded.\n * @return {number} Icon height (in pixels).\n * @api\n */\n getHeight() {\n const scale = this.getScaleArray();\n if (this.size_) {\n return this.size_[1] * scale[1];\n }\n if (this.iconImage_.getImageState() == ImageState.LOADED) {\n return this.iconImage_.getSize()[1] * scale[1];\n }\n return undefined;\n }\n\n /**\n * Set the scale.\n *\n * @param {number|import(\"../size.js\").Size} scale Scale.\n * @api\n */\n setScale(scale) {\n delete this.initialOptions_;\n super.setScale(scale);\n }\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n listenImageChange(listener) {\n this.iconImage_.addEventListener(EventType.CHANGE, listener);\n }\n\n /**\n * Load not yet loaded URI.\n * When rendering a feature with an icon style, the vector renderer will\n * automatically call this method. However, you might want to call this\n * method yourself for preloading or other purposes.\n * @api\n */\n load() {\n this.iconImage_.load();\n }\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n unlistenImageChange(listener) {\n this.iconImage_.removeEventListener(EventType.CHANGE, listener);\n }\n}\n\nexport default Icon;\n","/**\n * @module ol/proj/Units\n */\n\n/**\n * @typedef {'radians' | 'degrees' | 'ft' | 'm' | 'pixels' | 'tile-pixels' | 'us-ft'} Units\n * Projection units.\n */\n\n/**\n * See http://duff.ess.washington.edu/data/raster/drg/docs/geotiff.txt\n * @type {Object}\n */\nconst unitByCode = {\n '9001': 'm',\n '9002': 'ft',\n '9003': 'us-ft',\n '9101': 'radians',\n '9102': 'degrees',\n};\n\n/**\n * @param {number} code Unit code.\n * @return {Units} Units.\n */\nexport function fromCode(code) {\n return unitByCode[code];\n}\n\n/**\n * @typedef {Object} MetersPerUnitLookup\n * @property {number} radians Radians\n * @property {number} degrees Degrees\n * @property {number} ft Feet\n * @property {number} m Meters\n * @property {number} us-ft US feet\n */\n\n/**\n * Meters per unit lookup table.\n * @const\n * @type {MetersPerUnitLookup}\n * @api\n */\nexport const METERS_PER_UNIT = {\n // use the radius of the Normal sphere\n 'radians': 6370997 / (2 * Math.PI),\n 'degrees': (2 * Math.PI * 6370997) / 360,\n 'ft': 0.3048,\n 'm': 1,\n 'us-ft': 1200 / 3937,\n};\n","/**\n * @module ol/proj/Projection\n */\nimport {METERS_PER_UNIT} from './Units.js';\n\n/**\n * @typedef {Object} Options\n * @property {string} code The SRS identifier code, e.g. `EPSG:4326`.\n * @property {import(\"./Units.js\").Units} [units] Units. Required unless a\n * proj4 projection is defined for `code`.\n * @property {import(\"../extent.js\").Extent} [extent] The validity extent for the SRS.\n * @property {string} [axisOrientation='enu'] The axis orientation as specified in Proj4.\n * @property {boolean} [global=false] Whether the projection is valid for the whole globe.\n * @property {number} [metersPerUnit] The meters per unit for the SRS.\n * If not provided, the `units` are used to get the meters per unit from the {@link METERS_PER_UNIT}\n * lookup table.\n * @property {import(\"../extent.js\").Extent} [worldExtent] The world extent for the SRS.\n * @property {function(number, import(\"../coordinate.js\").Coordinate):number} [getPointResolution]\n * Function to determine resolution at a point. The function is called with a\n * `number` view resolution and a {@link module:ol/coordinate~Coordinate} as arguments, and returns\n * the `number` resolution in projection units at the passed coordinate. If this is `undefined`,\n * the default {@link module:ol/proj.getPointResolution} function will be used.\n */\n\n/**\n * @classdesc\n * Projection definition class. One of these is created for each projection\n * supported in the application and stored in the {@link module:ol/proj} namespace.\n * You can use these in applications, but this is not required, as API params\n * and options use {@link module:ol/proj~ProjectionLike} which means the simple string\n * code will suffice.\n *\n * You can use {@link module:ol/proj.get} to retrieve the object for a particular\n * projection.\n *\n * The library includes definitions for `EPSG:4326` and `EPSG:3857`, together\n * with the following aliases:\n * * `EPSG:4326`: CRS:84, urn:ogc:def:crs:EPSG:6.6:4326,\n * urn:ogc:def:crs:OGC:1.3:CRS84, urn:ogc:def:crs:OGC:2:84,\n * http://www.opengis.net/gml/srs/epsg.xml#4326,\n * urn:x-ogc:def:crs:EPSG:4326\n * * `EPSG:3857`: EPSG:102100, EPSG:102113, EPSG:900913,\n * urn:ogc:def:crs:EPSG:6.18:3:3857,\n * http://www.opengis.net/gml/srs/epsg.xml#3857\n *\n * If you use [proj4js](https://github.com/proj4js/proj4js), aliases can\n * be added using `proj4.defs()`. After all required projection definitions are\n * added, call the {@link module:ol/proj/proj4.register} function.\n *\n * @api\n */\nclass Projection {\n /**\n * @param {Options} options Projection options.\n */\n constructor(options) {\n /**\n * @private\n * @type {string}\n */\n this.code_ = options.code;\n\n /**\n * Units of projected coordinates. When set to `TILE_PIXELS`, a\n * `this.extent_` and `this.worldExtent_` must be configured properly for each\n * tile.\n * @private\n * @type {import(\"./Units.js\").Units}\n */\n this.units_ = /** @type {import(\"./Units.js\").Units} */ (options.units);\n\n /**\n * Validity extent of the projection in projected coordinates. For projections\n * with `TILE_PIXELS` units, this is the extent of the tile in\n * tile pixel space.\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.extent_ = options.extent !== undefined ? options.extent : null;\n\n /**\n * Extent of the world in EPSG:4326. For projections with\n * `TILE_PIXELS` units, this is the extent of the tile in\n * projected coordinate space.\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.worldExtent_ =\n options.worldExtent !== undefined ? options.worldExtent : null;\n\n /**\n * @private\n * @type {string}\n */\n this.axisOrientation_ =\n options.axisOrientation !== undefined ? options.axisOrientation : 'enu';\n\n /**\n * @private\n * @type {boolean}\n */\n this.global_ = options.global !== undefined ? options.global : false;\n\n /**\n * @private\n * @type {boolean}\n */\n this.canWrapX_ = !!(this.global_ && this.extent_);\n\n /**\n * @private\n * @type {function(number, import(\"../coordinate.js\").Coordinate):number|undefined}\n */\n this.getPointResolutionFunc_ = options.getPointResolution;\n\n /**\n * @private\n * @type {import(\"../tilegrid/TileGrid.js\").default}\n */\n this.defaultTileGrid_ = null;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.metersPerUnit_ = options.metersPerUnit;\n }\n\n /**\n * @return {boolean} The projection is suitable for wrapping the x-axis\n */\n canWrapX() {\n return this.canWrapX_;\n }\n\n /**\n * Get the code for this projection, e.g. 'EPSG:4326'.\n * @return {string} Code.\n * @api\n */\n getCode() {\n return this.code_;\n }\n\n /**\n * Get the validity extent for this projection.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getExtent() {\n return this.extent_;\n }\n\n /**\n * Get the units of this projection.\n * @return {import(\"./Units.js\").Units} Units.\n * @api\n */\n getUnits() {\n return this.units_;\n }\n\n /**\n * Get the amount of meters per unit of this projection. If the projection is\n * not configured with `metersPerUnit` or a units identifier, the return is\n * `undefined`.\n * @return {number|undefined} Meters.\n * @api\n */\n getMetersPerUnit() {\n return this.metersPerUnit_ || METERS_PER_UNIT[this.units_];\n }\n\n /**\n * Get the world extent for this projection.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getWorldExtent() {\n return this.worldExtent_;\n }\n\n /**\n * Get the axis orientation of this projection.\n * Example values are:\n * enu - the default easting, northing, elevation.\n * neu - northing, easting, up - useful for \"lat/long\" geographic coordinates,\n * or south orientated transverse mercator.\n * wnu - westing, northing, up - some planetary coordinate systems have\n * \"west positive\" coordinate systems\n * @return {string} Axis orientation.\n * @api\n */\n getAxisOrientation() {\n return this.axisOrientation_;\n }\n\n /**\n * Is this projection a global projection which spans the whole world?\n * @return {boolean} Whether the projection is global.\n * @api\n */\n isGlobal() {\n return this.global_;\n }\n\n /**\n * Set if the projection is a global projection which spans the whole world\n * @param {boolean} global Whether the projection is global.\n * @api\n */\n setGlobal(global) {\n this.global_ = global;\n this.canWrapX_ = !!(global && this.extent_);\n }\n\n /**\n * @return {import(\"../tilegrid/TileGrid.js\").default} The default tile grid.\n */\n getDefaultTileGrid() {\n return this.defaultTileGrid_;\n }\n\n /**\n * @param {import(\"../tilegrid/TileGrid.js\").default} tileGrid The default tile grid.\n */\n setDefaultTileGrid(tileGrid) {\n this.defaultTileGrid_ = tileGrid;\n }\n\n /**\n * Set the validity extent for this projection.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @api\n */\n setExtent(extent) {\n this.extent_ = extent;\n this.canWrapX_ = !!(this.global_ && extent);\n }\n\n /**\n * Set the world extent for this projection.\n * @param {import(\"../extent.js\").Extent} worldExtent World extent\n * [minlon, minlat, maxlon, maxlat].\n * @api\n */\n setWorldExtent(worldExtent) {\n this.worldExtent_ = worldExtent;\n }\n\n /**\n * Set the getPointResolution function (see {@link module:ol/proj.getPointResolution}\n * for this projection.\n * @param {function(number, import(\"../coordinate.js\").Coordinate):number} func Function\n * @api\n */\n setGetPointResolution(func) {\n this.getPointResolutionFunc_ = func;\n }\n\n /**\n * Get the custom point resolution function for this projection (if set).\n * @return {function(number, import(\"../coordinate.js\").Coordinate):number|undefined} The custom point\n * resolution function (if set).\n */\n getPointResolutionFunc() {\n return this.getPointResolutionFunc_;\n }\n}\n\nexport default Projection;\n","/**\n * @module ol/proj/epsg3857\n */\nimport Projection from './Projection.js';\n\n/**\n * Radius of WGS84 sphere\n *\n * @const\n * @type {number}\n */\nexport const RADIUS = 6378137;\n\n/**\n * @const\n * @type {number}\n */\nexport const HALF_SIZE = Math.PI * RADIUS;\n\n/**\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const EXTENT = [-HALF_SIZE, -HALF_SIZE, HALF_SIZE, HALF_SIZE];\n\n/**\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const WORLD_EXTENT = [-180, -85, 180, 85];\n\n/**\n * Maximum safe value in y direction\n * @const\n * @type {number}\n */\nexport const MAX_SAFE_Y = RADIUS * Math.log(Math.tan(Math.PI / 2));\n\n/**\n * @classdesc\n * Projection object for web/spherical Mercator (EPSG:3857).\n */\nclass EPSG3857Projection extends Projection {\n /**\n * @param {string} code Code.\n */\n constructor(code) {\n super({\n code: code,\n units: 'm',\n extent: EXTENT,\n global: true,\n worldExtent: WORLD_EXTENT,\n getPointResolution: function (resolution, point) {\n return resolution / Math.cosh(point[1] / RADIUS);\n },\n });\n }\n}\n\n/**\n * Projections equal to EPSG:3857.\n *\n * @const\n * @type {Array}\n */\nexport const PROJECTIONS = [\n new EPSG3857Projection('EPSG:3857'),\n new EPSG3857Projection('EPSG:102100'),\n new EPSG3857Projection('EPSG:102113'),\n new EPSG3857Projection('EPSG:900913'),\n new EPSG3857Projection('http://www.opengis.net/def/crs/EPSG/0/3857'),\n new EPSG3857Projection('http://www.opengis.net/gml/srs/epsg.xml#3857'),\n];\n\n/**\n * Transformation from EPSG:4326 to EPSG:3857.\n *\n * @param {Array} input Input array of coordinate values.\n * @param {Array} [output] Output array of coordinate values.\n * @param {number} [dimension] Dimension (default is `2`).\n * @return {Array} Output array of coordinate values.\n */\nexport function fromEPSG4326(input, output, dimension) {\n const length = input.length;\n dimension = dimension > 1 ? dimension : 2;\n if (output === undefined) {\n if (dimension > 2) {\n // preserve values beyond second dimension\n output = input.slice();\n } else {\n output = new Array(length);\n }\n }\n for (let i = 0; i < length; i += dimension) {\n output[i] = (HALF_SIZE * input[i]) / 180;\n let y = RADIUS * Math.log(Math.tan((Math.PI * (+input[i + 1] + 90)) / 360));\n if (y > MAX_SAFE_Y) {\n y = MAX_SAFE_Y;\n } else if (y < -MAX_SAFE_Y) {\n y = -MAX_SAFE_Y;\n }\n output[i + 1] = y;\n }\n return output;\n}\n\n/**\n * Transformation from EPSG:3857 to EPSG:4326.\n *\n * @param {Array} input Input array of coordinate values.\n * @param {Array} [output] Output array of coordinate values.\n * @param {number} [dimension] Dimension (default is `2`).\n * @return {Array} Output array of coordinate values.\n */\nexport function toEPSG4326(input, output, dimension) {\n const length = input.length;\n dimension = dimension > 1 ? dimension : 2;\n if (output === undefined) {\n if (dimension > 2) {\n // preserve values beyond second dimension\n output = input.slice();\n } else {\n output = new Array(length);\n }\n }\n for (let i = 0; i < length; i += dimension) {\n output[i] = (180 * input[i]) / HALF_SIZE;\n output[i + 1] =\n (360 * Math.atan(Math.exp(input[i + 1] / RADIUS))) / Math.PI - 90;\n }\n return output;\n}\n","/**\n * @module ol/proj/epsg4326\n */\nimport Projection from './Projection.js';\n\n/**\n * Semi-major radius of the WGS84 ellipsoid.\n *\n * @const\n * @type {number}\n */\nexport const RADIUS = 6378137;\n\n/**\n * Extent of the EPSG:4326 projection which is the whole world.\n *\n * @const\n * @type {import(\"../extent.js\").Extent}\n */\nexport const EXTENT = [-180, -90, 180, 90];\n\n/**\n * @const\n * @type {number}\n */\nexport const METERS_PER_UNIT = (Math.PI * RADIUS) / 180;\n\n/**\n * @classdesc\n * Projection object for WGS84 geographic coordinates (EPSG:4326).\n *\n * Note that OpenLayers does not strictly comply with the EPSG definition.\n * The EPSG registry defines 4326 as a CRS for Latitude,Longitude (y,x).\n * OpenLayers treats EPSG:4326 as a pseudo-projection, with x,y coordinates.\n */\nclass EPSG4326Projection extends Projection {\n /**\n * @param {string} code Code.\n * @param {string} [axisOrientation] Axis orientation.\n */\n constructor(code, axisOrientation) {\n super({\n code: code,\n units: 'degrees',\n extent: EXTENT,\n axisOrientation: axisOrientation,\n global: true,\n metersPerUnit: METERS_PER_UNIT,\n worldExtent: EXTENT,\n });\n }\n}\n\n/**\n * Projections equal to EPSG:4326.\n *\n * @const\n * @type {Array}\n */\nexport const PROJECTIONS = [\n new EPSG4326Projection('CRS:84'),\n new EPSG4326Projection('EPSG:4326', 'neu'),\n new EPSG4326Projection('urn:ogc:def:crs:OGC:1.3:CRS84'),\n new EPSG4326Projection('urn:ogc:def:crs:OGC:2:84'),\n new EPSG4326Projection('http://www.opengis.net/def/crs/OGC/1.3/CRS84'),\n new EPSG4326Projection('http://www.opengis.net/gml/srs/epsg.xml#4326', 'neu'),\n new EPSG4326Projection('http://www.opengis.net/def/crs/EPSG/0/4326', 'neu'),\n];\n","/**\n * @module ol/proj/projections\n */\n\n/**\n * @type {Object}\n */\nlet cache = {};\n\n/**\n * Clear the projections cache.\n */\nexport function clear() {\n cache = {};\n}\n\n/**\n * Get a cached projection by code.\n * @param {string} code The code for the projection.\n * @return {import(\"./Projection.js\").default} The projection (if cached).\n */\nexport function get(code) {\n return (\n cache[code] ||\n cache[code.replace(/urn:(x-)?ogc:def:crs:EPSG:(.*:)?(\\w+)$/, 'EPSG:$3')] ||\n null\n );\n}\n\n/**\n * Add a projection to the cache.\n * @param {string} code The projection code.\n * @param {import(\"./Projection.js\").default} projection The projection to cache.\n */\nexport function add(code, projection) {\n cache[code] = projection;\n}\n","/**\n * @module ol/proj/transforms\n */\nimport {isEmpty} from '../obj.js';\n\n/**\n * @private\n * @type {!Object>}\n */\nlet transforms = {};\n\n/**\n * Clear the transform cache.\n */\nexport function clear() {\n transforms = {};\n}\n\n/**\n * Registers a conversion function to convert coordinates from the source\n * projection to the destination projection.\n *\n * @param {import(\"./Projection.js\").default} source Source.\n * @param {import(\"./Projection.js\").default} destination Destination.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform.\n */\nexport function add(source, destination, transformFn) {\n const sourceCode = source.getCode();\n const destinationCode = destination.getCode();\n if (!(sourceCode in transforms)) {\n transforms[sourceCode] = {};\n }\n transforms[sourceCode][destinationCode] = transformFn;\n}\n\n/**\n * Unregisters the conversion function to convert coordinates from the source\n * projection to the destination projection. This method is used to clean up\n * cached transforms during testing.\n *\n * @param {import(\"./Projection.js\").default} source Source projection.\n * @param {import(\"./Projection.js\").default} destination Destination projection.\n * @return {import(\"../proj.js\").TransformFunction} transformFn The unregistered transform.\n */\nexport function remove(source, destination) {\n const sourceCode = source.getCode();\n const destinationCode = destination.getCode();\n const transform = transforms[sourceCode][destinationCode];\n delete transforms[sourceCode][destinationCode];\n if (isEmpty(transforms[sourceCode])) {\n delete transforms[sourceCode];\n }\n return transform;\n}\n\n/**\n * Get a transform given a source code and a destination code.\n * @param {string} sourceCode The code for the source projection.\n * @param {string} destinationCode The code for the destination projection.\n * @return {import(\"../proj.js\").TransformFunction|undefined} The transform function (if found).\n */\nexport function get(sourceCode, destinationCode) {\n let transform;\n if (sourceCode in transforms && destinationCode in transforms[sourceCode]) {\n transform = transforms[sourceCode][destinationCode];\n }\n return transform;\n}\n","/**\n * @module ol/extent/Relationship\n */\n\n/**\n * Relationship to an extent.\n * @enum {number}\n */\nexport default {\n UNKNOWN: 0,\n INTERSECTING: 1,\n ABOVE: 2,\n RIGHT: 4,\n BELOW: 8,\n LEFT: 16,\n};\n","/**\n * @module ol/extent\n */\nimport Relationship from './extent/Relationship.js';\n\n/**\n * An array of numbers representing an extent: `[minx, miny, maxx, maxy]`.\n * @typedef {Array} Extent\n * @api\n */\n\n/**\n * Extent corner.\n * @typedef {'bottom-left' | 'bottom-right' | 'top-left' | 'top-right'} Corner\n */\n\n/**\n * Build an extent that includes all given coordinates.\n *\n * @param {Array} coordinates Coordinates.\n * @return {Extent} Bounding extent.\n * @api\n */\nexport function boundingExtent(coordinates) {\n const extent = createEmpty();\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n extendCoordinate(extent, coordinates[i]);\n }\n return extent;\n}\n\n/**\n * @param {Array} xs Xs.\n * @param {Array} ys Ys.\n * @param {Extent} [dest] Destination extent.\n * @private\n * @return {Extent} Extent.\n */\nfunction _boundingExtentXYs(xs, ys, dest) {\n const minX = Math.min.apply(null, xs);\n const minY = Math.min.apply(null, ys);\n const maxX = Math.max.apply(null, xs);\n const maxY = Math.max.apply(null, ys);\n return createOrUpdate(minX, minY, maxX, maxY, dest);\n}\n\n/**\n * Return extent increased by the provided value.\n * @param {Extent} extent Extent.\n * @param {number} value The amount by which the extent should be buffered.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n * @api\n */\nexport function buffer(extent, value, dest) {\n if (dest) {\n dest[0] = extent[0] - value;\n dest[1] = extent[1] - value;\n dest[2] = extent[2] + value;\n dest[3] = extent[3] + value;\n return dest;\n }\n return [\n extent[0] - value,\n extent[1] - value,\n extent[2] + value,\n extent[3] + value,\n ];\n}\n\n/**\n * Creates a clone of an extent.\n *\n * @param {Extent} extent Extent to clone.\n * @param {Extent} [dest] Extent.\n * @return {Extent} The clone.\n */\nexport function clone(extent, dest) {\n if (dest) {\n dest[0] = extent[0];\n dest[1] = extent[1];\n dest[2] = extent[2];\n dest[3] = extent[3];\n return dest;\n }\n return extent.slice();\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {number} Closest squared distance.\n */\nexport function closestSquaredDistanceXY(extent, x, y) {\n let dx, dy;\n if (x < extent[0]) {\n dx = extent[0] - x;\n } else if (extent[2] < x) {\n dx = x - extent[2];\n } else {\n dx = 0;\n }\n if (y < extent[1]) {\n dy = extent[1] - y;\n } else if (extent[3] < y) {\n dy = y - extent[3];\n } else {\n dy = 0;\n }\n return dx * dx + dy * dy;\n}\n\n/**\n * Check if the passed coordinate is contained or on the edge of the extent.\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} The coordinate is contained in the extent.\n * @api\n */\nexport function containsCoordinate(extent, coordinate) {\n return containsXY(extent, coordinate[0], coordinate[1]);\n}\n\n/**\n * Check if one extent contains another.\n *\n * An extent is deemed contained if it lies completely within the other extent,\n * including if they share one or more edges.\n *\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {boolean} The second extent is contained by or on the edge of the\n * first.\n * @api\n */\nexport function containsExtent(extent1, extent2) {\n return (\n extent1[0] <= extent2[0] &&\n extent2[2] <= extent1[2] &&\n extent1[1] <= extent2[1] &&\n extent2[3] <= extent1[3]\n );\n}\n\n/**\n * Check if the passed coordinate is contained or on the edge of the extent.\n *\n * @param {Extent} extent Extent.\n * @param {number} x X coordinate.\n * @param {number} y Y coordinate.\n * @return {boolean} The x, y values are contained in the extent.\n * @api\n */\nexport function containsXY(extent, x, y) {\n return extent[0] <= x && x <= extent[2] && extent[1] <= y && y <= extent[3];\n}\n\n/**\n * Get the relationship between a coordinate and extent.\n * @param {Extent} extent The extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate The coordinate.\n * @return {import(\"./extent/Relationship.js\").default} The relationship (bitwise compare with\n * import(\"./extent/Relationship.js\").Relationship).\n */\nexport function coordinateRelationship(extent, coordinate) {\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const x = coordinate[0];\n const y = coordinate[1];\n let relationship = Relationship.UNKNOWN;\n if (x < minX) {\n relationship = relationship | Relationship.LEFT;\n } else if (x > maxX) {\n relationship = relationship | Relationship.RIGHT;\n }\n if (y < minY) {\n relationship = relationship | Relationship.BELOW;\n } else if (y > maxY) {\n relationship = relationship | Relationship.ABOVE;\n }\n if (relationship === Relationship.UNKNOWN) {\n relationship = Relationship.INTERSECTING;\n }\n return relationship;\n}\n\n/**\n * Create an empty extent.\n * @return {Extent} Empty extent.\n * @api\n */\nexport function createEmpty() {\n return [Infinity, Infinity, -Infinity, -Infinity];\n}\n\n/**\n * Create a new extent or update the provided extent.\n * @param {number} minX Minimum X.\n * @param {number} minY Minimum Y.\n * @param {number} maxX Maximum X.\n * @param {number} maxY Maximum Y.\n * @param {Extent} [dest] Destination extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdate(minX, minY, maxX, maxY, dest) {\n if (dest) {\n dest[0] = minX;\n dest[1] = minY;\n dest[2] = maxX;\n dest[3] = maxY;\n return dest;\n }\n return [minX, minY, maxX, maxY];\n}\n\n/**\n * Create a new empty extent or make the provided one empty.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateEmpty(dest) {\n return createOrUpdate(Infinity, Infinity, -Infinity, -Infinity, dest);\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromCoordinate(coordinate, dest) {\n const x = coordinate[0];\n const y = coordinate[1];\n return createOrUpdate(x, y, x, y, dest);\n}\n\n/**\n * @param {Array} coordinates Coordinates.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromCoordinates(coordinates, dest) {\n const extent = createOrUpdateEmpty(dest);\n return extendCoordinates(extent, coordinates);\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromFlatCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n dest\n) {\n const extent = createOrUpdateEmpty(dest);\n return extendFlatCoordinates(extent, flatCoordinates, offset, end, stride);\n}\n\n/**\n * @param {Array>} rings Rings.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function createOrUpdateFromRings(rings, dest) {\n const extent = createOrUpdateEmpty(dest);\n return extendRings(extent, rings);\n}\n\n/**\n * Determine if two extents are equivalent.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {boolean} The two extents are equivalent.\n * @api\n */\nexport function equals(extent1, extent2) {\n return (\n extent1[0] == extent2[0] &&\n extent1[2] == extent2[2] &&\n extent1[1] == extent2[1] &&\n extent1[3] == extent2[3]\n );\n}\n\n/**\n * Determine if two extents are approximately equivalent.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @param {number} tolerance Tolerance in extent coordinate units.\n * @return {boolean} The two extents differ by less than the tolerance.\n */\nexport function approximatelyEquals(extent1, extent2, tolerance) {\n return (\n Math.abs(extent1[0] - extent2[0]) < tolerance &&\n Math.abs(extent1[2] - extent2[2]) < tolerance &&\n Math.abs(extent1[1] - extent2[1]) < tolerance &&\n Math.abs(extent1[3] - extent2[3]) < tolerance\n );\n}\n\n/**\n * Modify an extent to include another extent.\n * @param {Extent} extent1 The extent to be modified.\n * @param {Extent} extent2 The extent that will be included in the first.\n * @return {Extent} A reference to the first (extended) extent.\n * @api\n */\nexport function extend(extent1, extent2) {\n if (extent2[0] < extent1[0]) {\n extent1[0] = extent2[0];\n }\n if (extent2[2] > extent1[2]) {\n extent1[2] = extent2[2];\n }\n if (extent2[1] < extent1[1]) {\n extent1[1] = extent2[1];\n }\n if (extent2[3] > extent1[3]) {\n extent1[3] = extent2[3];\n }\n return extent1;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n */\nexport function extendCoordinate(extent, coordinate) {\n if (coordinate[0] < extent[0]) {\n extent[0] = coordinate[0];\n }\n if (coordinate[0] > extent[2]) {\n extent[2] = coordinate[0];\n }\n if (coordinate[1] < extent[1]) {\n extent[1] = coordinate[1];\n }\n if (coordinate[1] > extent[3]) {\n extent[3] = coordinate[1];\n }\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array} coordinates Coordinates.\n * @return {Extent} Extent.\n */\nexport function extendCoordinates(extent, coordinates) {\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n extendCoordinate(extent, coordinates[i]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {Extent} Extent.\n */\nexport function extendFlatCoordinates(\n extent,\n flatCoordinates,\n offset,\n end,\n stride\n) {\n for (; offset < end; offset += stride) {\n extendXY(extent, flatCoordinates[offset], flatCoordinates[offset + 1]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Array>} rings Rings.\n * @return {Extent} Extent.\n */\nexport function extendRings(extent, rings) {\n for (let i = 0, ii = rings.length; i < ii; ++i) {\n extendCoordinates(extent, rings[i]);\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} x X.\n * @param {number} y Y.\n */\nexport function extendXY(extent, x, y) {\n extent[0] = Math.min(extent[0], x);\n extent[1] = Math.min(extent[1], y);\n extent[2] = Math.max(extent[2], x);\n extent[3] = Math.max(extent[3], y);\n}\n\n/**\n * This function calls `callback` for each corner of the extent. If the\n * callback returns a truthy value the function returns that value\n * immediately. Otherwise the function returns `false`.\n * @param {Extent} extent Extent.\n * @param {function(import(\"./coordinate.js\").Coordinate): S} callback Callback.\n * @return {S|boolean} Value.\n * @template S\n */\nexport function forEachCorner(extent, callback) {\n let val;\n val = callback(getBottomLeft(extent));\n if (val) {\n return val;\n }\n val = callback(getBottomRight(extent));\n if (val) {\n return val;\n }\n val = callback(getTopRight(extent));\n if (val) {\n return val;\n }\n val = callback(getTopLeft(extent));\n if (val) {\n return val;\n }\n return false;\n}\n\n/**\n * Get the size of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Area.\n * @api\n */\nexport function getArea(extent) {\n let area = 0;\n if (!isEmpty(extent)) {\n area = getWidth(extent) * getHeight(extent);\n }\n return area;\n}\n\n/**\n * Get the bottom left coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Bottom left coordinate.\n * @api\n */\nexport function getBottomLeft(extent) {\n return [extent[0], extent[1]];\n}\n\n/**\n * Get the bottom right coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Bottom right coordinate.\n * @api\n */\nexport function getBottomRight(extent) {\n return [extent[2], extent[1]];\n}\n\n/**\n * Get the center coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Center.\n * @api\n */\nexport function getCenter(extent) {\n return [(extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2];\n}\n\n/**\n * Get a corner coordinate of an extent.\n * @param {Extent} extent Extent.\n * @param {Corner} corner Corner.\n * @return {import(\"./coordinate.js\").Coordinate} Corner coordinate.\n */\nexport function getCorner(extent, corner) {\n let coordinate;\n if (corner === 'bottom-left') {\n coordinate = getBottomLeft(extent);\n } else if (corner === 'bottom-right') {\n coordinate = getBottomRight(extent);\n } else if (corner === 'top-left') {\n coordinate = getTopLeft(extent);\n } else if (corner === 'top-right') {\n coordinate = getTopRight(extent);\n } else {\n throw new Error('Invalid corner');\n }\n return coordinate;\n}\n\n/**\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {number} Enlarged area.\n */\nexport function getEnlargedArea(extent1, extent2) {\n const minX = Math.min(extent1[0], extent2[0]);\n const minY = Math.min(extent1[1], extent2[1]);\n const maxX = Math.max(extent1[2], extent2[2]);\n const maxY = Math.max(extent1[3], extent2[3]);\n return (maxX - minX) * (maxY - minY);\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} center Center.\n * @param {number} resolution Resolution.\n * @param {number} rotation Rotation.\n * @param {import(\"./size.js\").Size} size Size.\n * @param {Extent} [dest] Destination extent.\n * @return {Extent} Extent.\n */\nexport function getForViewAndSize(center, resolution, rotation, size, dest) {\n const [x0, y0, x1, y1, x2, y2, x3, y3] = getRotatedViewport(\n center,\n resolution,\n rotation,\n size\n );\n return createOrUpdate(\n Math.min(x0, x1, x2, x3),\n Math.min(y0, y1, y2, y3),\n Math.max(x0, x1, x2, x3),\n Math.max(y0, y1, y2, y3),\n dest\n );\n}\n\n/**\n * @param {import(\"./coordinate.js\").Coordinate} center Center.\n * @param {number} resolution Resolution.\n * @param {number} rotation Rotation.\n * @param {import(\"./size.js\").Size} size Size.\n * @return {Array} Linear ring representing the viewport.\n */\nexport function getRotatedViewport(center, resolution, rotation, size) {\n const dx = (resolution * size[0]) / 2;\n const dy = (resolution * size[1]) / 2;\n const cosRotation = Math.cos(rotation);\n const sinRotation = Math.sin(rotation);\n const xCos = dx * cosRotation;\n const xSin = dx * sinRotation;\n const yCos = dy * cosRotation;\n const ySin = dy * sinRotation;\n const x = center[0];\n const y = center[1];\n return [\n x - xCos + ySin,\n y - xSin - yCos,\n x - xCos - ySin,\n y - xSin + yCos,\n x + xCos - ySin,\n y + xSin + yCos,\n x + xCos + ySin,\n y + xSin - yCos,\n x - xCos + ySin,\n y - xSin - yCos,\n ];\n}\n\n/**\n * Get the height of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Height.\n * @api\n */\nexport function getHeight(extent) {\n return extent[3] - extent[1];\n}\n\n/**\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @return {number} Intersection area.\n */\nexport function getIntersectionArea(extent1, extent2) {\n const intersection = getIntersection(extent1, extent2);\n return getArea(intersection);\n}\n\n/**\n * Get the intersection of two extents.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent 2.\n * @param {Extent} [dest] Optional extent to populate with intersection.\n * @return {Extent} Intersecting extent.\n * @api\n */\nexport function getIntersection(extent1, extent2, dest) {\n const intersection = dest ? dest : createEmpty();\n if (intersects(extent1, extent2)) {\n if (extent1[0] > extent2[0]) {\n intersection[0] = extent1[0];\n } else {\n intersection[0] = extent2[0];\n }\n if (extent1[1] > extent2[1]) {\n intersection[1] = extent1[1];\n } else {\n intersection[1] = extent2[1];\n }\n if (extent1[2] < extent2[2]) {\n intersection[2] = extent1[2];\n } else {\n intersection[2] = extent2[2];\n }\n if (extent1[3] < extent2[3]) {\n intersection[3] = extent1[3];\n } else {\n intersection[3] = extent2[3];\n }\n } else {\n createOrUpdateEmpty(intersection);\n }\n return intersection;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @return {number} Margin.\n */\nexport function getMargin(extent) {\n return getWidth(extent) + getHeight(extent);\n}\n\n/**\n * Get the size (width, height) of an extent.\n * @param {Extent} extent The extent.\n * @return {import(\"./size.js\").Size} The extent size.\n * @api\n */\nexport function getSize(extent) {\n return [extent[2] - extent[0], extent[3] - extent[1]];\n}\n\n/**\n * Get the top left coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Top left coordinate.\n * @api\n */\nexport function getTopLeft(extent) {\n return [extent[0], extent[3]];\n}\n\n/**\n * Get the top right coordinate of an extent.\n * @param {Extent} extent Extent.\n * @return {import(\"./coordinate.js\").Coordinate} Top right coordinate.\n * @api\n */\nexport function getTopRight(extent) {\n return [extent[2], extent[3]];\n}\n\n/**\n * Get the width of an extent.\n * @param {Extent} extent Extent.\n * @return {number} Width.\n * @api\n */\nexport function getWidth(extent) {\n return extent[2] - extent[0];\n}\n\n/**\n * Determine if one extent intersects another.\n * @param {Extent} extent1 Extent 1.\n * @param {Extent} extent2 Extent.\n * @return {boolean} The two extents intersect.\n * @api\n */\nexport function intersects(extent1, extent2) {\n return (\n extent1[0] <= extent2[2] &&\n extent1[2] >= extent2[0] &&\n extent1[1] <= extent2[3] &&\n extent1[3] >= extent2[1]\n );\n}\n\n/**\n * Determine if an extent is empty.\n * @param {Extent} extent Extent.\n * @return {boolean} Is empty.\n * @api\n */\nexport function isEmpty(extent) {\n return extent[2] < extent[0] || extent[3] < extent[1];\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {Extent} [dest] Extent.\n * @return {Extent} Extent.\n */\nexport function returnOrUpdate(extent, dest) {\n if (dest) {\n dest[0] = extent[0];\n dest[1] = extent[1];\n dest[2] = extent[2];\n dest[3] = extent[3];\n return dest;\n }\n return extent;\n}\n\n/**\n * @param {Extent} extent Extent.\n * @param {number} value Value.\n */\nexport function scaleFromCenter(extent, value) {\n const deltaX = ((extent[2] - extent[0]) / 2) * (value - 1);\n const deltaY = ((extent[3] - extent[1]) / 2) * (value - 1);\n extent[0] -= deltaX;\n extent[2] += deltaX;\n extent[1] -= deltaY;\n extent[3] += deltaY;\n}\n\n/**\n * Determine if the segment between two coordinates intersects (crosses,\n * touches, or is contained by) the provided extent.\n * @param {Extent} extent The extent.\n * @param {import(\"./coordinate.js\").Coordinate} start Segment start coordinate.\n * @param {import(\"./coordinate.js\").Coordinate} end Segment end coordinate.\n * @return {boolean} The segment intersects the extent.\n */\nexport function intersectsSegment(extent, start, end) {\n let intersects = false;\n const startRel = coordinateRelationship(extent, start);\n const endRel = coordinateRelationship(extent, end);\n if (\n startRel === Relationship.INTERSECTING ||\n endRel === Relationship.INTERSECTING\n ) {\n intersects = true;\n } else {\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const startX = start[0];\n const startY = start[1];\n const endX = end[0];\n const endY = end[1];\n const slope = (endY - startY) / (endX - startX);\n let x, y;\n if (!!(endRel & Relationship.ABOVE) && !(startRel & Relationship.ABOVE)) {\n // potentially intersects top\n x = endX - (endY - maxY) / slope;\n intersects = x >= minX && x <= maxX;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.RIGHT) &&\n !(startRel & Relationship.RIGHT)\n ) {\n // potentially intersects right\n y = endY - (endX - maxX) * slope;\n intersects = y >= minY && y <= maxY;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.BELOW) &&\n !(startRel & Relationship.BELOW)\n ) {\n // potentially intersects bottom\n x = endX - (endY - minY) / slope;\n intersects = x >= minX && x <= maxX;\n }\n if (\n !intersects &&\n !!(endRel & Relationship.LEFT) &&\n !(startRel & Relationship.LEFT)\n ) {\n // potentially intersects left\n y = endY - (endX - minX) * slope;\n intersects = y >= minY && y <= maxY;\n }\n }\n return intersects;\n}\n\n/**\n * Apply a transform function to the extent.\n * @param {Extent} extent Extent.\n * @param {import(\"./proj.js\").TransformFunction} transformFn Transform function.\n * Called with `[minX, minY, maxX, maxY]` extent coordinates.\n * @param {Extent} [dest] Destination extent.\n * @param {number} [stops] Number of stops per side used for the transform.\n * By default only the corners are used.\n * @return {Extent} Extent.\n * @api\n */\nexport function applyTransform(extent, transformFn, dest, stops) {\n if (isEmpty(extent)) {\n return createOrUpdateEmpty(dest);\n }\n let coordinates = [];\n if (stops > 1) {\n const width = extent[2] - extent[0];\n const height = extent[3] - extent[1];\n for (let i = 0; i < stops; ++i) {\n coordinates.push(\n extent[0] + (width * i) / stops,\n extent[1],\n extent[2],\n extent[1] + (height * i) / stops,\n extent[2] - (width * i) / stops,\n extent[3],\n extent[0],\n extent[3] - (height * i) / stops\n );\n }\n } else {\n coordinates = [\n extent[0],\n extent[1],\n extent[2],\n extent[1],\n extent[2],\n extent[3],\n extent[0],\n extent[3],\n ];\n }\n transformFn(coordinates, coordinates, 2);\n const xs = [];\n const ys = [];\n for (let i = 0, l = coordinates.length; i < l; i += 2) {\n xs.push(coordinates[i]);\n ys.push(coordinates[i + 1]);\n }\n return _boundingExtentXYs(xs, ys, dest);\n}\n\n/**\n * Modifies the provided extent in-place to be within the real world\n * extent.\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./proj/Projection.js\").default} projection Projection\n * @return {Extent} The extent within the real world extent.\n */\nexport function wrapX(extent, projection) {\n const projectionExtent = projection.getExtent();\n const center = getCenter(extent);\n if (\n projection.canWrapX() &&\n (center[0] < projectionExtent[0] || center[0] >= projectionExtent[2])\n ) {\n const worldWidth = getWidth(projectionExtent);\n const worldsAway = Math.floor(\n (center[0] - projectionExtent[0]) / worldWidth\n );\n const offset = worldsAway * worldWidth;\n extent[0] -= offset;\n extent[2] -= offset;\n }\n return extent;\n}\n\n/**\n * Fits the extent to the real world\n *\n * If the extent does not cross the anti meridian, this will return the extent in an array\n * If the extent crosses the anti meridian, the extent will be sliced, so each part fits within the\n * real world\n *\n *\n * @param {Extent} extent Extent.\n * @param {import(\"./proj/Projection.js\").default} projection Projection\n * @return {Array} The extent within the real world extent.\n */\nexport function wrapAndSliceX(extent, projection) {\n if (projection.canWrapX()) {\n const projectionExtent = projection.getExtent();\n\n if (!isFinite(extent[0]) || !isFinite(extent[2])) {\n return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];\n }\n\n wrapX(extent, projection);\n const worldWidth = getWidth(projectionExtent);\n\n if (getWidth(extent) > worldWidth) {\n // the extent wraps around on itself\n return [[projectionExtent[0], extent[1], projectionExtent[2], extent[3]]];\n }\n if (extent[0] < projectionExtent[0]) {\n // the extent crosses the anti meridian, so it needs to be sliced\n return [\n [extent[0] + worldWidth, extent[1], projectionExtent[2], extent[3]],\n [projectionExtent[0], extent[1], extent[2], extent[3]],\n ];\n }\n if (extent[2] > projectionExtent[2]) {\n // the extent crosses the anti meridian, so it needs to be sliced\n return [\n [extent[0], extent[1], projectionExtent[2], extent[3]],\n [projectionExtent[0], extent[1], extent[2] - worldWidth, extent[3]],\n ];\n }\n }\n\n return [extent];\n}\n","/**\n * @module ol/coordinate\n */\nimport {getWidth} from './extent.js';\nimport {modulo, toFixed} from './math.js';\nimport {padNumber} from './string.js';\n\n/**\n * An array of numbers representing an `xy`, `xyz` or `xyzm` coordinate.\n * Example: `[16, 48]`.\n * @typedef {Array} Coordinate\n * @api\n */\n\n/**\n * A function that takes a {@link module:ol/coordinate~Coordinate} and\n * transforms it into a `{string}`.\n *\n * @typedef {function((Coordinate|undefined)): string} CoordinateFormat\n * @api\n */\n\n/**\n * Add `delta` to `coordinate`. `coordinate` is modified in place and returned\n * by the function.\n *\n * Example:\n *\n * import {add} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * add(coord, [-2, 4]);\n * // coord is now [5.85, 51.983333]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {Coordinate} delta Delta.\n * @return {Coordinate} The input coordinate adjusted by\n * the given delta.\n * @api\n */\nexport function add(coordinate, delta) {\n coordinate[0] += +delta[0];\n coordinate[1] += +delta[1];\n return coordinate;\n}\n\n/**\n * Calculates the point closest to the passed coordinate on the passed circle.\n *\n * @param {Coordinate} coordinate The coordinate.\n * @param {import(\"./geom/Circle.js\").default} circle The circle.\n * @return {Coordinate} Closest point on the circumference.\n */\nexport function closestOnCircle(coordinate, circle) {\n const r = circle.getRadius();\n const center = circle.getCenter();\n const x0 = center[0];\n const y0 = center[1];\n const x1 = coordinate[0];\n const y1 = coordinate[1];\n\n let dx = x1 - x0;\n const dy = y1 - y0;\n if (dx === 0 && dy === 0) {\n dx = 1;\n }\n const d = Math.sqrt(dx * dx + dy * dy);\n\n const x = x0 + (r * dx) / d;\n const y = y0 + (r * dy) / d;\n\n return [x, y];\n}\n\n/**\n * Calculates the point closest to the passed coordinate on the passed segment.\n * This is the foot of the perpendicular of the coordinate to the segment when\n * the foot is on the segment, or the closest segment coordinate when the foot\n * is outside the segment.\n *\n * @param {Coordinate} coordinate The coordinate.\n * @param {Array} segment The two coordinates\n * of the segment.\n * @return {Coordinate} The foot of the perpendicular of\n * the coordinate to the segment.\n */\nexport function closestOnSegment(coordinate, segment) {\n const x0 = coordinate[0];\n const y0 = coordinate[1];\n const start = segment[0];\n const end = segment[1];\n const x1 = start[0];\n const y1 = start[1];\n const x2 = end[0];\n const y2 = end[1];\n const dx = x2 - x1;\n const dy = y2 - y1;\n const along =\n dx === 0 && dy === 0\n ? 0\n : (dx * (x0 - x1) + dy * (y0 - y1)) / (dx * dx + dy * dy || 0);\n let x, y;\n if (along <= 0) {\n x = x1;\n y = y1;\n } else if (along >= 1) {\n x = x2;\n y = y2;\n } else {\n x = x1 + along * dx;\n y = y1 + along * dy;\n }\n return [x, y];\n}\n\n/**\n * Returns a {@link module:ol/coordinate~CoordinateFormat} function that can be\n * used to format\n * a {Coordinate} to a string.\n *\n * Example without specifying the fractional digits:\n *\n * import {createStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const stringifyFunc = createStringXY();\n * const out = stringifyFunc(coord);\n * // out is now '8, 48'\n *\n * Example with explicitly specifying 2 fractional digits:\n *\n * import {createStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const stringifyFunc = createStringXY(2);\n * const out = stringifyFunc(coord);\n * // out is now '7.85, 47.98'\n *\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {CoordinateFormat} Coordinate format.\n * @api\n */\nexport function createStringXY(fractionDigits) {\n return (\n /**\n * @param {Coordinate} coordinate Coordinate.\n * @return {string} String XY.\n */\n function (coordinate) {\n return toStringXY(coordinate, fractionDigits);\n }\n );\n}\n\n/**\n * @param {string} hemispheres Hemispheres.\n * @param {number} degrees Degrees.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} String.\n */\nexport function degreesToStringHDMS(hemispheres, degrees, fractionDigits) {\n const normalizedDegrees = modulo(degrees + 180, 360) - 180;\n const x = Math.abs(3600 * normalizedDegrees);\n const decimals = fractionDigits || 0;\n\n let deg = Math.floor(x / 3600);\n let min = Math.floor((x - deg * 3600) / 60);\n let sec = toFixed(x - deg * 3600 - min * 60, decimals);\n\n if (sec >= 60) {\n sec = 0;\n min += 1;\n }\n\n if (min >= 60) {\n min = 0;\n deg += 1;\n }\n\n let hdms = deg + '\\u00b0';\n if (min !== 0 || sec !== 0) {\n hdms += ' ' + padNumber(min, 2) + '\\u2032';\n }\n if (sec !== 0) {\n hdms += ' ' + padNumber(sec, 2, decimals) + '\\u2033';\n }\n if (normalizedDegrees !== 0) {\n hdms += ' ' + hemispheres.charAt(normalizedDegrees < 0 ? 1 : 0);\n }\n\n return hdms;\n}\n\n/**\n * Transforms the given {@link module:ol/coordinate~Coordinate} to a string\n * using the given string template. The strings `{x}` and `{y}` in the template\n * will be replaced with the first and second coordinate values respectively.\n *\n * Example without specifying the fractional digits:\n *\n * import {format} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const template = 'Coordinate is ({x}|{y}).';\n * const out = format(coord, template);\n * // out is now 'Coordinate is (8|48).'\n *\n * Example explicitly specifying the fractional digits:\n *\n * import {format} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const template = 'Coordinate is ({x}|{y}).';\n * const out = format(coord, template, 2);\n * // out is now 'Coordinate is (7.85|47.98).'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {string} template A template string with `{x}` and `{y}` placeholders\n * that will be replaced by first and second coordinate values.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} Formatted coordinate.\n * @api\n */\nexport function format(coordinate, template, fractionDigits) {\n if (coordinate) {\n return template\n .replace('{x}', coordinate[0].toFixed(fractionDigits))\n .replace('{y}', coordinate[1].toFixed(fractionDigits));\n }\n return '';\n}\n\n/**\n * @param {Coordinate} coordinate1 First coordinate.\n * @param {Coordinate} coordinate2 Second coordinate.\n * @return {boolean} The two coordinates are equal.\n */\nexport function equals(coordinate1, coordinate2) {\n let equals = true;\n for (let i = coordinate1.length - 1; i >= 0; --i) {\n if (coordinate1[i] != coordinate2[i]) {\n equals = false;\n break;\n }\n }\n return equals;\n}\n\n/**\n * Rotate `coordinate` by `angle`. `coordinate` is modified in place and\n * returned by the function.\n *\n * Example:\n *\n * import {rotate} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const rotateRadians = Math.PI / 2; // 90 degrees\n * rotate(coord, rotateRadians);\n * // coord is now [-47.983333, 7.85]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} angle Angle in radian.\n * @return {Coordinate} Coordinate.\n * @api\n */\nexport function rotate(coordinate, angle) {\n const cosAngle = Math.cos(angle);\n const sinAngle = Math.sin(angle);\n const x = coordinate[0] * cosAngle - coordinate[1] * sinAngle;\n const y = coordinate[1] * cosAngle + coordinate[0] * sinAngle;\n coordinate[0] = x;\n coordinate[1] = y;\n return coordinate;\n}\n\n/**\n * Scale `coordinate` by `scale`. `coordinate` is modified in place and returned\n * by the function.\n *\n * Example:\n *\n * import {scale as scaleCoordinate} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const scale = 1.2;\n * scaleCoordinate(coord, scale);\n * // coord is now [9.42, 57.5799996]\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} scale Scale factor.\n * @return {Coordinate} Coordinate.\n */\nexport function scale(coordinate, scale) {\n coordinate[0] *= scale;\n coordinate[1] *= scale;\n return coordinate;\n}\n\n/**\n * @param {Coordinate} coord1 First coordinate.\n * @param {Coordinate} coord2 Second coordinate.\n * @return {number} Squared distance between coord1 and coord2.\n */\nexport function squaredDistance(coord1, coord2) {\n const dx = coord1[0] - coord2[0];\n const dy = coord1[1] - coord2[1];\n return dx * dx + dy * dy;\n}\n\n/**\n * @param {Coordinate} coord1 First coordinate.\n * @param {Coordinate} coord2 Second coordinate.\n * @return {number} Distance between coord1 and coord2.\n */\nexport function distance(coord1, coord2) {\n return Math.sqrt(squaredDistance(coord1, coord2));\n}\n\n/**\n * Calculate the squared distance from a coordinate to a line segment.\n *\n * @param {Coordinate} coordinate Coordinate of the point.\n * @param {Array} segment Line segment (2\n * coordinates).\n * @return {number} Squared distance from the point to the line segment.\n */\nexport function squaredDistanceToSegment(coordinate, segment) {\n return squaredDistance(coordinate, closestOnSegment(coordinate, segment));\n}\n\n/**\n * Format a geographic coordinate with the hemisphere, degrees, minutes, and\n * seconds.\n *\n * Example without specifying fractional digits:\n *\n * import {toStringHDMS} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringHDMS(coord);\n * // out is now '47° 58′ 60″ N 7° 50′ 60″ E'\n *\n * Example explicitly specifying 1 fractional digit:\n *\n * import {toStringHDMS} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringHDMS(coord, 1);\n * // out is now '47° 58′ 60.0″ N 7° 50′ 60.0″ E'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} Hemisphere, degrees, minutes and seconds.\n * @api\n */\nexport function toStringHDMS(coordinate, fractionDigits) {\n if (coordinate) {\n return (\n degreesToStringHDMS('NS', coordinate[1], fractionDigits) +\n ' ' +\n degreesToStringHDMS('EW', coordinate[0], fractionDigits)\n );\n }\n return '';\n}\n\n/**\n * Format a coordinate as a comma delimited string.\n *\n * Example without specifying fractional digits:\n *\n * import {toStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringXY(coord);\n * // out is now '8, 48'\n *\n * Example explicitly specifying 1 fractional digit:\n *\n * import {toStringXY} from 'ol/coordinate.js';\n *\n * const coord = [7.85, 47.983333];\n * const out = toStringXY(coord, 1);\n * // out is now '7.8, 48.0'\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {number} [fractionDigits] The number of digits to include\n * after the decimal point. Default is `0`.\n * @return {string} XY.\n * @api\n */\nexport function toStringXY(coordinate, fractionDigits) {\n return format(coordinate, '{x}, {y}', fractionDigits);\n}\n\n/**\n * Modifies the provided coordinate in-place to be within the real world\n * extent. The lower projection extent boundary is inclusive, the upper one\n * exclusive.\n *\n * @param {Coordinate} coordinate Coordinate.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @return {Coordinate} The coordinate within the real world extent.\n */\nexport function wrapX(coordinate, projection) {\n if (projection.canWrapX()) {\n const worldWidth = getWidth(projection.getExtent());\n const worldsAway = getWorldsAway(coordinate, projection, worldWidth);\n if (worldsAway) {\n coordinate[0] -= worldsAway * worldWidth;\n }\n }\n return coordinate;\n}\n/**\n * @param {Coordinate} coordinate Coordinate.\n * @param {import(\"./proj/Projection.js\").default} projection Projection.\n * @param {number} [sourceExtentWidth] Width of the source extent.\n * @return {number} Offset in world widths.\n */\nexport function getWorldsAway(coordinate, projection, sourceExtentWidth) {\n const projectionExtent = projection.getExtent();\n let worldsAway = 0;\n if (\n projection.canWrapX() &&\n (coordinate[0] < projectionExtent[0] || coordinate[0] > projectionExtent[2])\n ) {\n sourceExtentWidth = sourceExtentWidth || getWidth(projectionExtent);\n worldsAway = Math.floor(\n (coordinate[0] - projectionExtent[0]) / sourceExtentWidth\n );\n }\n return worldsAway;\n}\n","/**\n * @module ol/sphere\n */\nimport {toDegrees, toRadians} from './math.js';\n\n/**\n * Object literal with options for the {@link getLength} or {@link getArea}\n * functions.\n * @typedef {Object} SphereMetricOptions\n * @property {import(\"./proj.js\").ProjectionLike} [projection='EPSG:3857']\n * Projection of the geometry. By default, the geometry is assumed to be in\n * Web Mercator.\n * @property {number} [radius=6371008.8] Sphere radius. By default, the\n * [mean Earth radius](https://en.wikipedia.org/wiki/Earth_radius#Mean_radius)\n * for the WGS84 ellipsoid is used.\n */\n\n/**\n * The mean Earth radius (1/3 * (2a + b)) for the WGS84 ellipsoid.\n * https://en.wikipedia.org/wiki/Earth_radius#Mean_radius\n * @type {number}\n */\nexport const DEFAULT_RADIUS = 6371008.8;\n\n/**\n * Get the great circle distance (in meters) between two geographic coordinates.\n * @param {Array} c1 Starting coordinate.\n * @param {Array} c2 Ending coordinate.\n * @param {number} [radius] The sphere radius to use. Defaults to the Earth's\n * mean radius using the WGS84 ellipsoid.\n * @return {number} The great circle distance between the points (in meters).\n * @api\n */\nexport function getDistance(c1, c2, radius) {\n radius = radius || DEFAULT_RADIUS;\n const lat1 = toRadians(c1[1]);\n const lat2 = toRadians(c2[1]);\n const deltaLatBy2 = (lat2 - lat1) / 2;\n const deltaLonBy2 = toRadians(c2[0] - c1[0]) / 2;\n const a =\n Math.sin(deltaLatBy2) * Math.sin(deltaLatBy2) +\n Math.sin(deltaLonBy2) *\n Math.sin(deltaLonBy2) *\n Math.cos(lat1) *\n Math.cos(lat2);\n return 2 * radius * Math.atan2(Math.sqrt(a), Math.sqrt(1 - a));\n}\n\n/**\n * Get the cumulative great circle length of linestring coordinates (geographic).\n * @param {Array} coordinates Linestring coordinates.\n * @param {number} radius The sphere radius to use.\n * @return {number} The length (in meters).\n */\nfunction getLengthInternal(coordinates, radius) {\n let length = 0;\n for (let i = 0, ii = coordinates.length; i < ii - 1; ++i) {\n length += getDistance(coordinates[i], coordinates[i + 1], radius);\n }\n return length;\n}\n\n/**\n * Get the spherical length of a geometry. This length is the sum of the\n * great circle distances between coordinates. For polygons, the length is\n * the sum of all rings. For points, the length is zero. For multi-part\n * geometries, the length is the sum of the length of each part.\n * @param {import(\"./geom/Geometry.js\").default} geometry A geometry.\n * @param {SphereMetricOptions} [options] Options for the\n * length calculation. By default, geometries are assumed to be in 'EPSG:3857'.\n * You can change this by providing a `projection` option.\n * @return {number} The spherical length (in meters).\n * @api\n */\nexport function getLength(geometry, options) {\n options = options || {};\n const radius = options.radius || DEFAULT_RADIUS;\n const projection = options.projection || 'EPSG:3857';\n const type = geometry.getType();\n if (type !== 'GeometryCollection') {\n geometry = geometry.clone().transform(projection, 'EPSG:4326');\n }\n let length = 0;\n let coordinates, coords, i, ii, j, jj;\n switch (type) {\n case 'Point':\n case 'MultiPoint': {\n break;\n }\n case 'LineString':\n case 'LinearRing': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n length = getLengthInternal(coordinates, radius);\n break;\n }\n case 'MultiLineString':\n case 'Polygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n length += getLengthInternal(coordinates[i], radius);\n }\n break;\n }\n case 'MultiPolygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n coords = coordinates[i];\n for (j = 0, jj = coords.length; j < jj; ++j) {\n length += getLengthInternal(coords[j], radius);\n }\n }\n break;\n }\n case 'GeometryCollection': {\n const geometries =\n /** @type {import(\"./geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometries();\n for (i = 0, ii = geometries.length; i < ii; ++i) {\n length += getLength(geometries[i], options);\n }\n break;\n }\n default: {\n throw new Error('Unsupported geometry type: ' + type);\n }\n }\n return length;\n}\n\n/**\n * Returns the spherical area for a list of coordinates.\n *\n * [Reference](https://trs.jpl.nasa.gov/handle/2014/40409)\n * Robert. G. Chamberlain and William H. Duquette, \"Some Algorithms for\n * Polygons on a Sphere\", JPL Publication 07-03, Jet Propulsion\n * Laboratory, Pasadena, CA, June 2007\n *\n * @param {Array} coordinates List of coordinates of a linear\n * ring. If the ring is oriented clockwise, the area will be positive,\n * otherwise it will be negative.\n * @param {number} radius The sphere radius.\n * @return {number} Area (in square meters).\n */\nfunction getAreaInternal(coordinates, radius) {\n let area = 0;\n const len = coordinates.length;\n let x1 = coordinates[len - 1][0];\n let y1 = coordinates[len - 1][1];\n for (let i = 0; i < len; i++) {\n const x2 = coordinates[i][0];\n const y2 = coordinates[i][1];\n area +=\n toRadians(x2 - x1) *\n (2 + Math.sin(toRadians(y1)) + Math.sin(toRadians(y2)));\n x1 = x2;\n y1 = y2;\n }\n return (area * radius * radius) / 2.0;\n}\n\n/**\n * Get the spherical area of a geometry. This is the area (in meters) assuming\n * that polygon edges are segments of great circles on a sphere.\n * @param {import(\"./geom/Geometry.js\").default} geometry A geometry.\n * @param {SphereMetricOptions} [options] Options for the area\n * calculation. By default, geometries are assumed to be in 'EPSG:3857'.\n * You can change this by providing a `projection` option.\n * @return {number} The spherical area (in square meters).\n * @api\n */\nexport function getArea(geometry, options) {\n options = options || {};\n const radius = options.radius || DEFAULT_RADIUS;\n const projection = options.projection || 'EPSG:3857';\n const type = geometry.getType();\n if (type !== 'GeometryCollection') {\n geometry = geometry.clone().transform(projection, 'EPSG:4326');\n }\n let area = 0;\n let coordinates, coords, i, ii, j, jj;\n switch (type) {\n case 'Point':\n case 'MultiPoint':\n case 'LineString':\n case 'MultiLineString':\n case 'LinearRing': {\n break;\n }\n case 'Polygon': {\n coordinates = /** @type {import(\"./geom/Polygon.js\").default} */ (\n geometry\n ).getCoordinates();\n area = Math.abs(getAreaInternal(coordinates[0], radius));\n for (i = 1, ii = coordinates.length; i < ii; ++i) {\n area -= Math.abs(getAreaInternal(coordinates[i], radius));\n }\n break;\n }\n case 'MultiPolygon': {\n coordinates = /** @type {import(\"./geom/SimpleGeometry.js\").default} */ (\n geometry\n ).getCoordinates();\n for (i = 0, ii = coordinates.length; i < ii; ++i) {\n coords = coordinates[i];\n area += Math.abs(getAreaInternal(coords[0], radius));\n for (j = 1, jj = coords.length; j < jj; ++j) {\n area -= Math.abs(getAreaInternal(coords[j], radius));\n }\n }\n break;\n }\n case 'GeometryCollection': {\n const geometries =\n /** @type {import(\"./geom/GeometryCollection.js\").default} */ (\n geometry\n ).getGeometries();\n for (i = 0, ii = geometries.length; i < ii; ++i) {\n area += getArea(geometries[i], options);\n }\n break;\n }\n default: {\n throw new Error('Unsupported geometry type: ' + type);\n }\n }\n return area;\n}\n\n/**\n * Returns the coordinate at the given distance and bearing from `c1`.\n *\n * @param {import(\"./coordinate.js\").Coordinate} c1 The origin point (`[lon, lat]` in degrees).\n * @param {number} distance The great-circle distance between the origin\n * point and the target point.\n * @param {number} bearing The bearing (in radians).\n * @param {number} [radius] The sphere radius to use. Defaults to the Earth's\n * mean radius using the WGS84 ellipsoid.\n * @return {import(\"./coordinate.js\").Coordinate} The target point.\n */\nexport function offset(c1, distance, bearing, radius) {\n radius = radius || DEFAULT_RADIUS;\n const lat1 = toRadians(c1[1]);\n const lon1 = toRadians(c1[0]);\n const dByR = distance / radius;\n const lat = Math.asin(\n Math.sin(lat1) * Math.cos(dByR) +\n Math.cos(lat1) * Math.sin(dByR) * Math.cos(bearing)\n );\n const lon =\n lon1 +\n Math.atan2(\n Math.sin(bearing) * Math.sin(dByR) * Math.cos(lat1),\n Math.cos(dByR) - Math.sin(lat1) * Math.sin(lat)\n );\n return [toDegrees(lon), toDegrees(lat)];\n}\n","/**\n * @module ol/console\n */\n\n/**\n * @typedef {'info'|'warn'|'error'|'none'} Level\n */\n\n/**\n * @type {Object}\n */\nconst levels = {\n info: 1,\n warn: 2,\n error: 3,\n none: 4,\n};\n\n/**\n * @type {number}\n */\nlet level = levels.info;\n\n/**\n * Set the logging level. By default, the level is set to 'info' and all\n * messages will be logged. Set to 'warn' to only display warnings and errors.\n * Set to 'error' to only display errors. Set to 'none' to silence all messages.\n *\n * @param {Level} l The new level.\n */\nexport function setLevel(l) {\n level = levels[l];\n}\n\nexport function log(...args) {\n if (level > levels.info) {\n return;\n }\n console.log(...args); // eslint-disable-line no-console\n}\n\nexport function warn(...args) {\n if (level > levels.warn) {\n return;\n }\n console.warn(...args); // eslint-disable-line no-console\n}\n\nexport function error(...args) {\n if (level > levels.error) {\n return;\n }\n console.error(...args); // eslint-disable-line no-console\n}\n","/**\n * @module ol/proj\n */\n\n/**\n * The ol/proj module stores:\n * * a list of {@link module:ol/proj/Projection~Projection}\n * objects, one for each projection supported by the application\n * * a list of transform functions needed to convert coordinates in one projection\n * into another.\n *\n * The static functions are the methods used to maintain these.\n * Each transform function can handle not only simple coordinate pairs, but also\n * large arrays of coordinates such as vector geometries.\n *\n * When loaded, the library adds projection objects for EPSG:4326 (WGS84\n * geographic coordinates) and EPSG:3857 (Web or Spherical Mercator, as used\n * for example by Bing Maps or OpenStreetMap), together with the relevant\n * transform functions.\n *\n * Additional transforms may be added by using the http://proj4js.org/\n * library (version 2.2 or later). You can use the full build supplied by\n * Proj4js, or create a custom build to support those projections you need; see\n * the Proj4js website for how to do this. You also need the Proj4js definitions\n * for the required projections. These definitions can be obtained from\n * https://epsg.io/, and are a JS function, so can be loaded in a script\n * tag (as in the examples) or pasted into your application.\n *\n * After all required projection definitions are added to proj4's registry (by\n * using `proj4.defs()`), simply call `register(proj4)` from the `ol/proj/proj4`\n * package. Existing transforms are not changed by this function. See\n * examples/wms-image-custom-proj for an example of this.\n *\n * Additional projection definitions can be registered with `proj4.defs()` any\n * time. Just make sure to call `register(proj4)` again; for example, with user-supplied data where you don't\n * know in advance what projections are needed, you can initially load minimal\n * support and then load whichever are requested.\n *\n * Note that Proj4js does not support projection extents. If you want to add\n * one for creating default tile grids, you can add it after the Projection\n * object has been created with `setExtent`, for example,\n * `get('EPSG:1234').setExtent(extent)`.\n *\n * In addition to Proj4js support, any transform functions can be added with\n * {@link module:ol/proj.addCoordinateTransforms}. To use this, you must first create\n * a {@link module:ol/proj/Projection~Projection} object for the new projection and add it with\n * {@link module:ol/proj.addProjection}. You can then add the forward and inverse\n * functions with {@link module:ol/proj.addCoordinateTransforms}. See\n * examples/wms-custom-proj for an example of this.\n *\n * Note that if no transforms are needed and you only need to define the\n * projection, just add a {@link module:ol/proj/Projection~Projection} with\n * {@link module:ol/proj.addProjection}. See examples/wms-no-proj for an example of\n * this.\n */\nimport Projection from './proj/Projection.js';\nimport {\n PROJECTIONS as EPSG3857_PROJECTIONS,\n fromEPSG4326,\n toEPSG4326,\n} from './proj/epsg3857.js';\nimport {PROJECTIONS as EPSG4326_PROJECTIONS} from './proj/epsg4326.js';\nimport {METERS_PER_UNIT} from './proj/Units.js';\nimport {\n add as addProj,\n clear as clearProj,\n get as getProj,\n} from './proj/projections.js';\nimport {\n add as addTransformFunc,\n clear as clearTransformFuncs,\n get as getTransformFunc,\n} from './proj/transforms.js';\nimport {applyTransform, getWidth} from './extent.js';\nimport {clamp, modulo} from './math.js';\nimport {equals, getWorldsAway} from './coordinate.js';\nimport {getDistance} from './sphere.js';\nimport {warn} from './console.js';\n\n/**\n * A projection as {@link module:ol/proj/Projection~Projection}, SRS identifier\n * string or undefined.\n * @typedef {Projection|string|undefined} ProjectionLike\n * @api\n */\n\n/**\n * A transform function accepts an array of input coordinate values, an optional\n * output array, and an optional dimension (default should be 2). The function\n * transforms the input coordinate values, populates the output array, and\n * returns the output array.\n *\n * @typedef {function(Array, Array=, number=): Array} TransformFunction\n * @api\n */\n\nexport {METERS_PER_UNIT};\n\nexport {Projection};\n\nlet showCoordinateWarning = true;\n\n/**\n * @param {boolean} [disable = true] Disable console info about `useGeographic()`\n */\nexport function disableCoordinateWarning(disable) {\n const hide = disable === undefined ? true : disable;\n showCoordinateWarning = !hide;\n}\n\n/**\n * @param {Array} input Input coordinate array.\n * @param {Array} [output] Output array of coordinate values.\n * @return {Array} Output coordinate array (new array, same coordinate\n * values).\n */\nexport function cloneTransform(input, output) {\n if (output !== undefined) {\n for (let i = 0, ii = input.length; i < ii; ++i) {\n output[i] = input[i];\n }\n output = output;\n } else {\n output = input.slice();\n }\n return output;\n}\n\n/**\n * @param {Array} input Input coordinate array.\n * @param {Array} [output] Output array of coordinate values.\n * @return {Array} Input coordinate array (same array as input).\n */\nexport function identityTransform(input, output) {\n if (output !== undefined && input !== output) {\n for (let i = 0, ii = input.length; i < ii; ++i) {\n output[i] = input[i];\n }\n input = output;\n }\n return input;\n}\n\n/**\n * Add a Projection object to the list of supported projections that can be\n * looked up by their code.\n *\n * @param {Projection} projection Projection instance.\n * @api\n */\nexport function addProjection(projection) {\n addProj(projection.getCode(), projection);\n addTransformFunc(projection, projection, cloneTransform);\n}\n\n/**\n * @param {Array} projections Projections.\n */\nexport function addProjections(projections) {\n projections.forEach(addProjection);\n}\n\n/**\n * Fetches a Projection object for the code specified.\n *\n * @param {ProjectionLike} projectionLike Either a code string which is\n * a combination of authority and identifier such as \"EPSG:4326\", or an\n * existing projection object, or undefined.\n * @return {Projection|null} Projection object, or null if not in list.\n * @api\n */\nexport function get(projectionLike) {\n return typeof projectionLike === 'string'\n ? getProj(/** @type {string} */ (projectionLike))\n : /** @type {Projection} */ (projectionLike) || null;\n}\n\n/**\n * Get the resolution of the point in degrees or distance units.\n * For projections with degrees as the unit this will simply return the\n * provided resolution. For other projections the point resolution is\n * by default estimated by transforming the `point` pixel to EPSG:4326,\n * measuring its width and height on the normal sphere,\n * and taking the average of the width and height.\n * A custom function can be provided for a specific projection, either\n * by setting the `getPointResolution` option in the\n * {@link module:ol/proj/Projection~Projection} constructor or by using\n * {@link module:ol/proj/Projection~Projection#setGetPointResolution} to change an existing\n * projection object.\n * @param {ProjectionLike} projection The projection.\n * @param {number} resolution Nominal resolution in projection units.\n * @param {import(\"./coordinate.js\").Coordinate} point Point to find adjusted resolution at.\n * @param {import(\"./proj/Units.js\").Units} [units] Units to get the point resolution in.\n * Default is the projection's units.\n * @return {number} Point resolution.\n * @api\n */\nexport function getPointResolution(projection, resolution, point, units) {\n projection = get(projection);\n let pointResolution;\n const getter = projection.getPointResolutionFunc();\n if (getter) {\n pointResolution = getter(resolution, point);\n if (units && units !== projection.getUnits()) {\n const metersPerUnit = projection.getMetersPerUnit();\n if (metersPerUnit) {\n pointResolution =\n (pointResolution * metersPerUnit) / METERS_PER_UNIT[units];\n }\n }\n } else {\n const projUnits = projection.getUnits();\n if ((projUnits == 'degrees' && !units) || units == 'degrees') {\n pointResolution = resolution;\n } else {\n // Estimate point resolution by transforming the center pixel to EPSG:4326,\n // measuring its width and height on the normal sphere, and taking the\n // average of the width and height.\n const toEPSG4326 = getTransformFromProjections(\n projection,\n get('EPSG:4326')\n );\n if (toEPSG4326 === identityTransform && projUnits !== 'degrees') {\n // no transform is available\n pointResolution = resolution * projection.getMetersPerUnit();\n } else {\n let vertices = [\n point[0] - resolution / 2,\n point[1],\n point[0] + resolution / 2,\n point[1],\n point[0],\n point[1] - resolution / 2,\n point[0],\n point[1] + resolution / 2,\n ];\n vertices = toEPSG4326(vertices, vertices, 2);\n const width = getDistance(vertices.slice(0, 2), vertices.slice(2, 4));\n const height = getDistance(vertices.slice(4, 6), vertices.slice(6, 8));\n pointResolution = (width + height) / 2;\n }\n const metersPerUnit = units\n ? METERS_PER_UNIT[units]\n : projection.getMetersPerUnit();\n if (metersPerUnit !== undefined) {\n pointResolution /= metersPerUnit;\n }\n }\n }\n return pointResolution;\n}\n\n/**\n * Registers transformation functions that don't alter coordinates. Those allow\n * to transform between projections with equal meaning.\n *\n * @param {Array} projections Projections.\n * @api\n */\nexport function addEquivalentProjections(projections) {\n addProjections(projections);\n projections.forEach(function (source) {\n projections.forEach(function (destination) {\n if (source !== destination) {\n addTransformFunc(source, destination, cloneTransform);\n }\n });\n });\n}\n\n/**\n * Registers transformation functions to convert coordinates in any projection\n * in projection1 to any projection in projection2.\n *\n * @param {Array} projections1 Projections with equal\n * meaning.\n * @param {Array} projections2 Projections with equal\n * meaning.\n * @param {TransformFunction} forwardTransform Transformation from any\n * projection in projection1 to any projection in projection2.\n * @param {TransformFunction} inverseTransform Transform from any projection\n * in projection2 to any projection in projection1..\n */\nexport function addEquivalentTransforms(\n projections1,\n projections2,\n forwardTransform,\n inverseTransform\n) {\n projections1.forEach(function (projection1) {\n projections2.forEach(function (projection2) {\n addTransformFunc(projection1, projection2, forwardTransform);\n addTransformFunc(projection2, projection1, inverseTransform);\n });\n });\n}\n\n/**\n * Clear all cached projections and transforms.\n */\nexport function clearAllProjections() {\n clearProj();\n clearTransformFuncs();\n}\n\n/**\n * @param {Projection|string|undefined} projection Projection.\n * @param {string} defaultCode Default code.\n * @return {Projection} Projection.\n */\nexport function createProjection(projection, defaultCode) {\n if (!projection) {\n return get(defaultCode);\n }\n if (typeof projection === 'string') {\n return get(projection);\n }\n return /** @type {Projection} */ (projection);\n}\n\n/**\n * Creates a {@link module:ol/proj~TransformFunction} from a simple 2D coordinate transform\n * function.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} coordTransform Coordinate\n * transform.\n * @return {TransformFunction} Transform function.\n */\nexport function createTransformFromCoordinateTransform(coordTransform) {\n return (\n /**\n * @param {Array} input Input.\n * @param {Array} [output] Output.\n * @param {number} [dimension] Dimension.\n * @return {Array} Output.\n */\n function (input, output, dimension) {\n const length = input.length;\n dimension = dimension !== undefined ? dimension : 2;\n output = output !== undefined ? output : new Array(length);\n for (let i = 0; i < length; i += dimension) {\n const point = coordTransform(input.slice(i, i + dimension));\n const pointLength = point.length;\n for (let j = 0, jj = dimension; j < jj; ++j) {\n output[i + j] = j >= pointLength ? input[i + j] : point[j];\n }\n }\n return output;\n }\n );\n}\n\n/**\n * Registers coordinate transform functions to convert coordinates between the\n * source projection and the destination projection.\n * The forward and inverse functions convert coordinate pairs; this function\n * converts these into the functions used internally which also handle\n * extents and coordinate arrays.\n *\n * @param {ProjectionLike} source Source projection.\n * @param {ProjectionLike} destination Destination projection.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} forward The forward transform\n * function (that is, from the source projection to the destination\n * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns\n * the transformed {@link module:ol/coordinate~Coordinate}.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} inverse The inverse transform\n * function (that is, from the destination projection to the source\n * projection) that takes a {@link module:ol/coordinate~Coordinate} as argument and returns\n * the transformed {@link module:ol/coordinate~Coordinate}. If the transform function can only\n * transform less dimensions than the input coordinate, it is supposeed to return a coordinate\n * with only the length it can transform. The other dimensions will be taken unchanged from the\n * source.\n * @api\n */\nexport function addCoordinateTransforms(source, destination, forward, inverse) {\n const sourceProj = get(source);\n const destProj = get(destination);\n addTransformFunc(\n sourceProj,\n destProj,\n createTransformFromCoordinateTransform(forward)\n );\n addTransformFunc(\n destProj,\n sourceProj,\n createTransformFromCoordinateTransform(inverse)\n );\n}\n\n/**\n * Transforms a coordinate from longitude/latitude to a different projection.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate as longitude and latitude, i.e.\n * an array with longitude as 1st and latitude as 2nd element.\n * @param {ProjectionLike} [projection] Target projection. The\n * default is Web Mercator, i.e. 'EPSG:3857'.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate projected to the target projection.\n * @api\n */\nexport function fromLonLat(coordinate, projection) {\n disableCoordinateWarning();\n return transform(\n coordinate,\n 'EPSG:4326',\n projection !== undefined ? projection : 'EPSG:3857'\n );\n}\n\n/**\n * Transforms a coordinate to longitude/latitude.\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Projected coordinate.\n * @param {ProjectionLike} [projection] Projection of the coordinate.\n * The default is Web Mercator, i.e. 'EPSG:3857'.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate as longitude and latitude, i.e. an array\n * with longitude as 1st and latitude as 2nd element.\n * @api\n */\nexport function toLonLat(coordinate, projection) {\n const lonLat = transform(\n coordinate,\n projection !== undefined ? projection : 'EPSG:3857',\n 'EPSG:4326'\n );\n const lon = lonLat[0];\n if (lon < -180 || lon > 180) {\n lonLat[0] = modulo(lon + 180, 360) - 180;\n }\n return lonLat;\n}\n\n/**\n * Checks if two projections are the same, that is every coordinate in one\n * projection does represent the same geographic point as the same coordinate in\n * the other projection.\n *\n * @param {Projection} projection1 Projection 1.\n * @param {Projection} projection2 Projection 2.\n * @return {boolean} Equivalent.\n * @api\n */\nexport function equivalent(projection1, projection2) {\n if (projection1 === projection2) {\n return true;\n }\n const equalUnits = projection1.getUnits() === projection2.getUnits();\n if (projection1.getCode() === projection2.getCode()) {\n return equalUnits;\n }\n const transformFunc = getTransformFromProjections(projection1, projection2);\n return transformFunc === cloneTransform && equalUnits;\n}\n\n/**\n * Searches in the list of transform functions for the function for converting\n * coordinates from the source projection to the destination projection.\n *\n * @param {Projection} sourceProjection Source Projection object.\n * @param {Projection} destinationProjection Destination Projection\n * object.\n * @return {TransformFunction} Transform function.\n */\nexport function getTransformFromProjections(\n sourceProjection,\n destinationProjection\n) {\n const sourceCode = sourceProjection.getCode();\n const destinationCode = destinationProjection.getCode();\n let transformFunc = getTransformFunc(sourceCode, destinationCode);\n if (!transformFunc) {\n transformFunc = identityTransform;\n }\n return transformFunc;\n}\n\n/**\n * Given the projection-like objects, searches for a transformation\n * function to convert a coordinates array from the source projection to the\n * destination projection.\n *\n * @param {ProjectionLike} source Source.\n * @param {ProjectionLike} destination Destination.\n * @return {TransformFunction} Transform function.\n * @api\n */\nexport function getTransform(source, destination) {\n const sourceProjection = get(source);\n const destinationProjection = get(destination);\n return getTransformFromProjections(sourceProjection, destinationProjection);\n}\n\n/**\n * Transforms a coordinate from source projection to destination projection.\n * This returns a new coordinate (and does not modify the original).\n *\n * See {@link module:ol/proj.transformExtent} for extent transformation.\n * See the transform method of {@link module:ol/geom/Geometry~Geometry} and its\n * subclasses for geometry transforms.\n *\n * @param {import(\"./coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {ProjectionLike} source Source projection-like.\n * @param {ProjectionLike} destination Destination projection-like.\n * @return {import(\"./coordinate.js\").Coordinate} Coordinate.\n * @api\n */\nexport function transform(coordinate, source, destination) {\n const transformFunc = getTransform(source, destination);\n return transformFunc(coordinate, undefined, coordinate.length);\n}\n\n/**\n * Transforms an extent from source projection to destination projection. This\n * returns a new extent (and does not modify the original).\n *\n * @param {import(\"./extent.js\").Extent} extent The extent to transform.\n * @param {ProjectionLike} source Source projection-like.\n * @param {ProjectionLike} destination Destination projection-like.\n * @param {number} [stops] Number of stops per side used for the transform.\n * By default only the corners are used.\n * @return {import(\"./extent.js\").Extent} The transformed extent.\n * @api\n */\nexport function transformExtent(extent, source, destination, stops) {\n const transformFunc = getTransform(source, destination);\n return applyTransform(extent, transformFunc, undefined, stops);\n}\n\n/**\n * Transforms the given point to the destination projection.\n *\n * @param {import(\"./coordinate.js\").Coordinate} point Point.\n * @param {Projection} sourceProjection Source projection.\n * @param {Projection} destinationProjection Destination projection.\n * @return {import(\"./coordinate.js\").Coordinate} Point.\n */\nexport function transformWithProjections(\n point,\n sourceProjection,\n destinationProjection\n) {\n const transformFunc = getTransformFromProjections(\n sourceProjection,\n destinationProjection\n );\n return transformFunc(point);\n}\n\n/**\n * @type {Projection|null}\n */\nlet userProjection = null;\n\n/**\n * Set the projection for coordinates supplied from and returned by API methods.\n * This includes all API methods except for those interacting with tile grids,\n * plus {@link import(\"./Map.js\").FrameState} and {@link import(\"./View.js\").State}.\n * @param {ProjectionLike} projection The user projection.\n * @api\n */\nexport function setUserProjection(projection) {\n userProjection = get(projection);\n}\n\n/**\n * Clear the user projection if set.\n * @api\n */\nexport function clearUserProjection() {\n userProjection = null;\n}\n\n/**\n * Get the projection for coordinates supplied from and returned by API methods.\n * @return {Projection|null} The user projection (or null if not set).\n * @api\n */\nexport function getUserProjection() {\n return userProjection;\n}\n\n/**\n * Use geographic coordinates (WGS-84 datum) in API methods.\n * This includes all API methods except for those interacting with tile grids,\n * plus {@link import(\"./Map.js\").FrameState} and {@link import(\"./View.js\").State}.\n * @api\n */\nexport function useGeographic() {\n setUserProjection('EPSG:4326');\n}\n\n/**\n * Return a coordinate transformed into the user projection. If no user projection\n * is set, the original coordinate is returned.\n * @param {Array} coordinate Input coordinate.\n * @param {ProjectionLike} sourceProjection The input coordinate projection.\n * @return {Array} The input coordinate in the user projection.\n */\nexport function toUserCoordinate(coordinate, sourceProjection) {\n if (!userProjection) {\n return coordinate;\n }\n return transform(coordinate, sourceProjection, userProjection);\n}\n\n/**\n * Return a coordinate transformed from the user projection. If no user projection\n * is set, the original coordinate is returned.\n * @param {Array} coordinate Input coordinate.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {Array} The input coordinate transformed.\n */\nexport function fromUserCoordinate(coordinate, destProjection) {\n if (!userProjection) {\n if (\n showCoordinateWarning &&\n !equals(coordinate, [0, 0]) &&\n coordinate[0] >= -180 &&\n coordinate[0] <= 180 &&\n coordinate[1] >= -90 &&\n coordinate[1] <= 90\n ) {\n showCoordinateWarning = false;\n warn(\n 'Call useGeographic() from ol/proj once to work with [longitude, latitude] coordinates.'\n );\n }\n return coordinate;\n }\n return transform(coordinate, userProjection, destProjection);\n}\n\n/**\n * Return an extent transformed into the user projection. If no user projection\n * is set, the original extent is returned.\n * @param {import(\"./extent.js\").Extent} extent Input extent.\n * @param {ProjectionLike} sourceProjection The input extent projection.\n * @return {import(\"./extent.js\").Extent} The input extent in the user projection.\n */\nexport function toUserExtent(extent, sourceProjection) {\n if (!userProjection) {\n return extent;\n }\n return transformExtent(extent, sourceProjection, userProjection);\n}\n\n/**\n * Return an extent transformed from the user projection. If no user projection\n * is set, the original extent is returned.\n * @param {import(\"./extent.js\").Extent} extent Input extent.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {import(\"./extent.js\").Extent} The input extent transformed.\n */\nexport function fromUserExtent(extent, destProjection) {\n if (!userProjection) {\n return extent;\n }\n return transformExtent(extent, userProjection, destProjection);\n}\n\n/**\n * Return the resolution in user projection units per pixel. If no user projection\n * is set, or source or user projection are missing units, the original resolution\n * is returned.\n * @param {number} resolution Resolution in input projection units per pixel.\n * @param {ProjectionLike} sourceProjection The input projection.\n * @return {number} Resolution in user projection units per pixel.\n */\nexport function toUserResolution(resolution, sourceProjection) {\n if (!userProjection) {\n return resolution;\n }\n const sourceUnits = get(sourceProjection).getUnits();\n const userUnits = userProjection.getUnits();\n return sourceUnits && userUnits\n ? (resolution * METERS_PER_UNIT[sourceUnits]) / METERS_PER_UNIT[userUnits]\n : resolution;\n}\n\n/**\n * Return the resolution in user projection units per pixel. If no user projection\n * is set, or source or user projection are missing units, the original resolution\n * is returned.\n * @param {number} resolution Resolution in user projection units per pixel.\n * @param {ProjectionLike} destProjection The destination projection.\n * @return {number} Resolution in destination projection units per pixel.\n */\nexport function fromUserResolution(resolution, destProjection) {\n if (!userProjection) {\n return resolution;\n }\n const sourceUnits = get(destProjection).getUnits();\n const userUnits = userProjection.getUnits();\n return sourceUnits && userUnits\n ? (resolution * METERS_PER_UNIT[userUnits]) / METERS_PER_UNIT[sourceUnits]\n : resolution;\n}\n\n/**\n * Creates a safe coordinate transform function from a coordinate transform function.\n * \"Safe\" means that it can handle wrapping of x-coordinates for global projections,\n * and that coordinates exceeding the source projection validity extent's range will be\n * clamped to the validity range.\n * @param {Projection} sourceProj Source projection.\n * @param {Projection} destProj Destination projection.\n * @param {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} transform Transform function (source to destination).\n * @return {function(import(\"./coordinate.js\").Coordinate): import(\"./coordinate.js\").Coordinate} Safe transform function (source to destination).\n */\nexport function createSafeCoordinateTransform(sourceProj, destProj, transform) {\n return function (coord) {\n let transformed, worldsAway;\n if (sourceProj.canWrapX()) {\n const sourceExtent = sourceProj.getExtent();\n const sourceExtentWidth = getWidth(sourceExtent);\n coord = coord.slice(0);\n worldsAway = getWorldsAway(coord, sourceProj, sourceExtentWidth);\n if (worldsAway) {\n // Move x to the real world\n coord[0] = coord[0] - worldsAway * sourceExtentWidth;\n }\n coord[0] = clamp(coord[0], sourceExtent[0], sourceExtent[2]);\n coord[1] = clamp(coord[1], sourceExtent[1], sourceExtent[3]);\n transformed = transform(coord);\n } else {\n transformed = transform(coord);\n }\n if (worldsAway && destProj.canWrapX()) {\n // Move transformed coordinate back to the offset world\n transformed[0] += worldsAway * getWidth(destProj.getExtent());\n }\n return transformed;\n };\n}\n\n/**\n * Add transforms to and from EPSG:4326 and EPSG:3857. This function is called\n * by when this module is executed and should only need to be called again after\n * `clearAllProjections()` is called (e.g. in tests).\n */\nexport function addCommon() {\n // Add transformations that don't alter coordinates to convert within set of\n // projections with equal meaning.\n addEquivalentProjections(EPSG3857_PROJECTIONS);\n addEquivalentProjections(EPSG4326_PROJECTIONS);\n // Add transformations to convert EPSG:4326 like coordinates to EPSG:3857 like\n // coordinates and back.\n addEquivalentTransforms(\n EPSG4326_PROJECTIONS,\n EPSG3857_PROJECTIONS,\n fromEPSG4326,\n toEPSG4326\n );\n}\n\naddCommon();\n","/**\n * @module ol/format/Feature\n */\nimport {abstract} from '../util.js';\nimport {\n equivalent as equivalentProjection,\n get as getProjection,\n transformExtent,\n} from '../proj.js';\n\n/**\n * @typedef {Object} ReadOptions\n * @property {import(\"../proj.js\").ProjectionLike} [dataProjection] Projection of the data we are reading.\n * If not provided, the projection will be derived from the data (where possible) or\n * the `dataProjection` of the format is assigned (where set). If the projection\n * can not be derived from the data and if no `dataProjection` is set for a format,\n * the features will not be reprojected.\n * @property {import(\"../extent.js\").Extent} [extent] Tile extent in map units of the tile being read.\n * This is only required when reading data with tile pixels as geometry units. When configured,\n * a `dataProjection` with `TILE_PIXELS` as `units` and the tile's pixel extent as `extent` needs to be\n * provided.\n * @property {import(\"../proj.js\").ProjectionLike} [featureProjection] Projection of the feature geometries\n * created by the format reader. If not provided, features will be returned in the\n * `dataProjection`.\n */\n\n/**\n * @typedef {Object} WriteOptions\n * @property {import(\"../proj.js\").ProjectionLike} [dataProjection] Projection of the data we are writing.\n * If not provided, the `dataProjection` of the format is assigned (where set).\n * If no `dataProjection` is set for a format, the features will be returned\n * in the `featureProjection`.\n * @property {import(\"../proj.js\").ProjectionLike} [featureProjection] Projection of the feature geometries\n * that will be serialized by the format writer. If not provided, geometries are assumed\n * to be in the `dataProjection` if that is set; in other words, they are not transformed.\n * @property {boolean} [rightHanded] When writing geometries, follow the right-hand\n * rule for linear ring orientation. This means that polygons will have counter-clockwise\n * exterior rings and clockwise interior rings. By default, coordinates are serialized\n * as they are provided at construction. If `true`, the right-hand rule will\n * be applied. If `false`, the left-hand rule will be applied (clockwise for\n * exterior and counter-clockwise for interior rings). Note that not all\n * formats support this. The GeoJSON format does use this property when writing\n * geometries.\n * @property {number} [decimals] Maximum number of decimal places for coordinates.\n * Coordinates are stored internally as floats, but floating-point arithmetic can create\n * coordinates with a large number of decimal places, not generally wanted on output.\n * Set a number here to round coordinates. Can also be used to ensure that\n * coordinates read in can be written back out with the same number of decimals.\n * Default is no rounding.\n */\n\n/**\n * @typedef {'arraybuffer' | 'json' | 'text' | 'xml'} Type\n */\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Base class for feature formats.\n * {@link module:ol/format/Feature~FeatureFormat} subclasses provide the ability to decode and encode\n * {@link module:ol/Feature~Feature} objects from a variety of commonly used geospatial\n * file formats. See the documentation for each format for more details.\n *\n * @abstract\n * @api\n */\nclass FeatureFormat {\n constructor() {\n /**\n * @protected\n * @type {import(\"../proj/Projection.js\").default|undefined}\n */\n this.dataProjection = undefined;\n\n /**\n * @protected\n * @type {import(\"../proj/Projection.js\").default|undefined}\n */\n this.defaultFeatureProjection = undefined;\n\n /**\n * A list media types supported by the format in descending order of preference.\n * @type {Array}\n */\n this.supportedMediaTypes = null;\n }\n\n /**\n * Adds the data projection to the read options.\n * @param {Document|Element|Object|string} source Source.\n * @param {ReadOptions} [options] Options.\n * @return {ReadOptions|undefined} Options.\n * @protected\n */\n getReadOptions(source, options) {\n if (options) {\n let dataProjection = options.dataProjection\n ? getProjection(options.dataProjection)\n : this.readProjection(source);\n if (\n options.extent &&\n dataProjection &&\n dataProjection.getUnits() === 'tile-pixels'\n ) {\n dataProjection = getProjection(dataProjection);\n dataProjection.setWorldExtent(options.extent);\n }\n options = {\n dataProjection: dataProjection,\n featureProjection: options.featureProjection,\n };\n }\n return this.adaptOptions(options);\n }\n\n /**\n * Sets the `dataProjection` on the options, if no `dataProjection`\n * is set.\n * @param {WriteOptions|ReadOptions|undefined} options\n * Options.\n * @protected\n * @return {WriteOptions|ReadOptions|undefined}\n * Updated options.\n */\n adaptOptions(options) {\n return Object.assign(\n {\n dataProjection: this.dataProjection,\n featureProjection: this.defaultFeatureProjection,\n },\n options\n );\n }\n\n /**\n * @abstract\n * @return {Type} The format type.\n */\n getType() {\n return abstract();\n }\n\n /**\n * Read a single feature from a source.\n *\n * @abstract\n * @param {Document|Element|Object|string} source Source.\n * @param {ReadOptions} [options] Read options.\n * @return {import(\"../Feature.js\").FeatureLike} Feature.\n */\n readFeature(source, options) {\n return abstract();\n }\n\n /**\n * Read all features from a source.\n *\n * @abstract\n * @param {Document|Element|ArrayBuffer|Object|string} source Source.\n * @param {ReadOptions} [options] Read options.\n * @return {Array} Features.\n */\n readFeatures(source, options) {\n return abstract();\n }\n\n /**\n * Read a single geometry from a source.\n *\n * @abstract\n * @param {Document|Element|Object|string} source Source.\n * @param {ReadOptions} [options] Read options.\n * @return {import(\"../geom/Geometry.js\").default} Geometry.\n */\n readGeometry(source, options) {\n return abstract();\n }\n\n /**\n * Read the projection from a source.\n *\n * @abstract\n * @param {Document|Element|Object|string} source Source.\n * @return {import(\"../proj/Projection.js\").default|undefined} Projection.\n */\n readProjection(source) {\n return abstract();\n }\n\n /**\n * Encode a feature in this format.\n *\n * @abstract\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {WriteOptions} [options] Write options.\n * @return {string|ArrayBuffer} Result.\n */\n writeFeature(feature, options) {\n return abstract();\n }\n\n /**\n * Encode an array of features in this format.\n *\n * @abstract\n * @param {Array} features Features.\n * @param {WriteOptions} [options] Write options.\n * @return {string|ArrayBuffer} Result.\n */\n writeFeatures(features, options) {\n return abstract();\n }\n\n /**\n * Write a single geometry in this format.\n *\n * @abstract\n * @param {import(\"../geom/Geometry.js\").default} geometry Geometry.\n * @param {WriteOptions} [options] Write options.\n * @return {string|ArrayBuffer} Result.\n */\n writeGeometry(geometry, options) {\n return abstract();\n }\n}\n\nexport default FeatureFormat;\n\n/**\n * @param {import(\"../geom/Geometry.js\").default} geometry Geometry.\n * @param {boolean} write Set to true for writing, false for reading.\n * @param {WriteOptions|ReadOptions} [options] Options.\n * @return {import(\"../geom/Geometry.js\").default} Transformed geometry.\n */\nexport function transformGeometryWithOptions(geometry, write, options) {\n const featureProjection = options\n ? getProjection(options.featureProjection)\n : null;\n const dataProjection = options ? getProjection(options.dataProjection) : null;\n\n let transformed;\n if (\n featureProjection &&\n dataProjection &&\n !equivalentProjection(featureProjection, dataProjection)\n ) {\n transformed = (write ? geometry.clone() : geometry).transform(\n write ? featureProjection : dataProjection,\n write ? dataProjection : featureProjection\n );\n } else {\n transformed = geometry;\n }\n if (\n write &&\n options &&\n /** @type {WriteOptions} */ (options).decimals !== undefined\n ) {\n const power = Math.pow(10, /** @type {WriteOptions} */ (options).decimals);\n // if decimals option on write, round each coordinate appropriately\n /**\n * @param {Array} coordinates Coordinates.\n * @return {Array} Transformed coordinates.\n */\n const transform = function (coordinates) {\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n coordinates[i] = Math.round(coordinates[i] * power) / power;\n }\n return coordinates;\n };\n if (transformed === geometry) {\n transformed = geometry.clone();\n }\n transformed.applyTransform(transform);\n }\n return transformed;\n}\n\n/**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @param {ReadOptions} [options] Read options.\n * @return {import(\"../extent.js\").Extent} Transformed extent.\n */\nexport function transformExtentWithOptions(extent, options) {\n const featureProjection = options\n ? getProjection(options.featureProjection)\n : null;\n const dataProjection = options ? getProjection(options.dataProjection) : null;\n\n if (\n featureProjection &&\n dataProjection &&\n !equivalentProjection(featureProjection, dataProjection)\n ) {\n return transformExtent(extent, dataProjection, featureProjection);\n }\n return extent;\n}\n","/**\n * @module ol/transform\n */\nimport {WORKER_OFFSCREEN_CANVAS} from './has.js';\nimport {assert} from './asserts.js';\n\n/**\n * An array representing an affine 2d transformation for use with\n * {@link module:ol/transform} functions. The array has 6 elements.\n * @typedef {!Array} Transform\n * @api\n */\n\n/**\n * Collection of affine 2d transformation functions. The functions work on an\n * array of 6 elements. The element order is compatible with the [SVGMatrix\n * interface](https://developer.mozilla.org/en-US/docs/Web/API/SVGMatrix) and is\n * a subset (elements a to f) of a 3×3 matrix:\n * ```\n * [ a c e ]\n * [ b d f ]\n * [ 0 0 1 ]\n * ```\n */\n\n/**\n * @private\n * @type {Transform}\n */\nconst tmp_ = new Array(6);\n\n/**\n * Create an identity transform.\n * @return {!Transform} Identity transform.\n */\nexport function create() {\n return [1, 0, 0, 1, 0, 0];\n}\n\n/**\n * Resets the given transform to an identity transform.\n * @param {!Transform} transform Transform.\n * @return {!Transform} Transform.\n */\nexport function reset(transform) {\n return set(transform, 1, 0, 0, 1, 0, 0);\n}\n\n/**\n * Multiply the underlying matrices of two transforms and return the result in\n * the first transform.\n * @param {!Transform} transform1 Transform parameters of matrix 1.\n * @param {!Transform} transform2 Transform parameters of matrix 2.\n * @return {!Transform} transform1 multiplied with transform2.\n */\nexport function multiply(transform1, transform2) {\n const a1 = transform1[0];\n const b1 = transform1[1];\n const c1 = transform1[2];\n const d1 = transform1[3];\n const e1 = transform1[4];\n const f1 = transform1[5];\n const a2 = transform2[0];\n const b2 = transform2[1];\n const c2 = transform2[2];\n const d2 = transform2[3];\n const e2 = transform2[4];\n const f2 = transform2[5];\n\n transform1[0] = a1 * a2 + c1 * b2;\n transform1[1] = b1 * a2 + d1 * b2;\n transform1[2] = a1 * c2 + c1 * d2;\n transform1[3] = b1 * c2 + d1 * d2;\n transform1[4] = a1 * e2 + c1 * f2 + e1;\n transform1[5] = b1 * e2 + d1 * f2 + f1;\n\n return transform1;\n}\n\n/**\n * Set the transform components a-f on a given transform.\n * @param {!Transform} transform Transform.\n * @param {number} a The a component of the transform.\n * @param {number} b The b component of the transform.\n * @param {number} c The c component of the transform.\n * @param {number} d The d component of the transform.\n * @param {number} e The e component of the transform.\n * @param {number} f The f component of the transform.\n * @return {!Transform} Matrix with transform applied.\n */\nexport function set(transform, a, b, c, d, e, f) {\n transform[0] = a;\n transform[1] = b;\n transform[2] = c;\n transform[3] = d;\n transform[4] = e;\n transform[5] = f;\n return transform;\n}\n\n/**\n * Set transform on one matrix from another matrix.\n * @param {!Transform} transform1 Matrix to set transform to.\n * @param {!Transform} transform2 Matrix to set transform from.\n * @return {!Transform} transform1 with transform from transform2 applied.\n */\nexport function setFromArray(transform1, transform2) {\n transform1[0] = transform2[0];\n transform1[1] = transform2[1];\n transform1[2] = transform2[2];\n transform1[3] = transform2[3];\n transform1[4] = transform2[4];\n transform1[5] = transform2[5];\n return transform1;\n}\n\n/**\n * Transforms the given coordinate with the given transform returning the\n * resulting, transformed coordinate. The coordinate will be modified in-place.\n *\n * @param {Transform} transform The transformation.\n * @param {import(\"./coordinate.js\").Coordinate|import(\"./pixel.js\").Pixel} coordinate The coordinate to transform.\n * @return {import(\"./coordinate.js\").Coordinate|import(\"./pixel.js\").Pixel} return coordinate so that operations can be\n * chained together.\n */\nexport function apply(transform, coordinate) {\n const x = coordinate[0];\n const y = coordinate[1];\n coordinate[0] = transform[0] * x + transform[2] * y + transform[4];\n coordinate[1] = transform[1] * x + transform[3] * y + transform[5];\n return coordinate;\n}\n\n/**\n * Applies rotation to the given transform.\n * @param {!Transform} transform Transform.\n * @param {number} angle Angle in radians.\n * @return {!Transform} The rotated transform.\n */\nexport function rotate(transform, angle) {\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n return multiply(transform, set(tmp_, cos, sin, -sin, cos, 0, 0));\n}\n\n/**\n * Applies scale to a given transform.\n * @param {!Transform} transform Transform.\n * @param {number} x Scale factor x.\n * @param {number} y Scale factor y.\n * @return {!Transform} The scaled transform.\n */\nexport function scale(transform, x, y) {\n return multiply(transform, set(tmp_, x, 0, 0, y, 0, 0));\n}\n\n/**\n * Creates a scale transform.\n * @param {!Transform} target Transform to overwrite.\n * @param {number} x Scale factor x.\n * @param {number} y Scale factor y.\n * @return {!Transform} The scale transform.\n */\nexport function makeScale(target, x, y) {\n return set(target, x, 0, 0, y, 0, 0);\n}\n\n/**\n * Applies translation to the given transform.\n * @param {!Transform} transform Transform.\n * @param {number} dx Translation x.\n * @param {number} dy Translation y.\n * @return {!Transform} The translated transform.\n */\nexport function translate(transform, dx, dy) {\n return multiply(transform, set(tmp_, 1, 0, 0, 1, dx, dy));\n}\n\n/**\n * Creates a composite transform given an initial translation, scale, rotation, and\n * final translation (in that order only, not commutative).\n * @param {!Transform} transform The transform (will be modified in place).\n * @param {number} dx1 Initial translation x.\n * @param {number} dy1 Initial translation y.\n * @param {number} sx Scale factor x.\n * @param {number} sy Scale factor y.\n * @param {number} angle Rotation (in counter-clockwise radians).\n * @param {number} dx2 Final translation x.\n * @param {number} dy2 Final translation y.\n * @return {!Transform} The composite transform.\n */\nexport function compose(transform, dx1, dy1, sx, sy, angle, dx2, dy2) {\n const sin = Math.sin(angle);\n const cos = Math.cos(angle);\n transform[0] = sx * cos;\n transform[1] = sy * sin;\n transform[2] = -sx * sin;\n transform[3] = sy * cos;\n transform[4] = dx2 * sx * cos - dy2 * sx * sin + dx1;\n transform[5] = dx2 * sy * sin + dy2 * sy * cos + dy1;\n return transform;\n}\n\n/**\n * Creates a composite transform given an initial translation, scale, rotation, and\n * final translation (in that order only, not commutative). The resulting transform\n * string can be applied as `transform` property of an HTMLElement's style.\n * @param {number} dx1 Initial translation x.\n * @param {number} dy1 Initial translation y.\n * @param {number} sx Scale factor x.\n * @param {number} sy Scale factor y.\n * @param {number} angle Rotation (in counter-clockwise radians).\n * @param {number} dx2 Final translation x.\n * @param {number} dy2 Final translation y.\n * @return {string} The composite css transform.\n * @api\n */\nexport function composeCssTransform(dx1, dy1, sx, sy, angle, dx2, dy2) {\n return toString(compose(create(), dx1, dy1, sx, sy, angle, dx2, dy2));\n}\n\n/**\n * Invert the given transform.\n * @param {!Transform} source The source transform to invert.\n * @return {!Transform} The inverted (source) transform.\n */\nexport function invert(source) {\n return makeInverse(source, source);\n}\n\n/**\n * Invert the given transform.\n * @param {!Transform} target Transform to be set as the inverse of\n * the source transform.\n * @param {!Transform} source The source transform to invert.\n * @return {!Transform} The inverted (target) transform.\n */\nexport function makeInverse(target, source) {\n const det = determinant(source);\n assert(det !== 0, 'Transformation matrix cannot be inverted');\n\n const a = source[0];\n const b = source[1];\n const c = source[2];\n const d = source[3];\n const e = source[4];\n const f = source[5];\n\n target[0] = d / det;\n target[1] = -b / det;\n target[2] = -c / det;\n target[3] = a / det;\n target[4] = (c * f - d * e) / det;\n target[5] = -(a * f - b * e) / det;\n\n return target;\n}\n\n/**\n * Returns the determinant of the given matrix.\n * @param {!Transform} mat Matrix.\n * @return {number} Determinant.\n */\nexport function determinant(mat) {\n return mat[0] * mat[3] - mat[1] * mat[2];\n}\n\n/**\n * @type {HTMLElement}\n * @private\n */\nlet transformStringDiv;\n\n/**\n * A rounded string version of the transform. This can be used\n * for CSS transforms.\n * @param {!Transform} mat Matrix.\n * @return {string} The transform as a string.\n */\nexport function toString(mat) {\n const transformString = 'matrix(' + mat.join(', ') + ')';\n if (WORKER_OFFSCREEN_CANVAS) {\n return transformString;\n }\n const node =\n transformStringDiv || (transformStringDiv = document.createElement('div'));\n node.style.transform = transformString;\n return node.style.transform;\n}\n","/**\n * @module ol/geom/flat/transform\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../transform.js\").Transform} transform Transform.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function transform2D(\n flatCoordinates,\n offset,\n end,\n stride,\n transform,\n dest\n) {\n dest = dest ? dest : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const x = flatCoordinates[j];\n const y = flatCoordinates[j + 1];\n dest[i++] = transform[0] * x + transform[2] * y + transform[4];\n dest[i++] = transform[1] * x + transform[3] * y + transform[5];\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} angle Angle.\n * @param {Array} anchor Rotation anchor point.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function rotate(\n flatCoordinates,\n offset,\n end,\n stride,\n angle,\n anchor,\n dest\n) {\n dest = dest ? dest : [];\n const cos = Math.cos(angle);\n const sin = Math.sin(angle);\n const anchorX = anchor[0];\n const anchorY = anchor[1];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const deltaX = flatCoordinates[j] - anchorX;\n const deltaY = flatCoordinates[j + 1] - anchorY;\n dest[i++] = anchorX + deltaX * cos - deltaY * sin;\n dest[i++] = anchorY + deltaX * sin + deltaY * cos;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * Scale the coordinates.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} sx Scale factor in the x-direction.\n * @param {number} sy Scale factor in the y-direction.\n * @param {Array} anchor Scale anchor point.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function scale(\n flatCoordinates,\n offset,\n end,\n stride,\n sx,\n sy,\n anchor,\n dest\n) {\n dest = dest ? dest : [];\n const anchorX = anchor[0];\n const anchorY = anchor[1];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n const deltaX = flatCoordinates[j] - anchorX;\n const deltaY = flatCoordinates[j + 1] - anchorY;\n dest[i++] = anchorX + sx * deltaX;\n dest[i++] = anchorY + sy * deltaY;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed coordinates.\n */\nexport function translate(\n flatCoordinates,\n offset,\n end,\n stride,\n deltaX,\n deltaY,\n dest\n) {\n dest = dest ? dest : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n dest[i++] = flatCoordinates[j] + deltaX;\n dest[i++] = flatCoordinates[j + 1] + deltaY;\n for (let k = j + 2; k < j + stride; ++k) {\n dest[i++] = flatCoordinates[k];\n }\n }\n if (dest && dest.length != i) {\n dest.length = i;\n }\n return dest;\n}\n","/**\n * @module ol/geom/Geometry\n */\nimport BaseObject from '../Object.js';\nimport {abstract} from '../util.js';\nimport {\n compose as composeTransform,\n create as createTransform,\n} from '../transform.js';\nimport {\n createEmpty,\n createOrUpdateEmpty,\n getHeight,\n returnOrUpdate,\n} from '../extent.js';\nimport {get as getProjection, getTransform} from '../proj.js';\nimport {memoizeOne} from '../functions.js';\nimport {transform2D} from './flat/transform.js';\n\n/**\n * @typedef {'XY' | 'XYZ' | 'XYM' | 'XYZM'} GeometryLayout\n * The coordinate layout for geometries, indicating whether a 3rd or 4th z ('Z')\n * or measure ('M') coordinate is available.\n */\n\n/**\n * @typedef {'Point' | 'LineString' | 'LinearRing' | 'Polygon' | 'MultiPoint' | 'MultiLineString' | 'MultiPolygon' | 'GeometryCollection' | 'Circle'} Type\n * The geometry type. One of `'Point'`, `'LineString'`, `'LinearRing'`,\n * `'Polygon'`, `'MultiPoint'`, `'MultiLineString'`, `'MultiPolygon'`,\n * `'GeometryCollection'`, or `'Circle'`.\n */\n\n/**\n * @type {import(\"../transform.js\").Transform}\n */\nconst tmpTransform = createTransform();\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Base class for vector geometries.\n *\n * To get notified of changes to the geometry, register a listener for the\n * generic `change` event on your geometry instance.\n *\n * @abstract\n * @api\n */\nclass Geometry extends BaseObject {\n constructor() {\n super();\n\n /**\n * @private\n * @type {import(\"../extent.js\").Extent}\n */\n this.extent_ = createEmpty();\n\n /**\n * @private\n * @type {number}\n */\n this.extentRevision_ = -1;\n\n /**\n * @protected\n * @type {number}\n */\n this.simplifiedGeometryMaxMinSquaredTolerance = 0;\n\n /**\n * @protected\n * @type {number}\n */\n this.simplifiedGeometryRevision = 0;\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @abstract\n * @param {number} revision The geometry revision.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {Geometry} Simplified geometry.\n */\n this.simplifyTransformedInternal = memoizeOne(function (\n revision,\n squaredTolerance,\n transform\n ) {\n if (!transform) {\n return this.getSimplifiedGeometry(squaredTolerance);\n }\n const clone = this.clone();\n clone.applyTransform(transform);\n return clone.getSimplifiedGeometry(squaredTolerance);\n });\n }\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @abstract\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {Geometry} Simplified geometry.\n */\n simplifyTransformed(squaredTolerance, transform) {\n return this.simplifyTransformedInternal(\n this.getRevision(),\n squaredTolerance,\n transform\n );\n }\n\n /**\n * Make a complete copy of the geometry.\n * @abstract\n * @return {!Geometry} Clone.\n */\n clone() {\n return abstract();\n }\n\n /**\n * @abstract\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n return abstract();\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\n containsXY(x, y) {\n const coord = this.getClosestPoint([x, y]);\n return coord[0] === x && coord[1] === y;\n }\n\n /**\n * Return the closest point of the geometry to the passed point as\n * {@link module:ol/coordinate~Coordinate coordinate}.\n * @param {import(\"../coordinate.js\").Coordinate} point Point.\n * @param {import(\"../coordinate.js\").Coordinate} [closestPoint] Closest point.\n * @return {import(\"../coordinate.js\").Coordinate} Closest point.\n * @api\n */\n getClosestPoint(point, closestPoint) {\n closestPoint = closestPoint ? closestPoint : [NaN, NaN];\n this.closestPointXY(point[0], point[1], closestPoint, Infinity);\n return closestPoint;\n }\n\n /**\n * Returns true if this geometry includes the specified coordinate. If the\n * coordinate is on the boundary of the geometry, returns false.\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} Contains coordinate.\n * @api\n */\n intersectsCoordinate(coordinate) {\n return this.containsXY(coordinate[0], coordinate[1]);\n }\n\n /**\n * @abstract\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return abstract();\n }\n\n /**\n * Get the extent of the geometry.\n * @param {import(\"../extent.js\").Extent} [extent] Extent.\n * @return {import(\"../extent.js\").Extent} extent Extent.\n * @api\n */\n getExtent(extent) {\n if (this.extentRevision_ != this.getRevision()) {\n const extent = this.computeExtent(this.extent_);\n if (isNaN(extent[0]) || isNaN(extent[1])) {\n createOrUpdateEmpty(extent);\n }\n this.extentRevision_ = this.getRevision();\n }\n return returnOrUpdate(this.extent_, extent);\n }\n\n /**\n * Rotate the geometry around a given coordinate. This modifies the geometry\n * coordinates in place.\n * @abstract\n * @param {number} angle Rotation angle in radians.\n * @param {import(\"../coordinate.js\").Coordinate} anchor The rotation center.\n * @api\n */\n rotate(angle, anchor) {\n abstract();\n }\n\n /**\n * Scale the geometry (with an optional origin). This modifies the geometry\n * coordinates in place.\n * @abstract\n * @param {number} sx The scaling factor in the x-direction.\n * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).\n * @param {import(\"../coordinate.js\").Coordinate} [anchor] The scale origin (defaults to the center\n * of the geometry extent).\n * @api\n */\n scale(sx, sy, anchor) {\n abstract();\n }\n\n /**\n * Create a simplified version of this geometry. For linestrings, this uses\n * the [Douglas Peucker](https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm)\n * algorithm. For polygons, a quantization-based\n * simplification is used to preserve topology.\n * @param {number} tolerance The tolerance distance for simplification.\n * @return {Geometry} A new, simplified version of the original geometry.\n * @api\n */\n simplify(tolerance) {\n return this.getSimplifiedGeometry(tolerance * tolerance);\n }\n\n /**\n * Create a simplified version of this geometry using the Douglas Peucker\n * algorithm.\n * See https://en.wikipedia.org/wiki/Ramer-Douglas-Peucker_algorithm.\n * @abstract\n * @param {number} squaredTolerance Squared tolerance.\n * @return {Geometry} Simplified geometry.\n */\n getSimplifiedGeometry(squaredTolerance) {\n return abstract();\n }\n\n /**\n * Get the type of this geometry.\n * @abstract\n * @return {Type} Geometry type.\n */\n getType() {\n return abstract();\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @abstract\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n * Called with a flat array of geometry coordinates.\n */\n applyTransform(transformFn) {\n abstract();\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @abstract\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n */\n intersectsExtent(extent) {\n return abstract();\n }\n\n /**\n * Translate the geometry. This modifies the geometry coordinates in place. If\n * instead you want a new geometry, first `clone()` this geometry.\n * @abstract\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @api\n */\n translate(deltaX, deltaY) {\n abstract();\n }\n\n /**\n * Transform each coordinate of the geometry from one coordinate reference\n * system to another. The geometry is modified in place.\n * For example, a line will be transformed to a line and a circle to a circle.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n *\n * @param {import(\"../proj.js\").ProjectionLike} source The current projection. Can be a\n * string identifier or a {@link module:ol/proj/Projection~Projection} object.\n * @param {import(\"../proj.js\").ProjectionLike} destination The desired projection. Can be a\n * string identifier or a {@link module:ol/proj/Projection~Projection} object.\n * @return {Geometry} This geometry. Note that original geometry is\n * modified in place.\n * @api\n */\n transform(source, destination) {\n /** @type {import(\"../proj/Projection.js\").default} */\n const sourceProj = getProjection(source);\n const transformFn =\n sourceProj.getUnits() == 'tile-pixels'\n ? function (inCoordinates, outCoordinates, stride) {\n const pixelExtent = sourceProj.getExtent();\n const projectedExtent = sourceProj.getWorldExtent();\n const scale = getHeight(projectedExtent) / getHeight(pixelExtent);\n composeTransform(\n tmpTransform,\n projectedExtent[0],\n projectedExtent[3],\n scale,\n -scale,\n 0,\n 0,\n 0\n );\n transform2D(\n inCoordinates,\n 0,\n inCoordinates.length,\n stride,\n tmpTransform,\n outCoordinates\n );\n return getTransform(sourceProj, destination)(\n inCoordinates,\n outCoordinates,\n stride\n );\n }\n : getTransform(sourceProj, destination);\n this.applyTransform(transformFn);\n return this;\n }\n}\n\nexport default Geometry;\n","/**\n * @module ol/geom/SimpleGeometry\n */\nimport Geometry from './Geometry.js';\nimport {abstract} from '../util.js';\nimport {createOrUpdateFromFlatCoordinates, getCenter} from '../extent.js';\nimport {rotate, scale, transform2D, translate} from './flat/transform.js';\n\n/**\n * @classdesc\n * Abstract base class; only used for creating subclasses; do not instantiate\n * in apps, as cannot be rendered.\n *\n * @abstract\n * @api\n */\nclass SimpleGeometry extends Geometry {\n constructor() {\n super();\n\n /**\n * @protected\n * @type {import(\"./Geometry.js\").GeometryLayout}\n */\n this.layout = 'XY';\n\n /**\n * @protected\n * @type {number}\n */\n this.stride = 2;\n\n /**\n * @protected\n * @type {Array}\n */\n this.flatCoordinates = null;\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return createOrUpdateFromFlatCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n extent\n );\n }\n\n /**\n * @abstract\n * @return {Array<*> | null} Coordinates.\n */\n getCoordinates() {\n return abstract();\n }\n\n /**\n * Return the first coordinate of the geometry.\n * @return {import(\"../coordinate.js\").Coordinate} First coordinate.\n * @api\n */\n getFirstCoordinate() {\n return this.flatCoordinates.slice(0, this.stride);\n }\n\n /**\n * @return {Array} Flat coordinates.\n */\n getFlatCoordinates() {\n return this.flatCoordinates;\n }\n\n /**\n * Return the last coordinate of the geometry.\n * @return {import(\"../coordinate.js\").Coordinate} Last point.\n * @api\n */\n getLastCoordinate() {\n return this.flatCoordinates.slice(\n this.flatCoordinates.length - this.stride\n );\n }\n\n /**\n * Return the {@link import(\"./Geometry.js\").GeometryLayout layout} of the geometry.\n * @return {import(\"./Geometry.js\").GeometryLayout} Layout.\n * @api\n */\n getLayout() {\n return this.layout;\n }\n\n /**\n * Create a simplified version of this geometry using the Douglas Peucker algorithm.\n * @param {number} squaredTolerance Squared tolerance.\n * @return {SimpleGeometry} Simplified geometry.\n */\n getSimplifiedGeometry(squaredTolerance) {\n if (this.simplifiedGeometryRevision !== this.getRevision()) {\n this.simplifiedGeometryMaxMinSquaredTolerance = 0;\n this.simplifiedGeometryRevision = this.getRevision();\n }\n // If squaredTolerance is negative or if we know that simplification will not\n // have any effect then just return this.\n if (\n squaredTolerance < 0 ||\n (this.simplifiedGeometryMaxMinSquaredTolerance !== 0 &&\n squaredTolerance <= this.simplifiedGeometryMaxMinSquaredTolerance)\n ) {\n return this;\n }\n\n const simplifiedGeometry =\n this.getSimplifiedGeometryInternal(squaredTolerance);\n const simplifiedFlatCoordinates = simplifiedGeometry.getFlatCoordinates();\n if (simplifiedFlatCoordinates.length < this.flatCoordinates.length) {\n return simplifiedGeometry;\n }\n // Simplification did not actually remove any coordinates. We now know\n // that any calls to getSimplifiedGeometry with a squaredTolerance less\n // than or equal to the current squaredTolerance will also not have any\n // effect. This allows us to short circuit simplification (saving CPU\n // cycles) and prevents the cache of simplified geometries from filling\n // up with useless identical copies of this geometry (saving memory).\n this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;\n return this;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {SimpleGeometry} Simplified geometry.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n return this;\n }\n\n /**\n * @return {number} Stride.\n */\n getStride() {\n return this.stride;\n }\n\n /**\n * @param {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n * @param {Array} flatCoordinates Flat coordinates.\n */\n setFlatCoordinates(layout, flatCoordinates) {\n this.stride = getStrideForLayout(layout);\n this.layout = layout;\n this.flatCoordinates = flatCoordinates;\n }\n\n /**\n * @abstract\n * @param {!Array<*>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n setCoordinates(coordinates, layout) {\n abstract();\n }\n\n /**\n * @param {import(\"./Geometry.js\").GeometryLayout|undefined} layout Layout.\n * @param {Array<*>} coordinates Coordinates.\n * @param {number} nesting Nesting.\n * @protected\n */\n setLayout(layout, coordinates, nesting) {\n /** @type {number} */\n let stride;\n if (layout) {\n stride = getStrideForLayout(layout);\n } else {\n for (let i = 0; i < nesting; ++i) {\n if (coordinates.length === 0) {\n this.layout = 'XY';\n this.stride = 2;\n return;\n }\n coordinates = /** @type {Array} */ (coordinates[0]);\n }\n stride = coordinates.length;\n layout = getLayoutForStride(stride);\n }\n this.layout = layout;\n this.stride = stride;\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n * Called with a flat array of geometry coordinates.\n * @api\n */\n applyTransform(transformFn) {\n if (this.flatCoordinates) {\n transformFn(this.flatCoordinates, this.flatCoordinates, this.stride);\n this.changed();\n }\n }\n\n /**\n * Rotate the geometry around a given coordinate. This modifies the geometry\n * coordinates in place.\n * @param {number} angle Rotation angle in counter-clockwise radians.\n * @param {import(\"../coordinate.js\").Coordinate} anchor The rotation center.\n * @api\n */\n rotate(angle, anchor) {\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n rotate(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n angle,\n anchor,\n flatCoordinates\n );\n this.changed();\n }\n }\n\n /**\n * Scale the geometry (with an optional origin). This modifies the geometry\n * coordinates in place.\n * @param {number} sx The scaling factor in the x-direction.\n * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).\n * @param {import(\"../coordinate.js\").Coordinate} [anchor] The scale origin (defaults to the center\n * of the geometry extent).\n * @api\n */\n scale(sx, sy, anchor) {\n if (sy === undefined) {\n sy = sx;\n }\n if (!anchor) {\n anchor = getCenter(this.getExtent());\n }\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n scale(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n sx,\n sy,\n anchor,\n flatCoordinates\n );\n this.changed();\n }\n }\n\n /**\n * Translate the geometry. This modifies the geometry coordinates in place. If\n * instead you want a new geometry, first `clone()` this geometry.\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @api\n */\n translate(deltaX, deltaY) {\n const flatCoordinates = this.getFlatCoordinates();\n if (flatCoordinates) {\n const stride = this.getStride();\n translate(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n deltaX,\n deltaY,\n flatCoordinates\n );\n this.changed();\n }\n }\n}\n\n/**\n * @param {number} stride Stride.\n * @return {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n */\nfunction getLayoutForStride(stride) {\n let layout;\n if (stride == 2) {\n layout = 'XY';\n } else if (stride == 3) {\n layout = 'XYZ';\n } else if (stride == 4) {\n layout = 'XYZM';\n }\n return /** @type {import(\"./Geometry.js\").GeometryLayout} */ (layout);\n}\n\n/**\n * @param {import(\"./Geometry.js\").GeometryLayout} layout Layout.\n * @return {number} Stride.\n */\nexport function getStrideForLayout(layout) {\n let stride;\n if (layout == 'XY') {\n stride = 2;\n } else if (layout == 'XYZ' || layout == 'XYM') {\n stride = 3;\n } else if (layout == 'XYZM') {\n stride = 4;\n }\n return /** @type {number} */ (stride);\n}\n\n/**\n * @param {SimpleGeometry} simpleGeometry Simple geometry.\n * @param {import(\"../transform.js\").Transform} transform Transform.\n * @param {Array} [dest] Destination.\n * @return {Array} Transformed flat coordinates.\n */\nexport function transformGeom2D(simpleGeometry, transform, dest) {\n const flatCoordinates = simpleGeometry.getFlatCoordinates();\n if (!flatCoordinates) {\n return null;\n }\n const stride = simpleGeometry.getStride();\n return transform2D(\n flatCoordinates,\n 0,\n flatCoordinates.length,\n stride,\n transform,\n dest\n );\n}\n\nexport default SimpleGeometry;\n","/**\n * @module ol/geom/flat/closest\n */\nimport {lerp, squaredDistance as squaredDx} from '../../math.js';\n\n/**\n * Returns the point on the 2D line segment flatCoordinates[offset1] to\n * flatCoordinates[offset2] that is closest to the point (x, y). Extra\n * dimensions are linearly interpolated.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset1 Offset 1.\n * @param {number} offset2 Offset 2.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n */\nfunction assignClosest(\n flatCoordinates,\n offset1,\n offset2,\n stride,\n x,\n y,\n closestPoint\n) {\n const x1 = flatCoordinates[offset1];\n const y1 = flatCoordinates[offset1 + 1];\n const dx = flatCoordinates[offset2] - x1;\n const dy = flatCoordinates[offset2 + 1] - y1;\n let offset;\n if (dx === 0 && dy === 0) {\n offset = offset1;\n } else {\n const t = ((x - x1) * dx + (y - y1) * dy) / (dx * dx + dy * dy);\n if (t > 1) {\n offset = offset2;\n } else if (t > 0) {\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = lerp(\n flatCoordinates[offset1 + i],\n flatCoordinates[offset2 + i],\n t\n );\n }\n closestPoint.length = stride;\n return;\n } else {\n offset = offset1;\n }\n }\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[offset + i];\n }\n closestPoint.length = stride;\n}\n\n/**\n * Return the squared of the largest distance between any pair of consecutive\n * coordinates.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function maxSquaredDelta(flatCoordinates, offset, end, stride, max) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n for (offset += stride; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n const squaredDelta = squaredDx(x1, y1, x2, y2);\n if (squaredDelta > max) {\n max = squaredDelta;\n }\n x1 = x2;\n y1 = y2;\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function arrayMaxSquaredDelta(\n flatCoordinates,\n offset,\n ends,\n stride,\n max\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n max = maxSquaredDelta(flatCoordinates, offset, end, stride, max);\n offset = end;\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} max Max squared delta.\n * @return {number} Max squared delta.\n */\nexport function multiArrayMaxSquaredDelta(\n flatCoordinates,\n offset,\n endss,\n stride,\n max\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n max = arrayMaxSquaredDelta(flatCoordinates, offset, ends, stride, max);\n offset = ends[ends.length - 1];\n }\n return max;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestPoint(\n flatCoordinates,\n offset,\n end,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint\n) {\n if (offset == end) {\n return minSquaredDistance;\n }\n let i, squaredDistance;\n if (maxDelta === 0) {\n // All points are identical, so just test the first point.\n squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[offset],\n flatCoordinates[offset + 1]\n );\n if (squaredDistance < minSquaredDistance) {\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[offset + i];\n }\n closestPoint.length = stride;\n return squaredDistance;\n }\n return minSquaredDistance;\n }\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n let index = offset + stride;\n while (index < end) {\n assignClosest(\n flatCoordinates,\n index - stride,\n index,\n stride,\n x,\n y,\n tmpPoint\n );\n squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = tmpPoint[i];\n }\n closestPoint.length = stride;\n index += stride;\n } else {\n // Skip ahead multiple points, because we know that all the skipped\n // points cannot be any closer than the closest point we have found so\n // far. We know this because we know how close the current point is, how\n // close the closest point we have found so far is, and the maximum\n // distance between consecutive points. For example, if we're currently\n // at distance 10, the best we've found so far is 3, and that the maximum\n // distance between consecutive points is 2, then we'll need to skip at\n // least (10 - 3) / 2 == 3 (rounded down) points to have any chance of\n // finding a closer point. We use Math.max(..., 1) to ensure that we\n // always advance at least one point, to avoid an infinite loop.\n index +=\n stride *\n Math.max(\n ((Math.sqrt(squaredDistance) - Math.sqrt(minSquaredDistance)) /\n maxDelta) |\n 0,\n 1\n );\n }\n }\n if (isRing) {\n // Check the closing segment.\n assignClosest(\n flatCoordinates,\n end - stride,\n offset,\n stride,\n x,\n y,\n tmpPoint\n );\n squaredDistance = squaredDx(x, y, tmpPoint[0], tmpPoint[1]);\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (i = 0; i < stride; ++i) {\n closestPoint[i] = tmpPoint[i];\n }\n closestPoint.length = stride;\n }\n }\n return minSquaredDistance;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestArrayPoint(\n flatCoordinates,\n offset,\n ends,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint\n) {\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n minSquaredDistance = assignClosestPoint(\n flatCoordinates,\n offset,\n end,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint\n );\n offset = end;\n }\n return minSquaredDistance;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} maxDelta Max delta.\n * @param {boolean} isRing Is ring.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {Array} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @param {Array} [tmpPoint] Temporary point object.\n * @return {number} Minimum squared distance.\n */\nexport function assignClosestMultiArrayPoint(\n flatCoordinates,\n offset,\n endss,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint\n) {\n tmpPoint = tmpPoint ? tmpPoint : [NaN, NaN];\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n minSquaredDistance = assignClosestArrayPoint(\n flatCoordinates,\n offset,\n ends,\n stride,\n maxDelta,\n isRing,\n x,\n y,\n closestPoint,\n minSquaredDistance,\n tmpPoint\n );\n offset = ends[ends.length - 1];\n }\n return minSquaredDistance;\n}\n","/**\n * @module ol/geom/flat/deflate\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {import(\"../../coordinate.js\").Coordinate} coordinate Coordinate.\n * @param {number} stride Stride.\n * @return {number} offset Offset.\n */\nexport function deflateCoordinate(flatCoordinates, offset, coordinate, stride) {\n for (let i = 0, ii = coordinate.length; i < ii; ++i) {\n flatCoordinates[offset++] = coordinate[i];\n }\n return offset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} coordinates Coordinates.\n * @param {number} stride Stride.\n * @return {number} offset Offset.\n */\nexport function deflateCoordinates(\n flatCoordinates,\n offset,\n coordinates,\n stride\n) {\n for (let i = 0, ii = coordinates.length; i < ii; ++i) {\n const coordinate = coordinates[i];\n for (let j = 0; j < stride; ++j) {\n flatCoordinates[offset++] = coordinate[j];\n }\n }\n return offset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} coordinatess Coordinatess.\n * @param {number} stride Stride.\n * @param {Array} [ends] Ends.\n * @return {Array} Ends.\n */\nexport function deflateCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatess,\n stride,\n ends\n) {\n ends = ends ? ends : [];\n let i = 0;\n for (let j = 0, jj = coordinatess.length; j < jj; ++j) {\n const end = deflateCoordinates(\n flatCoordinates,\n offset,\n coordinatess[j],\n stride\n );\n ends[i++] = end;\n offset = end;\n }\n ends.length = i;\n return ends;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>>} coordinatesss Coordinatesss.\n * @param {number} stride Stride.\n * @param {Array>} [endss] Endss.\n * @return {Array>} Endss.\n */\nexport function deflateMultiCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatesss,\n stride,\n endss\n) {\n endss = endss ? endss : [];\n let i = 0;\n for (let j = 0, jj = coordinatesss.length; j < jj; ++j) {\n const ends = deflateCoordinatesArray(\n flatCoordinates,\n offset,\n coordinatesss[j],\n stride,\n endss[i]\n );\n if (ends.length === 0) {\n ends[0] = offset;\n }\n endss[i++] = ends;\n offset = ends[ends.length - 1];\n }\n endss.length = i;\n return endss;\n}\n","/**\n * @module ol/geom/flat/simplify\n */\n// Based on simplify-js https://github.com/mourner/simplify-js\n// Copyright (c) 2012, Vladimir Agafonkin\n// All rights reserved.\n//\n// Redistribution and use in source and binary forms, with or without\n// modification, are permitted provided that the following conditions are met:\n//\n// 1. Redistributions of source code must retain the above copyright notice,\n// this list of conditions and the following disclaimer.\n//\n// 2. Redistributions in binary form must reproduce the above copyright\n// notice, this list of conditions and the following disclaimer in the\n// documentation and/or other materials provided with the distribution.\n//\n// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n// POSSIBILITY OF SUCH DAMAGE.\n\nimport {squaredDistance, squaredSegmentDistance} from '../../math.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {boolean} highQuality Highest quality.\n * @param {Array} [simplifiedFlatCoordinates] Simplified flat\n * coordinates.\n * @return {Array} Simplified line string.\n */\nexport function simplifyLineString(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n highQuality,\n simplifiedFlatCoordinates\n) {\n simplifiedFlatCoordinates =\n simplifiedFlatCoordinates !== undefined ? simplifiedFlatCoordinates : [];\n if (!highQuality) {\n end = radialDistance(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0\n );\n flatCoordinates = simplifiedFlatCoordinates;\n offset = 0;\n stride = 2;\n }\n simplifiedFlatCoordinates.length = douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0\n );\n return simplifiedFlatCoordinates;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset\n) {\n const n = (end - offset) / stride;\n if (n < 3) {\n for (; offset < end; offset += stride) {\n simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + 1];\n }\n return simplifiedOffset;\n }\n /** @type {Array} */\n const markers = new Array(n);\n markers[0] = 1;\n markers[n - 1] = 1;\n /** @type {Array} */\n const stack = [offset, end - stride];\n let index = 0;\n while (stack.length > 0) {\n const last = stack.pop();\n const first = stack.pop();\n let maxSquaredDistance = 0;\n const x1 = flatCoordinates[first];\n const y1 = flatCoordinates[first + 1];\n const x2 = flatCoordinates[last];\n const y2 = flatCoordinates[last + 1];\n for (let i = first + stride; i < last; i += stride) {\n const x = flatCoordinates[i];\n const y = flatCoordinates[i + 1];\n const squaredDistance = squaredSegmentDistance(x, y, x1, y1, x2, y2);\n if (squaredDistance > maxSquaredDistance) {\n index = i;\n maxSquaredDistance = squaredDistance;\n }\n }\n if (maxSquaredDistance > squaredTolerance) {\n markers[(index - offset) / stride] = 1;\n if (first + stride < index) {\n stack.push(first, index);\n }\n if (index + stride < last) {\n stack.push(index, last);\n }\n }\n }\n for (let i = 0; i < n; ++i) {\n if (markers[i]) {\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + i * stride];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + i * stride + 1];\n }\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array} simplifiedEnds Simplified ends.\n * @return {number} Simplified offset.\n */\nexport function douglasPeuckerArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n simplifiedOffset = douglasPeucker(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset\n );\n simplifiedEnds.push(simplifiedOffset);\n offset = end;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array>} simplifiedEndss Simplified endss.\n * @return {number} Simplified offset.\n */\nexport function douglasPeuckerMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEndss\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n const simplifiedEnds = [];\n simplifiedOffset = douglasPeuckerArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds\n );\n simplifiedEndss.push(simplifiedEnds);\n offset = ends[ends.length - 1];\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} squaredTolerance Squared tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function radialDistance(\n flatCoordinates,\n offset,\n end,\n stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset\n) {\n if (end <= offset + stride) {\n // zero or one point, no simplification possible, so copy and return\n for (; offset < end; offset += stride) {\n simplifiedFlatCoordinates[simplifiedOffset++] = flatCoordinates[offset];\n simplifiedFlatCoordinates[simplifiedOffset++] =\n flatCoordinates[offset + 1];\n }\n return simplifiedOffset;\n }\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n // copy first point\n simplifiedFlatCoordinates[simplifiedOffset++] = x1;\n simplifiedFlatCoordinates[simplifiedOffset++] = y1;\n let x2 = x1;\n let y2 = y1;\n for (offset += stride; offset < end; offset += stride) {\n x2 = flatCoordinates[offset];\n y2 = flatCoordinates[offset + 1];\n if (squaredDistance(x1, y1, x2, y2) > squaredTolerance) {\n // copy point at offset\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n x1 = x2;\n y1 = y2;\n }\n }\n if (x2 != x1 || y2 != y1) {\n // copy last point\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {number} value Value.\n * @param {number} tolerance Tolerance.\n * @return {number} Rounded value.\n */\nexport function snap(value, tolerance) {\n return tolerance * Math.round(value / tolerance);\n}\n\n/**\n * Simplifies a line string using an algorithm designed by Tim Schaub.\n * Coordinates are snapped to the nearest value in a virtual grid and\n * consecutive duplicate coordinates are discarded. This effectively preserves\n * topology as the simplification of any subsection of a line string is\n * independent of the rest of the line string. This means that, for examples,\n * the common edge between two polygons will be simplified to the same line\n * string independently in both polygons. This implementation uses a single\n * pass over the coordinates and eliminates intermediate collinear points.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @return {number} Simplified offset.\n */\nexport function quantize(\n flatCoordinates,\n offset,\n end,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset\n) {\n // do nothing if the line is empty\n if (offset == end) {\n return simplifiedOffset;\n }\n // snap the first coordinate (P1)\n let x1 = snap(flatCoordinates[offset], tolerance);\n let y1 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n // add the first coordinate to the output\n simplifiedFlatCoordinates[simplifiedOffset++] = x1;\n simplifiedFlatCoordinates[simplifiedOffset++] = y1;\n // find the next coordinate that does not snap to the same value as the first\n // coordinate (P2)\n let x2, y2;\n do {\n x2 = snap(flatCoordinates[offset], tolerance);\n y2 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n if (offset == end) {\n // all coordinates snap to the same value, the line collapses to a point\n // push the last snapped value anyway to ensure that the output contains\n // at least two points\n // FIXME should we really return at least two points anyway?\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n return simplifiedOffset;\n }\n } while (x2 == x1 && y2 == y1);\n while (offset < end) {\n // snap the next coordinate (P3)\n const x3 = snap(flatCoordinates[offset], tolerance);\n const y3 = snap(flatCoordinates[offset + 1], tolerance);\n offset += stride;\n // skip P3 if it is equal to P2\n if (x3 == x2 && y3 == y2) {\n continue;\n }\n // calculate the delta between P1 and P2\n const dx1 = x2 - x1;\n const dy1 = y2 - y1;\n // calculate the delta between P3 and P1\n const dx2 = x3 - x1;\n const dy2 = y3 - y1;\n // if P1, P2, and P3 are colinear and P3 is further from P1 than P2 is from\n // P1 in the same direction then P2 is on the straight line between P1 and\n // P3\n if (\n dx1 * dy2 == dy1 * dx2 &&\n ((dx1 < 0 && dx2 < dx1) || dx1 == dx2 || (dx1 > 0 && dx2 > dx1)) &&\n ((dy1 < 0 && dy2 < dy1) || dy1 == dy2 || (dy1 > 0 && dy2 > dy1))\n ) {\n // discard P2 and set P2 = P3\n x2 = x3;\n y2 = y3;\n continue;\n }\n // either P1, P2, and P3 are not colinear, or they are colinear but P3 is\n // between P3 and P1 or on the opposite half of the line to P2. add P2,\n // and continue with P1 = P2 and P2 = P3\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n x1 = x2;\n y1 = y2;\n x2 = x3;\n y2 = y3;\n }\n // add the last point (P2)\n simplifiedFlatCoordinates[simplifiedOffset++] = x2;\n simplifiedFlatCoordinates[simplifiedOffset++] = y2;\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array} simplifiedEnds Simplified ends.\n * @return {number} Simplified offset.\n */\nexport function quantizeArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n simplifiedOffset = quantize(\n flatCoordinates,\n offset,\n end,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset\n );\n simplifiedEnds.push(simplifiedOffset);\n offset = end;\n }\n return simplifiedOffset;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} tolerance Tolerance.\n * @param {Array} simplifiedFlatCoordinates Simplified flat\n * coordinates.\n * @param {number} simplifiedOffset Simplified offset.\n * @param {Array>} simplifiedEndss Simplified endss.\n * @return {number} Simplified offset.\n */\nexport function quantizeMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEndss\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n const simplifiedEnds = [];\n simplifiedOffset = quantizeArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n tolerance,\n simplifiedFlatCoordinates,\n simplifiedOffset,\n simplifiedEnds\n );\n simplifiedEndss.push(simplifiedEnds);\n offset = ends[ends.length - 1];\n }\n return simplifiedOffset;\n}\n","/**\n * @module ol/geom/flat/segments\n */\n\n/**\n * This function calls `callback` for each segment of the flat coordinates\n * array. If the callback returns a truthy value the function returns that\n * value immediately. Otherwise the function returns `false`.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {function(import(\"../../coordinate.js\").Coordinate, import(\"../../coordinate.js\").Coordinate): T} callback Function\n * called for each segment.\n * @return {T|boolean} Value.\n * @template T\n */\nexport function forEach(flatCoordinates, offset, end, stride, callback) {\n let ret;\n offset += stride;\n for (; offset < end; offset += stride) {\n ret = callback(\n flatCoordinates.slice(offset - stride, offset),\n flatCoordinates.slice(offset, offset + stride)\n );\n if (ret) {\n return ret;\n }\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/inflate\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {Array} [coordinates] Coordinates.\n * @return {Array} Coordinates.\n */\nexport function inflateCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinates\n) {\n coordinates = coordinates !== undefined ? coordinates : [];\n let i = 0;\n for (let j = offset; j < end; j += stride) {\n coordinates[i++] = flatCoordinates.slice(j, j + stride);\n }\n coordinates.length = i;\n return coordinates;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {Array>} [coordinatess] Coordinatess.\n * @return {Array>} Coordinatess.\n */\nexport function inflateCoordinatesArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n coordinatess\n) {\n coordinatess = coordinatess !== undefined ? coordinatess : [];\n let i = 0;\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n const end = ends[j];\n coordinatess[i++] = inflateCoordinates(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinatess[i]\n );\n offset = end;\n }\n coordinatess.length = i;\n return coordinatess;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {Array>>} [coordinatesss]\n * Coordinatesss.\n * @return {Array>>} Coordinatesss.\n */\nexport function inflateMultiCoordinatesArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n coordinatesss\n) {\n coordinatesss = coordinatesss !== undefined ? coordinatesss : [];\n let i = 0;\n for (let j = 0, jj = endss.length; j < jj; ++j) {\n const ends = endss[j];\n coordinatesss[i++] =\n ends.length === 1 && ends[0] === offset\n ? []\n : inflateCoordinatesArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n coordinatesss[i]\n );\n offset = ends[ends.length - 1];\n }\n coordinatesss.length = i;\n return coordinatesss;\n}\n","/**\n * @module ol/geom/flat/interpolate\n */\nimport {binarySearch} from '../../array.js';\nimport {lerp} from '../../math.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} fraction Fraction.\n * @param {Array} [dest] Destination.\n * @param {number} [dimension] Destination dimension (default is `2`)\n * @return {Array} Destination.\n */\nexport function interpolatePoint(\n flatCoordinates,\n offset,\n end,\n stride,\n fraction,\n dest,\n dimension\n) {\n let o, t;\n const n = (end - offset) / stride;\n if (n === 1) {\n o = offset;\n } else if (n === 2) {\n o = offset;\n t = fraction;\n } else if (n !== 0) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n let length = 0;\n const cumulativeLengths = [0];\n for (let i = offset + stride; i < end; i += stride) {\n const x2 = flatCoordinates[i];\n const y2 = flatCoordinates[i + 1];\n length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n cumulativeLengths.push(length);\n x1 = x2;\n y1 = y2;\n }\n const target = fraction * length;\n const index = binarySearch(cumulativeLengths, target);\n if (index < 0) {\n t =\n (target - cumulativeLengths[-index - 2]) /\n (cumulativeLengths[-index - 1] - cumulativeLengths[-index - 2]);\n o = offset + (-index - 2) * stride;\n } else {\n o = offset + index * stride;\n }\n }\n dimension = dimension > 1 ? dimension : 2;\n dest = dest ? dest : new Array(dimension);\n for (let i = 0; i < dimension; ++i) {\n dest[i] =\n o === undefined\n ? NaN\n : t === undefined\n ? flatCoordinates[o + i]\n : lerp(flatCoordinates[o + i], flatCoordinates[o + stride + i], t);\n }\n return dest;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} m M.\n * @param {boolean} extrapolate Extrapolate.\n * @return {import(\"../../coordinate.js\").Coordinate|null} Coordinate.\n */\nexport function lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n end,\n stride,\n m,\n extrapolate\n) {\n if (end == offset) {\n return null;\n }\n let coordinate;\n if (m < flatCoordinates[offset + stride - 1]) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(offset, offset + stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n if (flatCoordinates[end - 1] < m) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(end - stride, end);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n // FIXME use O(1) search\n if (m == flatCoordinates[offset + stride - 1]) {\n return flatCoordinates.slice(offset, offset + stride);\n }\n let lo = offset / stride;\n let hi = end / stride;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (m < flatCoordinates[(mid + 1) * stride - 1]) {\n hi = mid;\n } else {\n lo = mid + 1;\n }\n }\n const m0 = flatCoordinates[lo * stride - 1];\n if (m == m0) {\n return flatCoordinates.slice((lo - 1) * stride, (lo - 1) * stride + stride);\n }\n const m1 = flatCoordinates[(lo + 1) * stride - 1];\n const t = (m - m0) / (m1 - m0);\n coordinate = [];\n for (let i = 0; i < stride - 1; ++i) {\n coordinate.push(\n lerp(\n flatCoordinates[(lo - 1) * stride + i],\n flatCoordinates[lo * stride + i],\n t\n )\n );\n }\n coordinate.push(m);\n return coordinate;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} m M.\n * @param {boolean} extrapolate Extrapolate.\n * @param {boolean} interpolate Interpolate.\n * @return {import(\"../../coordinate.js\").Coordinate|null} Coordinate.\n */\nexport function lineStringsCoordinateAtM(\n flatCoordinates,\n offset,\n ends,\n stride,\n m,\n extrapolate,\n interpolate\n) {\n if (interpolate) {\n return lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n ends[ends.length - 1],\n stride,\n m,\n extrapolate\n );\n }\n let coordinate;\n if (m < flatCoordinates[stride - 1]) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(0, stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n if (flatCoordinates[flatCoordinates.length - 1] < m) {\n if (extrapolate) {\n coordinate = flatCoordinates.slice(flatCoordinates.length - stride);\n coordinate[stride - 1] = m;\n return coordinate;\n }\n return null;\n }\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n if (offset == end) {\n continue;\n }\n if (m < flatCoordinates[offset + stride - 1]) {\n return null;\n }\n if (m <= flatCoordinates[end - 1]) {\n return lineStringCoordinateAtM(\n flatCoordinates,\n offset,\n end,\n stride,\n m,\n false\n );\n }\n offset = end;\n }\n return null;\n}\n","/**\n * @module ol/geom/flat/contains\n */\nimport {forEachCorner} from '../../extent.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} Contains extent.\n */\nexport function linearRingContainsExtent(\n flatCoordinates,\n offset,\n end,\n stride,\n extent\n) {\n const outside = forEachCorner(\n extent,\n /**\n * @param {import(\"../../coordinate.js\").Coordinate} coordinate Coordinate.\n * @return {boolean} Contains (x, y).\n */\n function (coordinate) {\n return !linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n coordinate[0],\n coordinate[1]\n );\n }\n );\n return !outside;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n x,\n y\n) {\n // https://geomalgorithms.com/a03-_inclusion.html\n // Copyright 2000 softSurfer, 2012 Dan Sunday\n // This code may be freely used and modified for any purpose\n // providing that this copyright notice is included with it.\n // SoftSurfer makes no warranty for this code, and cannot be held\n // liable for any real or imagined damage resulting from its use.\n // Users of this code must verify correctness for their application.\n let wn = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n if (y1 <= y) {\n if (y2 > y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) > 0) {\n wn++;\n }\n } else if (y2 <= y && (x2 - x1) * (y - y1) - (x - x1) * (y2 - y1) < 0) {\n wn--;\n }\n x1 = x2;\n y1 = y2;\n }\n return wn !== 0;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingsContainsXY(\n flatCoordinates,\n offset,\n ends,\n stride,\n x,\n y\n) {\n if (ends.length === 0) {\n return false;\n }\n if (!linearRingContainsXY(flatCoordinates, offset, ends[0], stride, x, y)) {\n return false;\n }\n for (let i = 1, ii = ends.length; i < ii; ++i) {\n if (\n linearRingContainsXY(flatCoordinates, ends[i - 1], ends[i], stride, x, y)\n ) {\n return false;\n }\n }\n return true;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\nexport function linearRingssContainsXY(\n flatCoordinates,\n offset,\n endss,\n stride,\n x,\n y\n) {\n if (endss.length === 0) {\n return false;\n }\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {\n return true;\n }\n offset = ends[ends.length - 1];\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/intersectsextent\n */\nimport {\n containsExtent,\n createEmpty,\n extendFlatCoordinates,\n intersects,\n intersectsSegment,\n} from '../../extent.js';\nimport {forEach as forEachSegment} from './segments.js';\nimport {linearRingContainsExtent, linearRingContainsXY} from './contains.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLineString(\n flatCoordinates,\n offset,\n end,\n stride,\n extent\n) {\n const coordinatesExtent = extendFlatCoordinates(\n createEmpty(),\n flatCoordinates,\n offset,\n end,\n stride\n );\n if (!intersects(extent, coordinatesExtent)) {\n return false;\n }\n if (containsExtent(extent, coordinatesExtent)) {\n return true;\n }\n if (coordinatesExtent[0] >= extent[0] && coordinatesExtent[2] <= extent[2]) {\n return true;\n }\n if (coordinatesExtent[1] >= extent[1] && coordinatesExtent[3] <= extent[3]) {\n return true;\n }\n return forEachSegment(\n flatCoordinates,\n offset,\n end,\n stride,\n /**\n * @param {import(\"../../coordinate.js\").Coordinate} point1 Start point.\n * @param {import(\"../../coordinate.js\").Coordinate} point2 End point.\n * @return {boolean} `true` if the segment and the extent intersect,\n * `false` otherwise.\n */\n function (point1, point2) {\n return intersectsSegment(extent, point1, point2);\n }\n );\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLineStringArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n extent\n) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n if (\n intersectsLineString(flatCoordinates, offset, ends[i], stride, extent)\n ) {\n return true;\n }\n offset = ends[i];\n }\n return false;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRing(\n flatCoordinates,\n offset,\n end,\n stride,\n extent\n) {\n if (intersectsLineString(flatCoordinates, offset, end, stride, extent)) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[0],\n extent[1]\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[0],\n extent[3]\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[2],\n extent[1]\n )\n ) {\n return true;\n }\n if (\n linearRingContainsXY(\n flatCoordinates,\n offset,\n end,\n stride,\n extent[2],\n extent[3]\n )\n ) {\n return true;\n }\n return false;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRingArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n extent\n) {\n if (!intersectsLinearRing(flatCoordinates, offset, ends[0], stride, extent)) {\n return false;\n }\n if (ends.length === 1) {\n return true;\n }\n for (let i = 1, ii = ends.length; i < ii; ++i) {\n if (\n linearRingContainsExtent(\n flatCoordinates,\n ends[i - 1],\n ends[i],\n stride,\n extent\n )\n ) {\n if (\n !intersectsLineString(\n flatCoordinates,\n ends[i - 1],\n ends[i],\n stride,\n extent\n )\n ) {\n return false;\n }\n }\n }\n return true;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {import(\"../../extent.js\").Extent} extent Extent.\n * @return {boolean} True if the geometry and the extent intersect.\n */\nexport function intersectsLinearRingMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n extent\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (\n intersectsLinearRingArray(flatCoordinates, offset, ends, stride, extent)\n ) {\n return true;\n }\n offset = ends[ends.length - 1];\n }\n return false;\n}\n","/**\n * @module ol/geom/flat/length\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Length.\n */\nexport function lineStringLength(flatCoordinates, offset, end, stride) {\n let x1 = flatCoordinates[offset];\n let y1 = flatCoordinates[offset + 1];\n let length = 0;\n for (let i = offset + stride; i < end; i += stride) {\n const x2 = flatCoordinates[i];\n const y2 = flatCoordinates[i + 1];\n length += Math.sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));\n x1 = x2;\n y1 = y2;\n }\n return length;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Perimeter.\n */\nexport function linearRingLength(flatCoordinates, offset, end, stride) {\n let perimeter = lineStringLength(flatCoordinates, offset, end, stride);\n const dx = flatCoordinates[end - stride] - flatCoordinates[offset];\n const dy = flatCoordinates[end - stride + 1] - flatCoordinates[offset + 1];\n perimeter += Math.sqrt(dx * dx + dy * dy);\n return perimeter;\n}\n","/**\n * @module ol/geom/LineString\n */\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport {deflateCoordinates} from './flat/deflate.js';\nimport {douglasPeucker} from './flat/simplify.js';\nimport {extend} from '../array.js';\nimport {forEach as forEachSegment} from './flat/segments.js';\nimport {inflateCoordinates} from './flat/inflate.js';\nimport {interpolatePoint, lineStringCoordinateAtM} from './flat/interpolate.js';\nimport {intersectsLineString} from './flat/intersectsextent.js';\nimport {lineStringLength} from './flat/length.js';\n\n/**\n * @classdesc\n * Linestring geometry.\n *\n * @api\n */\nclass LineString extends SimpleGeometry {\n /**\n * @param {Array|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n\n /**\n * @private\n * @type {import(\"../coordinate.js\").Coordinate}\n */\n this.flatMidpoint_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.flatMidpointRevision_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n if (layout !== undefined && !Array.isArray(coordinates[0])) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates)\n );\n } else {\n this.setCoordinates(\n /** @type {Array} */ (\n coordinates\n ),\n layout\n );\n }\n }\n\n /**\n * Append the passed coordinate to the coordinates of the linestring.\n * @param {import(\"../coordinate.js\").Coordinate} coordinate Coordinate.\n * @api\n */\n appendCoordinate(coordinate) {\n if (!this.flatCoordinates) {\n this.flatCoordinates = coordinate.slice();\n } else {\n extend(this.flatCoordinates, coordinate);\n }\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!LineString} Clone.\n * @api\n */\n clone() {\n const lineString = new LineString(\n this.flatCoordinates.slice(),\n this.layout\n );\n lineString.applyProperties(this);\n return lineString;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n maxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n 0\n )\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestPoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n this.maxDelta_,\n false,\n x,\n y,\n closestPoint,\n minSquaredDistance\n );\n }\n\n /**\n * Iterate over each segment, calling the provided callback.\n * If the callback returns a truthy value the function returns that\n * value immediately. Otherwise the function returns `false`.\n *\n * @param {function(this: S, import(\"../coordinate.js\").Coordinate, import(\"../coordinate.js\").Coordinate): T} callback Function\n * called for each segment. The function will receive two arguments, the start and end coordinates of the segment.\n * @return {T|boolean} Value.\n * @template T,S\n * @api\n */\n forEachSegment(callback) {\n return forEachSegment(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n callback\n );\n }\n\n /**\n * Returns the coordinate at `m` using linear interpolation, or `null` if no\n * such coordinate exists.\n *\n * `extrapolate` controls extrapolation beyond the range of Ms in the\n * MultiLineString. If `extrapolate` is `true` then Ms less than the first\n * M will return the first coordinate and Ms greater than the last M will\n * return the last coordinate.\n *\n * @param {number} m M.\n * @param {boolean} [extrapolate] Extrapolate. Default is `false`.\n * @return {import(\"../coordinate.js\").Coordinate|null} Coordinate.\n * @api\n */\n getCoordinateAtM(m, extrapolate) {\n if (this.layout != 'XYM' && this.layout != 'XYZM') {\n return null;\n }\n extrapolate = extrapolate !== undefined ? extrapolate : false;\n return lineStringCoordinateAtM(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n m,\n extrapolate\n );\n }\n\n /**\n * Return the coordinates of the linestring.\n * @return {Array} Coordinates.\n * @api\n */\n getCoordinates() {\n return inflateCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride\n );\n }\n\n /**\n * Return the coordinate at the provided fraction along the linestring.\n * The `fraction` is a number between 0 and 1, where 0 is the start of the\n * linestring and 1 is the end.\n * @param {number} fraction Fraction.\n * @param {import(\"../coordinate.js\").Coordinate} [dest] Optional coordinate whose values will\n * be modified. If not provided, a new coordinate will be returned.\n * @return {import(\"../coordinate.js\").Coordinate} Coordinate of the interpolated point.\n * @api\n */\n getCoordinateAt(fraction, dest) {\n return interpolatePoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n fraction,\n dest,\n this.stride\n );\n }\n\n /**\n * Return the length of the linestring on projected plane.\n * @return {number} Length (on projected plane).\n * @api\n */\n getLength() {\n return lineStringLength(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride\n );\n }\n\n /**\n * @return {Array} Flat midpoint.\n */\n getFlatMidpoint() {\n if (this.flatMidpointRevision_ != this.getRevision()) {\n this.flatMidpoint_ = this.getCoordinateAt(0.5, this.flatMidpoint_);\n this.flatMidpointRevision_ = this.getRevision();\n }\n return this.flatMidpoint_;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {LineString} Simplified LineString.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n const simplifiedFlatCoordinates = [];\n simplifiedFlatCoordinates.length = douglasPeucker(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0\n );\n return new LineString(simplifiedFlatCoordinates, 'XY');\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'LineString';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return intersectsLineString(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n extent\n );\n }\n\n /**\n * Set the coordinates of the linestring.\n * @param {!Array} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 1);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinates(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride\n );\n this.changed();\n }\n}\n\nexport default LineString;\n","/**\n * @module ol/geom/MultiLineString\n */\nimport LineString from './LineString.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {arrayMaxSquaredDelta, assignClosestArrayPoint} from './flat/closest.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport {deflateCoordinatesArray} from './flat/deflate.js';\nimport {douglasPeuckerArray} from './flat/simplify.js';\nimport {extend} from '../array.js';\nimport {inflateCoordinatesArray} from './flat/inflate.js';\nimport {\n interpolatePoint,\n lineStringsCoordinateAtM,\n} from './flat/interpolate.js';\nimport {intersectsLineStringArray} from './flat/intersectsextent.js';\n\n/**\n * @classdesc\n * Multi-linestring geometry.\n *\n * @api\n */\nclass MultiLineString extends SimpleGeometry {\n /**\n * @param {Array|LineString>|Array} coordinates\n * Coordinates or LineString geometries. (For internal use, flat coordinates in\n * combination with `layout` and `ends` are also accepted.)\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @param {Array} [ends] Flat coordinate ends for internal use.\n */\n constructor(coordinates, layout, ends) {\n super();\n\n /**\n * @type {Array}\n * @private\n */\n this.ends_ = [];\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n if (Array.isArray(coordinates[0])) {\n this.setCoordinates(\n /** @type {Array>} */ (\n coordinates\n ),\n layout\n );\n } else if (layout !== undefined && ends) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates)\n );\n this.ends_ = ends;\n } else {\n let layout = this.getLayout();\n const lineStrings = /** @type {Array} */ (coordinates);\n const flatCoordinates = [];\n const ends = [];\n for (let i = 0, ii = lineStrings.length; i < ii; ++i) {\n const lineString = lineStrings[i];\n if (i === 0) {\n layout = lineString.getLayout();\n }\n extend(flatCoordinates, lineString.getFlatCoordinates());\n ends.push(flatCoordinates.length);\n }\n this.setFlatCoordinates(layout, flatCoordinates);\n this.ends_ = ends;\n }\n }\n\n /**\n * Append the passed linestring to the multilinestring.\n * @param {LineString} lineString LineString.\n * @api\n */\n appendLineString(lineString) {\n if (!this.flatCoordinates) {\n this.flatCoordinates = lineString.getFlatCoordinates().slice();\n } else {\n extend(this.flatCoordinates, lineString.getFlatCoordinates().slice());\n }\n this.ends_.push(this.flatCoordinates.length);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!MultiLineString} Clone.\n * @api\n */\n clone() {\n const multiLineString = new MultiLineString(\n this.flatCoordinates.slice(),\n this.layout,\n this.ends_.slice()\n );\n multiLineString.applyProperties(this);\n return multiLineString;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n arrayMaxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n 0\n )\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestArrayPoint(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n this.maxDelta_,\n false,\n x,\n y,\n closestPoint,\n minSquaredDistance\n );\n }\n\n /**\n * Returns the coordinate at `m` using linear interpolation, or `null` if no\n * such coordinate exists.\n *\n * `extrapolate` controls extrapolation beyond the range of Ms in the\n * MultiLineString. If `extrapolate` is `true` then Ms less than the first\n * M will return the first coordinate and Ms greater than the last M will\n * return the last coordinate.\n *\n * `interpolate` controls interpolation between consecutive LineStrings\n * within the MultiLineString. If `interpolate` is `true` the coordinates\n * will be linearly interpolated between the last coordinate of one LineString\n * and the first coordinate of the next LineString. If `interpolate` is\n * `false` then the function will return `null` for Ms falling between\n * LineStrings.\n *\n * @param {number} m M.\n * @param {boolean} [extrapolate] Extrapolate. Default is `false`.\n * @param {boolean} [interpolate] Interpolate. Default is `false`.\n * @return {import(\"../coordinate.js\").Coordinate|null} Coordinate.\n * @api\n */\n getCoordinateAtM(m, extrapolate, interpolate) {\n if (\n (this.layout != 'XYM' && this.layout != 'XYZM') ||\n this.flatCoordinates.length === 0\n ) {\n return null;\n }\n extrapolate = extrapolate !== undefined ? extrapolate : false;\n interpolate = interpolate !== undefined ? interpolate : false;\n return lineStringsCoordinateAtM(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n m,\n extrapolate,\n interpolate\n );\n }\n\n /**\n * Return the coordinates of the multilinestring.\n * @return {Array>} Coordinates.\n * @api\n */\n getCoordinates() {\n return inflateCoordinatesArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride\n );\n }\n\n /**\n * @return {Array} Ends.\n */\n getEnds() {\n return this.ends_;\n }\n\n /**\n * Return the linestring at the specified index.\n * @param {number} index Index.\n * @return {LineString} LineString.\n * @api\n */\n getLineString(index) {\n if (index < 0 || this.ends_.length <= index) {\n return null;\n }\n return new LineString(\n this.flatCoordinates.slice(\n index === 0 ? 0 : this.ends_[index - 1],\n this.ends_[index]\n ),\n this.layout\n );\n }\n\n /**\n * Return the linestrings of this multilinestring.\n * @return {Array} LineStrings.\n * @api\n */\n getLineStrings() {\n const flatCoordinates = this.flatCoordinates;\n const ends = this.ends_;\n const layout = this.layout;\n /** @type {Array} */\n const lineStrings = [];\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const lineString = new LineString(\n flatCoordinates.slice(offset, end),\n layout\n );\n lineStrings.push(lineString);\n offset = end;\n }\n return lineStrings;\n }\n\n /**\n * @return {Array} Flat midpoints.\n */\n getFlatMidpoints() {\n const midpoints = [];\n const flatCoordinates = this.flatCoordinates;\n let offset = 0;\n const ends = this.ends_;\n const stride = this.stride;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const midpoint = interpolatePoint(\n flatCoordinates,\n offset,\n end,\n stride,\n 0.5\n );\n extend(midpoints, midpoint);\n offset = end;\n }\n return midpoints;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {MultiLineString} Simplified MultiLineString.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n const simplifiedFlatCoordinates = [];\n const simplifiedEnds = [];\n simplifiedFlatCoordinates.length = douglasPeuckerArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0,\n simplifiedEnds\n );\n return new MultiLineString(simplifiedFlatCoordinates, 'XY', simplifiedEnds);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'MultiLineString';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return intersectsLineStringArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n extent\n );\n }\n\n /**\n * Set the coordinates of the multilinestring.\n * @param {!Array>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 2);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n const ends = deflateCoordinatesArray(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n this.ends_\n );\n this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];\n this.changed();\n }\n}\n\nexport default MultiLineString;\n","/**\n * @module ol/geom/Point\n */\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {containsXY, createOrUpdateFromCoordinate} from '../extent.js';\nimport {deflateCoordinate} from './flat/deflate.js';\nimport {squaredDistance as squaredDx} from '../math.js';\n\n/**\n * @classdesc\n * Point geometry.\n *\n * @api\n */\nclass Point extends SimpleGeometry {\n /**\n * @param {import(\"../coordinate.js\").Coordinate} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n this.setCoordinates(coordinates, layout);\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!Point} Clone.\n * @api\n */\n clone() {\n const point = new Point(this.flatCoordinates.slice(), this.layout);\n point.applyProperties(this);\n return point;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n const flatCoordinates = this.flatCoordinates;\n const squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[0],\n flatCoordinates[1]\n );\n if (squaredDistance < minSquaredDistance) {\n const stride = this.stride;\n for (let i = 0; i < stride; ++i) {\n closestPoint[i] = flatCoordinates[i];\n }\n closestPoint.length = stride;\n return squaredDistance;\n }\n return minSquaredDistance;\n }\n\n /**\n * Return the coordinate of the point.\n * @return {import(\"../coordinate.js\").Coordinate} Coordinates.\n * @api\n */\n getCoordinates() {\n return !this.flatCoordinates ? [] : this.flatCoordinates.slice();\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n return createOrUpdateFromCoordinate(this.flatCoordinates, extent);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'Point';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return containsXY(extent, this.flatCoordinates[0], this.flatCoordinates[1]);\n }\n\n /**\n * @param {!Array<*>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 0);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinate(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride\n );\n this.changed();\n }\n}\n\nexport default Point;\n","/**\n * @module ol/geom/MultiPoint\n */\nimport Point from './Point.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {closestSquaredDistanceXY, containsXY} from '../extent.js';\nimport {deflateCoordinates} from './flat/deflate.js';\nimport {extend} from '../array.js';\nimport {inflateCoordinates} from './flat/inflate.js';\nimport {squaredDistance as squaredDx} from '../math.js';\n\n/**\n * @classdesc\n * Multi-point geometry.\n *\n * @api\n */\nclass MultiPoint extends SimpleGeometry {\n /**\n * @param {Array|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n if (layout && !Array.isArray(coordinates[0])) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates)\n );\n } else {\n this.setCoordinates(\n /** @type {Array} */ (\n coordinates\n ),\n layout\n );\n }\n }\n\n /**\n * Append the passed point to this multipoint.\n * @param {Point} point Point.\n * @api\n */\n appendPoint(point) {\n if (!this.flatCoordinates) {\n this.flatCoordinates = point.getFlatCoordinates().slice();\n } else {\n extend(this.flatCoordinates, point.getFlatCoordinates());\n }\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!MultiPoint} Clone.\n * @api\n */\n clone() {\n const multiPoint = new MultiPoint(\n this.flatCoordinates.slice(),\n this.layout\n );\n multiPoint.applyProperties(this);\n return multiPoint;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n const flatCoordinates = this.flatCoordinates;\n const stride = this.stride;\n for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {\n const squaredDistance = squaredDx(\n x,\n y,\n flatCoordinates[i],\n flatCoordinates[i + 1]\n );\n if (squaredDistance < minSquaredDistance) {\n minSquaredDistance = squaredDistance;\n for (let j = 0; j < stride; ++j) {\n closestPoint[j] = flatCoordinates[i + j];\n }\n closestPoint.length = stride;\n }\n }\n return minSquaredDistance;\n }\n\n /**\n * Return the coordinates of the multipoint.\n * @return {Array} Coordinates.\n * @api\n */\n getCoordinates() {\n return inflateCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride\n );\n }\n\n /**\n * Return the point at the specified index.\n * @param {number} index Index.\n * @return {Point} Point.\n * @api\n */\n getPoint(index) {\n const n = !this.flatCoordinates\n ? 0\n : this.flatCoordinates.length / this.stride;\n if (index < 0 || n <= index) {\n return null;\n }\n return new Point(\n this.flatCoordinates.slice(\n index * this.stride,\n (index + 1) * this.stride\n ),\n this.layout\n );\n }\n\n /**\n * Return the points of this multipoint.\n * @return {Array} Points.\n * @api\n */\n getPoints() {\n const flatCoordinates = this.flatCoordinates;\n const layout = this.layout;\n const stride = this.stride;\n /** @type {Array} */\n const points = [];\n for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {\n const point = new Point(flatCoordinates.slice(i, i + stride), layout);\n points.push(point);\n }\n return points;\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'MultiPoint';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n const flatCoordinates = this.flatCoordinates;\n const stride = this.stride;\n for (let i = 0, ii = flatCoordinates.length; i < ii; i += stride) {\n const x = flatCoordinates[i];\n const y = flatCoordinates[i + 1];\n if (containsXY(extent, x, y)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * Set the coordinates of the multipoint.\n * @param {!Array} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 1);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinates(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride\n );\n this.changed();\n }\n}\n\nexport default MultiPoint;\n","/**\n * @module ol/geom/flat/area\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRing(flatCoordinates, offset, end, stride) {\n let twiceArea = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n twiceArea += y1 * x2 - x1 * y2;\n x1 = x2;\n y1 = y2;\n }\n return twiceArea / 2;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRings(flatCoordinates, offset, ends, stride) {\n let area = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n area += linearRing(flatCoordinates, offset, end, stride);\n offset = end;\n }\n return area;\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @return {number} Area.\n */\nexport function linearRingss(flatCoordinates, offset, endss, stride) {\n let area = 0;\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n area += linearRings(flatCoordinates, offset, ends, stride);\n offset = ends[ends.length - 1];\n }\n return area;\n}\n","/**\n * @module ol/geom/LinearRing\n */\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {assignClosestPoint, maxSquaredDelta} from './flat/closest.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport {deflateCoordinates} from './flat/deflate.js';\nimport {douglasPeucker} from './flat/simplify.js';\nimport {inflateCoordinates} from './flat/inflate.js';\nimport {linearRing as linearRingArea} from './flat/area.js';\n\n/**\n * @classdesc\n * Linear ring geometry. Only used as part of polygon; cannot be rendered\n * on its own.\n *\n * @api\n */\nclass LinearRing extends SimpleGeometry {\n /**\n * @param {Array|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n */\n constructor(coordinates, layout) {\n super();\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n if (layout !== undefined && !Array.isArray(coordinates[0])) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates)\n );\n } else {\n this.setCoordinates(\n /** @type {Array} */ (\n coordinates\n ),\n layout\n );\n }\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!LinearRing} Clone.\n * @api\n */\n clone() {\n return new LinearRing(this.flatCoordinates.slice(), this.layout);\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n maxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n 0\n )\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestPoint(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance\n );\n }\n\n /**\n * Return the area of the linear ring on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingArea(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride\n );\n }\n\n /**\n * Return the coordinates of the linear ring.\n * @return {Array} Coordinates.\n * @api\n */\n getCoordinates() {\n return inflateCoordinates(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride\n );\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {LinearRing} Simplified LinearRing.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n const simplifiedFlatCoordinates = [];\n simplifiedFlatCoordinates.length = douglasPeucker(\n this.flatCoordinates,\n 0,\n this.flatCoordinates.length,\n this.stride,\n squaredTolerance,\n simplifiedFlatCoordinates,\n 0\n );\n return new LinearRing(simplifiedFlatCoordinates, 'XY');\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'LinearRing';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return false;\n }\n\n /**\n * Set the coordinates of the linear ring.\n * @param {!Array} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 1);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n this.flatCoordinates.length = deflateCoordinates(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride\n );\n this.changed();\n }\n}\n\nexport default LinearRing;\n","/**\n * @module ol/geom/flat/interiorpoint\n */\nimport {ascending} from '../../array.js';\nimport {linearRingsContainsXY} from './contains.js';\n\n/**\n * Calculates a point that is likely to lie in the interior of the linear rings.\n * Inspired by JTS's com.vividsolutions.jts.geom.Geometry#getInteriorPoint.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {Array} flatCenters Flat centers.\n * @param {number} flatCentersOffset Flat center offset.\n * @param {Array} [dest] Destination.\n * @return {Array} Destination point as XYM coordinate, where M is the\n * length of the horizontal intersection that the point belongs to.\n */\nexport function getInteriorPointOfArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n flatCenters,\n flatCentersOffset,\n dest\n) {\n let i, ii, x, x1, x2, y1, y2;\n const y = flatCenters[flatCentersOffset + 1];\n /** @type {Array} */\n const intersections = [];\n // Calculate intersections with the horizontal line\n for (let r = 0, rr = ends.length; r < rr; ++r) {\n const end = ends[r];\n x1 = flatCoordinates[end - stride];\n y1 = flatCoordinates[end - stride + 1];\n for (i = offset; i < end; i += stride) {\n x2 = flatCoordinates[i];\n y2 = flatCoordinates[i + 1];\n if ((y <= y1 && y2 <= y) || (y1 <= y && y <= y2)) {\n x = ((y - y1) / (y2 - y1)) * (x2 - x1) + x1;\n intersections.push(x);\n }\n x1 = x2;\n y1 = y2;\n }\n }\n // Find the longest segment of the horizontal line that has its center point\n // inside the linear ring.\n let pointX = NaN;\n let maxSegmentLength = -Infinity;\n intersections.sort(ascending);\n x1 = intersections[0];\n for (i = 1, ii = intersections.length; i < ii; ++i) {\n x2 = intersections[i];\n const segmentLength = Math.abs(x2 - x1);\n if (segmentLength > maxSegmentLength) {\n x = (x1 + x2) / 2;\n if (linearRingsContainsXY(flatCoordinates, offset, ends, stride, x, y)) {\n pointX = x;\n maxSegmentLength = segmentLength;\n }\n }\n x1 = x2;\n }\n if (isNaN(pointX)) {\n // There is no horizontal line that has its center point inside the linear\n // ring. Use the center of the the linear ring's extent.\n pointX = flatCenters[flatCentersOffset];\n }\n if (dest) {\n dest.push(pointX, y, maxSegmentLength);\n return dest;\n }\n return [pointX, y, maxSegmentLength];\n}\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @param {Array} flatCenters Flat centers.\n * @return {Array} Interior points as XYM coordinates, where M is the\n * length of the horizontal intersection that the point belongs to.\n */\nexport function getInteriorPointsOfMultiArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n flatCenters\n) {\n let interiorPoints = [];\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n interiorPoints = getInteriorPointOfArray(\n flatCoordinates,\n offset,\n ends,\n stride,\n flatCenters,\n 2 * i,\n interiorPoints\n );\n offset = ends[ends.length - 1];\n }\n return interiorPoints;\n}\n","/**\n * @module ol/geom/flat/reverse\n */\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n */\nexport function coordinates(flatCoordinates, offset, end, stride) {\n while (offset < end - stride) {\n for (let i = 0; i < stride; ++i) {\n const tmp = flatCoordinates[offset + i];\n flatCoordinates[offset + i] = flatCoordinates[end - stride + i];\n flatCoordinates[end - stride + i] = tmp;\n }\n offset += stride;\n end -= stride;\n }\n}\n","/**\n * @module ol/geom/flat/orient\n */\nimport {coordinates as reverseCoordinates} from './reverse.js';\n\n/**\n * Is the linear ring oriented clockwise in a coordinate system with a bottom-left\n * coordinate origin? For a coordinate system with a top-left coordinate origin,\n * the ring's orientation is clockwise when this function returns false.\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {number} end End.\n * @param {number} stride Stride.\n * @return {boolean} Is clockwise.\n */\nexport function linearRingIsClockwise(flatCoordinates, offset, end, stride) {\n // https://stackoverflow.com/q/1165647/clockwise-method#1165943\n // https://github.com/OSGeo/gdal/blob/master/gdal/ogr/ogrlinearring.cpp\n let edge = 0;\n let x1 = flatCoordinates[end - stride];\n let y1 = flatCoordinates[end - stride + 1];\n for (; offset < end; offset += stride) {\n const x2 = flatCoordinates[offset];\n const y2 = flatCoordinates[offset + 1];\n edge += (x2 - x1) * (y2 + y1);\n x1 = x2;\n y1 = y2;\n }\n return edge === 0 ? undefined : edge > 0;\n}\n\n/**\n * Determines if linear rings are oriented. By default, left-hand orientation\n * is tested (first ring must be clockwise, remaining rings counter-clockwise).\n * To test for right-hand orientation, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Test for right-hand orientation\n * (counter-clockwise exterior ring and clockwise interior rings).\n * @return {boolean} Rings are correctly oriented.\n */\nexport function linearRingsAreOriented(\n flatCoordinates,\n offset,\n ends,\n stride,\n right\n) {\n right = right !== undefined ? right : false;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const isClockwise = linearRingIsClockwise(\n flatCoordinates,\n offset,\n end,\n stride\n );\n if (i === 0) {\n if ((right && isClockwise) || (!right && !isClockwise)) {\n return false;\n }\n } else {\n if ((right && !isClockwise) || (!right && isClockwise)) {\n return false;\n }\n }\n offset = end;\n }\n return true;\n}\n\n/**\n * Determines if linear rings are oriented. By default, left-hand orientation\n * is tested (first ring must be clockwise, remaining rings counter-clockwise).\n * To test for right-hand orientation, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Array of array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Test for right-hand orientation\n * (counter-clockwise exterior ring and clockwise interior rings).\n * @return {boolean} Rings are correctly oriented.\n */\nexport function linearRingssAreOriented(\n flatCoordinates,\n offset,\n endss,\n stride,\n right\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n if (!linearRingsAreOriented(flatCoordinates, offset, ends, stride, right)) {\n return false;\n }\n if (ends.length) {\n offset = ends[ends.length - 1];\n }\n }\n return true;\n}\n\n/**\n * Orient coordinates in a flat array of linear rings. By default, rings\n * are oriented following the left-hand rule (clockwise for exterior and\n * counter-clockwise for interior rings). To orient according to the\n * right-hand rule, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array} ends Ends.\n * @param {number} stride Stride.\n * @param {boolean} [right] Follow the right-hand rule for orientation.\n * @return {number} End.\n */\nexport function orientLinearRings(\n flatCoordinates,\n offset,\n ends,\n stride,\n right\n) {\n right = right !== undefined ? right : false;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const isClockwise = linearRingIsClockwise(\n flatCoordinates,\n offset,\n end,\n stride\n );\n const reverse =\n i === 0\n ? (right && isClockwise) || (!right && !isClockwise)\n : (right && !isClockwise) || (!right && isClockwise);\n if (reverse) {\n reverseCoordinates(flatCoordinates, offset, end, stride);\n }\n offset = end;\n }\n return offset;\n}\n\n/**\n * Orient coordinates in a flat array of linear rings. By default, rings\n * are oriented following the left-hand rule (clockwise for exterior and\n * counter-clockwise for interior rings). To orient according to the\n * right-hand rule, use the `right` argument.\n *\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Array of array of end indexes.\n * @param {number} stride Stride.\n * @param {boolean} [right] Follow the right-hand rule for orientation.\n * @return {number} End.\n */\nexport function orientLinearRingsArray(\n flatCoordinates,\n offset,\n endss,\n stride,\n right\n) {\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n offset = orientLinearRings(\n flatCoordinates,\n offset,\n endss[i],\n stride,\n right\n );\n }\n return offset;\n}\n\n/**\n * Return a two-dimensional endss\n * @param {Array} flatCoordinates Flat coordinates\n * @param {Array} ends Linear ring end indexes\n * @return {Array>} Two dimensional endss array that can\n * be used to construct a MultiPolygon\n */\nexport function inflateEnds(flatCoordinates, ends) {\n const endss = [];\n let offset = 0;\n let prevEndIndex = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n // classifies an array of rings into polygons with outer rings and holes\n if (!linearRingIsClockwise(flatCoordinates, offset, end, 2)) {\n endss.push(ends.slice(prevEndIndex, i + 1));\n } else {\n if (endss.length === 0) {\n continue;\n }\n endss[endss.length - 1].push(ends[prevEndIndex]);\n }\n prevEndIndex = i + 1;\n offset = end;\n }\n return endss;\n}\n","/**\n * @module ol/geom/Polygon\n */\nimport LinearRing from './LinearRing.js';\nimport Point from './Point.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {arrayMaxSquaredDelta, assignClosestArrayPoint} from './flat/closest.js';\nimport {closestSquaredDistanceXY, getCenter, isEmpty} from '../extent.js';\nimport {deflateCoordinatesArray} from './flat/deflate.js';\nimport {extend} from '../array.js';\nimport {getInteriorPointOfArray} from './flat/interiorpoint.js';\nimport {inflateCoordinatesArray} from './flat/inflate.js';\nimport {intersectsLinearRingArray} from './flat/intersectsextent.js';\nimport {linearRingsAreOriented, orientLinearRings} from './flat/orient.js';\nimport {linearRings as linearRingsArea} from './flat/area.js';\nimport {linearRingsContainsXY} from './flat/contains.js';\nimport {modulo} from '../math.js';\nimport {quantizeArray} from './flat/simplify.js';\nimport {offset as sphereOffset} from '../sphere.js';\n\n/**\n * @classdesc\n * Polygon geometry.\n *\n * @api\n */\nclass Polygon extends SimpleGeometry {\n /**\n * @param {!Array>|!Array} coordinates\n * Array of linear rings that define the polygon. The first linear ring of the\n * array defines the outer-boundary or surface of the polygon. Each subsequent\n * linear ring defines a hole in the surface of the polygon. A linear ring is\n * an array of vertices' coordinates where the first coordinate and the last are\n * equivalent. (For internal use, flat coordinates in combination with\n * `layout` and `ends` are also accepted.)\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @param {Array} [ends] Ends (for internal use with flat coordinates).\n */\n constructor(coordinates, layout, ends) {\n super();\n\n /**\n * @type {Array}\n * @private\n */\n this.ends_ = [];\n\n /**\n * @private\n * @type {number}\n */\n this.flatInteriorPointRevision_ = -1;\n\n /**\n * @private\n * @type {import(\"../coordinate.js\").Coordinate}\n */\n this.flatInteriorPoint_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.orientedRevision_ = -1;\n\n /**\n * @private\n * @type {Array}\n */\n this.orientedFlatCoordinates_ = null;\n\n if (layout !== undefined && ends) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates)\n );\n this.ends_ = ends;\n } else {\n this.setCoordinates(\n /** @type {Array>} */ (\n coordinates\n ),\n layout\n );\n }\n }\n\n /**\n * Append the passed linear ring to this polygon.\n * @param {LinearRing} linearRing Linear ring.\n * @api\n */\n appendLinearRing(linearRing) {\n if (!this.flatCoordinates) {\n this.flatCoordinates = linearRing.getFlatCoordinates().slice();\n } else {\n extend(this.flatCoordinates, linearRing.getFlatCoordinates());\n }\n this.ends_.push(this.flatCoordinates.length);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!Polygon} Clone.\n * @api\n */\n clone() {\n const polygon = new Polygon(\n this.flatCoordinates.slice(),\n this.layout,\n this.ends_.slice()\n );\n polygon.applyProperties(this);\n return polygon;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n arrayMaxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n 0\n )\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestArrayPoint(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance\n );\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\n containsXY(x, y) {\n return linearRingsContainsXY(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n x,\n y\n );\n }\n\n /**\n * Return the area of the polygon on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingsArea(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride\n );\n }\n\n /**\n * Get the coordinate array for this geometry. This array has the structure\n * of a GeoJSON coordinate array for polygons.\n *\n * @param {boolean} [right] Orient coordinates according to the right-hand\n * rule (counter-clockwise for exterior and clockwise for interior rings).\n * If `false`, coordinates will be oriented according to the left-hand rule\n * (clockwise for exterior and counter-clockwise for interior rings).\n * By default, coordinate orientation will depend on how the geometry was\n * constructed.\n * @return {Array>} Coordinates.\n * @api\n */\n getCoordinates(right) {\n let flatCoordinates;\n if (right !== undefined) {\n flatCoordinates = this.getOrientedFlatCoordinates().slice();\n orientLinearRings(flatCoordinates, 0, this.ends_, this.stride, right);\n } else {\n flatCoordinates = this.flatCoordinates;\n }\n\n return inflateCoordinatesArray(flatCoordinates, 0, this.ends_, this.stride);\n }\n\n /**\n * @return {Array} Ends.\n */\n getEnds() {\n return this.ends_;\n }\n\n /**\n * @return {Array} Interior point.\n */\n getFlatInteriorPoint() {\n if (this.flatInteriorPointRevision_ != this.getRevision()) {\n const flatCenter = getCenter(this.getExtent());\n this.flatInteriorPoint_ = getInteriorPointOfArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n flatCenter,\n 0\n );\n this.flatInteriorPointRevision_ = this.getRevision();\n }\n return this.flatInteriorPoint_;\n }\n\n /**\n * Return an interior point of the polygon.\n * @return {Point} Interior point as XYM coordinate, where M is the\n * length of the horizontal intersection that the point belongs to.\n * @api\n */\n getInteriorPoint() {\n return new Point(this.getFlatInteriorPoint(), 'XYM');\n }\n\n /**\n * Return the number of rings of the polygon, this includes the exterior\n * ring and any interior rings.\n *\n * @return {number} Number of rings.\n * @api\n */\n getLinearRingCount() {\n return this.ends_.length;\n }\n\n /**\n * Return the Nth linear ring of the polygon geometry. Return `null` if the\n * given index is out of range.\n * The exterior linear ring is available at index `0` and the interior rings\n * at index `1` and beyond.\n *\n * @param {number} index Index.\n * @return {LinearRing|null} Linear ring.\n * @api\n */\n getLinearRing(index) {\n if (index < 0 || this.ends_.length <= index) {\n return null;\n }\n return new LinearRing(\n this.flatCoordinates.slice(\n index === 0 ? 0 : this.ends_[index - 1],\n this.ends_[index]\n ),\n this.layout\n );\n }\n\n /**\n * Return the linear rings of the polygon.\n * @return {Array} Linear rings.\n * @api\n */\n getLinearRings() {\n const layout = this.layout;\n const flatCoordinates = this.flatCoordinates;\n const ends = this.ends_;\n const linearRings = [];\n let offset = 0;\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const linearRing = new LinearRing(\n flatCoordinates.slice(offset, end),\n layout\n );\n linearRings.push(linearRing);\n offset = end;\n }\n return linearRings;\n }\n\n /**\n * @return {Array} Oriented flat coordinates.\n */\n getOrientedFlatCoordinates() {\n if (this.orientedRevision_ != this.getRevision()) {\n const flatCoordinates = this.flatCoordinates;\n if (linearRingsAreOriented(flatCoordinates, 0, this.ends_, this.stride)) {\n this.orientedFlatCoordinates_ = flatCoordinates;\n } else {\n this.orientedFlatCoordinates_ = flatCoordinates.slice();\n this.orientedFlatCoordinates_.length = orientLinearRings(\n this.orientedFlatCoordinates_,\n 0,\n this.ends_,\n this.stride\n );\n }\n this.orientedRevision_ = this.getRevision();\n }\n return this.orientedFlatCoordinates_;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {Polygon} Simplified Polygon.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n const simplifiedFlatCoordinates = [];\n const simplifiedEnds = [];\n simplifiedFlatCoordinates.length = quantizeArray(\n this.flatCoordinates,\n 0,\n this.ends_,\n this.stride,\n Math.sqrt(squaredTolerance),\n simplifiedFlatCoordinates,\n 0,\n simplifiedEnds\n );\n return new Polygon(simplifiedFlatCoordinates, 'XY', simplifiedEnds);\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'Polygon';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return intersectsLinearRingArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.ends_,\n this.stride,\n extent\n );\n }\n\n /**\n * Set the coordinates of the polygon.\n * @param {!Array>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 2);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n const ends = deflateCoordinatesArray(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n this.ends_\n );\n this.flatCoordinates.length = ends.length === 0 ? 0 : ends[ends.length - 1];\n this.changed();\n }\n}\n\nexport default Polygon;\n\n/**\n * Create an approximation of a circle on the surface of a sphere.\n * @param {import(\"../coordinate.js\").Coordinate} center Center (`[lon, lat]` in degrees).\n * @param {number} radius The great-circle distance from the center to\n * the polygon vertices in meters.\n * @param {number} [n] Optional number of vertices for the resulting\n * polygon. Default is `32`.\n * @param {number} [sphereRadius] Optional radius for the sphere (defaults to\n * the Earth's mean radius using the WGS84 ellipsoid).\n * @return {Polygon} The \"circular\" polygon.\n * @api\n */\nexport function circular(center, radius, n, sphereRadius) {\n n = n ? n : 32;\n /** @type {Array} */\n const flatCoordinates = [];\n for (let i = 0; i < n; ++i) {\n extend(\n flatCoordinates,\n sphereOffset(center, radius, (2 * Math.PI * i) / n, sphereRadius)\n );\n }\n flatCoordinates.push(flatCoordinates[0], flatCoordinates[1]);\n return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);\n}\n\n/**\n * Create a polygon from an extent. The layout used is `XY`.\n * @param {import(\"../extent.js\").Extent} extent The extent.\n * @return {Polygon} The polygon.\n * @api\n */\nexport function fromExtent(extent) {\n if (isEmpty(extent)) {\n throw new Error('Cannot create polygon from empty extent');\n }\n const minX = extent[0];\n const minY = extent[1];\n const maxX = extent[2];\n const maxY = extent[3];\n const flatCoordinates = [\n minX,\n minY,\n minX,\n maxY,\n maxX,\n maxY,\n maxX,\n minY,\n minX,\n minY,\n ];\n return new Polygon(flatCoordinates, 'XY', [flatCoordinates.length]);\n}\n\n/**\n * Create a regular polygon from a circle.\n * @param {import(\"./Circle.js\").default} circle Circle geometry.\n * @param {number} [sides] Number of sides of the polygon. Default is 32.\n * @param {number} [angle] Start angle for the first vertex of the polygon in\n * counter-clockwise radians. 0 means East. Default is 0.\n * @return {Polygon} Polygon geometry.\n * @api\n */\nexport function fromCircle(circle, sides, angle) {\n sides = sides ? sides : 32;\n const stride = circle.getStride();\n const layout = circle.getLayout();\n const center = circle.getCenter();\n const arrayLength = stride * (sides + 1);\n const flatCoordinates = new Array(arrayLength);\n for (let i = 0; i < arrayLength; i += stride) {\n flatCoordinates[i] = 0;\n flatCoordinates[i + 1] = 0;\n for (let j = 2; j < stride; j++) {\n flatCoordinates[i + j] = center[j];\n }\n }\n const ends = [flatCoordinates.length];\n const polygon = new Polygon(flatCoordinates, layout, ends);\n makeRegular(polygon, center, circle.getRadius(), angle);\n return polygon;\n}\n\n/**\n * Modify the coordinates of a polygon to make it a regular polygon.\n * @param {Polygon} polygon Polygon geometry.\n * @param {import(\"../coordinate.js\").Coordinate} center Center of the regular polygon.\n * @param {number} radius Radius of the regular polygon.\n * @param {number} [angle] Start angle for the first vertex of the polygon in\n * counter-clockwise radians. 0 means East. Default is 0.\n */\nexport function makeRegular(polygon, center, radius, angle) {\n const flatCoordinates = polygon.getFlatCoordinates();\n const stride = polygon.getStride();\n const sides = flatCoordinates.length / stride - 1;\n const startAngle = angle ? angle : 0;\n for (let i = 0; i <= sides; ++i) {\n const offset = i * stride;\n const angle = startAngle + (modulo(i, sides) * 2 * Math.PI) / sides;\n flatCoordinates[offset] = center[0] + radius * Math.cos(angle);\n flatCoordinates[offset + 1] = center[1] + radius * Math.sin(angle);\n }\n polygon.changed();\n}\n","/**\n * @module ol/geom/flat/center\n */\nimport {createEmpty, createOrUpdateFromFlatCoordinates} from '../../extent.js';\n\n/**\n * @param {Array} flatCoordinates Flat coordinates.\n * @param {number} offset Offset.\n * @param {Array>} endss Endss.\n * @param {number} stride Stride.\n * @return {Array} Flat centers.\n */\nexport function linearRingss(flatCoordinates, offset, endss, stride) {\n const flatCenters = [];\n let extent = createEmpty();\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i];\n extent = createOrUpdateFromFlatCoordinates(\n flatCoordinates,\n offset,\n ends[0],\n stride\n );\n flatCenters.push((extent[0] + extent[2]) / 2, (extent[1] + extent[3]) / 2);\n offset = ends[ends.length - 1];\n }\n return flatCenters;\n}\n","/**\n * @module ol/geom/MultiPolygon\n */\nimport MultiPoint from './MultiPoint.js';\nimport Polygon from './Polygon.js';\nimport SimpleGeometry from './SimpleGeometry.js';\nimport {\n assignClosestMultiArrayPoint,\n multiArrayMaxSquaredDelta,\n} from './flat/closest.js';\nimport {closestSquaredDistanceXY} from '../extent.js';\nimport {deflateMultiCoordinatesArray} from './flat/deflate.js';\nimport {extend} from '../array.js';\nimport {getInteriorPointsOfMultiArray} from './flat/interiorpoint.js';\nimport {inflateMultiCoordinatesArray} from './flat/inflate.js';\nimport {intersectsLinearRingMultiArray} from './flat/intersectsextent.js';\nimport {\n linearRingssAreOriented,\n orientLinearRingsArray,\n} from './flat/orient.js';\nimport {linearRingss as linearRingssArea} from './flat/area.js';\nimport {linearRingss as linearRingssCenter} from './flat/center.js';\nimport {linearRingssContainsXY} from './flat/contains.js';\nimport {quantizeMultiArray} from './flat/simplify.js';\n\n/**\n * @classdesc\n * Multi-polygon geometry.\n *\n * @api\n */\nclass MultiPolygon extends SimpleGeometry {\n /**\n * @param {Array>|Polygon>|Array} coordinates Coordinates.\n * For internal use, flat coordinates in combination with `layout` and `endss` are also accepted.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @param {Array>} [endss] Array of ends for internal use with flat coordinates.\n */\n constructor(coordinates, layout, endss) {\n super();\n\n /**\n * @type {Array>}\n * @private\n */\n this.endss_ = [];\n\n /**\n * @private\n * @type {number}\n */\n this.flatInteriorPointsRevision_ = -1;\n\n /**\n * @private\n * @type {Array}\n */\n this.flatInteriorPoints_ = null;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDelta_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.maxDeltaRevision_ = -1;\n\n /**\n * @private\n * @type {number}\n */\n this.orientedRevision_ = -1;\n\n /**\n * @private\n * @type {Array}\n */\n this.orientedFlatCoordinates_ = null;\n\n if (!endss && !Array.isArray(coordinates[0])) {\n let thisLayout = this.getLayout();\n const polygons = /** @type {Array} */ (coordinates);\n const flatCoordinates = [];\n const thisEndss = [];\n for (let i = 0, ii = polygons.length; i < ii; ++i) {\n const polygon = polygons[i];\n if (i === 0) {\n thisLayout = polygon.getLayout();\n }\n const offset = flatCoordinates.length;\n const ends = polygon.getEnds();\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n ends[j] += offset;\n }\n extend(flatCoordinates, polygon.getFlatCoordinates());\n thisEndss.push(ends);\n }\n layout = thisLayout;\n coordinates = flatCoordinates;\n endss = thisEndss;\n }\n if (layout !== undefined && endss) {\n this.setFlatCoordinates(\n layout,\n /** @type {Array} */ (coordinates)\n );\n this.endss_ = endss;\n } else {\n this.setCoordinates(\n /** @type {Array>>} */ (\n coordinates\n ),\n layout\n );\n }\n }\n\n /**\n * Append the passed polygon to this multipolygon.\n * @param {Polygon} polygon Polygon.\n * @api\n */\n appendPolygon(polygon) {\n /** @type {Array} */\n let ends;\n if (!this.flatCoordinates) {\n this.flatCoordinates = polygon.getFlatCoordinates().slice();\n ends = polygon.getEnds().slice();\n this.endss_.push();\n } else {\n const offset = this.flatCoordinates.length;\n extend(this.flatCoordinates, polygon.getFlatCoordinates());\n ends = polygon.getEnds().slice();\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n ends[i] += offset;\n }\n }\n this.endss_.push(ends);\n this.changed();\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!MultiPolygon} Clone.\n * @api\n */\n clone() {\n const len = this.endss_.length;\n const newEndss = new Array(len);\n for (let i = 0; i < len; ++i) {\n newEndss[i] = this.endss_[i].slice();\n }\n\n const multiPolygon = new MultiPolygon(\n this.flatCoordinates.slice(),\n this.layout,\n newEndss\n );\n multiPolygon.applyProperties(this);\n\n return multiPolygon;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n if (this.maxDeltaRevision_ != this.getRevision()) {\n this.maxDelta_ = Math.sqrt(\n multiArrayMaxSquaredDelta(\n this.flatCoordinates,\n 0,\n this.endss_,\n this.stride,\n 0\n )\n );\n this.maxDeltaRevision_ = this.getRevision();\n }\n return assignClosestMultiArrayPoint(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride,\n this.maxDelta_,\n true,\n x,\n y,\n closestPoint,\n minSquaredDistance\n );\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\n containsXY(x, y) {\n return linearRingssContainsXY(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride,\n x,\n y\n );\n }\n\n /**\n * Return the area of the multipolygon on projected plane.\n * @return {number} Area (on projected plane).\n * @api\n */\n getArea() {\n return linearRingssArea(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride\n );\n }\n\n /**\n * Get the coordinate array for this geometry. This array has the structure\n * of a GeoJSON coordinate array for multi-polygons.\n *\n * @param {boolean} [right] Orient coordinates according to the right-hand\n * rule (counter-clockwise for exterior and clockwise for interior rings).\n * If `false`, coordinates will be oriented according to the left-hand rule\n * (clockwise for exterior and counter-clockwise for interior rings).\n * By default, coordinate orientation will depend on how the geometry was\n * constructed.\n * @return {Array>>} Coordinates.\n * @api\n */\n getCoordinates(right) {\n let flatCoordinates;\n if (right !== undefined) {\n flatCoordinates = this.getOrientedFlatCoordinates().slice();\n orientLinearRingsArray(\n flatCoordinates,\n 0,\n this.endss_,\n this.stride,\n right\n );\n } else {\n flatCoordinates = this.flatCoordinates;\n }\n\n return inflateMultiCoordinatesArray(\n flatCoordinates,\n 0,\n this.endss_,\n this.stride\n );\n }\n\n /**\n * @return {Array>} Endss.\n */\n getEndss() {\n return this.endss_;\n }\n\n /**\n * @return {Array} Flat interior points.\n */\n getFlatInteriorPoints() {\n if (this.flatInteriorPointsRevision_ != this.getRevision()) {\n const flatCenters = linearRingssCenter(\n this.flatCoordinates,\n 0,\n this.endss_,\n this.stride\n );\n this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride,\n flatCenters\n );\n this.flatInteriorPointsRevision_ = this.getRevision();\n }\n return this.flatInteriorPoints_;\n }\n\n /**\n * Return the interior points as {@link module:ol/geom/MultiPoint~MultiPoint multipoint}.\n * @return {MultiPoint} Interior points as XYM coordinates, where M is\n * the length of the horizontal intersection that the point belongs to.\n * @api\n */\n getInteriorPoints() {\n return new MultiPoint(this.getFlatInteriorPoints().slice(), 'XYM');\n }\n\n /**\n * @return {Array} Oriented flat coordinates.\n */\n getOrientedFlatCoordinates() {\n if (this.orientedRevision_ != this.getRevision()) {\n const flatCoordinates = this.flatCoordinates;\n if (\n linearRingssAreOriented(flatCoordinates, 0, this.endss_, this.stride)\n ) {\n this.orientedFlatCoordinates_ = flatCoordinates;\n } else {\n this.orientedFlatCoordinates_ = flatCoordinates.slice();\n this.orientedFlatCoordinates_.length = orientLinearRingsArray(\n this.orientedFlatCoordinates_,\n 0,\n this.endss_,\n this.stride\n );\n }\n this.orientedRevision_ = this.getRevision();\n }\n return this.orientedFlatCoordinates_;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {MultiPolygon} Simplified MultiPolygon.\n * @protected\n */\n getSimplifiedGeometryInternal(squaredTolerance) {\n const simplifiedFlatCoordinates = [];\n const simplifiedEndss = [];\n simplifiedFlatCoordinates.length = quantizeMultiArray(\n this.flatCoordinates,\n 0,\n this.endss_,\n this.stride,\n Math.sqrt(squaredTolerance),\n simplifiedFlatCoordinates,\n 0,\n simplifiedEndss\n );\n return new MultiPolygon(simplifiedFlatCoordinates, 'XY', simplifiedEndss);\n }\n\n /**\n * Return the polygon at the specified index.\n * @param {number} index Index.\n * @return {Polygon} Polygon.\n * @api\n */\n getPolygon(index) {\n if (index < 0 || this.endss_.length <= index) {\n return null;\n }\n let offset;\n if (index === 0) {\n offset = 0;\n } else {\n const prevEnds = this.endss_[index - 1];\n offset = prevEnds[prevEnds.length - 1];\n }\n const ends = this.endss_[index].slice();\n const end = ends[ends.length - 1];\n if (offset !== 0) {\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n ends[i] -= offset;\n }\n }\n return new Polygon(\n this.flatCoordinates.slice(offset, end),\n this.layout,\n ends\n );\n }\n\n /**\n * Return the polygons of this multipolygon.\n * @return {Array} Polygons.\n * @api\n */\n getPolygons() {\n const layout = this.layout;\n const flatCoordinates = this.flatCoordinates;\n const endss = this.endss_;\n const polygons = [];\n let offset = 0;\n for (let i = 0, ii = endss.length; i < ii; ++i) {\n const ends = endss[i].slice();\n const end = ends[ends.length - 1];\n if (offset !== 0) {\n for (let j = 0, jj = ends.length; j < jj; ++j) {\n ends[j] -= offset;\n }\n }\n const polygon = new Polygon(\n flatCoordinates.slice(offset, end),\n layout,\n ends\n );\n polygons.push(polygon);\n offset = end;\n }\n return polygons;\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'MultiPolygon';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n return intersectsLinearRingMultiArray(\n this.getOrientedFlatCoordinates(),\n 0,\n this.endss_,\n this.stride,\n extent\n );\n }\n\n /**\n * Set the coordinates of the multipolygon.\n * @param {!Array>>} coordinates Coordinates.\n * @param {import(\"./Geometry.js\").GeometryLayout} [layout] Layout.\n * @api\n */\n setCoordinates(coordinates, layout) {\n this.setLayout(layout, coordinates, 3);\n if (!this.flatCoordinates) {\n this.flatCoordinates = [];\n }\n const endss = deflateMultiCoordinatesArray(\n this.flatCoordinates,\n 0,\n coordinates,\n this.stride,\n this.endss_\n );\n if (endss.length === 0) {\n this.flatCoordinates.length = 0;\n } else {\n const lastEnds = endss[endss.length - 1];\n this.flatCoordinates.length =\n lastEnds.length === 0 ? 0 : lastEnds[lastEnds.length - 1];\n }\n this.changed();\n }\n}\n\nexport default MultiPolygon;\n","/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh */\nexports.read = function (buffer, offset, isLE, mLen, nBytes) {\n var e, m\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var nBits = -7\n var i = isLE ? (nBytes - 1) : 0\n var d = isLE ? -1 : 1\n var s = buffer[offset + i]\n\n i += d\n\n e = s & ((1 << (-nBits)) - 1)\n s >>= (-nBits)\n nBits += eLen\n for (; nBits > 0; e = (e * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n m = e & ((1 << (-nBits)) - 1)\n e >>= (-nBits)\n nBits += mLen\n for (; nBits > 0; m = (m * 256) + buffer[offset + i], i += d, nBits -= 8) {}\n\n if (e === 0) {\n e = 1 - eBias\n } else if (e === eMax) {\n return m ? NaN : ((s ? -1 : 1) * Infinity)\n } else {\n m = m + Math.pow(2, mLen)\n e = e - eBias\n }\n return (s ? -1 : 1) * m * Math.pow(2, e - mLen)\n}\n\nexports.write = function (buffer, value, offset, isLE, mLen, nBytes) {\n var e, m, c\n var eLen = (nBytes * 8) - mLen - 1\n var eMax = (1 << eLen) - 1\n var eBias = eMax >> 1\n var rt = (mLen === 23 ? Math.pow(2, -24) - Math.pow(2, -77) : 0)\n var i = isLE ? 0 : (nBytes - 1)\n var d = isLE ? 1 : -1\n var s = value < 0 || (value === 0 && 1 / value < 0) ? 1 : 0\n\n value = Math.abs(value)\n\n if (isNaN(value) || value === Infinity) {\n m = isNaN(value) ? 1 : 0\n e = eMax\n } else {\n e = Math.floor(Math.log(value) / Math.LN2)\n if (value * (c = Math.pow(2, -e)) < 1) {\n e--\n c *= 2\n }\n if (e + eBias >= 1) {\n value += rt / c\n } else {\n value += rt * Math.pow(2, 1 - eBias)\n }\n if (value * c >= 2) {\n e++\n c /= 2\n }\n\n if (e + eBias >= eMax) {\n m = 0\n e = eMax\n } else if (e + eBias >= 1) {\n m = ((value * c) - 1) * Math.pow(2, mLen)\n e = e + eBias\n } else {\n m = value * Math.pow(2, eBias - 1) * Math.pow(2, mLen)\n e = 0\n }\n }\n\n for (; mLen >= 8; buffer[offset + i] = m & 0xff, i += d, m /= 256, mLen -= 8) {}\n\n e = (e << mLen) | m\n eLen += mLen\n for (; eLen > 0; buffer[offset + i] = e & 0xff, i += d, e /= 256, eLen -= 8) {}\n\n buffer[offset + i - d] |= s * 128\n}\n","'use strict';\n\nmodule.exports = Pbf;\n\nvar ieee754 = require('ieee754');\n\nfunction Pbf(buf) {\n this.buf = ArrayBuffer.isView && ArrayBuffer.isView(buf) ? buf : new Uint8Array(buf || 0);\n this.pos = 0;\n this.type = 0;\n this.length = this.buf.length;\n}\n\nPbf.Varint = 0; // varint: int32, int64, uint32, uint64, sint32, sint64, bool, enum\nPbf.Fixed64 = 1; // 64-bit: double, fixed64, sfixed64\nPbf.Bytes = 2; // length-delimited: string, bytes, embedded messages, packed repeated fields\nPbf.Fixed32 = 5; // 32-bit: float, fixed32, sfixed32\n\nvar SHIFT_LEFT_32 = (1 << 16) * (1 << 16),\n SHIFT_RIGHT_32 = 1 / SHIFT_LEFT_32;\n\n// Threshold chosen based on both benchmarking and knowledge about browser string\n// data structures (which currently switch structure types at 12 bytes or more)\nvar TEXT_DECODER_MIN_LENGTH = 12;\nvar utf8TextDecoder = typeof TextDecoder === 'undefined' ? null : new TextDecoder('utf8');\n\nPbf.prototype = {\n\n destroy: function() {\n this.buf = null;\n },\n\n // === READING =================================================================\n\n readFields: function(readField, result, end) {\n end = end || this.length;\n\n while (this.pos < end) {\n var val = this.readVarint(),\n tag = val >> 3,\n startPos = this.pos;\n\n this.type = val & 0x7;\n readField(tag, result, this);\n\n if (this.pos === startPos) this.skip(val);\n }\n return result;\n },\n\n readMessage: function(readField, result) {\n return this.readFields(readField, result, this.readVarint() + this.pos);\n },\n\n readFixed32: function() {\n var val = readUInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n readSFixed32: function() {\n var val = readInt32(this.buf, this.pos);\n this.pos += 4;\n return val;\n },\n\n // 64-bit int handling is based on github.com/dpw/node-buffer-more-ints (MIT-licensed)\n\n readFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readUInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readSFixed64: function() {\n var val = readUInt32(this.buf, this.pos) + readInt32(this.buf, this.pos + 4) * SHIFT_LEFT_32;\n this.pos += 8;\n return val;\n },\n\n readFloat: function() {\n var val = ieee754.read(this.buf, this.pos, true, 23, 4);\n this.pos += 4;\n return val;\n },\n\n readDouble: function() {\n var val = ieee754.read(this.buf, this.pos, true, 52, 8);\n this.pos += 8;\n return val;\n },\n\n readVarint: function(isSigned) {\n var buf = this.buf,\n val, b;\n\n b = buf[this.pos++]; val = b & 0x7f; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 7; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 14; if (b < 0x80) return val;\n b = buf[this.pos++]; val |= (b & 0x7f) << 21; if (b < 0x80) return val;\n b = buf[this.pos]; val |= (b & 0x0f) << 28;\n\n return readVarintRemainder(val, isSigned, this);\n },\n\n readVarint64: function() { // for compatibility with v2.0.1\n return this.readVarint(true);\n },\n\n readSVarint: function() {\n var num = this.readVarint();\n return num % 2 === 1 ? (num + 1) / -2 : num / 2; // zigzag encoding\n },\n\n readBoolean: function() {\n return Boolean(this.readVarint());\n },\n\n readString: function() {\n var end = this.readVarint() + this.pos;\n var pos = this.pos;\n this.pos = end;\n\n if (end - pos >= TEXT_DECODER_MIN_LENGTH && utf8TextDecoder) {\n // longer strings are fast with the built-in browser TextDecoder API\n return readUtf8TextDecoder(this.buf, pos, end);\n }\n // short strings are fast with our custom implementation\n return readUtf8(this.buf, pos, end);\n },\n\n readBytes: function() {\n var end = this.readVarint() + this.pos,\n buffer = this.buf.subarray(this.pos, end);\n this.pos = end;\n return buffer;\n },\n\n // verbose for performance reasons; doesn't affect gzipped size\n\n readPackedVarint: function(arr, isSigned) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readVarint(isSigned));\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readVarint(isSigned));\n return arr;\n },\n readPackedSVarint: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSVarint());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSVarint());\n return arr;\n },\n readPackedBoolean: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readBoolean());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readBoolean());\n return arr;\n },\n readPackedFloat: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFloat());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFloat());\n return arr;\n },\n readPackedDouble: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readDouble());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readDouble());\n return arr;\n },\n readPackedFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed32());\n return arr;\n },\n readPackedSFixed32: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed32());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed32());\n return arr;\n },\n readPackedFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readFixed64());\n return arr;\n },\n readPackedSFixed64: function(arr) {\n if (this.type !== Pbf.Bytes) return arr.push(this.readSFixed64());\n var end = readPackedEnd(this);\n arr = arr || [];\n while (this.pos < end) arr.push(this.readSFixed64());\n return arr;\n },\n\n skip: function(val) {\n var type = val & 0x7;\n if (type === Pbf.Varint) while (this.buf[this.pos++] > 0x7f) {}\n else if (type === Pbf.Bytes) this.pos = this.readVarint() + this.pos;\n else if (type === Pbf.Fixed32) this.pos += 4;\n else if (type === Pbf.Fixed64) this.pos += 8;\n else throw new Error('Unimplemented type: ' + type);\n },\n\n // === WRITING =================================================================\n\n writeTag: function(tag, type) {\n this.writeVarint((tag << 3) | type);\n },\n\n realloc: function(min) {\n var length = this.length || 16;\n\n while (length < this.pos + min) length *= 2;\n\n if (length !== this.length) {\n var buf = new Uint8Array(length);\n buf.set(this.buf);\n this.buf = buf;\n this.length = length;\n }\n },\n\n finish: function() {\n this.length = this.pos;\n this.pos = 0;\n return this.buf.subarray(0, this.length);\n },\n\n writeFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeSFixed32: function(val) {\n this.realloc(4);\n writeInt32(this.buf, val, this.pos);\n this.pos += 4;\n },\n\n writeFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeSFixed64: function(val) {\n this.realloc(8);\n writeInt32(this.buf, val & -1, this.pos);\n writeInt32(this.buf, Math.floor(val * SHIFT_RIGHT_32), this.pos + 4);\n this.pos += 8;\n },\n\n writeVarint: function(val) {\n val = +val || 0;\n\n if (val > 0xfffffff || val < 0) {\n writeBigVarint(val, this);\n return;\n }\n\n this.realloc(4);\n\n this.buf[this.pos++] = val & 0x7f | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = ((val >>>= 7) & 0x7f) | (val > 0x7f ? 0x80 : 0); if (val <= 0x7f) return;\n this.buf[this.pos++] = (val >>> 7) & 0x7f;\n },\n\n writeSVarint: function(val) {\n this.writeVarint(val < 0 ? -val * 2 - 1 : val * 2);\n },\n\n writeBoolean: function(val) {\n this.writeVarint(Boolean(val));\n },\n\n writeString: function(str) {\n str = String(str);\n this.realloc(str.length * 4);\n\n this.pos++; // reserve 1 byte for short string length\n\n var startPos = this.pos;\n // write the string directly to the buffer and see how much was written\n this.pos = writeUtf8(this.buf, str, this.pos);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeFloat: function(val) {\n this.realloc(4);\n ieee754.write(this.buf, val, this.pos, true, 23, 4);\n this.pos += 4;\n },\n\n writeDouble: function(val) {\n this.realloc(8);\n ieee754.write(this.buf, val, this.pos, true, 52, 8);\n this.pos += 8;\n },\n\n writeBytes: function(buffer) {\n var len = buffer.length;\n this.writeVarint(len);\n this.realloc(len);\n for (var i = 0; i < len; i++) this.buf[this.pos++] = buffer[i];\n },\n\n writeRawMessage: function(fn, obj) {\n this.pos++; // reserve 1 byte for short message length\n\n // write the message directly to the buffer and see how much was written\n var startPos = this.pos;\n fn(obj, this);\n var len = this.pos - startPos;\n\n if (len >= 0x80) makeRoomForExtraLength(startPos, len, this);\n\n // finally, write the message length in the reserved place and restore the position\n this.pos = startPos - 1;\n this.writeVarint(len);\n this.pos += len;\n },\n\n writeMessage: function(tag, fn, obj) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeRawMessage(fn, obj);\n },\n\n writePackedVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedVarint, arr); },\n writePackedSVarint: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSVarint, arr); },\n writePackedBoolean: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedBoolean, arr); },\n writePackedFloat: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFloat, arr); },\n writePackedDouble: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedDouble, arr); },\n writePackedFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed32, arr); },\n writePackedSFixed32: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed32, arr); },\n writePackedFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedFixed64, arr); },\n writePackedSFixed64: function(tag, arr) { if (arr.length) this.writeMessage(tag, writePackedSFixed64, arr); },\n\n writeBytesField: function(tag, buffer) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeBytes(buffer);\n },\n writeFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFixed32(val);\n },\n writeSFixed32Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeSFixed32(val);\n },\n writeFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeFixed64(val);\n },\n writeSFixed64Field: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeSFixed64(val);\n },\n writeVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeVarint(val);\n },\n writeSVarintField: function(tag, val) {\n this.writeTag(tag, Pbf.Varint);\n this.writeSVarint(val);\n },\n writeStringField: function(tag, str) {\n this.writeTag(tag, Pbf.Bytes);\n this.writeString(str);\n },\n writeFloatField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed32);\n this.writeFloat(val);\n },\n writeDoubleField: function(tag, val) {\n this.writeTag(tag, Pbf.Fixed64);\n this.writeDouble(val);\n },\n writeBooleanField: function(tag, val) {\n this.writeVarintField(tag, Boolean(val));\n }\n};\n\nfunction readVarintRemainder(l, s, p) {\n var buf = p.buf,\n h, b;\n\n b = buf[p.pos++]; h = (b & 0x70) >> 4; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 3; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 10; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 17; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x7f) << 24; if (b < 0x80) return toNum(l, h, s);\n b = buf[p.pos++]; h |= (b & 0x01) << 31; if (b < 0x80) return toNum(l, h, s);\n\n throw new Error('Expected varint not more than 10 bytes');\n}\n\nfunction readPackedEnd(pbf) {\n return pbf.type === Pbf.Bytes ?\n pbf.readVarint() + pbf.pos : pbf.pos + 1;\n}\n\nfunction toNum(low, high, isSigned) {\n if (isSigned) {\n return high * 0x100000000 + (low >>> 0);\n }\n\n return ((high >>> 0) * 0x100000000) + (low >>> 0);\n}\n\nfunction writeBigVarint(val, pbf) {\n var low, high;\n\n if (val >= 0) {\n low = (val % 0x100000000) | 0;\n high = (val / 0x100000000) | 0;\n } else {\n low = ~(-val % 0x100000000);\n high = ~(-val / 0x100000000);\n\n if (low ^ 0xffffffff) {\n low = (low + 1) | 0;\n } else {\n low = 0;\n high = (high + 1) | 0;\n }\n }\n\n if (val >= 0x10000000000000000 || val < -0x10000000000000000) {\n throw new Error('Given varint doesn\\'t fit into 10 bytes');\n }\n\n pbf.realloc(10);\n\n writeBigVarintLow(low, high, pbf);\n writeBigVarintHigh(high, pbf);\n}\n\nfunction writeBigVarintLow(low, high, pbf) {\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos++] = low & 0x7f | 0x80; low >>>= 7;\n pbf.buf[pbf.pos] = low & 0x7f;\n}\n\nfunction writeBigVarintHigh(high, pbf) {\n var lsb = (high & 0x07) << 4;\n\n pbf.buf[pbf.pos++] |= lsb | ((high >>>= 3) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f | ((high >>>= 7) ? 0x80 : 0); if (!high) return;\n pbf.buf[pbf.pos++] = high & 0x7f;\n}\n\nfunction makeRoomForExtraLength(startPos, len, pbf) {\n var extraLen =\n len <= 0x3fff ? 1 :\n len <= 0x1fffff ? 2 :\n len <= 0xfffffff ? 3 : Math.floor(Math.log(len) / (Math.LN2 * 7));\n\n // if 1 byte isn't enough for encoding message length, shift the data to the right\n pbf.realloc(extraLen);\n for (var i = pbf.pos - 1; i >= startPos; i--) pbf.buf[i + extraLen] = pbf.buf[i];\n}\n\nfunction writePackedVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeVarint(arr[i]); }\nfunction writePackedSVarint(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSVarint(arr[i]); }\nfunction writePackedFloat(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFloat(arr[i]); }\nfunction writePackedDouble(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeDouble(arr[i]); }\nfunction writePackedBoolean(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeBoolean(arr[i]); }\nfunction writePackedFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed32(arr[i]); }\nfunction writePackedSFixed32(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed32(arr[i]); }\nfunction writePackedFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeFixed64(arr[i]); }\nfunction writePackedSFixed64(arr, pbf) { for (var i = 0; i < arr.length; i++) pbf.writeSFixed64(arr[i]); }\n\n// Buffer code below from https://github.com/feross/buffer, MIT-licensed\n\nfunction readUInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] * 0x1000000);\n}\n\nfunction writeInt32(buf, val, pos) {\n buf[pos] = val;\n buf[pos + 1] = (val >>> 8);\n buf[pos + 2] = (val >>> 16);\n buf[pos + 3] = (val >>> 24);\n}\n\nfunction readInt32(buf, pos) {\n return ((buf[pos]) |\n (buf[pos + 1] << 8) |\n (buf[pos + 2] << 16)) +\n (buf[pos + 3] << 24);\n}\n\nfunction readUtf8(buf, pos, end) {\n var str = '';\n var i = pos;\n\n while (i < end) {\n var b0 = buf[i];\n var c = null; // codepoint\n var bytesPerSequence =\n b0 > 0xEF ? 4 :\n b0 > 0xDF ? 3 :\n b0 > 0xBF ? 2 : 1;\n\n if (i + bytesPerSequence > end) break;\n\n var b1, b2, b3;\n\n if (bytesPerSequence === 1) {\n if (b0 < 0x80) {\n c = b0;\n }\n } else if (bytesPerSequence === 2) {\n b1 = buf[i + 1];\n if ((b1 & 0xC0) === 0x80) {\n c = (b0 & 0x1F) << 0x6 | (b1 & 0x3F);\n if (c <= 0x7F) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 3) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0xC | (b1 & 0x3F) << 0x6 | (b2 & 0x3F);\n if (c <= 0x7FF || (c >= 0xD800 && c <= 0xDFFF)) {\n c = null;\n }\n }\n } else if (bytesPerSequence === 4) {\n b1 = buf[i + 1];\n b2 = buf[i + 2];\n b3 = buf[i + 3];\n if ((b1 & 0xC0) === 0x80 && (b2 & 0xC0) === 0x80 && (b3 & 0xC0) === 0x80) {\n c = (b0 & 0xF) << 0x12 | (b1 & 0x3F) << 0xC | (b2 & 0x3F) << 0x6 | (b3 & 0x3F);\n if (c <= 0xFFFF || c >= 0x110000) {\n c = null;\n }\n }\n }\n\n if (c === null) {\n c = 0xFFFD;\n bytesPerSequence = 1;\n\n } else if (c > 0xFFFF) {\n c -= 0x10000;\n str += String.fromCharCode(c >>> 10 & 0x3FF | 0xD800);\n c = 0xDC00 | c & 0x3FF;\n }\n\n str += String.fromCharCode(c);\n i += bytesPerSequence;\n }\n\n return str;\n}\n\nfunction readUtf8TextDecoder(buf, pos, end) {\n return utf8TextDecoder.decode(buf.subarray(pos, end));\n}\n\nfunction writeUtf8(buf, str, pos) {\n for (var i = 0, c, lead; i < str.length; i++) {\n c = str.charCodeAt(i); // code point\n\n if (c > 0xD7FF && c < 0xE000) {\n if (lead) {\n if (c < 0xDC00) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = c;\n continue;\n } else {\n c = lead - 0xD800 << 10 | c - 0xDC00 | 0x10000;\n lead = null;\n }\n } else {\n if (c > 0xDBFF || (i + 1 === str.length)) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n } else {\n lead = c;\n }\n continue;\n }\n } else if (lead) {\n buf[pos++] = 0xEF;\n buf[pos++] = 0xBF;\n buf[pos++] = 0xBD;\n lead = null;\n }\n\n if (c < 0x80) {\n buf[pos++] = c;\n } else {\n if (c < 0x800) {\n buf[pos++] = c >> 0x6 | 0xC0;\n } else {\n if (c < 0x10000) {\n buf[pos++] = c >> 0xC | 0xE0;\n } else {\n buf[pos++] = c >> 0x12 | 0xF0;\n buf[pos++] = c >> 0xC & 0x3F | 0x80;\n }\n buf[pos++] = c >> 0x6 & 0x3F | 0x80;\n }\n buf[pos++] = c & 0x3F | 0x80;\n }\n }\n return pos;\n}\n","/**\n * @module ol/geom/GeometryCollection\n */\nimport EventType from '../events/EventType.js';\nimport Geometry from './Geometry.js';\nimport {\n closestSquaredDistanceXY,\n createOrUpdateEmpty,\n extend,\n getCenter,\n} from '../extent.js';\nimport {listen, unlistenByKey} from '../events.js';\n\n/**\n * @classdesc\n * An array of {@link module:ol/geom/Geometry~Geometry} objects.\n *\n * @api\n */\nclass GeometryCollection extends Geometry {\n /**\n * @param {Array} [geometries] Geometries.\n */\n constructor(geometries) {\n super();\n\n /**\n * @private\n * @type {Array}\n */\n this.geometries_ = geometries ? geometries : null;\n\n /**\n * @type {Array}\n */\n this.changeEventsKeys_ = [];\n\n this.listenGeometriesChange_();\n }\n\n /**\n * @private\n */\n unlistenGeometriesChange_() {\n this.changeEventsKeys_.forEach(unlistenByKey);\n this.changeEventsKeys_.length = 0;\n }\n\n /**\n * @private\n */\n listenGeometriesChange_() {\n if (!this.geometries_) {\n return;\n }\n for (let i = 0, ii = this.geometries_.length; i < ii; ++i) {\n this.changeEventsKeys_.push(\n listen(this.geometries_[i], EventType.CHANGE, this.changed, this)\n );\n }\n }\n\n /**\n * Make a complete copy of the geometry.\n * @return {!GeometryCollection} Clone.\n * @api\n */\n clone() {\n const geometryCollection = new GeometryCollection(null);\n geometryCollection.setGeometries(this.geometries_);\n geometryCollection.applyProperties(this);\n return geometryCollection;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../coordinate.js\").Coordinate} closestPoint Closest point.\n * @param {number} minSquaredDistance Minimum squared distance.\n * @return {number} Minimum squared distance.\n */\n closestPointXY(x, y, closestPoint, minSquaredDistance) {\n if (minSquaredDistance < closestSquaredDistanceXY(this.getExtent(), x, y)) {\n return minSquaredDistance;\n }\n const geometries = this.geometries_;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n minSquaredDistance = geometries[i].closestPointXY(\n x,\n y,\n closestPoint,\n minSquaredDistance\n );\n }\n return minSquaredDistance;\n }\n\n /**\n * @param {number} x X.\n * @param {number} y Y.\n * @return {boolean} Contains (x, y).\n */\n containsXY(x, y) {\n const geometries = this.geometries_;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n if (geometries[i].containsXY(x, y)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @protected\n * @return {import(\"../extent.js\").Extent} extent Extent.\n */\n computeExtent(extent) {\n createOrUpdateEmpty(extent);\n const geometries = this.geometries_;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n extend(extent, geometries[i].getExtent());\n }\n return extent;\n }\n\n /**\n * Return the geometries that make up this geometry collection.\n * @return {Array} Geometries.\n * @api\n */\n getGeometries() {\n return cloneGeometries(this.geometries_);\n }\n\n /**\n * @return {Array} Geometries.\n */\n getGeometriesArray() {\n return this.geometries_;\n }\n\n /**\n * @return {Array} Geometries.\n */\n getGeometriesArrayRecursive() {\n /** @type {Array} */\n let geometriesArray = [];\n const geometries = this.geometries_;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n if (geometries[i].getType() === this.getType()) {\n geometriesArray = geometriesArray.concat(\n /** @type {GeometryCollection} */ (\n geometries[i]\n ).getGeometriesArrayRecursive()\n );\n } else {\n geometriesArray.push(geometries[i]);\n }\n }\n return geometriesArray;\n }\n\n /**\n * Create a simplified version of this geometry using the Douglas Peucker algorithm.\n * @param {number} squaredTolerance Squared tolerance.\n * @return {GeometryCollection} Simplified GeometryCollection.\n */\n getSimplifiedGeometry(squaredTolerance) {\n if (this.simplifiedGeometryRevision !== this.getRevision()) {\n this.simplifiedGeometryMaxMinSquaredTolerance = 0;\n this.simplifiedGeometryRevision = this.getRevision();\n }\n if (\n squaredTolerance < 0 ||\n (this.simplifiedGeometryMaxMinSquaredTolerance !== 0 &&\n squaredTolerance < this.simplifiedGeometryMaxMinSquaredTolerance)\n ) {\n return this;\n }\n\n const simplifiedGeometries = [];\n const geometries = this.geometries_;\n let simplified = false;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n const geometry = geometries[i];\n const simplifiedGeometry =\n geometry.getSimplifiedGeometry(squaredTolerance);\n simplifiedGeometries.push(simplifiedGeometry);\n if (simplifiedGeometry !== geometry) {\n simplified = true;\n }\n }\n if (simplified) {\n const simplifiedGeometryCollection = new GeometryCollection(null);\n simplifiedGeometryCollection.setGeometriesArray(simplifiedGeometries);\n return simplifiedGeometryCollection;\n }\n this.simplifiedGeometryMaxMinSquaredTolerance = squaredTolerance;\n return this;\n }\n\n /**\n * Get the type of this geometry.\n * @return {import(\"./Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return 'GeometryCollection';\n }\n\n /**\n * Test if the geometry and the passed extent intersect.\n * @param {import(\"../extent.js\").Extent} extent Extent.\n * @return {boolean} `true` if the geometry and the extent intersect.\n * @api\n */\n intersectsExtent(extent) {\n const geometries = this.geometries_;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n if (geometries[i].intersectsExtent(extent)) {\n return true;\n }\n }\n return false;\n }\n\n /**\n * @return {boolean} Is empty.\n */\n isEmpty() {\n return this.geometries_.length === 0;\n }\n\n /**\n * Rotate the geometry around a given coordinate. This modifies the geometry\n * coordinates in place.\n * @param {number} angle Rotation angle in radians.\n * @param {import(\"../coordinate.js\").Coordinate} anchor The rotation center.\n * @api\n */\n rotate(angle, anchor) {\n const geometries = this.geometries_;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n geometries[i].rotate(angle, anchor);\n }\n this.changed();\n }\n\n /**\n * Scale the geometry (with an optional origin). This modifies the geometry\n * coordinates in place.\n * @abstract\n * @param {number} sx The scaling factor in the x-direction.\n * @param {number} [sy] The scaling factor in the y-direction (defaults to sx).\n * @param {import(\"../coordinate.js\").Coordinate} [anchor] The scale origin (defaults to the center\n * of the geometry extent).\n * @api\n */\n scale(sx, sy, anchor) {\n if (!anchor) {\n anchor = getCenter(this.getExtent());\n }\n const geometries = this.geometries_;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n geometries[i].scale(sx, sy, anchor);\n }\n this.changed();\n }\n\n /**\n * Set the geometries that make up this geometry collection.\n * @param {Array} geometries Geometries.\n * @api\n */\n setGeometries(geometries) {\n this.setGeometriesArray(cloneGeometries(geometries));\n }\n\n /**\n * @param {Array} geometries Geometries.\n */\n setGeometriesArray(geometries) {\n this.unlistenGeometriesChange_();\n this.geometries_ = geometries;\n this.listenGeometriesChange_();\n this.changed();\n }\n\n /**\n * Apply a transform function to the coordinates of the geometry.\n * The geometry is modified in place.\n * If you do not want the geometry modified in place, first `clone()` it and\n * then use this function on the clone.\n * @param {import(\"../proj.js\").TransformFunction} transformFn Transform function.\n * Called with a flat array of geometry coordinates.\n * @api\n */\n applyTransform(transformFn) {\n const geometries = this.geometries_;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n geometries[i].applyTransform(transformFn);\n }\n this.changed();\n }\n\n /**\n * Translate the geometry. This modifies the geometry coordinates in place. If\n * instead you want a new geometry, first `clone()` this geometry.\n * @param {number} deltaX Delta X.\n * @param {number} deltaY Delta Y.\n * @api\n */\n translate(deltaX, deltaY) {\n const geometries = this.geometries_;\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n geometries[i].translate(deltaX, deltaY);\n }\n this.changed();\n }\n\n /**\n * Clean up.\n */\n disposeInternal() {\n this.unlistenGeometriesChange_();\n super.disposeInternal();\n }\n}\n\n/**\n * @param {Array} geometries Geometries.\n * @return {Array} Cloned geometries.\n */\nfunction cloneGeometries(geometries) {\n const clonedGeometries = [];\n for (let i = 0, ii = geometries.length; i < ii; ++i) {\n clonedGeometries.push(geometries[i].clone());\n }\n return clonedGeometries;\n}\n\nexport default GeometryCollection;\n","/**\n * @module ol/render/Feature\n */\nimport Feature from '../Feature.js';\nimport {\n LineString,\n MultiLineString,\n MultiPoint,\n MultiPolygon,\n Point,\n Polygon,\n} from '../geom.js';\nimport {\n compose as composeTransform,\n create as createTransform,\n} from '../transform.js';\nimport {\n createOrUpdateFromCoordinate,\n createOrUpdateFromFlatCoordinates,\n getCenter,\n getHeight,\n} from '../extent.js';\nimport {extend} from '../array.js';\nimport {\n getInteriorPointOfArray,\n getInteriorPointsOfMultiArray,\n} from '../geom/flat/interiorpoint.js';\nimport {get as getProjection} from '../proj.js';\nimport {inflateEnds} from '../geom/flat/orient.js';\nimport {interpolatePoint} from '../geom/flat/interpolate.js';\nimport {linearRingss as linearRingssCenter} from '../geom/flat/center.js';\nimport {transform2D} from '../geom/flat/transform.js';\n\n/**\n * @type {import(\"../transform.js\").Transform}\n */\nconst tmpTransform = createTransform();\n\n/**\n * Lightweight, read-only, {@link module:ol/Feature~Feature} and {@link module:ol/geom/Geometry~Geometry} like\n * structure, optimized for vector tile rendering and styling. Geometry access\n * through the API is limited to getting the type and extent of the geometry.\n */\nclass RenderFeature {\n /**\n * @param {import(\"../geom/Geometry.js\").Type} type Geometry type.\n * @param {Array} flatCoordinates Flat coordinates. These always need\n * to be right-handed for polygons.\n * @param {Array|Array>} ends Ends or Endss.\n * @param {Object} properties Properties.\n * @param {number|string|undefined} id Feature id.\n */\n constructor(type, flatCoordinates, ends, properties, id) {\n /**\n * @type {import(\"../style/Style.js\").StyleFunction|undefined}\n */\n this.styleFunction;\n\n /**\n * @private\n * @type {import(\"../extent.js\").Extent|undefined}\n */\n this.extent_;\n\n /**\n * @private\n * @type {number|string|undefined}\n */\n this.id_ = id;\n\n /**\n * @private\n * @type {import(\"../geom/Geometry.js\").Type}\n */\n this.type_ = type;\n\n /**\n * @private\n * @type {Array}\n */\n this.flatCoordinates_ = flatCoordinates;\n\n /**\n * @private\n * @type {Array}\n */\n this.flatInteriorPoints_ = null;\n\n /**\n * @private\n * @type {Array}\n */\n this.flatMidpoints_ = null;\n\n /**\n * @private\n * @type {Array|Array>}\n */\n this.ends_ = ends;\n\n /**\n * @private\n * @type {Object}\n */\n this.properties_ = properties;\n }\n\n /**\n * Get a feature property by its key.\n * @param {string} key Key\n * @return {*} Value for the requested key.\n * @api\n */\n get(key) {\n return this.properties_[key];\n }\n\n /**\n * Get the extent of this feature's geometry.\n * @return {import(\"../extent.js\").Extent} Extent.\n * @api\n */\n getExtent() {\n if (!this.extent_) {\n this.extent_ =\n this.type_ === 'Point'\n ? createOrUpdateFromCoordinate(this.flatCoordinates_)\n : createOrUpdateFromFlatCoordinates(\n this.flatCoordinates_,\n 0,\n this.flatCoordinates_.length,\n 2\n );\n }\n return this.extent_;\n }\n\n /**\n * @return {Array} Flat interior points.\n */\n getFlatInteriorPoint() {\n if (!this.flatInteriorPoints_) {\n const flatCenter = getCenter(this.getExtent());\n this.flatInteriorPoints_ = getInteriorPointOfArray(\n this.flatCoordinates_,\n 0,\n /** @type {Array} */ (this.ends_),\n 2,\n flatCenter,\n 0\n );\n }\n return this.flatInteriorPoints_;\n }\n\n /**\n * @return {Array} Flat interior points.\n */\n getFlatInteriorPoints() {\n if (!this.flatInteriorPoints_) {\n const flatCenters = linearRingssCenter(\n this.flatCoordinates_,\n 0,\n /** @type {Array>} */ (this.ends_),\n 2\n );\n this.flatInteriorPoints_ = getInteriorPointsOfMultiArray(\n this.flatCoordinates_,\n 0,\n /** @type {Array>} */ (this.ends_),\n 2,\n flatCenters\n );\n }\n return this.flatInteriorPoints_;\n }\n\n /**\n * @return {Array} Flat midpoint.\n */\n getFlatMidpoint() {\n if (!this.flatMidpoints_) {\n this.flatMidpoints_ = interpolatePoint(\n this.flatCoordinates_,\n 0,\n this.flatCoordinates_.length,\n 2,\n 0.5\n );\n }\n return this.flatMidpoints_;\n }\n\n /**\n * @return {Array} Flat midpoints.\n */\n getFlatMidpoints() {\n if (!this.flatMidpoints_) {\n this.flatMidpoints_ = [];\n const flatCoordinates = this.flatCoordinates_;\n let offset = 0;\n const ends = /** @type {Array} */ (this.ends_);\n for (let i = 0, ii = ends.length; i < ii; ++i) {\n const end = ends[i];\n const midpoint = interpolatePoint(flatCoordinates, offset, end, 2, 0.5);\n extend(this.flatMidpoints_, midpoint);\n offset = end;\n }\n }\n return this.flatMidpoints_;\n }\n\n /**\n * Get the feature identifier. This is a stable identifier for the feature and\n * is set when reading data from a remote source.\n * @return {number|string|undefined} Id.\n * @api\n */\n getId() {\n return this.id_;\n }\n\n /**\n * @return {Array} Flat coordinates.\n */\n getOrientedFlatCoordinates() {\n return this.flatCoordinates_;\n }\n\n /**\n * For API compatibility with {@link module:ol/Feature~Feature}, this method is useful when\n * determining the geometry type in style function (see {@link #getType}).\n * @return {RenderFeature} Feature.\n * @api\n */\n getGeometry() {\n return this;\n }\n\n /**\n * @param {number} squaredTolerance Squared tolerance.\n * @return {RenderFeature} Simplified geometry.\n */\n getSimplifiedGeometry(squaredTolerance) {\n return this;\n }\n\n /**\n * Get a transformed and simplified version of the geometry.\n * @abstract\n * @param {number} squaredTolerance Squared tolerance.\n * @param {import(\"../proj.js\").TransformFunction} [transform] Optional transform function.\n * @return {RenderFeature} Simplified geometry.\n */\n simplifyTransformed(squaredTolerance, transform) {\n return this;\n }\n\n /**\n * Get the feature properties.\n * @return {Object} Feature properties.\n * @api\n */\n getProperties() {\n return this.properties_;\n }\n\n /**\n * Get an object of all property names and values. This has the same behavior as getProperties,\n * but is here to conform with the {@link module:ol/Feature~Feature} interface.\n * @return {Object?} Object.\n */\n getPropertiesInternal() {\n return this.properties_;\n }\n\n /**\n * @return {number} Stride.\n */\n getStride() {\n return 2;\n }\n\n /**\n * @return {import('../style/Style.js').StyleFunction|undefined} Style\n */\n getStyleFunction() {\n return this.styleFunction;\n }\n\n /**\n * Get the type of this feature's geometry.\n * @return {import(\"../geom/Geometry.js\").Type} Geometry type.\n * @api\n */\n getType() {\n return this.type_;\n }\n\n /**\n * Transform geometry coordinates from tile pixel space to projected.\n *\n * @param {import(\"../proj.js\").ProjectionLike} projection The data projection\n */\n transform(projection) {\n projection = getProjection(projection);\n const pixelExtent = projection.getExtent();\n const projectedExtent = projection.getWorldExtent();\n if (pixelExtent && projectedExtent) {\n const scale = getHeight(projectedExtent) / getHeight(pixelExtent);\n composeTransform(\n tmpTransform,\n projectedExtent[0],\n projectedExtent[3],\n scale,\n -scale,\n 0,\n 0,\n 0\n );\n transform2D(\n this.flatCoordinates_,\n 0,\n this.flatCoordinates_.length,\n 2,\n tmpTransform,\n this.flatCoordinates_\n );\n }\n }\n /**\n * @return {Array|Array>} Ends or endss.\n */\n getEnds() {\n return this.ends_;\n }\n}\n\nRenderFeature.prototype.getEndss = RenderFeature.prototype.getEnds;\n\n/**\n * @return {Array} Flat coordinates.\n */\nRenderFeature.prototype.getFlatCoordinates =\n RenderFeature.prototype.getOrientedFlatCoordinates;\n\n/**\n * Create a geometry from an `ol/render/Feature`\n * @param {RenderFeature} renderFeature\n * Render Feature\n * @return {Point|MultiPoint|LineString|MultiLineString|Polygon|MultiPolygon}\n * New geometry instance.\n * @api\n */\nexport function toGeometry(renderFeature) {\n const geometryType = renderFeature.getType();\n switch (geometryType) {\n case 'Point':\n return new Point(renderFeature.getFlatCoordinates());\n case 'MultiPoint':\n return new MultiPoint(renderFeature.getFlatCoordinates(), 'XY');\n case 'LineString':\n return new LineString(renderFeature.getFlatCoordinates(), 'XY');\n case 'MultiLineString':\n return new MultiLineString(\n renderFeature.getFlatCoordinates(),\n 'XY',\n /** @type {Array} */ (renderFeature.getEnds())\n );\n case 'Polygon':\n const flatCoordinates = renderFeature.getFlatCoordinates();\n const ends = /** @type {Array} */ (renderFeature.getEnds());\n const endss = inflateEnds(flatCoordinates, ends);\n return endss.length > 1\n ? new MultiPolygon(flatCoordinates, 'XY', endss)\n : new Polygon(flatCoordinates, 'XY', ends);\n default:\n throw new Error('Invalid geometry type:' + geometryType);\n }\n}\n\n/**\n * Create an `ol/Feature` from an `ol/render/Feature`\n * @param {RenderFeature} renderFeature RenderFeature\n * @param {string} [geometryName='geometry'] Geometry name to use\n * when creating the Feature.\n * @return {Feature} Newly constructed `ol/Feature` with properties,\n * geometry, and id copied over.\n * @api\n */\nexport function toFeature(renderFeature, geometryName) {\n const id = renderFeature.getId();\n const geometry = toGeometry(renderFeature);\n const properties = renderFeature.getProperties();\n const feature = new Feature();\n if (geometryName !== undefined) {\n feature.setGeometryName(geometryName);\n }\n feature.setGeometry(geometry);\n if (id !== undefined) {\n feature.setId(id);\n }\n feature.setProperties(properties, true);\n return feature;\n}\n\nexport default RenderFeature;\n","/**\n * @module ol/format/MVT\n */\n//FIXME Implement projection handling\n\nimport FeatureFormat, {transformGeometryWithOptions} from './Feature.js';\nimport LineString from '../geom/LineString.js';\nimport MultiLineString from '../geom/MultiLineString.js';\nimport MultiPoint from '../geom/MultiPoint.js';\nimport MultiPolygon from '../geom/MultiPolygon.js';\nimport PBF from 'pbf';\nimport Point from '../geom/Point.js';\nimport Polygon from '../geom/Polygon.js';\nimport Projection from '../proj/Projection.js';\nimport RenderFeature from '../render/Feature.js';\nimport {get} from '../proj.js';\nimport {inflateEnds} from '../geom/flat/orient.js';\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../Feature.js\").FeatureClass} [featureClass] Class for features returned by\n * {@link module:ol/format/MVT~MVT#readFeatures}. Set to {@link module:ol/Feature~Feature} to get full editing and geometry\n * support at the cost of decreased rendering performance. The default is\n * {@link module:ol/render/Feature~RenderFeature}, which is optimized for rendering and hit detection.\n * @property {string} [geometryName='geometry'] Geometry name to use when creating features.\n * @property {string} [layerName='layer'] Name of the feature attribute that holds the layer name.\n * @property {Array} [layers] Layers to read features from. If not provided, features will be read from all\n * @property {string} [idProperty] Optional property that will be assigned as the feature id and removed from the properties.\n * layers.\n */\n\n/**\n * @classdesc\n * Feature format for reading data in the Mapbox MVT format.\n *\n * @param {Options} [options] Options.\n * @api\n */\nclass MVT extends FeatureFormat {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n super();\n\n options = options ? options : {};\n\n /**\n * @type {Projection}\n */\n this.dataProjection = new Projection({\n code: '',\n units: 'tile-pixels',\n });\n\n /**\n * @private\n * @type {import(\"../Feature.js\").FeatureClass}\n */\n this.featureClass_ = options.featureClass\n ? options.featureClass\n : RenderFeature;\n\n /**\n * @private\n * @type {string|undefined}\n */\n this.geometryName_ = options.geometryName;\n\n /**\n * @private\n * @type {string}\n */\n this.layerName_ = options.layerName ? options.layerName : 'layer';\n\n /**\n * @private\n * @type {Array|null}\n */\n this.layers_ = options.layers ? options.layers : null;\n\n /**\n * @private\n * @type {string}\n */\n this.idProperty_ = options.idProperty;\n\n this.supportedMediaTypes = [\n 'application/vnd.mapbox-vector-tile',\n 'application/x-protobuf',\n ];\n }\n\n /**\n * Read the raw geometry from the pbf offset stored in a raw feature's geometry\n * property.\n * @param {PBF} pbf PBF.\n * @param {Object} feature Raw feature.\n * @param {Array} flatCoordinates Array to store flat coordinates in.\n * @param {Array} ends Array to store ends in.\n * @private\n */\n readRawGeometry_(pbf, feature, flatCoordinates, ends) {\n pbf.pos = feature.geometry;\n\n const end = pbf.readVarint() + pbf.pos;\n let cmd = 1;\n let length = 0;\n let x = 0;\n let y = 0;\n let coordsLen = 0;\n let currentEnd = 0;\n\n while (pbf.pos < end) {\n if (!length) {\n const cmdLen = pbf.readVarint();\n cmd = cmdLen & 0x7;\n length = cmdLen >> 3;\n }\n\n length--;\n\n if (cmd === 1 || cmd === 2) {\n x += pbf.readSVarint();\n y += pbf.readSVarint();\n\n if (cmd === 1) {\n // moveTo\n if (coordsLen > currentEnd) {\n ends.push(coordsLen);\n currentEnd = coordsLen;\n }\n }\n\n flatCoordinates.push(x, y);\n coordsLen += 2;\n } else if (cmd === 7) {\n if (coordsLen > currentEnd) {\n // close polygon\n flatCoordinates.push(\n flatCoordinates[currentEnd],\n flatCoordinates[currentEnd + 1]\n );\n coordsLen += 2;\n }\n } else {\n throw new Error('Invalid command found in the PBF');\n }\n }\n\n if (coordsLen > currentEnd) {\n ends.push(coordsLen);\n currentEnd = coordsLen;\n }\n }\n\n /**\n * @private\n * @param {PBF} pbf PBF\n * @param {Object} rawFeature Raw Mapbox feature.\n * @param {import(\"./Feature.js\").ReadOptions} options Read options.\n * @return {import(\"../Feature.js\").FeatureLike|null} Feature.\n */\n createFeature_(pbf, rawFeature, options) {\n const type = rawFeature.type;\n if (type === 0) {\n return null;\n }\n\n let feature;\n const values = rawFeature.properties;\n\n let id;\n if (!this.idProperty_) {\n id = rawFeature.id;\n } else {\n id = values[this.idProperty_];\n delete values[this.idProperty_];\n }\n\n values[this.layerName_] = rawFeature.layer.name;\n\n const flatCoordinates = /** @type {Array} */ ([]);\n const ends = /** @type {Array} */ ([]);\n this.readRawGeometry_(pbf, rawFeature, flatCoordinates, ends);\n\n const geometryType = getGeometryType(type, ends.length);\n\n if (this.featureClass_ === RenderFeature) {\n feature = new this.featureClass_(\n geometryType,\n flatCoordinates,\n ends,\n values,\n id\n );\n feature.transform(options.dataProjection);\n } else {\n let geom;\n if (geometryType == 'Polygon') {\n const endss = inflateEnds(flatCoordinates, ends);\n geom =\n endss.length > 1\n ? new MultiPolygon(flatCoordinates, 'XY', endss)\n : new Polygon(flatCoordinates, 'XY', ends);\n } else {\n geom =\n geometryType === 'Point'\n ? new Point(flatCoordinates, 'XY')\n : geometryType === 'LineString'\n ? new LineString(flatCoordinates, 'XY')\n : geometryType === 'MultiPoint'\n ? new MultiPoint(flatCoordinates, 'XY')\n : geometryType === 'MultiLineString'\n ? new MultiLineString(flatCoordinates, 'XY', ends)\n : null;\n }\n const ctor = /** @type {typeof import(\"../Feature.js\").default} */ (\n this.featureClass_\n );\n feature = new ctor();\n if (this.geometryName_) {\n feature.setGeometryName(this.geometryName_);\n }\n const geometry = transformGeometryWithOptions(geom, false, options);\n feature.setGeometry(geometry);\n if (id !== undefined) {\n feature.setId(id);\n }\n feature.setProperties(values, true);\n }\n\n return feature;\n }\n\n /**\n * @return {import(\"./Feature.js\").Type} Format.\n */\n getType() {\n return 'arraybuffer';\n }\n\n /**\n * Read all features.\n *\n * @param {ArrayBuffer} source Source.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @return {Array} Features.\n * @api\n */\n readFeatures(source, options) {\n const layers = this.layers_;\n options = this.adaptOptions(options);\n const dataProjection = get(options.dataProjection);\n dataProjection.setWorldExtent(options.extent);\n options.dataProjection = dataProjection;\n\n const pbf = new PBF(/** @type {ArrayBuffer} */ (source));\n const pbfLayers = pbf.readFields(layersPBFReader, {});\n const features = [];\n for (const name in pbfLayers) {\n if (layers && !layers.includes(name)) {\n continue;\n }\n const pbfLayer = pbfLayers[name];\n\n const extent = pbfLayer ? [0, 0, pbfLayer.extent, pbfLayer.extent] : null;\n dataProjection.setExtent(extent);\n\n for (let i = 0, ii = pbfLayer.length; i < ii; ++i) {\n const rawFeature = readRawFeature(pbf, pbfLayer, i);\n const feature = this.createFeature_(pbf, rawFeature, options);\n if (feature !== null) {\n features.push(feature);\n }\n }\n }\n\n return features;\n }\n\n /**\n * Read the projection from the source.\n *\n * @param {Document|Element|Object|string} source Source.\n * @return {import(\"../proj/Projection.js\").default} Projection.\n * @api\n */\n readProjection(source) {\n return this.dataProjection;\n }\n\n /**\n * Sets the layers that features will be read from.\n * @param {Array} layers Layers.\n * @api\n */\n setLayers(layers) {\n this.layers_ = layers;\n }\n}\n\n/**\n * Reader callback for parsing layers.\n * @param {number} tag The tag.\n * @param {Object} layers The layers object.\n * @param {PBF} pbf The PBF.\n */\nfunction layersPBFReader(tag, layers, pbf) {\n if (tag === 3) {\n const layer = {\n keys: [],\n values: [],\n features: [],\n };\n const end = pbf.readVarint() + pbf.pos;\n pbf.readFields(layerPBFReader, layer, end);\n layer.length = layer.features.length;\n if (layer.length) {\n layers[layer.name] = layer;\n }\n }\n}\n\n/**\n * Reader callback for parsing layer.\n * @param {number} tag The tag.\n * @param {Object} layer The layer object.\n * @param {PBF} pbf The PBF.\n */\nfunction layerPBFReader(tag, layer, pbf) {\n if (tag === 15) {\n layer.version = pbf.readVarint();\n } else if (tag === 1) {\n layer.name = pbf.readString();\n } else if (tag === 5) {\n layer.extent = pbf.readVarint();\n } else if (tag === 2) {\n layer.features.push(pbf.pos);\n } else if (tag === 3) {\n layer.keys.push(pbf.readString());\n } else if (tag === 4) {\n let value = null;\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n tag = pbf.readVarint() >> 3;\n value =\n tag === 1\n ? pbf.readString()\n : tag === 2\n ? pbf.readFloat()\n : tag === 3\n ? pbf.readDouble()\n : tag === 4\n ? pbf.readVarint64()\n : tag === 5\n ? pbf.readVarint()\n : tag === 6\n ? pbf.readSVarint()\n : tag === 7\n ? pbf.readBoolean()\n : null;\n }\n layer.values.push(value);\n }\n}\n\n/**\n * Reader callback for parsing feature.\n * @param {number} tag The tag.\n * @param {Object} feature The feature object.\n * @param {PBF} pbf The PBF.\n */\nfunction featurePBFReader(tag, feature, pbf) {\n if (tag == 1) {\n feature.id = pbf.readVarint();\n } else if (tag == 2) {\n const end = pbf.readVarint() + pbf.pos;\n while (pbf.pos < end) {\n const key = feature.layer.keys[pbf.readVarint()];\n const value = feature.layer.values[pbf.readVarint()];\n feature.properties[key] = value;\n }\n } else if (tag == 3) {\n feature.type = pbf.readVarint();\n } else if (tag == 4) {\n feature.geometry = pbf.pos;\n }\n}\n\n/**\n * Read a raw feature from the pbf offset stored at index `i` in the raw layer.\n * @param {PBF} pbf PBF.\n * @param {Object} layer Raw layer.\n * @param {number} i Index of the feature in the raw layer's `features` array.\n * @return {Object} Raw feature.\n */\nfunction readRawFeature(pbf, layer, i) {\n pbf.pos = layer.features[i];\n const end = pbf.readVarint() + pbf.pos;\n\n const feature = {\n layer: layer,\n type: 0,\n properties: {},\n };\n pbf.readFields(featurePBFReader, feature, end);\n return feature;\n}\n\n/**\n * @param {number} type The raw feature's geometry type\n * @param {number} numEnds Number of ends of the flat coordinates of the\n * geometry.\n * @return {import(\"../geom/Geometry.js\").Type} The geometry type.\n */\nfunction getGeometryType(type, numEnds) {\n /** @type {import(\"../geom/Geometry.js\").Type} */\n let geometryType;\n if (type === 1) {\n geometryType = numEnds === 1 ? 'Point' : 'MultiPoint';\n } else if (type === 2) {\n geometryType = numEnds === 1 ? 'LineString' : 'MultiLineString';\n } else if (type === 3) {\n geometryType = 'Polygon';\n // MultiPolygon not relevant for rendering - winding order determines\n // outer rings of polygons.\n }\n return geometryType;\n}\n\nexport default MVT;\n","/**\n * @module ol/format/JSONFeature\n */\nimport FeatureFormat from './Feature.js';\nimport {abstract} from '../util.js';\n\n/**\n * @classdesc\n * Abstract base class; normally only used for creating subclasses and not\n * instantiated in apps.\n * Base class for JSON feature formats.\n *\n * @abstract\n */\nclass JSONFeature extends FeatureFormat {\n constructor() {\n super();\n }\n\n /**\n * @return {import(\"./Feature.js\").Type} Format.\n */\n getType() {\n return 'json';\n }\n\n /**\n * Read a feature. Only works for a single feature. Use `readFeatures` to\n * read a feature collection.\n *\n * @param {ArrayBuffer|Document|Element|Object|string} source Source.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @return {import(\"../Feature.js\").default} Feature.\n * @api\n */\n readFeature(source, options) {\n return this.readFeatureFromObject(\n getObject(source),\n this.getReadOptions(source, options)\n );\n }\n\n /**\n * Read all features. Works with both a single feature and a feature\n * collection.\n *\n * @param {ArrayBuffer|Document|Element|Object|string} source Source.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @return {Array} Features.\n * @api\n */\n readFeatures(source, options) {\n return this.readFeaturesFromObject(\n getObject(source),\n this.getReadOptions(source, options)\n );\n }\n\n /**\n * @abstract\n * @param {Object} object Object.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @protected\n * @return {import(\"../Feature.js\").default} Feature.\n */\n readFeatureFromObject(object, options) {\n return abstract();\n }\n\n /**\n * @abstract\n * @param {Object} object Object.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @protected\n * @return {Array} Features.\n */\n readFeaturesFromObject(object, options) {\n return abstract();\n }\n\n /**\n * Read a geometry.\n *\n * @param {ArrayBuffer|Document|Element|Object|string} source Source.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @return {import(\"../geom/Geometry.js\").default} Geometry.\n * @api\n */\n readGeometry(source, options) {\n return this.readGeometryFromObject(\n getObject(source),\n this.getReadOptions(source, options)\n );\n }\n\n /**\n * @abstract\n * @param {Object} object Object.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @protected\n * @return {import(\"../geom/Geometry.js\").default} Geometry.\n */\n readGeometryFromObject(object, options) {\n return abstract();\n }\n\n /**\n * Read the projection.\n *\n * @param {ArrayBuffer|Document|Element|Object|string} source Source.\n * @return {import(\"../proj/Projection.js\").default} Projection.\n * @api\n */\n readProjection(source) {\n return this.readProjectionFromObject(getObject(source));\n }\n\n /**\n * @abstract\n * @param {Object} object Object.\n * @protected\n * @return {import(\"../proj/Projection.js\").default} Projection.\n */\n readProjectionFromObject(object) {\n return abstract();\n }\n\n /**\n * Encode a feature as string.\n *\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {string} Encoded feature.\n * @api\n */\n writeFeature(feature, options) {\n return JSON.stringify(this.writeFeatureObject(feature, options));\n }\n\n /**\n * @abstract\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {Object} Object.\n */\n writeFeatureObject(feature, options) {\n return abstract();\n }\n\n /**\n * Encode an array of features as string.\n *\n * @param {Array} features Features.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {string} Encoded features.\n * @api\n */\n writeFeatures(features, options) {\n return JSON.stringify(this.writeFeaturesObject(features, options));\n }\n\n /**\n * @abstract\n * @param {Array} features Features.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {Object} Object.\n */\n writeFeaturesObject(features, options) {\n return abstract();\n }\n\n /**\n * Encode a geometry as string.\n *\n * @param {import(\"../geom/Geometry.js\").default} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {string} Encoded geometry.\n * @api\n */\n writeGeometry(geometry, options) {\n return JSON.stringify(this.writeGeometryObject(geometry, options));\n }\n\n /**\n * @abstract\n * @param {import(\"../geom/Geometry.js\").default} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {Object} Object.\n */\n writeGeometryObject(geometry, options) {\n return abstract();\n }\n}\n\n/**\n * @param {Document|Element|Object|string} source Source.\n * @return {Object} Object.\n */\nfunction getObject(source) {\n if (typeof source === 'string') {\n const object = JSON.parse(source);\n return object ? /** @type {Object} */ (object) : null;\n }\n if (source !== null) {\n return source;\n }\n return null;\n}\n\nexport default JSONFeature;\n","/**\n * @module ol/format/GeoJSON\n */\n\nimport Feature from '../Feature.js';\nimport GeometryCollection from '../geom/GeometryCollection.js';\nimport JSONFeature from './JSONFeature.js';\nimport LineString from '../geom/LineString.js';\nimport MultiLineString from '../geom/MultiLineString.js';\nimport MultiPoint from '../geom/MultiPoint.js';\nimport MultiPolygon from '../geom/MultiPolygon.js';\nimport Point from '../geom/Point.js';\nimport Polygon from '../geom/Polygon.js';\nimport {get as getProjection} from '../proj.js';\nimport {isEmpty} from '../obj.js';\nimport {transformGeometryWithOptions} from './Feature.js';\n\n/**\n * @typedef {import(\"geojson\").GeoJSON} GeoJSONObject\n * @typedef {import(\"geojson\").Feature} GeoJSONFeature\n * @typedef {import(\"geojson\").FeatureCollection} GeoJSONFeatureCollection\n * @typedef {import(\"geojson\").Geometry} GeoJSONGeometry\n * @typedef {import(\"geojson\").Point} GeoJSONPoint\n * @typedef {import(\"geojson\").LineString} GeoJSONLineString\n * @typedef {import(\"geojson\").Polygon} GeoJSONPolygon\n * @typedef {import(\"geojson\").MultiPoint} GeoJSONMultiPoint\n * @typedef {import(\"geojson\").MultiLineString} GeoJSONMultiLineString\n * @typedef {import(\"geojson\").MultiPolygon} GeoJSONMultiPolygon\n * @typedef {import(\"geojson\").GeometryCollection} GeoJSONGeometryCollection\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../proj.js\").ProjectionLike} [dataProjection='EPSG:4326'] Default data projection.\n * @property {import(\"../proj.js\").ProjectionLike} [featureProjection] Projection for features read or\n * written by the format. Options passed to read or write methods will take precedence.\n * @property {string} [geometryName] Geometry name to use when creating features.\n * @property {boolean} [extractGeometryName=false] Certain GeoJSON providers include\n * the geometry_name field in the feature GeoJSON. If set to `true` the GeoJSON reader\n * will look for that field to set the geometry name. If both this field is set to `true`\n * and a `geometryName` is provided, the `geometryName` will take precedence.\n */\n\n/**\n * @classdesc\n * Feature format for reading and writing data in the GeoJSON format.\n *\n * @api\n */\nclass GeoJSON extends JSONFeature {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options ? options : {};\n\n super();\n\n /**\n * @type {import(\"../proj/Projection.js\").default}\n */\n this.dataProjection = getProjection(\n options.dataProjection ? options.dataProjection : 'EPSG:4326'\n );\n\n if (options.featureProjection) {\n /**\n * @type {import(\"../proj/Projection.js\").default}\n */\n this.defaultFeatureProjection = getProjection(options.featureProjection);\n }\n\n /**\n * Name of the geometry attribute for features.\n * @type {string|undefined}\n * @private\n */\n this.geometryName_ = options.geometryName;\n\n /**\n * Look for the geometry name in the feature GeoJSON\n * @type {boolean|undefined}\n * @private\n */\n this.extractGeometryName_ = options.extractGeometryName;\n\n this.supportedMediaTypes = [\n 'application/geo+json',\n 'application/vnd.geo+json',\n ];\n }\n\n /**\n * @param {Object} object Object.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @protected\n * @return {import(\"../Feature.js\").default} Feature.\n */\n readFeatureFromObject(object, options) {\n /**\n * @type {GeoJSONFeature}\n */\n let geoJSONFeature = null;\n if (object['type'] === 'Feature') {\n geoJSONFeature = /** @type {GeoJSONFeature} */ (object);\n } else {\n geoJSONFeature = {\n 'type': 'Feature',\n 'geometry': /** @type {GeoJSONGeometry} */ (object),\n 'properties': null,\n };\n }\n\n const geometry = readGeometry(geoJSONFeature['geometry'], options);\n const feature = new Feature();\n if (this.geometryName_) {\n feature.setGeometryName(this.geometryName_);\n } else if (\n this.extractGeometryName_ &&\n 'geometry_name' in geoJSONFeature !== undefined\n ) {\n feature.setGeometryName(geoJSONFeature['geometry_name']);\n }\n feature.setGeometry(geometry);\n\n if ('id' in geoJSONFeature) {\n feature.setId(geoJSONFeature['id']);\n }\n\n if (geoJSONFeature['properties']) {\n feature.setProperties(geoJSONFeature['properties'], true);\n }\n return feature;\n }\n\n /**\n * @param {Object} object Object.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @protected\n * @return {Array} Features.\n */\n readFeaturesFromObject(object, options) {\n const geoJSONObject = /** @type {GeoJSONObject} */ (object);\n /** @type {Array} */\n let features = null;\n if (geoJSONObject['type'] === 'FeatureCollection') {\n const geoJSONFeatureCollection = /** @type {GeoJSONFeatureCollection} */ (\n object\n );\n features = [];\n const geoJSONFeatures = geoJSONFeatureCollection['features'];\n for (let i = 0, ii = geoJSONFeatures.length; i < ii; ++i) {\n features.push(this.readFeatureFromObject(geoJSONFeatures[i], options));\n }\n } else {\n features = [this.readFeatureFromObject(object, options)];\n }\n return features;\n }\n\n /**\n * @param {GeoJSONGeometry} object Object.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @protected\n * @return {import(\"../geom/Geometry.js\").default} Geometry.\n */\n readGeometryFromObject(object, options) {\n return readGeometry(object, options);\n }\n\n /**\n * @param {Object} object Object.\n * @protected\n * @return {import(\"../proj/Projection.js\").default} Projection.\n */\n readProjectionFromObject(object) {\n const crs = object['crs'];\n let projection;\n if (crs) {\n if (crs['type'] == 'name') {\n projection = getProjection(crs['properties']['name']);\n } else if (crs['type'] === 'EPSG') {\n projection = getProjection('EPSG:' + crs['properties']['code']);\n } else {\n throw new Error('Unknown SRS type');\n }\n } else {\n projection = this.dataProjection;\n }\n return /** @type {import(\"../proj/Projection.js\").default} */ (projection);\n }\n\n /**\n * Encode a feature as a GeoJSON Feature object.\n *\n * @param {import(\"../Feature.js\").default} feature Feature.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONFeature} Object.\n * @api\n */\n writeFeatureObject(feature, options) {\n options = this.adaptOptions(options);\n\n /** @type {GeoJSONFeature} */\n const object = {\n 'type': 'Feature',\n geometry: null,\n properties: null,\n };\n\n const id = feature.getId();\n if (id !== undefined) {\n object.id = id;\n }\n\n if (!feature.hasProperties()) {\n return object;\n }\n\n const properties = feature.getProperties();\n const geometry = feature.getGeometry();\n if (geometry) {\n object.geometry = writeGeometry(geometry, options);\n\n delete properties[feature.getGeometryName()];\n }\n\n if (!isEmpty(properties)) {\n object.properties = properties;\n }\n\n return object;\n }\n\n /**\n * Encode an array of features as a GeoJSON object.\n *\n * @param {Array} features Features.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONFeatureCollection} GeoJSON Object.\n * @api\n */\n writeFeaturesObject(features, options) {\n options = this.adaptOptions(options);\n const objects = [];\n for (let i = 0, ii = features.length; i < ii; ++i) {\n objects.push(this.writeFeatureObject(features[i], options));\n }\n return {\n type: 'FeatureCollection',\n features: objects,\n };\n }\n\n /**\n * Encode a geometry as a GeoJSON object.\n *\n * @param {import(\"../geom/Geometry.js\").default} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONGeometry|GeoJSONGeometryCollection} Object.\n * @api\n */\n writeGeometryObject(geometry, options) {\n return writeGeometry(geometry, this.adaptOptions(options));\n }\n}\n\n/**\n * @param {GeoJSONGeometry|GeoJSONGeometryCollection} object Object.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @return {import(\"../geom/Geometry.js\").default} Geometry.\n */\nfunction readGeometry(object, options) {\n if (!object) {\n return null;\n }\n\n /**\n * @type {import(\"../geom/Geometry.js\").default}\n */\n let geometry;\n switch (object['type']) {\n case 'Point': {\n geometry = readPointGeometry(/** @type {GeoJSONPoint} */ (object));\n break;\n }\n case 'LineString': {\n geometry = readLineStringGeometry(\n /** @type {GeoJSONLineString} */ (object)\n );\n break;\n }\n case 'Polygon': {\n geometry = readPolygonGeometry(/** @type {GeoJSONPolygon} */ (object));\n break;\n }\n case 'MultiPoint': {\n geometry = readMultiPointGeometry(\n /** @type {GeoJSONMultiPoint} */ (object)\n );\n break;\n }\n case 'MultiLineString': {\n geometry = readMultiLineStringGeometry(\n /** @type {GeoJSONMultiLineString} */ (object)\n );\n break;\n }\n case 'MultiPolygon': {\n geometry = readMultiPolygonGeometry(\n /** @type {GeoJSONMultiPolygon} */ (object)\n );\n break;\n }\n case 'GeometryCollection': {\n geometry = readGeometryCollectionGeometry(\n /** @type {GeoJSONGeometryCollection} */ (object)\n );\n break;\n }\n default: {\n throw new Error('Unsupported GeoJSON type: ' + object['type']);\n }\n }\n return transformGeometryWithOptions(geometry, false, options);\n}\n\n/**\n * @param {GeoJSONGeometryCollection} object Object.\n * @param {import(\"./Feature.js\").ReadOptions} [options] Read options.\n * @return {GeometryCollection} Geometry collection.\n */\nfunction readGeometryCollectionGeometry(object, options) {\n const geometries = object['geometries'].map(\n /**\n * @param {GeoJSONGeometry} geometry Geometry.\n * @return {import(\"../geom/Geometry.js\").default} geometry Geometry.\n */\n function (geometry) {\n return readGeometry(geometry, options);\n }\n );\n return new GeometryCollection(geometries);\n}\n\n/**\n * @param {GeoJSONPoint} object Object.\n * @return {Point} Point.\n */\nfunction readPointGeometry(object) {\n return new Point(object['coordinates']);\n}\n\n/**\n * @param {GeoJSONLineString} object Object.\n * @return {LineString} LineString.\n */\nfunction readLineStringGeometry(object) {\n return new LineString(object['coordinates']);\n}\n\n/**\n * @param {GeoJSONMultiLineString} object Object.\n * @return {MultiLineString} MultiLineString.\n */\nfunction readMultiLineStringGeometry(object) {\n return new MultiLineString(object['coordinates']);\n}\n\n/**\n * @param {GeoJSONMultiPoint} object Object.\n * @return {MultiPoint} MultiPoint.\n */\nfunction readMultiPointGeometry(object) {\n return new MultiPoint(object['coordinates']);\n}\n\n/**\n * @param {GeoJSONMultiPolygon} object Object.\n * @return {MultiPolygon} MultiPolygon.\n */\nfunction readMultiPolygonGeometry(object) {\n return new MultiPolygon(object['coordinates']);\n}\n\n/**\n * @param {GeoJSONPolygon} object Object.\n * @return {Polygon} Polygon.\n */\nfunction readPolygonGeometry(object) {\n return new Polygon(object['coordinates']);\n}\n\n/**\n * @param {import(\"../geom/Geometry.js\").default} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONGeometry} GeoJSON geometry.\n */\nfunction writeGeometry(geometry, options) {\n geometry = transformGeometryWithOptions(geometry, true, options);\n const type = geometry.getType();\n\n /** @type {GeoJSONGeometry} */\n let geoJSON;\n switch (type) {\n case 'Point': {\n geoJSON = writePointGeometry(/** @type {Point} */ (geometry), options);\n break;\n }\n case 'LineString': {\n geoJSON = writeLineStringGeometry(\n /** @type {LineString} */ (geometry),\n options\n );\n break;\n }\n case 'Polygon': {\n geoJSON = writePolygonGeometry(\n /** @type {Polygon} */ (geometry),\n options\n );\n break;\n }\n case 'MultiPoint': {\n geoJSON = writeMultiPointGeometry(\n /** @type {MultiPoint} */ (geometry),\n options\n );\n break;\n }\n case 'MultiLineString': {\n geoJSON = writeMultiLineStringGeometry(\n /** @type {MultiLineString} */ (geometry),\n options\n );\n break;\n }\n case 'MultiPolygon': {\n geoJSON = writeMultiPolygonGeometry(\n /** @type {MultiPolygon} */ (geometry),\n options\n );\n break;\n }\n case 'GeometryCollection': {\n geoJSON = writeGeometryCollectionGeometry(\n /** @type {GeometryCollection} */ (geometry),\n options\n );\n break;\n }\n case 'Circle': {\n geoJSON = {\n type: 'GeometryCollection',\n geometries: [],\n };\n break;\n }\n default: {\n throw new Error('Unsupported geometry type: ' + type);\n }\n }\n return geoJSON;\n}\n\n/**\n * @param {GeometryCollection} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONGeometryCollection} GeoJSON geometry collection.\n */\nfunction writeGeometryCollectionGeometry(geometry, options) {\n options = Object.assign({}, options);\n delete options.featureProjection;\n const geometries = geometry.getGeometriesArray().map(function (geometry) {\n return writeGeometry(geometry, options);\n });\n return {\n type: 'GeometryCollection',\n geometries: geometries,\n };\n}\n\n/**\n * @param {LineString} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONGeometry} GeoJSON geometry.\n */\nfunction writeLineStringGeometry(geometry, options) {\n return {\n type: 'LineString',\n coordinates: geometry.getCoordinates(),\n };\n}\n\n/**\n * @param {MultiLineString} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONGeometry} GeoJSON geometry.\n */\nfunction writeMultiLineStringGeometry(geometry, options) {\n return {\n type: 'MultiLineString',\n coordinates: geometry.getCoordinates(),\n };\n}\n\n/**\n * @param {MultiPoint} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONGeometry} GeoJSON geometry.\n */\nfunction writeMultiPointGeometry(geometry, options) {\n return {\n type: 'MultiPoint',\n coordinates: geometry.getCoordinates(),\n };\n}\n\n/**\n * @param {MultiPolygon} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONGeometry} GeoJSON geometry.\n */\nfunction writeMultiPolygonGeometry(geometry, options) {\n let right;\n if (options) {\n right = options.rightHanded;\n }\n return {\n type: 'MultiPolygon',\n coordinates: geometry.getCoordinates(right),\n };\n}\n\n/**\n * @param {Point} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONGeometry} GeoJSON geometry.\n */\nfunction writePointGeometry(geometry, options) {\n return {\n type: 'Point',\n coordinates: geometry.getCoordinates(),\n };\n}\n\n/**\n * @param {Polygon} geometry Geometry.\n * @param {import(\"./Feature.js\").WriteOptions} [options] Write options.\n * @return {GeoJSONGeometry} GeoJSON geometry.\n */\nfunction writePolygonGeometry(geometry, options) {\n let right;\n if (options) {\n right = options.rightHanded;\n }\n return {\n type: 'Polygon',\n coordinates: geometry.getCoordinates(right),\n };\n}\n\nexport default GeoJSON;\n","/**\n * @module ol/style/Fill\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|null} [color=null] A color, gradient or pattern.\n * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats.\n * Default null; if null, the Canvas/renderer default black will be used.\n */\n\n/**\n * @classdesc\n * Set fill style for vector features.\n * @api\n */\nclass Fill {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options || {};\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|null}\n */\n this.color_ = options.color !== undefined ? options.color : null;\n }\n\n /**\n * Clones the style. The color is not cloned if it is an {@link module:ol/colorlike~ColorLike}.\n * @return {Fill} The cloned style.\n * @api\n */\n clone() {\n const color = this.getColor();\n return new Fill({\n color: Array.isArray(color) ? color.slice() : color || undefined,\n });\n }\n\n /**\n * Get the fill color.\n * @return {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|null} Color.\n * @api\n */\n getColor() {\n return this.color_;\n }\n\n /**\n * Set the color.\n *\n * @param {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike|null} color Color.\n * @api\n */\n setColor(color) {\n this.color_ = color;\n }\n}\n\nexport default Fill;\n","/**\n * @module ol/style/Stroke\n */\n\n/**\n * @typedef {Object} Options\n * @property {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} [color] A color, gradient or pattern.\n * See {@link module:ol/color~Color} and {@link module:ol/colorlike~ColorLike} for possible formats.\n * Default null; if null, the Canvas/renderer default black will be used.\n * @property {CanvasLineCap} [lineCap='round'] Line cap style: `butt`, `round`, or `square`.\n * @property {CanvasLineJoin} [lineJoin='round'] Line join style: `bevel`, `round`, or `miter`.\n * @property {Array} [lineDash] Line dash pattern. Default is `null` (no dash).\n * @property {number} [lineDashOffset=0] Line dash offset.\n * @property {number} [miterLimit=10] Miter limit.\n * @property {number} [width] Width.\n */\n\n/**\n * @classdesc\n * Set stroke style for vector features.\n * Note that the defaults given are the Canvas defaults, which will be used if\n * option is not defined. The `get` functions return whatever was entered in\n * the options; they will not return the default.\n * @api\n */\nclass Stroke {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options || {};\n\n /**\n * @private\n * @type {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike}\n */\n this.color_ = options.color !== undefined ? options.color : null;\n\n /**\n * @private\n * @type {CanvasLineCap|undefined}\n */\n this.lineCap_ = options.lineCap;\n\n /**\n * @private\n * @type {Array|null}\n */\n this.lineDash_ = options.lineDash !== undefined ? options.lineDash : null;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.lineDashOffset_ = options.lineDashOffset;\n\n /**\n * @private\n * @type {CanvasLineJoin|undefined}\n */\n this.lineJoin_ = options.lineJoin;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.miterLimit_ = options.miterLimit;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.width_ = options.width;\n }\n\n /**\n * Clones the style.\n * @return {Stroke} The cloned style.\n * @api\n */\n clone() {\n const color = this.getColor();\n return new Stroke({\n color: Array.isArray(color) ? color.slice() : color || undefined,\n lineCap: this.getLineCap(),\n lineDash: this.getLineDash() ? this.getLineDash().slice() : undefined,\n lineDashOffset: this.getLineDashOffset(),\n lineJoin: this.getLineJoin(),\n miterLimit: this.getMiterLimit(),\n width: this.getWidth(),\n });\n }\n\n /**\n * Get the stroke color.\n * @return {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} Color.\n * @api\n */\n getColor() {\n return this.color_;\n }\n\n /**\n * Get the line cap type for the stroke.\n * @return {CanvasLineCap|undefined} Line cap.\n * @api\n */\n getLineCap() {\n return this.lineCap_;\n }\n\n /**\n * Get the line dash style for the stroke.\n * @return {Array|null} Line dash.\n * @api\n */\n getLineDash() {\n return this.lineDash_;\n }\n\n /**\n * Get the line dash offset for the stroke.\n * @return {number|undefined} Line dash offset.\n * @api\n */\n getLineDashOffset() {\n return this.lineDashOffset_;\n }\n\n /**\n * Get the line join type for the stroke.\n * @return {CanvasLineJoin|undefined} Line join.\n * @api\n */\n getLineJoin() {\n return this.lineJoin_;\n }\n\n /**\n * Get the miter limit for the stroke.\n * @return {number|undefined} Miter limit.\n * @api\n */\n getMiterLimit() {\n return this.miterLimit_;\n }\n\n /**\n * Get the stroke width.\n * @return {number|undefined} Width.\n * @api\n */\n getWidth() {\n return this.width_;\n }\n\n /**\n * Set the color.\n *\n * @param {import(\"../color.js\").Color|import(\"../colorlike.js\").ColorLike} color Color.\n * @api\n */\n setColor(color) {\n this.color_ = color;\n }\n\n /**\n * Set the line cap.\n *\n * @param {CanvasLineCap|undefined} lineCap Line cap.\n * @api\n */\n setLineCap(lineCap) {\n this.lineCap_ = lineCap;\n }\n\n /**\n * Set the line dash.\n *\n * @param {Array|null} lineDash Line dash.\n * @api\n */\n setLineDash(lineDash) {\n this.lineDash_ = lineDash;\n }\n\n /**\n * Set the line dash offset.\n *\n * @param {number|undefined} lineDashOffset Line dash offset.\n * @api\n */\n setLineDashOffset(lineDashOffset) {\n this.lineDashOffset_ = lineDashOffset;\n }\n\n /**\n * Set the line join.\n *\n * @param {CanvasLineJoin|undefined} lineJoin Line join.\n * @api\n */\n setLineJoin(lineJoin) {\n this.lineJoin_ = lineJoin;\n }\n\n /**\n * Set the miter limit.\n *\n * @param {number|undefined} miterLimit Miter limit.\n * @api\n */\n setMiterLimit(miterLimit) {\n this.miterLimit_ = miterLimit;\n }\n\n /**\n * Set the width.\n *\n * @param {number|undefined} width Width.\n * @api\n */\n setWidth(width) {\n this.width_ = width;\n }\n}\n\nexport default Stroke;\n","/**\n * @module ol/colorlike\n */\nimport {toString} from './color.js';\n\n/**\n * A type accepted by CanvasRenderingContext2D.fillStyle\n * or CanvasRenderingContext2D.strokeStyle.\n * Represents a color, pattern, or gradient. The origin for patterns and\n * gradients as fill style is an increment of 512 css pixels from map coordinate\n * `[0, 0]`. For seamless repeat patterns, width and height of the pattern image\n * must be a factor of two (2, 4, 8, ..., 512).\n *\n * @typedef {string|CanvasPattern|CanvasGradient} ColorLike\n * @api\n */\n\n/**\n * @param {import(\"./color.js\").Color|ColorLike} color Color.\n * @return {ColorLike} The color as an {@link ol/colorlike~ColorLike}.\n * @api\n */\nexport function asColorLike(color) {\n if (Array.isArray(color)) {\n return toString(color);\n }\n return color;\n}\n","/**\n * @module ol/css\n */\n\n/**\n * @typedef {Object} FontParameters\n * @property {string} style Style.\n * @property {string} variant Variant.\n * @property {string} weight Weight.\n * @property {string} size Size.\n * @property {string} lineHeight LineHeight.\n * @property {string} family Family.\n * @property {Array} families Families.\n */\n\n/**\n * The CSS class for hidden feature.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_HIDDEN = 'ol-hidden';\n\n/**\n * The CSS class that we'll give the DOM elements to have them selectable.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_SELECTABLE = 'ol-selectable';\n\n/**\n * The CSS class that we'll give the DOM elements to have them unselectable.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_UNSELECTABLE = 'ol-unselectable';\n\n/**\n * The CSS class for unsupported feature.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_UNSUPPORTED = 'ol-unsupported';\n\n/**\n * The CSS class for controls.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_CONTROL = 'ol-control';\n\n/**\n * The CSS class that we'll give the DOM elements that are collapsed, i.e.\n * to those elements which usually can be expanded.\n *\n * @const\n * @type {string}\n */\nexport const CLASS_COLLAPSED = 'ol-collapsed';\n\n/**\n * From https://stackoverflow.com/questions/10135697/regex-to-parse-any-css-font\n * @type {RegExp}\n */\nconst fontRegEx = new RegExp(\n [\n '^\\\\s*(?=(?:(?:[-a-z]+\\\\s*){0,2}(italic|oblique))?)',\n '(?=(?:(?:[-a-z]+\\\\s*){0,2}(small-caps))?)',\n '(?=(?:(?:[-a-z]+\\\\s*){0,2}(bold(?:er)?|lighter|[1-9]00 ))?)',\n '(?:(?:normal|\\\\1|\\\\2|\\\\3)\\\\s*){0,3}((?:xx?-)?',\n '(?:small|large)|medium|smaller|larger|[\\\\.\\\\d]+(?:\\\\%|in|[cem]m|ex|p[ctx]))',\n '(?:\\\\s*\\\\/\\\\s*(normal|[\\\\.\\\\d]+(?:\\\\%|in|[cem]m|ex|p[ctx])?))',\n '?\\\\s*([-,\\\\\"\\\\\\'\\\\sa-z]+?)\\\\s*$',\n ].join(''),\n 'i'\n);\nconst fontRegExMatchIndex = [\n 'style',\n 'variant',\n 'weight',\n 'size',\n 'lineHeight',\n 'family',\n];\n\n/**\n * Get the list of font families from a font spec. Note that this doesn't work\n * for font families that have commas in them.\n * @param {string} fontSpec The CSS font property.\n * @return {FontParameters|null} The font parameters (or null if the input spec is invalid).\n */\nexport const getFontParameters = function (fontSpec) {\n const match = fontSpec.match(fontRegEx);\n if (!match) {\n return null;\n }\n const style = /** @type {FontParameters} */ ({\n lineHeight: 'normal',\n size: '1.2em',\n style: 'normal',\n weight: 'normal',\n variant: 'normal',\n });\n for (let i = 0, ii = fontRegExMatchIndex.length; i < ii; ++i) {\n const value = match[i + 1];\n if (value !== undefined) {\n style[fontRegExMatchIndex[i]] = value;\n }\n }\n style.families = style.family.split(/,\\s?/);\n return style;\n};\n","/**\n * @module ol/render/canvas\n */\nimport BaseObject from '../Object.js';\nimport {WORKER_OFFSCREEN_CANVAS} from '../has.js';\nimport {clear} from '../obj.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {getFontParameters} from '../css.js';\n\n/**\n * @typedef {'Circle' | 'Image' | 'LineString' | 'Polygon' | 'Text' | 'Default'} BuilderType\n */\n\n/**\n * @typedef {Object} FillState\n * @property {import(\"../colorlike.js\").ColorLike} fillStyle FillStyle.\n */\n\n/**\n * @typedef Label\n * @property {number} width Width.\n * @property {number} height Height.\n * @property {Array} contextInstructions ContextInstructions.\n */\n\n/**\n * @typedef {Object} FillStrokeState\n * @property {import(\"../colorlike.js\").ColorLike} [currentFillStyle] Current FillStyle.\n * @property {import(\"../colorlike.js\").ColorLike} [currentStrokeStyle] Current StrokeStyle.\n * @property {CanvasLineCap} [currentLineCap] Current LineCap.\n * @property {Array} currentLineDash Current LineDash.\n * @property {number} [currentLineDashOffset] Current LineDashOffset.\n * @property {CanvasLineJoin} [currentLineJoin] Current LineJoin.\n * @property {number} [currentLineWidth] Current LineWidth.\n * @property {number} [currentMiterLimit] Current MiterLimit.\n * @property {number} [lastStroke] Last stroke.\n * @property {import(\"../colorlike.js\").ColorLike} [fillStyle] FillStyle.\n * @property {import(\"../colorlike.js\").ColorLike} [strokeStyle] StrokeStyle.\n * @property {CanvasLineCap} [lineCap] LineCap.\n * @property {Array} lineDash LineDash.\n * @property {number} [lineDashOffset] LineDashOffset.\n * @property {CanvasLineJoin} [lineJoin] LineJoin.\n * @property {number} [lineWidth] LineWidth.\n * @property {number} [miterLimit] MiterLimit.\n */\n\n/**\n * @typedef {Object} StrokeState\n * @property {CanvasLineCap} lineCap LineCap.\n * @property {Array} lineDash LineDash.\n * @property {number} lineDashOffset LineDashOffset.\n * @property {CanvasLineJoin} lineJoin LineJoin.\n * @property {number} lineWidth LineWidth.\n * @property {number} miterLimit MiterLimit.\n * @property {import(\"../colorlike.js\").ColorLike} strokeStyle StrokeStyle.\n */\n\n/**\n * @typedef {Object} TextState\n * @property {string} font Font.\n * @property {CanvasTextAlign} [textAlign] TextAlign.\n * @property {number} [repeat] Repeat.\n * @property {import(\"../style/Text.js\").TextJustify} [justify] Justify.\n * @property {CanvasTextBaseline} textBaseline TextBaseline.\n * @property {import(\"../style/Text.js\").TextPlacement} [placement] Placement.\n * @property {number} [maxAngle] MaxAngle.\n * @property {boolean} [overflow] Overflow.\n * @property {import(\"../style/Fill.js\").default} [backgroundFill] BackgroundFill.\n * @property {import(\"../style/Stroke.js\").default} [backgroundStroke] BackgroundStroke.\n * @property {import(\"../size.js\").Size} [scale] Scale.\n * @property {Array} [padding] Padding.\n */\n\n/**\n * @typedef {Object} SerializableInstructions\n * @property {Array<*>} instructions The rendering instructions.\n * @property {Array<*>} hitDetectionInstructions The rendering hit detection instructions.\n * @property {Array} coordinates The array of all coordinates.\n * @property {!Object} [textStates] The text states (decluttering).\n * @property {!Object} [fillStates] The fill states (decluttering).\n * @property {!Object} [strokeStates] The stroke states (decluttering).\n */\n\n/**\n * @typedef {Object} DeclutterImageWithText\n */\n\n/**\n * @const\n * @type {string}\n */\nexport const defaultFont = '10px sans-serif';\n\n/**\n * @const\n * @type {string}\n */\nexport const defaultFillStyle = '#000';\n\n/**\n * @const\n * @type {CanvasLineCap}\n */\nexport const defaultLineCap = 'round';\n\n/**\n * @const\n * @type {Array}\n */\nexport const defaultLineDash = [];\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultLineDashOffset = 0;\n\n/**\n * @const\n * @type {CanvasLineJoin}\n */\nexport const defaultLineJoin = 'round';\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultMiterLimit = 10;\n\n/**\n * @const\n * @type {import(\"../colorlike.js\").ColorLike}\n */\nexport const defaultStrokeStyle = '#000';\n\n/**\n * @const\n * @type {CanvasTextAlign}\n */\nexport const defaultTextAlign = 'center';\n\n/**\n * @const\n * @type {CanvasTextBaseline}\n */\nexport const defaultTextBaseline = 'middle';\n\n/**\n * @const\n * @type {Array}\n */\nexport const defaultPadding = [0, 0, 0, 0];\n\n/**\n * @const\n * @type {number}\n */\nexport const defaultLineWidth = 1;\n\n/**\n * @type {BaseObject}\n */\nexport const checkedFonts = new BaseObject();\n\n/**\n * @type {CanvasRenderingContext2D}\n */\nlet measureContext = null;\n\n/**\n * @type {string}\n */\nlet measureFont;\n\n/**\n * @type {!Object}\n */\nexport const textHeights = {};\n\n/**\n * Clears the label cache when a font becomes available.\n * @param {string} fontSpec CSS font spec.\n */\nexport const registerFont = (function () {\n const retries = 100;\n const size = '32px ';\n const referenceFonts = ['monospace', 'serif'];\n const len = referenceFonts.length;\n const text = 'wmytzilWMYTZIL@#/&?$%10\\uF013';\n let interval, referenceWidth;\n\n /**\n * @param {string} fontStyle Css font-style\n * @param {string} fontWeight Css font-weight\n * @param {*} fontFamily Css font-family\n * @return {boolean} Font with style and weight is available\n */\n function isAvailable(fontStyle, fontWeight, fontFamily) {\n let available = true;\n for (let i = 0; i < len; ++i) {\n const referenceFont = referenceFonts[i];\n referenceWidth = measureTextWidth(\n fontStyle + ' ' + fontWeight + ' ' + size + referenceFont,\n text\n );\n if (fontFamily != referenceFont) {\n const width = measureTextWidth(\n fontStyle +\n ' ' +\n fontWeight +\n ' ' +\n size +\n fontFamily +\n ',' +\n referenceFont,\n text\n );\n // If width and referenceWidth are the same, then the fallback was used\n // instead of the font we wanted, so the font is not available.\n available = available && width != referenceWidth;\n }\n }\n if (available) {\n return true;\n }\n return false;\n }\n\n function check() {\n let done = true;\n const fonts = checkedFonts.getKeys();\n for (let i = 0, ii = fonts.length; i < ii; ++i) {\n const font = fonts[i];\n if (checkedFonts.get(font) < retries) {\n if (isAvailable.apply(this, font.split('\\n'))) {\n clear(textHeights);\n // Make sure that loaded fonts are picked up by Safari\n measureContext = null;\n measureFont = undefined;\n checkedFonts.set(font, retries);\n } else {\n checkedFonts.set(font, checkedFonts.get(font) + 1, true);\n done = false;\n }\n }\n }\n if (done) {\n clearInterval(interval);\n interval = undefined;\n }\n }\n\n return function (fontSpec) {\n const font = getFontParameters(fontSpec);\n if (!font) {\n return;\n }\n const families = font.families;\n for (let i = 0, ii = families.length; i < ii; ++i) {\n const family = families[i];\n const key = font.style + '\\n' + font.weight + '\\n' + family;\n if (checkedFonts.get(key) === undefined) {\n checkedFonts.set(key, retries, true);\n if (!isAvailable(font.style, font.weight, family)) {\n checkedFonts.set(key, 0, true);\n if (interval === undefined) {\n interval = setInterval(check, 32);\n }\n }\n }\n }\n };\n})();\n\n/**\n * @param {string} font Font to use for measuring.\n * @return {import(\"../size.js\").Size} Measurement.\n */\nexport const measureTextHeight = (function () {\n /**\n * @type {HTMLDivElement}\n */\n let measureElement;\n return function (fontSpec) {\n let height = textHeights[fontSpec];\n if (height == undefined) {\n if (WORKER_OFFSCREEN_CANVAS) {\n const font = getFontParameters(fontSpec);\n const metrics = measureText(fontSpec, 'Žg');\n const lineHeight = isNaN(Number(font.lineHeight))\n ? 1.2\n : Number(font.lineHeight);\n height =\n lineHeight *\n (metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent);\n } else {\n if (!measureElement) {\n measureElement = document.createElement('div');\n measureElement.innerHTML = 'M';\n measureElement.style.minHeight = '0';\n measureElement.style.maxHeight = 'none';\n measureElement.style.height = 'auto';\n measureElement.style.padding = '0';\n measureElement.style.border = 'none';\n measureElement.style.position = 'absolute';\n measureElement.style.display = 'block';\n measureElement.style.left = '-99999px';\n }\n measureElement.style.font = fontSpec;\n document.body.appendChild(measureElement);\n height = measureElement.offsetHeight;\n document.body.removeChild(measureElement);\n }\n textHeights[fontSpec] = height;\n }\n return height;\n };\n})();\n\n/**\n * @param {string} font Font.\n * @param {string} text Text.\n * @return {TextMetrics} Text metrics.\n */\nfunction measureText(font, text) {\n if (!measureContext) {\n measureContext = createCanvasContext2D(1, 1);\n }\n if (font != measureFont) {\n measureContext.font = font;\n measureFont = measureContext.font;\n }\n return measureContext.measureText(text);\n}\n\n/**\n * @param {string} font Font.\n * @param {string} text Text.\n * @return {number} Width.\n */\nexport function measureTextWidth(font, text) {\n return measureText(font, text).width;\n}\n\n/**\n * Measure text width using a cache.\n * @param {string} font The font.\n * @param {string} text The text to measure.\n * @param {Object} cache A lookup of cached widths by text.\n * @return {number} The text width.\n */\nexport function measureAndCacheTextWidth(font, text, cache) {\n if (text in cache) {\n return cache[text];\n }\n const width = text\n .split('\\n')\n .reduce((prev, curr) => Math.max(prev, measureTextWidth(font, curr)), 0);\n cache[text] = width;\n return width;\n}\n\n/**\n * @param {TextState} baseStyle Base style.\n * @param {Array} chunks Text chunks to measure.\n * @return {{width: number, height: number, widths: Array, heights: Array, lineWidths: Array}}} Text metrics.\n */\nexport function getTextDimensions(baseStyle, chunks) {\n const widths = [];\n const heights = [];\n const lineWidths = [];\n let width = 0;\n let lineWidth = 0;\n let height = 0;\n let lineHeight = 0;\n for (let i = 0, ii = chunks.length; i <= ii; i += 2) {\n const text = chunks[i];\n if (text === '\\n' || i === ii) {\n width = Math.max(width, lineWidth);\n lineWidths.push(lineWidth);\n lineWidth = 0;\n height += lineHeight;\n continue;\n }\n const font = chunks[i + 1] || baseStyle.font;\n const currentWidth = measureTextWidth(font, text);\n widths.push(currentWidth);\n lineWidth += currentWidth;\n const currentHeight = measureTextHeight(font);\n heights.push(currentHeight);\n lineHeight = Math.max(lineHeight, currentHeight);\n }\n return {width, height, widths, heights, lineWidths};\n}\n\n/**\n * @param {CanvasRenderingContext2D} context Context.\n * @param {number} rotation Rotation.\n * @param {number} offsetX X offset.\n * @param {number} offsetY Y offset.\n */\nexport function rotateAtOffset(context, rotation, offsetX, offsetY) {\n if (rotation !== 0) {\n context.translate(offsetX, offsetY);\n context.rotate(rotation);\n context.translate(-offsetX, -offsetY);\n }\n}\n\n/**\n * @param {CanvasRenderingContext2D} context Context.\n * @param {import(\"../transform.js\").Transform|null} transform Transform.\n * @param {number} opacity Opacity.\n * @param {Label|HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} labelOrImage Label.\n * @param {number} originX Origin X.\n * @param {number} originY Origin Y.\n * @param {number} w Width.\n * @param {number} h Height.\n * @param {number} x X.\n * @param {number} y Y.\n * @param {import(\"../size.js\").Size} scale Scale.\n */\nexport function drawImageOrLabel(\n context,\n transform,\n opacity,\n labelOrImage,\n originX,\n originY,\n w,\n h,\n x,\n y,\n scale\n) {\n context.save();\n\n if (opacity !== 1) {\n context.globalAlpha *= opacity;\n }\n if (transform) {\n context.transform.apply(context, transform);\n }\n\n if (/** @type {*} */ (labelOrImage).contextInstructions) {\n // label\n context.translate(x, y);\n context.scale(scale[0], scale[1]);\n executeLabelInstructions(/** @type {Label} */ (labelOrImage), context);\n } else if (scale[0] < 0 || scale[1] < 0) {\n // flipped image\n context.translate(x, y);\n context.scale(scale[0], scale[1]);\n context.drawImage(\n /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (\n labelOrImage\n ),\n originX,\n originY,\n w,\n h,\n 0,\n 0,\n w,\n h\n );\n } else {\n // if image not flipped translate and scale can be avoided\n context.drawImage(\n /** @type {HTMLCanvasElement|HTMLImageElement|HTMLVideoElement} */ (\n labelOrImage\n ),\n originX,\n originY,\n w,\n h,\n x,\n y,\n w * scale[0],\n h * scale[1]\n );\n }\n\n context.restore();\n}\n\n/**\n * @param {Label} label Label.\n * @param {CanvasRenderingContext2D} context Context.\n */\nfunction executeLabelInstructions(label, context) {\n const contextInstructions = label.contextInstructions;\n for (let i = 0, ii = contextInstructions.length; i < ii; i += 2) {\n if (Array.isArray(contextInstructions[i + 1])) {\n context[contextInstructions[i]].apply(\n context,\n contextInstructions[i + 1]\n );\n } else {\n context[contextInstructions[i]] = contextInstructions[i + 1];\n }\n }\n}\n","/**\n * @module ol/style/RegularShape\n */\n\nimport ImageState from '../ImageState.js';\nimport ImageStyle from './Image.js';\nimport {asArray} from '../color.js';\nimport {asColorLike} from '../colorlike.js';\nimport {createCanvasContext2D} from '../dom.js';\nimport {\n defaultFillStyle,\n defaultLineCap,\n defaultLineJoin,\n defaultLineWidth,\n defaultMiterLimit,\n defaultStrokeStyle,\n} from '../render/canvas.js';\n\n/**\n * Specify radius for regular polygons, or radius1 and radius2 for stars.\n * @typedef {Object} Options\n * @property {import(\"./Fill.js\").default} [fill] Fill style.\n * @property {number} points Number of points for stars and regular polygons. In case of a polygon, the number of points\n * is the number of sides.\n * @property {number} [radius] Radius of a regular polygon.\n * @property {number} [radius1] First radius of a star. Ignored if radius is set.\n * @property {number} [radius2] Second radius of a star.\n * @property {number} [angle=0] Shape's angle in radians. A value of 0 will have one of the shape's points facing up.\n * @property {Array} [displacement=[0, 0]] Displacement of the shape in pixels.\n * Positive values will shift the shape right and up.\n * @property {import(\"./Stroke.js\").default} [stroke] Stroke style.\n * @property {number} [rotation=0] Rotation in radians (positive rotation clockwise).\n * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view.\n * @property {number|import(\"../size.js\").Size} [scale=1] Scale. Unless two dimensional scaling is required a better\n * result may be obtained with appropriate settings for `radius`, `radius1` and `radius2`.\n * @property {\"declutter\"|\"obstacle\"|\"none\"|undefined} [declutterMode] Declutter mode.\n */\n\n/**\n * @typedef {Object} RenderOptions\n * @property {import(\"../colorlike.js\").ColorLike} [strokeStyle] StrokeStyle.\n * @property {number} strokeWidth StrokeWidth.\n * @property {number} size Size.\n * @property {CanvasLineCap} lineCap LineCap.\n * @property {Array|null} lineDash LineDash.\n * @property {number} lineDashOffset LineDashOffset.\n * @property {CanvasLineJoin} lineJoin LineJoin.\n * @property {number} miterLimit MiterLimit.\n */\n\n/**\n * @classdesc\n * Set regular shape style for vector features. The resulting shape will be\n * a regular polygon when `radius` is provided, or a star when `radius1` and\n * `radius2` are provided.\n * @api\n */\nclass RegularShape extends ImageStyle {\n /**\n * @param {Options} options Options.\n */\n constructor(options) {\n /**\n * @type {boolean}\n */\n const rotateWithView =\n options.rotateWithView !== undefined ? options.rotateWithView : false;\n\n super({\n opacity: 1,\n rotateWithView: rotateWithView,\n rotation: options.rotation !== undefined ? options.rotation : 0,\n scale: options.scale !== undefined ? options.scale : 1,\n displacement:\n options.displacement !== undefined ? options.displacement : [0, 0],\n declutterMode: options.declutterMode,\n });\n\n /**\n * @private\n * @type {Object}\n */\n this.canvas_ = undefined;\n\n /**\n * @private\n * @type {HTMLCanvasElement}\n */\n this.hitDetectionCanvas_ = null;\n\n /**\n * @private\n * @type {import(\"./Fill.js\").default}\n */\n this.fill_ = options.fill !== undefined ? options.fill : null;\n\n /**\n * @private\n * @type {Array}\n */\n this.origin_ = [0, 0];\n\n /**\n * @private\n * @type {number}\n */\n this.points_ = options.points;\n\n /**\n * @protected\n * @type {number}\n */\n this.radius_ =\n options.radius !== undefined ? options.radius : options.radius1;\n\n /**\n * @private\n * @type {number|undefined}\n */\n this.radius2_ = options.radius2;\n\n /**\n * @private\n * @type {number}\n */\n this.angle_ = options.angle !== undefined ? options.angle : 0;\n\n /**\n * @private\n * @type {import(\"./Stroke.js\").default}\n */\n this.stroke_ = options.stroke !== undefined ? options.stroke : null;\n\n /**\n * @private\n * @type {import(\"../size.js\").Size}\n */\n this.size_ = null;\n\n /**\n * @private\n * @type {RenderOptions}\n */\n this.renderOptions_ = null;\n\n this.render();\n }\n\n /**\n * Clones the style.\n * @return {RegularShape} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n const style = new RegularShape({\n fill: this.getFill() ? this.getFill().clone() : undefined,\n points: this.getPoints(),\n radius: this.getRadius(),\n radius2: this.getRadius2(),\n angle: this.getAngle(),\n stroke: this.getStroke() ? this.getStroke().clone() : undefined,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n style.setOpacity(this.getOpacity());\n return style;\n }\n\n /**\n * Get the anchor point in pixels. The anchor determines the center point for the\n * symbolizer.\n * @return {Array} Anchor.\n * @api\n */\n getAnchor() {\n const size = this.size_;\n if (!size) {\n return null;\n }\n const displacement = this.getDisplacement();\n const scale = this.getScaleArray();\n // anchor is scaled by renderer but displacement should not be scaled\n // so divide by scale here\n return [\n size[0] / 2 - displacement[0] / scale[0],\n size[1] / 2 + displacement[1] / scale[1],\n ];\n }\n\n /**\n * Get the angle used in generating the shape.\n * @return {number} Shape's rotation in radians.\n * @api\n */\n getAngle() {\n return this.angle_;\n }\n\n /**\n * Get the fill style for the shape.\n * @return {import(\"./Fill.js\").default} Fill style.\n * @api\n */\n getFill() {\n return this.fill_;\n }\n\n /**\n * Set the fill style.\n * @param {import(\"./Fill.js\").default} fill Fill style.\n * @api\n */\n setFill(fill) {\n this.fill_ = fill;\n this.render();\n }\n\n /**\n * @return {HTMLCanvasElement} Image element.\n */\n getHitDetectionImage() {\n if (!this.hitDetectionCanvas_) {\n this.createHitDetectionCanvas_(this.renderOptions_);\n }\n return this.hitDetectionCanvas_;\n }\n\n /**\n * Get the image icon.\n * @param {number} pixelRatio Pixel ratio.\n * @return {HTMLCanvasElement} Image or Canvas element.\n * @api\n */\n getImage(pixelRatio) {\n let image = this.canvas_[pixelRatio];\n if (!image) {\n const renderOptions = this.renderOptions_;\n const context = createCanvasContext2D(\n renderOptions.size * pixelRatio,\n renderOptions.size * pixelRatio\n );\n this.draw_(renderOptions, context, pixelRatio);\n\n image = context.canvas;\n this.canvas_[pixelRatio] = image;\n }\n return image;\n }\n\n /**\n * Get the image pixel ratio.\n * @param {number} pixelRatio Pixel ratio.\n * @return {number} Pixel ratio.\n */\n getPixelRatio(pixelRatio) {\n return pixelRatio;\n }\n\n /**\n * @return {import(\"../size.js\").Size} Image size.\n */\n getImageSize() {\n return this.size_;\n }\n\n /**\n * @return {import(\"../ImageState.js\").default} Image state.\n */\n getImageState() {\n return ImageState.LOADED;\n }\n\n /**\n * Get the origin of the symbolizer.\n * @return {Array} Origin.\n * @api\n */\n getOrigin() {\n return this.origin_;\n }\n\n /**\n * Get the number of points for generating the shape.\n * @return {number} Number of points for stars and regular polygons.\n * @api\n */\n getPoints() {\n return this.points_;\n }\n\n /**\n * Get the (primary) radius for the shape.\n * @return {number} Radius.\n * @api\n */\n getRadius() {\n return this.radius_;\n }\n\n /**\n * Get the secondary radius for the shape.\n * @return {number|undefined} Radius2.\n * @api\n */\n getRadius2() {\n return this.radius2_;\n }\n\n /**\n * Get the size of the symbolizer (in pixels).\n * @return {import(\"../size.js\").Size} Size.\n * @api\n */\n getSize() {\n return this.size_;\n }\n\n /**\n * Get the stroke style for the shape.\n * @return {import(\"./Stroke.js\").default} Stroke style.\n * @api\n */\n getStroke() {\n return this.stroke_;\n }\n\n /**\n * Set the stroke style.\n * @param {import(\"./Stroke.js\").default} stroke Stroke style.\n * @api\n */\n setStroke(stroke) {\n this.stroke_ = stroke;\n this.render();\n }\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n listenImageChange(listener) {}\n\n /**\n * Load not yet loaded URI.\n */\n load() {}\n\n /**\n * @param {function(import(\"../events/Event.js\").default): void} listener Listener function.\n */\n unlistenImageChange(listener) {}\n\n /**\n * Calculate additional canvas size needed for the miter.\n * @param {string} lineJoin Line join\n * @param {number} strokeWidth Stroke width\n * @param {number} miterLimit Miter limit\n * @return {number} Additional canvas size needed\n * @private\n */\n calculateLineJoinSize_(lineJoin, strokeWidth, miterLimit) {\n if (\n strokeWidth === 0 ||\n this.points_ === Infinity ||\n (lineJoin !== 'bevel' && lineJoin !== 'miter')\n ) {\n return strokeWidth;\n }\n // m | ^\n // i | |\\ .\n // t >| #\\\n // e | |\\ \\ .\n // r \\s\\\n // | \\t\\ . .\n // \\r\\ . .\n // | \\o\\ . . . . .\n // e \\k\\ . . . .\n // | \\e\\ . . . . .\n // d \\ \\ . . . .\n // | _ _a_ _\\# . . .\n // r1 / ` . .\n // | . .\n // b / . .\n // | . .\n // / r2 . .\n // | . .\n // / . .\n // |α . .\n // / . .\n // ° center\n let r1 = this.radius_;\n let r2 = this.radius2_ === undefined ? r1 : this.radius2_;\n if (r1 < r2) {\n const tmp = r1;\n r1 = r2;\n r2 = tmp;\n }\n const points =\n this.radius2_ === undefined ? this.points_ : this.points_ * 2;\n const alpha = (2 * Math.PI) / points;\n const a = r2 * Math.sin(alpha);\n const b = Math.sqrt(r2 * r2 - a * a);\n const d = r1 - b;\n const e = Math.sqrt(a * a + d * d);\n const miterRatio = e / a;\n if (lineJoin === 'miter' && miterRatio <= miterLimit) {\n return miterRatio * strokeWidth;\n }\n // Calculate the distance from center to the stroke corner where\n // it was cut short because of the miter limit.\n // l\n // ----+---- <= distance from center to here is maxr\n // /####|k ##\\\n // /#####^#####\\\n // /#### /+\\# s #\\\n // /### h/+++\\# t #\\\n // /### t/+++++\\# r #\\\n // /### a/+++++++\\# o #\\\n // /### p/++ fill +\\# k #\\\n ///#### /+++++^+++++\\# e #\\\n //#####/+++++/+\\+++++\\#####\\\n const k = strokeWidth / 2 / miterRatio;\n const l = (strokeWidth / 2) * (d / e);\n const maxr = Math.sqrt((r1 + k) * (r1 + k) + l * l);\n const bevelAdd = maxr - r1;\n if (this.radius2_ === undefined || lineJoin === 'bevel') {\n return bevelAdd * 2;\n }\n // If outer miter is over the miter limit the inner miter may reach through the\n // center and be longer than the bevel, same calculation as above but swap r1 / r2.\n const aa = r1 * Math.sin(alpha);\n const bb = Math.sqrt(r1 * r1 - aa * aa);\n const dd = r2 - bb;\n const ee = Math.sqrt(aa * aa + dd * dd);\n const innerMiterRatio = ee / aa;\n if (innerMiterRatio <= miterLimit) {\n const innerLength = (innerMiterRatio * strokeWidth) / 2 - r2 - r1;\n return 2 * Math.max(bevelAdd, innerLength);\n }\n return bevelAdd * 2;\n }\n\n /**\n * @return {RenderOptions} The render options\n * @protected\n */\n createRenderOptions() {\n let lineCap = defaultLineCap;\n let lineJoin = defaultLineJoin;\n let miterLimit = 0;\n let lineDash = null;\n let lineDashOffset = 0;\n let strokeStyle;\n let strokeWidth = 0;\n\n if (this.stroke_) {\n strokeStyle = this.stroke_.getColor();\n if (strokeStyle === null) {\n strokeStyle = defaultStrokeStyle;\n }\n strokeStyle = asColorLike(strokeStyle);\n strokeWidth = this.stroke_.getWidth();\n if (strokeWidth === undefined) {\n strokeWidth = defaultLineWidth;\n }\n lineDash = this.stroke_.getLineDash();\n lineDashOffset = this.stroke_.getLineDashOffset();\n lineJoin = this.stroke_.getLineJoin();\n if (lineJoin === undefined) {\n lineJoin = defaultLineJoin;\n }\n lineCap = this.stroke_.getLineCap();\n if (lineCap === undefined) {\n lineCap = defaultLineCap;\n }\n miterLimit = this.stroke_.getMiterLimit();\n if (miterLimit === undefined) {\n miterLimit = defaultMiterLimit;\n }\n }\n\n const add = this.calculateLineJoinSize_(lineJoin, strokeWidth, miterLimit);\n const maxRadius = Math.max(this.radius_, this.radius2_ || 0);\n const size = Math.ceil(2 * maxRadius + add);\n\n return {\n strokeStyle: strokeStyle,\n strokeWidth: strokeWidth,\n size: size,\n lineCap: lineCap,\n lineDash: lineDash,\n lineDashOffset: lineDashOffset,\n lineJoin: lineJoin,\n miterLimit: miterLimit,\n };\n }\n\n /**\n * @protected\n */\n render() {\n this.renderOptions_ = this.createRenderOptions();\n const size = this.renderOptions_.size;\n this.canvas_ = {};\n this.size_ = [size, size];\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @param {CanvasRenderingContext2D} context The rendering context.\n * @param {number} pixelRatio The pixel ratio.\n */\n draw_(renderOptions, context, pixelRatio) {\n context.scale(pixelRatio, pixelRatio);\n // set origin to canvas center\n context.translate(renderOptions.size / 2, renderOptions.size / 2);\n\n this.createPath_(context);\n\n if (this.fill_) {\n let color = this.fill_.getColor();\n if (color === null) {\n color = defaultFillStyle;\n }\n context.fillStyle = asColorLike(color);\n context.fill();\n }\n if (this.stroke_) {\n context.strokeStyle = renderOptions.strokeStyle;\n context.lineWidth = renderOptions.strokeWidth;\n if (renderOptions.lineDash) {\n context.setLineDash(renderOptions.lineDash);\n context.lineDashOffset = renderOptions.lineDashOffset;\n }\n context.lineCap = renderOptions.lineCap;\n context.lineJoin = renderOptions.lineJoin;\n context.miterLimit = renderOptions.miterLimit;\n context.stroke();\n }\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n */\n createHitDetectionCanvas_(renderOptions) {\n if (this.fill_) {\n let color = this.fill_.getColor();\n\n // determine if fill is transparent (or pattern or gradient)\n let opacity = 0;\n if (typeof color === 'string') {\n color = asArray(color);\n }\n if (color === null) {\n opacity = 1;\n } else if (Array.isArray(color)) {\n opacity = color.length === 4 ? color[3] : 1;\n }\n if (opacity === 0) {\n // if a transparent fill style is set, create an extra hit-detection image\n // with a default fill style\n const context = createCanvasContext2D(\n renderOptions.size,\n renderOptions.size\n );\n this.hitDetectionCanvas_ = context.canvas;\n\n this.drawHitDetectionCanvas_(renderOptions, context);\n }\n }\n if (!this.hitDetectionCanvas_) {\n this.hitDetectionCanvas_ = this.getImage(1);\n }\n }\n\n /**\n * @private\n * @param {CanvasRenderingContext2D} context The context to draw in.\n */\n createPath_(context) {\n let points = this.points_;\n const radius = this.radius_;\n if (points === Infinity) {\n context.arc(0, 0, radius, 0, 2 * Math.PI);\n } else {\n const radius2 = this.radius2_ === undefined ? radius : this.radius2_;\n if (this.radius2_ !== undefined) {\n points *= 2;\n }\n const startAngle = this.angle_ - Math.PI / 2;\n const step = (2 * Math.PI) / points;\n for (let i = 0; i < points; i++) {\n const angle0 = startAngle + i * step;\n const radiusC = i % 2 === 0 ? radius : radius2;\n context.lineTo(radiusC * Math.cos(angle0), radiusC * Math.sin(angle0));\n }\n context.closePath();\n }\n }\n\n /**\n * @private\n * @param {RenderOptions} renderOptions Render options.\n * @param {CanvasRenderingContext2D} context The context.\n */\n drawHitDetectionCanvas_(renderOptions, context) {\n // set origin to canvas center\n context.translate(renderOptions.size / 2, renderOptions.size / 2);\n\n this.createPath_(context);\n\n context.fillStyle = defaultFillStyle;\n context.fill();\n if (this.stroke_) {\n context.strokeStyle = renderOptions.strokeStyle;\n context.lineWidth = renderOptions.strokeWidth;\n if (renderOptions.lineDash) {\n context.setLineDash(renderOptions.lineDash);\n context.lineDashOffset = renderOptions.lineDashOffset;\n }\n context.lineJoin = renderOptions.lineJoin;\n context.miterLimit = renderOptions.miterLimit;\n context.stroke();\n }\n }\n}\n\nexport default RegularShape;\n","/**\n * @module ol/style/Circle\n */\n\nimport RegularShape from './RegularShape.js';\n\n/**\n * @typedef {Object} Options\n * @property {import(\"./Fill.js\").default} [fill] Fill style.\n * @property {number} radius Circle radius.\n * @property {import(\"./Stroke.js\").default} [stroke] Stroke style.\n * @property {Array} [displacement=[0,0]] displacement\n * @property {number|import(\"../size.js\").Size} [scale=1] Scale. A two dimensional scale will produce an ellipse.\n * Unless two dimensional scaling is required a better result may be obtained with an appropriate setting for `radius`.\n * @property {number} [rotation=0] Rotation in radians\n * (positive rotation clockwise, meaningful only when used in conjunction with a two dimensional scale).\n * @property {boolean} [rotateWithView=false] Whether to rotate the shape with the view\n * (meaningful only when used in conjunction with a two dimensional scale).\n * @property {\"declutter\"|\"obstacle\"|\"none\"|undefined} [declutterMode] Declutter mode\n */\n\n/**\n * @classdesc\n * Set circle style for vector features.\n * @api\n */\nclass CircleStyle extends RegularShape {\n /**\n * @param {Options} [options] Options.\n */\n constructor(options) {\n options = options ? options : {radius: 5};\n\n super({\n points: Infinity,\n fill: options.fill,\n radius: options.radius,\n stroke: options.stroke,\n scale: options.scale !== undefined ? options.scale : 1,\n rotation: options.rotation !== undefined ? options.rotation : 0,\n rotateWithView:\n options.rotateWithView !== undefined ? options.rotateWithView : false,\n displacement:\n options.displacement !== undefined ? options.displacement : [0, 0],\n declutterMode: options.declutterMode,\n });\n }\n\n /**\n * Clones the style.\n * @return {CircleStyle} The cloned style.\n * @api\n */\n clone() {\n const scale = this.getScale();\n const style = new CircleStyle({\n fill: this.getFill() ? this.getFill().clone() : undefined,\n stroke: this.getStroke() ? this.getStroke().clone() : undefined,\n radius: this.getRadius(),\n scale: Array.isArray(scale) ? scale.slice() : scale,\n rotation: this.getRotation(),\n rotateWithView: this.getRotateWithView(),\n displacement: this.getDisplacement().slice(),\n declutterMode: this.getDeclutterMode(),\n });\n style.setOpacity(this.getOpacity());\n return style;\n }\n\n /**\n * Set the circle radius.\n *\n * @param {number} radius Circle radius.\n * @api\n */\n setRadius(radius) {\n this.radius_ = radius;\n this.render();\n }\n}\n\nexport default CircleStyle;\n","/**\n * @module ol/style/Style\n */\n\nimport CircleStyle from './Circle.js';\nimport Fill from './Fill.js';\nimport Stroke from './Stroke.js';\nimport {assert} from '../asserts.js';\n\n/**\n * A function that takes an {@link module:ol/Feature~Feature} and a `{number}`\n * representing the view's resolution. The function should return a\n * {@link module:ol/style/Style~Style} or an array of them. This way e.g. a\n * vector layer can be styled. If the function returns `undefined`, the\n * feature will not be rendered.\n *\n * @typedef {function(import(\"../Feature.js\").FeatureLike, number):(Style|Array