@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
1 lines • 30.2 kB
JavaScript
"use strict";(self.webpackChunkRemoteClient=self.webpackChunkRemoteClient||[]).push([[3500],{330(e,t,s){function i(e,t){if(!e||!t)return[];let s=t;t.includes("/")?(s=t.slice(0,t.indexOf("/")),t=t.slice(t.indexOf("/")+1)):t="";const n=[];if(t){const r=i(e,s);for(let e=0;e<r.length;e++)i(r[e],t).forEach(e=>n.push(e));return n}const r=e.getElementsByTagNameNS("*",s);if(!r||0===r.length)return[];for(let e=0;e<r.length;e++)n.push(r[e]||r.item(e));return n}function n(e,t){if(!e||!t)return null;let s=t;t.includes("/")?(s=t.slice(0,t.indexOf("/")),t=t.slice(t.indexOf("/")+1)):t="";const r=i(e,s);return r.length>0?t?n(r[0],t):r[0]:null}function r(e,t=null){const s=t?n(e,t):e;let i;return s?(i=s.textContent||s.nodeValue,i?i.trim():null):null}function o(e,t){const s=i(e,t),n=[];let r;for(let e=0;e<s.length;e++)r=s[e].textContent||s[e].nodeValue,r&&(r=r.trim(),""!==r&&n.push(r));return n}function l(e,t=null){const s=r(e,t);return s?.split(" ").map(e=>Number(e))??[]}function a(e,t){return o(e,t).map(e=>Number(e))}function c(e,t){const s=r(e,t);return Number(s)}function h(e,t){const s=e?.nodeName?.toLowerCase(),i=t.toLowerCase();return s.slice(s.lastIndexOf(":")+1)===i}function u(e){return e.nodeName.slice(e.nodeName.lastIndexOf(":")+1)}s.d(t,{Dy:()=>o,IC:()=>i,Ui:()=>a,V6:()=>n,g7:()=>h,mX:()=>r,pN:()=>l,v7:()=>c,vv:()=>u})},563(e,t,s){s.d(t,{QueueProcessor:()=>c,SharedConcurrency:()=>u});var i=s(97768),n=s(74887),r=s(9775),o=s(32587),l=s(76030),a=s(44794);class c{constructor(e){this._schedule=null,this._deferreds=new o.A,this._controllers=new o.A,this._processingItems=new o.A,this._pausedSignal=(0,a.v)(!1),this.process=e.process,this.concurrency=e.concurrency,this.sharedConcurrency=e.sharedConcurrency??f,this._queue=new r.A(e.peeker)}destroy(){this.clear(),this._schedule=(0,i.xt)(this._schedule)}get updating(){return this.running}get length(){return this._processingItems.size+this._queue.length}get running(){return!this._pausedSignal.value&&this._queue.length>0&&!this.full}get full(){return this._processingItems.size>=this.concurrency||this.sharedConcurrency.full}abort(e){const t=this._controllers.get(e);t?.abort()}clear(){this._queue.clear();const e=Array.from(this._controllers.values());this._controllers.clear(),e.forEach(e=>e.abort()),this.sharedConcurrency.current.value-=this._processingItems.size,this._processingItems.clear(),this._cancelNext()}forEach(e){this._deferreds.forEach((t,s)=>e(s))}_get(e){const t=this._deferreds.get(e);return t?.promise}pause(){this._pausedSignal.value||(this._pausedSignal.value=!0,this._cancelNext())}push(e,t){const s=this._get(e);if(s)return s;const i=new AbortController,r=(0,n.Tw)(),o=t?(0,n.u7)(t,()=>i.abort()):null,l=(0,n.NY)(i.signal,()=>{const t=this._processingItems.get(e);t&&t.controller.abort(),a(),r.reject((0,n.NK)())}),a=()=>{l.remove(),o?.remove(),this._removeItem(e),this._queue.remove(e),this._scheduleNext()};return this._deferreds.set(e,r),this._controllers.set(e,i),r.promise.then(a,a),this._queue.push(e),this._scheduleNext(),r.promise}last(){return this._queue.last()}reset(){const e=Array.from(this._processingItems.values());this.sharedConcurrency.current.value-=this._processingItems.size,this._processingItems.clear();for(const t of e)this._queue.push(t.item),t.controller.abort();this._scheduleNext()}resume(){this._pausedSignal.value&&(this._pausedSignal.value=!1,this._scheduleNext())}takeAll(){const e=[];for(;this._queue.length;)e.push(this._queue.pop());return this.clear(),e}_removeItem(e){this._deferreds.delete(e),this._controllers.delete(e),this._processingItems.has(e)&&(this._processingItems.delete(e),this.sharedConcurrency.current.value-=1)}_scheduleNext(){this._pausedSignal.value||this._schedule||(this._schedule=(0,l._)(()=>{this._schedule=null,this._next()}))}_next(){for(;this._queue.length>0&&this._processingItems.size<this.concurrency&&!this.sharedConcurrency.full;)this._process(this._queue.pop())}_cancelNext(){this._schedule&&(this._schedule.remove(),this._schedule=null)}_processResult(e,t){this._canProcessFulfillment(e)&&(this._scheduleNext(),this._deferreds.get(e.item).resolve(t))}_processError(e,t){this._canProcessFulfillment(e)&&(this._scheduleNext(),this._deferreds.get(e.item).reject(t))}_canProcessFulfillment(e){return!!this._deferreds.get(e.item)&&this._processingItems.get(e.item)===e}_process(e){if(null==e)return;let t;const s=new AbortController,i=new h(e,s);this._processingItems.set(e,i),this.sharedConcurrency.current.value+=1;try{t=this.process(e,s.signal)}catch(e){this._processError(i,e)}(0,n.$X)(t)?(i.promise=t,t.then(e=>this._processResult(i,e),e=>this._processError(i,e))):this._processResult(i,t)}}class h{constructor(e,t){this.item=e,this.controller=t,this.promise=null}}class u{constructor(e){this.limit=e,this.current=(0,a.v)(0)}get full(){return this.current.value>=this.limit}}const f=new u(1/0)},32587(e,t,s){s.d(t,{A:()=>r});var i=s(62788),n=s(95488);class r{constructor(e){this._observable=new n.I,this._notifyPending=!1,this._batchDepth=0,this._map=new Map(e)}get size(){return(0,i.gc)(this._observable),this._map.size}batch(e){try{this._batchDepth++,e()}finally{this._batchDepth--,this._notifyPending&&0===this._batchDepth&&(this._notifyPending=!1,this._notify())}}clear(){this._map.size>0&&(this._map.clear(),this._notify())}delete(e){const t=this._map.delete(e);return t&&this._notify(),t}entries(){return(0,i.gc)(this._observable),this._map.entries()}forEach(e,t){(0,i.gc)(this._observable),this._map.forEach((s,i)=>e.call(t,s,i,this),t)}get(e){return(0,i.gc)(this._observable),this._map.get(e)}has(e){return(0,i.gc)(this._observable),this._map.has(e)}keys(){return(0,i.gc)(this._observable),this._map.keys()}set(e,t){return this._map.set(e,t),this._notify(),this}transformValues(e,t=this._map.keys()){this.batch(()=>{for(const s of t){if(!this._map.has(s))continue;const t=this._map.get(s),i=e(t,s);i!==t&&this.set(s,i)}})}values(){return(0,i.gc)(this._observable),this._map.values()}[Symbol.iterator](){return(0,i.gc)(this._observable),this._map[Symbol.iterator]()}[Symbol.dispose](){this._observable.destroy()}get[Symbol.toStringTag](){return this._map[Symbol.toStringTag]}_notify(){this._batchDepth>0?this._notifyPending=!0:this._observable.notify()}}},44794(e,t,s){s.d(t,{v:()=>l});var i=s(4718),n=s(62788),r=s(95488);class o{constructor(e,t){this._observable=new r.I,this._value=e,this._equalityFunction=t}get value(){return(0,n.gc)(this._observable),this._value}set value(e){this._equalityFunction(e,this._value)||(this._value=e,this._observable.notify())}mutate(e){e(this._value),this._observable.notify()}}function l(e,t=i.gh){return new o(e,t)}},49859(e,t,s){s.d(t,{A:()=>E});var i=s(5482),n=s(11254),r=s(49186),o=s(25482),l=s(53966),a=s(74887),c=s(563),h=s(91429),u=s(56507),f=s(5443),m=s(86738),d=s(16930),p=s(7548),g=s(4366),x=s(37373);const y=new Map,_=new class{constructor(e=15e3,t=5e3){this._timer=null,this._cachedBlocks=new Map,this._size=-1,this._duration=e,this._interval=Math.min(e,t)}decreaseRefCount(e,t){const s=e+"/"+t,i=this._cachedBlocks;if(i.has(s)){const e=i.get(s);return e.refCount--,e.refCount<=0&&(i.delete(s),e.controller&&e.controller.abort()),e.refCount}return 0}getBlock(e,t){const s=e+"/"+t,i=this._cachedBlocks;if(i.has(s)){const e=i.get(s);return e.ts=Date.now(),e.refCount++,i.delete(s),i.set(s,e),e.block}return null}putBlock(e,t,s,i){const n=this._cachedBlocks,r=e+"/"+t;if(n.has(r)){const e=n.get(r);e.ts=Date.now(),e.refCount++}else n.set(r,{block:s,ts:Date.now(),refCount:1,controller:i});this._trim(),this._updateTimer()}deleteBlock(e,t){const s=this._cachedBlocks,i=e+"/"+t;s.has(i)&&s.delete(i)}updateMaxSize(e){this._size=e,this._trim()}empty(){this._cachedBlocks.clear(),this._clearTimer()}getCurrentSize(){return this._cachedBlocks.size}_updateTimer(){if(null!=this._timer)return;const e=this._cachedBlocks;this._timer=setInterval(()=>{const t=Array.from(e),s=Date.now();for(let i=0;i<t.length&&t[i][1].ts<=s-this._duration;i++)e.delete(t[i][0]);0===e.size&&this._clearTimer()},this._interval)}_trim(){const e=this._cachedBlocks;if(-1===this._size||this._size>=e.size)return;const t=Array.from(e);for(let s=0;s<t.length-this._size;s++)e.delete(t[s][0])}_clearTimer(){null!=this._timer&&(clearInterval(this._timer),this._timer=null)}};function I(e,t,s){const i=y.get(e);if(!i)return null==t?_.decreaseRefCount(e,s):0;if(null==t||null==i[t])return _.decreaseRefCount(e,s);const n=i[t]?.cache,r=n?.get(s);if(n&&r){if(r.refCount--,0===r.refCount){n.delete(s);for(let e=0;e<i.length;e++)i[e]?.cache.delete(s);r.controller&&r.controller.abort()}return r.refCount}return 0}function b(e,t,s){const i=y.get(e);if(!i)return null==t?_.getBlock(e,s):null;if(null==t||null==i[t]){for(let e=0;e<i.length;e++){const t=i[e]?.cache.get(s);if(t)return t.refCount++,t.block}return _.getBlock(e,s)}const n=i[t]?.cache.get(s);if(n)return n.refCount++,n.block;for(let e=0;e<i.length;e++){if(e===t||!i[e])continue;const n=i[e]?.cache,r=n?.get(s);if(n&&r)return r.refCount++,n.set(s,r),r.block}return null}function v(e,t,s,i,n=null){const r=y.get(e);if(!r)return void(null==t&&_.putBlock(e,s,i,n));if(null==t||null==r[t])return void _.putBlock(e,s,i,n);const o={refCount:1,block:i,isResolved:!1,isRejected:!1,controller:n};i.then(()=>o.isResolved=!0).catch(()=>o.isRejected=!0),r[t]?.cache.set(s,o)}function w(e,t,s){const i=y.get(e);i?null!=t&&null!=i[t]?i[t]?.cache.delete(s):_.deleteBlock(e,s):null==t&&_.deleteBlock(e,s)}var k=s(94778),R=s(20758),S=s(47520),C=s(34251),T=s(60694),B=s(10873),M=s(45617),P=s(91806),A=s(20223),z=s(87045);let W=0,E=class extends o.o{constructor(){super(...arguments),this._tileFetchQueue=new c.QueueProcessor({concurrency:32,process:(e,t)=>this.fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"},this.rawBlockRegistryIds=[],this.refresh=(0,a.sg)(async e=>{await this._openPromise;const t=await this._refresh(e);return t.dataChanged&&function(e,t){const s=y.get(e);if(s){const e=t.map(e=>s[e]).filter(e=>null!=e);for(const t of e)t&&(Array.from(t.cache.values()).forEach(e=>{e.isResolved||e.isRejected||!e.controller||e.controller.abort()}),t.cache.clear())}}(this.rasterId,this.rawBlockRegistryIds),t})}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:z.A.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=(0,x.FT)(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),(0,p.qg)(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||"rasterId-"+W++}set url(e){this._set("url",(0,T.Jf)(e,l.A.getLogger(this)))}async open(e){return this._openPromise??=(0,x.Hh)().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,s,i={}){const n=i.tileInfo||this.rasterInfo.storageInfo.tileInfo,o=this.getTileExtentFromTileInfo(e,t,s,n);if(!o)throw new r.A("imagery-tile:out-of-bounds","Level for fetch tile out of range");return i={noClip:!0,...i},this.fetchPixels(o,n.size[0],n.size[1],i)}async identify(e,t={}){e=(0,u.PZ)(m.A,e).clone().normalize();const{multidimensionalDefinition:s,timeExtent:i}=t,{rasterInfo:n}=this,{hasMultidimensionalTranspose:r,multidimensionalInfo:o}=n;let{transposedVariableName:l}=t;const a=null!=o&&r&&(null!=i||(0,g.DY)(s));a&&!l&&(l=null!=s&&s.length>0?s[0].variableName??void 0:o.variables[0].name,t={...t,transposedVariableName:l}),t=this._getRequestOptionsWithSliceId(t);const{spatialReference:c,extent:h}=n,{datumTransformation:d}=t;let y=(0,x._I)(e,c,d);if(!h.intersects(y))return{location:y,value:null};if(null!=n.transform){const e=n.transform.inverseTransform(y);if(!n.nativeExtent.intersects(e))return{location:e,value:null};y=e}let _=0;const I=null!=l&&null!=o&&n.hasMultidimensionalTranspose;if((0,p.qg)(this)){const e=this.primaryRasters.rasters[0];if(I)return e.identify(y,t);const{pixelSize:i}=n,r=3,o=i.x*r/2,l=i.y*r/2,a=new f.A({xmin:y.x-o,xmax:y.x+o,ymin:y.y-l,ymax:y.y+l,spatialReference:c}),h={interpolation:"nearest",multidimensionalDefinition:s,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:u}=await e.fetchPixels(a,r,r,h),{pixelBlock:m}=await this.fetchPixels(a,r,r,h);if(null==u)return{location:y,value:null};const d=Math.floor(r*r*.5),p=!u.mask||u.mask[d]?u.pixels.map(e=>e[d]):null;let g;return null!=m&&(g=!m.mask||m.mask[d]?m.pixels.map(e=>e[d]):void 0),{location:y,value:p,processedValue:g,pyramidLevel:0}}if(!I)if(t.srcResolution)_=(0,x.t$)(t.srcResolution,n,this.ioConfig.sampling).pyramidLevel;else if(_=await this.computeBestPyramidLevelForLocation(e,t),null==_)return{location:y,value:null};const b=this.identifyPixelLocation(y,_,null,I);if(null===b)return{location:y,value:null};const{row:v,col:w,rowOffset:k,colOffset:R,blockWidth:S}=b,C=await this._fetchRawTile(_,v,w,t);if(!C?.pixels?.length)return{location:y,value:null};const T=k*S+R;return this._processIdentifyResult(C,{srcLocation:y,position:T,pyramidLevel:_,useTransposedTile:!!I,requestSomeSlices:a,identifyOptions:t})}async fetchPixels(e,t,s,i={}){e=(0,x.Ps)(e),i=this._getRequestOptionsWithSliceId(i);const{_hasNoneOrGCSShiftTransform:n}=this;if(i.requestRawData&&n)return this._fetchPixels(e,t,s,i);const r=(0,x.FT)(e.spatialReference),o=(0,x.OM)(e);if(null==r||0===o||1===o&&this._isGlobalWrappableSource&&n)return this._fetchPixels(e,t,s,i);if(o>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,h=Math.round(r/(c-a)*t),u=h-Math.round((r/2-a)/(c-a)*t);let m=0;const d=[];for(let n=0;n<=o;n++){const p=new f.A({xmin:0===n?a:-r/2,xmax:n===o?c-r*n:r/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),g=0===n?h-u:n===o?t-m:h;m+=g,d.push(g);const x=i.disableWrapAround&&n>0?null:this._fetchPixels(p,g,s,i);l.push(x)}const p=(await Promise.all(l)).map(e=>e?.pixelBlock);let g=null;const y={width:t,height:s};return g=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:y,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:d},i)).pixelBlock:(0,S.z7)(p,y,{blockWidths:d}),{extent:e,srcExtent:(0,x._l)(e,this.rasterInfo.spatialReference,i.datumTransformation),pixelBlock:g}}async fetchRawPixels(e,t,s,i={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const n=await this._fetchRawTiles(e,t,s,i),{nativeExtent:r,nativePixelSize:o,storageInfo:l}=this.rasterInfo,a=2**e,c=o.x*a,h=o.y*a,u=new f.A({xmin:r.xmin+c*t.x,xmax:r.xmin+c*(t.x+s.width-1),ymin:r.ymax-h*(t.y+s.height-1),ymax:r.ymax-h*t.y,spatialReference:r.spatialReference});if(!n)return{extent:u,srcExtent:u,pixelBlock:null};const{pixelBlocks:m,mosaicSize:d}=n;if(1===m.length&&null!=m[0]&&m[0].width===s.width&&m[0].height===s.height)return{extent:u,srcExtent:u,pixelBlock:n.pixelBlocks[0]};const p=e>0?l.pyramidBlockWidth:l.blockWidth,g=e>0?l.pyramidBlockHeight:l.blockHeight,x={x:t.x%p,y:t.y%g};let y;return y=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:m,srcMosaicSize:d,destDimension:s,clipOffset:x,clipSize:s,coefs:null,sampleSpacing:null,interpolation:i.interpolation,alignmentInfo:null,blockWidths:null},i)).pixelBlock:(0,S.z7)(m,d,{clipOffset:x,clipSize:s}),{extent:u,srcExtent:u,pixelBlock:y}}fetchRawTile(e,t,s,i){throw new r.A("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return(0,x._l)(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?(0,R.D)(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,t,s=0){const{customFetchParameters:i}=this.ioConfig,{range:r,query:o,headers:l}=t;s=s??t.retryCount??this.ioConfig.retryCount;const a=r?{Range:`bytes=${r.from}-${r.to}`}:null;try{return await(0,n.A)(e,{...t,query:{...o,...i},headers:{...l,...a}})}catch(i){if(s>0)return s--,this.request(e,t,s);throw i}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:(0,g.NG)(e,t)}getTileExtentFromTileInfo(e,t,s,i){const n=i.lodAt(e);return n?this.getTileExtent({x:n.resolution,y:n.resolution},t,s,i.origin,i.spatialReference,i.size):null}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:s,pixelSize:i}=this.rasterInfo,{pyramidResolutions:n}=e;if(!e.tileInfo){const r=[],o=e.maximumPyramidLevel||0;let l=(i.x+i.y)/2,a=1/.0254*96*l;for(let e=0;e<=o&&(r.unshift(new P.A({level:o-e,resolution:l,scale:a})),e!==o);e++)if(n){const t=(n[e].x+n[e].y)/2;a*=t/l,l=t}else l*=2,a*=2;const c=new m.A({x:s.xmin,y:s.ymax,spatialReference:t});e.tileInfo=new z.A({origin:c,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:r}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,s=512,i){const{width:n,height:r,nativeExtent:o,pixelSize:l,spatialReference:a}=e,c=new m.A({x:o.xmin,y:o.ymax,spatialReference:a});null==i&&(i=Math.max(0,Math.round(Math.log(Math.max(n,r))/Math.LN2-8)));const h=this.computeBlockBoundary(o,512,512,{x:o.xmin,y:o.ymax},[l],i);e.storageInfo=new A.A({blockWidth:t,blockHeight:s,pyramidBlockWidth:t,pyramidBlockHeight:s,origin:c,firstPyramidLevel:1,maximumPyramidLevel:i,blockBoundary:h})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,s,i,n,r=0,o=2){if(1===n.length&&r>0){n=[...n];let{x:e,y:t}=n[0];for(let s=0;s<r;s++)e*=o,t*=o,n.push({x:e,y:t})}const l=[],{x:a,y:c}=i;for(let i=0;i<n.length;i++){const{x:r,y:o}=n[i];l.push({minCol:Math.floor((e.xmin-a+.1*r)/t/r),maxCol:Math.floor((e.xmax-a-.1*r)/t/r),minRow:Math.floor((c-e.ymax+.1*o)/s/o),maxRow:Math.floor((c-e.ymin-.1*o)/s/o)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:s,pyramidScalingFactor:i}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=s&&s.length)return s[e-1];const n=i**e;return{x:t.x*n,y:t.y*n}}identifyPixelLocation(e,t,s,i){const{spatialReference:n,nativeExtent:r,storageInfo:o}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=o,h=i&&null!=c?c.tileSize[0]:o.blockWidth,u=i&&null!=c?c.tileSize[1]:o.blockHeight,f=(0,x._I)(e,n,s);if(!r.intersects(f))return null;if(t<0||t>l)return null;const m=this.getPyramidPixelSize(t),{x:d,y:p}=m,g=(a.y-f.y)/p/u,y=(f.x-a.x)/d/h,_=Math.min(u-1,Math.floor((g-Math.floor(g))*u)),I=Math.min(h-1,Math.floor((y-Math.floor(y))*h));return{pyramidLevel:t,row:Math.floor(g),col:Math.floor(y),rowOffset:_,colOffset:I,blockWidth:h,srcLocation:f}}getTileExtent(e,t,s,i,n,r){const[o,l]=r,a=i.x+s*o*e.x,c=a+o*e.x,h=i.y-t*l*e.y,u=h-l*e.y;return new f.A({xmin:a,xmax:c,ymin:u,ymax:h,spatialReference:n})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,s){const i=this.rasterInfo.storageInfo.blockBoundary[e];return!i||i.maxRow<t||i.maxCol<s||i.minRow>t||i.minCol>s}updateImageSpaceRasterInfo(e){const{pixelSize:t}=e,{width:s,height:i}=e,n=d.A.WebMercator;e.spatialReference=n,e.extent=e.nativeExtent=new f.A({xmin:-.5,ymax:.5,xmax:s-.5,ymin:.5-i,spatialReference:n}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new m.A({x:1,y:1,spatialReference:n});const{extent:r,storageInfo:o}=e;if(o){o.origin=new m.A({x:r.xmin,y:r.ymax,spatialReference:n});const{pyramidResolutions:s,tileInfo:i}=o;if(s&&s.forEach(e=>{e.x/=t.x,e.y/=t.y}),i){i.origin=o.origin;const t=(e.nativePixelSize.x+e.nativePixelSize.y)/2;i.lods.forEach((e,s)=>{e.resolution=t*2**s,e.scale=96*e.resolution/.0254})}}}async _refresh(e){return{dataChanged:!0}}async _fetchPixels(e,t,s,i={}){let n=(0,x.OM)(e);if(n>=2)return{extent:e,pixelBlock:null};const r=this._getSourceDataInfo(e,t,s,i),{pyramidLevel:o,srcResolution:l,srcExtent:a,srcWidth:c,srcHeight:h,ul:u}=r;if(0===c||0===h)return{extent:e,srcExtent:a,pixelBlock:null};const{rasterInfo:f}=this,d=f.transform,p="gcs-shift"===d?.type,g=null!=(0,x.FT)(e.spatialReference);!p&&g||(n=(0,x.OM)(r.srcExtent,p));const y=await this._fetchRawTiles(o,u,{width:c,height:h,wrapCount:n},i);if(!y)return{extent:e,srcExtent:a,pixelBlock:null};const _=f.storageInfo,I=o>0?_.pyramidBlockWidth:_.blockWidth,b=o>0?_.pyramidBlockHeight:_.blockHeight;let{x:v,y:w}=f.pixelSize;if(o>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=_;if(null!=e&&e[o-1])({x:v,y:w}=e[o-1]);else{const e=t**o;v*=e,w*=e}}const k=f.spatialReference,R=new m.A({x:v,y:w,spatialReference:k}),T=I===c&&b===h&&u.x%I===0&&u.y%b===0,B=new m.A({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/s,spatialReference:e.spatialReference}),M=!e.spatialReference.equals(k),P=k.isGeographic?1e-9:1e-4,{datumTransformation:A}=i;if(!M&&T&&1===y.pixelBlocks.length&&I===t&&b===s&&function(e,t,s){return Math.abs(e.x-t.x)<s&&Math.abs(e.y-t.y)<s}(l,B,P))return{extent:e,srcExtent:a,srcTilePixelSize:R,pixelBlock:y.pixelBlocks[0]};const z=g&&null!=(0,x.FT)(a.spatialReference)&&this._hasNoneOrGCSShiftTransform,W=i.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");W&&!this.rasterJobHandler&&await(0,x.Hh)();const E=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:B.toJSON(),datumTransformation:A,rasterTransform:d,hasWrapAround:n>0||z,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:W},i):(0,x.l0)({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:B,datumTransformation:A,rasterTransform:d,hasWrapAround:n>0||z,isAdaptive:!1,includeGCSGrid:W});let N;const D=!i.requestRawData,H={rows:E.spacing[0],cols:E.spacing[1]},q=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(o,y.extent.xmin):void 0,{pixelBlocks:L,mosaicSize:O,isPartiallyFilled:F}=y;let G=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:L,srcMosaicSize:O,destDimension:D?{width:t,height:s}:null,coefs:D?E.coefficients:null,sampleSpacing:D?H:null,projectDirections:W,gcsGrid:W?E.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:i.interpolation,alignmentInfo:q,blockWidths:null},i);({pixelBlock:N,localNorthDirections:G}=e)}else{const e=(0,S.z7)(L,O,{alignmentInfo:q});N=D?(0,S.$i)(e,{width:t,height:s},E.coefficients,H,i.interpolation):e,W&&E.gcsGrid&&(G=(0,S.QF)({width:t,height:s},E.gcsGrid),N=(0,C.Y2)(N,this.rasterInfo.dataType,G))}return i.requestRawData||W?{extent:e,srcExtent:a,srcTilePixelSize:R,pixelBlock:N,transformGrid:E,localNorthDirections:G,isPartiallyFilled:F}:{extent:e,srcExtent:a,srcTilePixelSize:R,pixelBlock:N}}async _fetchRawTiles(e,t,s,i){const{origin:n,blockBoundary:r}=this.rasterInfo.storageInfo,{blockWidth:o,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:h,height:u,wrapCount:m}=s;const d=this._getRasterTileAlignmentInfo(e,0);i.buffer&&(a-=i.buffer.cols,c-=i.buffer.rows,h+=2*i.buffer.cols,u+=2*i.buffer.rows);let p=0,g=0,x=0;m&&null!=d&&(({worldColumnCountFromOrigin:g,originColumnOffset:x,rightPadding:p}=d),g*d.blockWidth-p>=a+h&&(p=0));const y=Math.floor(a/o),_=Math.floor(c/l),I=Math.floor((a+h+p-1)/o),b=Math.floor((c+u+p-1)/l),v=r[e];if(!v)return null;const{minRow:w,minCol:k,maxCol:R,maxRow:S}=v;if(0===m&&(b<w||I<k||_>S||y>R))return null;const C=new Array;let T=!1;const B=null==this.ioConfig.allowPartialFill?i.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=_;t<=b;t++)for(let s=y;s<=I;s++){let n=s;if(!i.disableWrapAround&&m&&null!=d&&g<=s&&(n=s-g-x),t>=w&&n>=k&&S>=t&&R>=n){const s=this._fetchRawTile(e,t,n,i);B?C.push(new Promise(e=>{s.then(t=>e(t)).catch(()=>{T=!0,e(null)})})):C.push(s)}else C.push(Promise.resolve(null))}if(0===C.length)return null;const M=await Promise.all(C),P={height:(b-_+1)*l,width:(I-y+1)*o},{spatialReference:A}=this.rasterInfo,z=this.getPyramidPixelSize(e),{x:W,y:E}=z;return{extent:new f.A({xmin:n.x+y*o*W,xmax:n.x+(I+1)*o*W,ymin:n.y-(b+1)*l*E,ymax:n.y-_*l*E,spatialReference:A}),pixelBlocks:M,mosaicSize:P,isPartiallyFilled:T}}_fetchRawTile(e,t,s,i){const{storageInfo:n}=this.rasterInfo,r=null!=n.transposeInfo&&!!i.transposedVariableName;if(!r){const i=n.blockBoundary[e];if(!i)return Promise.resolve(null);const{minRow:r,minCol:o,maxCol:l,maxRow:a}=i;if(t<r||s<o||t>a||s>l)return Promise.resolve(null)}const o=r?i.transposeVariableName:i.sliceId,l=n.isBsqTile?i.bandIds:null,c=function(e,t,s){const i=[];return null!=t&&i.push(`sliceId=${t}`),null!=s&&i.push(`bandIds=${s.join(",")}`),i.length?`${e}?${i.join("&")}`:e}(this.rasterId,o,l),h=`${e}/${t}/${s}`;let u=b(c,i.registryId,h);if(null==u){const r=new AbortController,o=i.bandIds?.slice();if(o?.length&&n.isBsqTile){const n=new Set(o),l=[],a=Array.from(n);for(const n of a)l.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:s,options:{...i,bandIds:[n]}},{signal:r.signal}));u=Promise.all(l).then(e=>{if(e.some(e=>null==e))return null;if(a.length!==o.length){const t=[];for(const s of o){let i=e[a.indexOf(s)];t.includes(i)&&(i=i.clone()),t.push(i)}e=t}return this.rasterJobHandler?this.rasterJobHandler.compositeBands({pixelBlocks:e},{signal:r.signal,transferPixelsToWorker:!0}):(0,S.Wy)(e)})}else u=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:s,options:i},{signal:r.signal});v(c,i.registryId,h,u,r),u.catch(()=>w(c,i.registryId,h))}return i.signal&&(0,a.u7)(i,()=>{I(c,i.registryId,h)}),u}_computeMagDirValues(e){const{bandCount:t,dataType:s}=this.rasterInfo;if((2!==t||"vector-magdir"!==s)&&"vector-uv"!==s||2!==e?.length||!e[0]?.length)return null;const i=e[0].length;if("vector-magdir"===s){const t=e[1].map(e=>(e+360)%360);return[e[0],t]}const[n,r]=e,o=[],l=[];for(let e=0;e<i;e++){const[t,s]=(0,C.Lu)([n[e],r[e]]);o.push(t),l.push(s)}return[o,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=(0,x.DO)(this.rasterInfo)),null==this._rasterTileAlignmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,s,i={}){const n={datumTransformation:i.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};i.srcResolution&&(n.srcResolution=i.srcResolution,this._updateSourceDataInfo(e,n));const r=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:o,srcHeight:l,pyramidLevel:a}=n,c=o/t,h=l/s,u=a<r&&c*h>=16,f=a===r&&this._requireTooManySrcTiles(o,l,t,s);if(u||f||0===o||0===l){const o=new m.A({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/s,spatialReference:e.spatialReference});let l=(0,x.Wo)(o,this.rasterInfo.spatialReference,e,n.datumTransformation);const f=!l||i.srcResolution&&l.x+l.y<i.srcResolution.x+i.srcResolution.y;if(u&&i.srcResolution&&f){const e=Math.round(Math.log(Math.max(c,h))/Math.LN2)-1;if(r-a+3>=e){const t=2**e;l={x:i.srcResolution.x*t,y:i.srcResolution.y*t}}}l&&(n.srcResolution=l,this._updateSourceDataInfo(e,n))}return this._requireTooManySrcTiles(n.srcWidth,n.srcHeight,t,s)&&(n.srcWidth=0,n.srcHeight=0),n}_requireTooManySrcTiles(e,t,s,i){const{tileInfo:n}=this.rasterInfo.storageInfo,r=e/s,o=t/i;return Math.ceil(e/n.size[0])*Math.ceil(t/n.size[1])>=256*Math.max(1,(s+i)/1024)||r>8||o>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:s}=this,i=s.spatialReference,{srcResolution:n,datumTransformation:r}=t,{pyramidLevel:o,pyramidResolution:l,excessiveReading:a}=(0,x.t$)(n,s,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||(0,x._l)(e,i,r);if(null==c)return;const h=s.transform;h&&(c=h.inverseTransform(c)),t.srcExtent=c;const{origin:u}=s.storageInfo,{width:f,height:m,ul:d}=(0,p.$g)(c,u,l,o);t.pyramidLevel=o,t.pyramidResolution=l,t.srcWidth=f,t.srcHeight=m,t.ul=d}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:s,position:i,pyramidLevel:n,useTransposedTile:r}=t,o=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[i])return{location:s,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!r){const t=e.pixels.map(e=>e[i]),r={location:s,value:t,pyramidLevel:n},o=this._computeMagDirValues(t.map(e=>[e]));return o?.length&&(r.magdirValue=o.map(e=>e[0])),r}let a=e.pixels.map(e=>e.slice(i*o,i*o+o)),c=this._computeMagDirValues(a);const{requestSomeSlices:h,identifyOptions:u}=t;let f=(0,g.QW)(l,u.transposedVariableName);if(h){const e=(0,g.xx)(f,u.multidimensionalDefinition,u.timeExtent);a=a.map(t=>e.map(e=>t[e])),c=c?.map(t=>e.map(e=>t[e])),f=e.map(e=>f[e])}const m=e.noDataValues||this.rasterInfo.noDataValue,d={pixels:a,pixelType:e.pixelType};let p;return null!=m&&((0,k.Sp)(d,m),p=d.mask),{location:s,value:null,dataSeries:f.map((e,t)=>{const s={value:0===p?.[t]?null:a.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new M.A({...e,isSlice:!0}))};return c?.length&&(s.magdirValue=[c[0][t],c[1][t]]),s}),pyramidLevel:n}}};(0,i.Cg)([(0,h.MZ)()],E.prototype,"_rasterTileAlignmentInfo",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"_tileFetchQueue",void 0),(0,i.Cg)([(0,h.MZ)({readOnly:!0})],E.prototype,"_isGlobalWrappableSource",null),(0,i.Cg)([(0,h.MZ)({readOnly:!0})],E.prototype,"_hasNoneOrGCSShiftTransform",null),(0,i.Cg)([(0,h.MZ)()],E.prototype,"_openPromise",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"rasterJobHandler",null),(0,i.Cg)([(0,h.MZ)({readOnly:!0})],E.prototype,"rasterId",null),(0,i.Cg)([(0,h.MZ)(B.OZ)],E.prototype,"url",null),(0,i.Cg)([(0,h.MZ)({type:String,json:{write:!0}})],E.prototype,"datasetName",void 0),(0,i.Cg)([(0,h.MZ)({type:String,json:{write:!0}})],E.prototype,"datasetFormat",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"hasUniqueSourceStorageInfo",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"rasterInfo",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"ioConfig",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"sourceJSON",void 0),(0,i.Cg)([(0,h.MZ)()],E.prototype,"rawBlockRegistryIds",void 0),E=(0,i.Cg)([(0,h.$K)("esri.layers.raster.datasets.BaseRaster")],E)}}]);