@arcgis/core 4.30.0-next.20240312 → 4.30.0-next.20240313
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{182f94904b6eb611b886.js → 052005514ce006ce0027.js} +1 -1
- package/assets/esri/core/workers/chunks/129ea550bf7ad7ad24f9.js +1 -0
- package/assets/esri/core/workers/chunks/{c3d619f978136f740a42.js → 1f5b7880ccf47ef9229d.js} +5 -5
- package/assets/esri/core/workers/chunks/{523903a812624d0d6d06.js → 2427699e34e1895ed024.js} +1 -1
- package/assets/esri/core/workers/chunks/{86fe8077986a991f0462.js → 500f39a5f74fa289df25.js} +1 -1
- package/assets/esri/core/workers/chunks/67ab6af927ea04c01a40.js +1 -0
- package/assets/esri/core/workers/chunks/c76e155332aa0491de3d.js +1 -0
- package/assets/esri/core/workers/chunks/dd5a078b7919f749ba3e.js +1 -0
- package/assets/esri/core/workers/chunks/f7cfdba77cb614fd3725.js +1 -0
- package/assets/esri/core/workers/chunks/f9427ac73435d1726d6c.js +1 -0
- package/assets/esri/core/workers/chunks/ff4151d794ec73064fac.js +1 -0
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/mixins/SceneService.js +1 -1
- package/layers/support/ExportImageServiceParameters.js +1 -1
- package/layers/support/LayerContingentValuesCache.js +1 -1
- package/layers/support/PixelBlock.js +1 -1
- package/layers/support/Tilemap.js +1 -1
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/layers/support/rasterDatasets/CloudRaster.js +1 -1
- package/layers/support/rasterDatasets/FunctionRaster.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterDatasets/MRFRaster.js +1 -1
- package/layers/support/rasterDatasets/TIFFRaster.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
- package/package.json +1 -1
- package/request.js +1 -1
- package/rest/symbolService.js +1 -1
- package/support/revision.js +1 -1
- package/views/3d/layers/MediaLayerView3D.js +1 -1
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/support/LaserlinePathData.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/MagnifierHelper.js +1 -1
- package/views/3d/webgl-engine/lib/Object3DStateSet.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/TextRenderParameters.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeWorkerHandle.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace/support/ResultAreaHandler.js +1 -1
- package/assets/esri/core/workers/chunks/0272af5adbbd4482f50d.js +0 -1
- package/assets/esri/core/workers/chunks/16f1ede633a712a555a6.js +0 -1
- package/assets/esri/core/workers/chunks/52fa794d75ab8841e808.js +0 -1
- package/assets/esri/core/workers/chunks/771b95d28e1c9a14df64.js +0 -1
- package/assets/esri/core/workers/chunks/79f36c3a2026c2f35fb0.js +0 -1
- package/assets/esri/core/workers/chunks/899b4539e516f44c51af.js +0 -1
- package/assets/esri/core/workers/chunks/bbedc4ff3d0aadbde16a.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{clone as i}from"../../core/lang.js";import l from"../../core/Logger.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as o}from"../../core/accessorSupport/decorators/cast.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{SimpleBandStatistics as a}from"./SimpleBandStatistics.js";import{getPixelValueRange as h}from"./rasterFormats/pixelRangeUtils.js";var p;let c=p=class extends s{static createEmptyBand(t,e){return new(p.getPixelArrayConstructor(t))(e)}static combineBandMasks(t){if(t.length<2)return t[0];const e=t[0].length,s=new Uint8Array(e).fill(255);for(let i=0;i<t.length;i++){const l=t[i];for(let t=0;t<e;t++)l[t]||(s[t]=0)}return s}static getPixelArrayConstructor(t){let e;switch(t){case"u1":case"u2":case"u4":case"u8":e=Uint8Array;break;case"u16":e=Uint16Array;break;case"u32":e=Uint32Array;break;case"s8":e=Int8Array;break;case"s16":e=Int16Array;break;case"s32":e=Int32Array;break;case"f32":case"c64":case"c128":case"unknown":e=Float32Array;break;case"f64":e=Float64Array}return e}constructor(t){super(t),this.width=null,this.height=null,this.pixelType="f32",this.validPixelCount=null,this.mask=null,this.maskIsAlpha=!1,this.premultiplyAlpha=!1,this.statistics=null,this.depthCount=1}castPixelType(t){if(!t)return"f32";let e=t.toLowerCase();return["u1","u2","u4"].includes(e)?e="u8":["unknown","u8","s8","u16","s16","u32","s32","f32","f64"].includes(e)||(e="f32"),e}getPlaneCount(){return this.pixels?.length}addData(t){if(!t.pixels||t.pixels.length!==this.width*this.height)throw new e("pixelblock:invalid-or-missing-pixels","add data requires valid pixels array that has same length defined by pixel block width * height");this.pixels||(this.pixels=[]),this.statistics||(this.statistics=[]),this.pixels.push(t.pixels),this.statistics.push(t.statistics??new a)}getAsRGBA(){const t=new ArrayBuffer(this.width*this.height*4);switch(this.pixelType){case"s8":case"s16":case"u16":case"s32":case"u32":case"f32":case"f64":this._fillFromNon8Bit(t);break;default:this._fillFrom8Bit(t)}return new Uint8ClampedArray(t)}getAsRGBAFloat(){const t=new Float32Array(this.width*this.height*4);return this._fillFrom32Bit(t),t}updateStatistics(){if(!this.pixels)return;this.statistics=this.pixels.map((t=>
|
|
5
|
+
import{_ as t}from"../../chunks/tslib.es6.js";import e from"../../core/Error.js";import{JSONSupport as s}from"../../core/JSONSupport.js";import{clone as i}from"../../core/lang.js";import l from"../../core/Logger.js";import{property as r}from"../../core/accessorSupport/decorators/property.js";import{cast as o}from"../../core/accessorSupport/decorators/cast.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{SimpleBandStatistics as a}from"./SimpleBandStatistics.js";import{getPixelValueRange as h}from"./rasterFormats/pixelRangeUtils.js";var p;let c=p=class extends s{static createEmptyBand(t,e){return new(p.getPixelArrayConstructor(t))(e)}static combineBandMasks(t){if(t.length<2)return t[0];const e=t[0].length,s=new Uint8Array(e).fill(255);for(let i=0;i<t.length;i++){const l=t[i];for(let t=0;t<e;t++)l[t]||(s[t]=0)}return s}static getPixelArrayConstructor(t){let e;switch(t){case"u1":case"u2":case"u4":case"u8":e=Uint8Array;break;case"u16":e=Uint16Array;break;case"u32":e=Uint32Array;break;case"s8":e=Int8Array;break;case"s16":e=Int16Array;break;case"s32":e=Int32Array;break;case"f32":case"c64":case"c128":case"unknown":e=Float32Array;break;case"f64":e=Float64Array}return e}constructor(t){super(t),this.width=null,this.height=null,this.pixelType="f32",this.validPixelCount=null,this.mask=null,this.maskIsAlpha=!1,this.premultiplyAlpha=!1,this.statistics=null,this.depthCount=1}castPixelType(t){if(!t)return"f32";let e=t.toLowerCase();return["u1","u2","u4"].includes(e)?e="u8":["unknown","u8","s8","u16","s16","u32","s32","f32","f64"].includes(e)||(e="f32"),e}getPlaneCount(){return this.pixels?.length}addData(t){if(!t.pixels||t.pixels.length!==this.width*this.height)throw new e("pixelblock:invalid-or-missing-pixels","add data requires valid pixels array that has same length defined by pixel block width * height");this.pixels||(this.pixels=[]),this.statistics||(this.statistics=[]),this.pixels.push(t.pixels),this.statistics.push(t.statistics??new a)}getAsRGBA(){const t=new ArrayBuffer(this.width*this.height*4);switch(this.pixelType){case"s8":case"s16":case"u16":case"s32":case"u32":case"f32":case"f64":this._fillFromNon8Bit(t);break;default:this._fillFrom8Bit(t)}return new Uint8ClampedArray(t)}getAsRGBAFloat(){const t=new Float32Array(this.width*this.height*4);return this._fillFrom32Bit(t),t}updateStatistics(){if(!this.pixels)return;this.statistics=this.pixels.map((t=>u(t,this.mask)));const t=this.mask;let e=0;if(null!=t)for(let s=0;s<t.length;s++)t[s]&&e++;else e=this.width*this.height;this.validPixelCount=e}clamp(t){if(!t||"f64"===t||"f32"===t||!this.pixels)return;const[e,s]=h(t),i=this.pixels,l=this.width*this.height,r=i.length;let o,n,a;const c=[];for(let h=0;h<r;h++){a=p.createEmptyBand(t,l),o=i[h];for(let t=0;t<l;t++)n=o[t],a[t]=n>s?s:n<e?e:n;c.push(a)}this.pixels=c,this.pixelType=t}extractBands(t){const{pixels:e,statistics:s}=this;if(null==t||0===t.length||!e||0===e.length)return this;const i=e.length,l=t.some((t=>t>=e.length)),r=i===t.length&&!t.some(((t,e)=>t!==e));if(l||r)return this;const o=this.bandMasks?.length===i?t.map((t=>this.bandMasks[t])):void 0;let{mask:n,validPixelCount:a}=this;const{width:h,height:c}=this;return o?.length&&(n=p.combineBandMasks(o),a=n.filter((t=>!!t)).length),new p({pixelType:this.pixelType,width:h,height:c,mask:n,bandMasks:o,validPixelCount:a,maskIsAlpha:this.maskIsAlpha,pixels:t.map((t=>e[t])),statistics:s&&t.map((t=>s[t]))})}clone(){const t=new p({width:this.width,height:this.height,pixelType:this.pixelType,maskIsAlpha:this.maskIsAlpha,validPixelCount:this.validPixelCount});let e;null!=this.mask&&(t.mask=new Uint8Array(this.mask)),this.bandMasks&&(t.bandMasks=this.bandMasks.map((t=>new Uint8Array(t))));const s=p.getPixelArrayConstructor(this.pixelType);if(this.pixels&&this.pixels.length>0){t.pixels=[];const i=!!this.pixels[0].slice;for(e=0;e<this.pixels.length;e++)t.pixels[e]=i?this.pixels[e].slice(0,this.pixels[e].length):new s(this.pixels[e])}if(this.statistics)for(t.statistics=[],e=0;e<this.statistics.length;e++)t.statistics[e]=i(this.statistics[e]);return t.premultiplyAlpha=this.premultiplyAlpha,t}_fillFrom8Bit(t){const{mask:e,maskIsAlpha:s,premultiplyAlpha:i,pixels:r}=this;if(!t||!r?.length)return void l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");let o,n,a,h;o=n=a=r[0],r.length>=3?(n=r[1],a=r[2]):2===r.length&&(n=r[1]);const p=new Uint32Array(t),c=this.width*this.height;if(o.length===c)if(null!=e&&e.length===c)if(s)for(h=0;h<c;h++){const t=e[h];if(t){const e=t/255;p[h]=i?t<<24|a[h]*e<<16|n[h]*e<<8|o[h]*e:t<<24|a[h]<<16|n[h]<<8|o[h]}}else for(h=0;h<c;h++)e[h]&&(p[h]=255<<24|a[h]<<16|n[h]<<8|o[h]);else for(h=0;h<c;h++)p[h]=255<<24|a[h]<<16|n[h]<<8|o[h];else l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.")}_fillFromNon8Bit(t){const{pixels:e,mask:s,statistics:i}=this;if(!t||!e?.length)return void l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");const r=this.pixelType;let o=1,n=0,a=1;if(i&&i.length>0){for(const t of i)if(null!=t.minValue&&(n=Math.min(n,t.minValue)),null!=t.maxValue&&null!=t.minValue){const e=t.maxValue-t.minValue;a=Math.max(a,e)}o=255/a}else{let t=255;"s8"===r?(n=-128,t=127):"u16"===r?t=65535:"s16"===r?(n=-32768,t=32767):"u32"===r?t=4294967295:"s32"===r?(n=-2147483648,t=2147483647):"f32"===r?(n=-34e38,t=34e38):"f64"===r&&(n=-Number.MAX_VALUE,t=Number.MAX_VALUE),o=255/(t-n)}const h=new Uint32Array(t),p=this.width*this.height;let c,u,g,f,m;if(c=u=g=e[0],c.length!==p)return l.getLogger(this).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.");if(e.length>=2)if(u=e[1],e.length>=3&&(g=e[2]),null!=s&&s.length===p)for(f=0;f<p;f++)s[f]&&(h[f]=255<<24|(g[f]-n)*o<<16|(u[f]-n)*o<<8|(c[f]-n)*o);else for(f=0;f<p;f++)h[f]=255<<24|(g[f]-n)*o<<16|(u[f]-n)*o<<8|(c[f]-n)*o;else if(null!=s&&s.length===p)for(f=0;f<p;f++)m=(c[f]-n)*o,s[f]&&(h[f]=255<<24|m<<16|m<<8|m);else for(f=0;f<p;f++)m=(c[f]-n)*o,h[f]=255<<24|m<<16|m<<8|m}_fillFrom32Bit(t){const{pixels:e,mask:s}=this;if(!t||!e?.length)return l.getLogger(this).error("getAsRGBAFloat()","Unable to convert to RGBA. The input pixel block is empty.");let i,r,o,n;i=r=o=e[0],e.length>=3?(r=e[1],o=e[2]):2===e.length&&(r=e[1]);const a=this.width*this.height;if(i.length!==a)return l.getLogger(this).error("getAsRGBAFloat()","Unable to convert to RGBA. The pixelblock is invalid.");let h=0;if(null!=s&&s.length===a)for(n=0;n<a;n++)t[h++]=i[n],t[h++]=r[n],t[h++]=o[n],t[h++]=1&s[n];else for(n=0;n<a;n++)t[h++]=i[n],t[h++]=r[n],t[h++]=o[n],t[h++]=1}};function u(t,e){let s=1/0,i=-1/0;const l=t.length;let r,o=0;if(null!=e)for(r=0;r<l;r++)e[r]&&(o=t[r],s=o<s?o:s,i=o>i?o:i);else for(r=0;r<l;r++)o=t[r],s=o<s?o:s,i=o>i?o:i;return new a(s,i)}t([r({json:{write:!0}})],c.prototype,"width",void 0),t([r({json:{write:!0}})],c.prototype,"height",void 0),t([r({json:{write:!0}})],c.prototype,"pixelType",void 0),t([o("pixelType")],c.prototype,"castPixelType",null),t([r({json:{write:!0}})],c.prototype,"validPixelCount",void 0),t([r({json:{write:!0}})],c.prototype,"mask",void 0),t([r({json:{write:!0}})],c.prototype,"maskIsAlpha",void 0),t([r({json:{write:!0}})],c.prototype,"pixels",void 0),t([r()],c.prototype,"premultiplyAlpha",void 0),t([r({json:{write:!0}})],c.prototype,"statistics",void 0),t([r({json:{write:!0}})],c.prototype,"depthCount",void 0),t([r({json:{write:!0}})],c.prototype,"noDataValues",void 0),t([r({json:{write:!0}})],c.prototype,"bandMasks",void 0),c=p=t([n("esri.layers.support.PixelBlock")],c);const g=c;export{g as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../../request.js";import{constant as i}from"../../core/arrayUtils.js";import e from"../../core/Error.js";import{clone as a}from"../../core/lang.js";import{estimateSize as o}from"../../core/typedArrayUtil.js";import{newUintArray as l}from"../../geometry/support/UintArray.js";class r{constructor(t){
|
|
5
|
+
import t from"../../request.js";import{constant as i}from"../../core/arrayUtils.js";import e from"../../core/Error.js";import{clone as a}from"../../core/lang.js";import{estimateSize as o}from"../../core/typedArrayUtil.js";import{newUintArray as l}from"../../geometry/support/UintArray.js";class r{constructor(t){h(t);const{location:i,data:e}=t;this.location=Object.freeze(a(i));const r=this.location.width,n=this.location.height;let s=!0,c=!0;const m=Math.ceil(r*n/32),f=l(m);let d=0;for(let a=0;a<e.length;a++){const t=a%32;e[a]?(c=!1,f[d]|=1<<t):s=!1,31===t&&++d}c?(this._availability="unavailable",this.byteSize=40):s?(this._availability="available",this.byteSize=40):(this._availability=f,this.byteSize=40+o(f))}getAvailability(t,i){if("unavailable"===this._availability||"available"===this._availability)return this._availability;const e=(t-this.location.top)*this.location.width+(i-this.location.left),a=e%32,o=e>>5,l=this._availability;return o<0||o>l.length?"unknown":l[o]&1<<a?"available":"unavailable"}static fromDefinition(a,o){const l=a.service.request||t,{row:n,col:h,width:c,height:m}=a,f={query:{f:"json"}};return o=o?{...f,...o}:f,l(s(a),o).then((t=>t.data)).catch((t=>{if(t&&t.details&&422===t.details.httpStatus)return{location:{top:n,left:h,width:c,height:m},valid:!0,data:i(c*m,0)};throw t})).then((t=>{if(t.location&&(t.location.top!==n||t.location.left!==h||t.location.width!==c||t.location.height!==m))throw new e("tilemap:location-mismatch","Tilemap response for different location than requested",{response:t,definition:{top:n,left:h,width:c,height:m}});return r.fromJSON(t)}))}static fromJSON(t){return Object.freeze(new r(t))}}function n(t){return`${t.level}/${t.row}/${t.col}/${t.width}/${t.height}`}function s(t){let i;if(t.service.tileServers?.length){const e=t.service.tileServers;i=`${e&&e.length?e[t.row%e.length]:t.service.url}/tilemap/${t.level}/${t.row}/${t.col}/${t.width}/${t.height}`}else i=`${t.service.url}/tilemap/${t.level}/${t.row}/${t.col}/${t.width}/${t.height}`;const e=t.service.query;return e&&(i=`${i}?${e}`),i}function h(t){if(!t?.location)throw new e("tilemap:missing-location","Location missing from tilemap response");if(!1===t.valid)throw new e("tilemap:invalid","Tilemap response was marked as invalid");if(!t.data)throw new e("tilemap:missing-data","Data missing from tilemap response");if(!Array.isArray(t.data))throw new e("tilemap:data-mismatch","Data must be an array of numbers");if(t.data.length!==t.location.width*t.location.height)throw new e("tilemap:data-mismatch","Number of data items does not match width/height of tilemap")}export{r as Tilemap,n as tilemapDefinitionId};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import i from"../../../core/Error.js";import{JSONSupport as o}from"../../../core/JSONSupport.js";import r from"../../../core/Logger.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{onAbort as s}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import{ensureClass as a}from"../../../core/accessorSupport/ensureType.js";import"../../../core/RandomLCG.js";import"../../../core/has.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as m}from"../arcgisLayerUrl.js";import{url as f}from"../commonProperties.js";import u from"../DimensionalDefinition.js";import h from"../LOD.js";import p from"../RasterStorageInfo.js";import d from"../TileInfo.js";import{isMultiSliceOrRangeDefinition as x,getSliceIndex as y,createSlices as g,getSliceIds as I}from"./multidimensionalUtils.js";import{getRasterId as R,getBlock as w,putBlock as S,deleteBlock as k,decreaseRefCount as v}from"./RawBlockCache.js";import{convertNoDataToMask as T}from"../rasterFormats/pixelRangeUtils.js";import{decode as b}from"../rasterFormats/RasterCodec.js";import{mosaic as P,approximateTransform as B,getLocalArithmeticNorthRotations as M}from"../rasterFunctions/pixelUtils.js";import{load as _,getWorldWidth as C,projectPoint as W,snapPyramid as j,shiftExtent as z,getWorldWrapCount as H,projectExtent as L,getProjectionOffsetGrid as E,getRasterDatasetAlignmentInfo as D,projectResolution as F}from"../rasterFunctions/rasterProjectionHelper.js";import{convertToLocalDirections as O,uvComponentToVector as A}from"../rasterFunctions/vectorFieldUtils.js";import{QueueProcessor as G}from"../../../views/support/QueueProcessor.js";import q from"../../../geometry/Extent.js";import J from"../../../geometry/Point.js";import N from"../../../geometry/SpatialReference.js";const V=8,U=256;let $=0,Q=class extends(n(o)){constructor(){super(...arguments),this._tileFetchQueue=new G({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"}}async init(){const e=_();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:d.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=C(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),"Function"===this.datasetFormat&&this.primaryRasters?.rasters?.forEach((t=>t.rasterJobHandler=e))}get rasterId(){return this.url||"rasterId-"+$++}set url(e){this._set("url",m(e,r.getLogger(this)))}async open(e){throw new i("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,o={}){const r=o.tileInfo||this.rasterInfo.storageInfo.tileInfo,n=this.getTileExtentFromTileInfo(e,t,i,r);return o={noClip:!0,...o},this.fetchPixels(n,r.size[0],r.size[1],o)}async identify(e,t={}){e=a(J,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:o}=t,{rasterInfo:r}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:s}=r;let{transposedVariableName:l}=t;const c=null!=s&&n&&(null!=o||x(i));if(c&&!l){l=null!=i&&i.length>0?i[0].variableName??void 0:s.variables[0].name,t={...t,transposedVariableName:l}}t=this._getRequestOptionsWithSliceId(t);const{spatialReference:m,extent:f}=r,{datumTransformation:u}=t;let h=W(e,m,u);if(!f.intersects(h))return{location:h,value:null};if(null!=r.transform){const e=r.transform.inverseTransform(h);if(!r.nativeExtent.intersects(e))return{location:e,value:null};h=e}let p=0;const d=null!=l&&null!=s&&r.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(d)return e.identify(h,t);const{pixelSize:o}=r,n=3,s=o.x*n/2,l=o.y*n/2,a=new q({xmin:h.x-s,xmax:h.x+s,ymin:h.y-l,ymax:h.y+l,spatialReference:m}),c={interpolation:"nearest",multidimensionalDefinition:i,sliceId:t.sliceId},{pixelBlock:f}=await e.fetchPixels(a,n,n,c),{pixelBlock:u}=await this.fetchPixels(a,n,n,c);if(null==f)return{location:h,value:null};const p=Math.floor(n*n*.5),x=!f.mask||f.mask[p]?f.pixels.map((e=>e[p])):null;let y;return null!=u&&(y=!u.mask||u.mask[p]?u.pixels.map((e=>e[p])):void 0),{location:h,value:x,processedValue:y,pyramidLevel:0}}if(!d)if(t.srcResolution){p=j(t.srcResolution,r,this.ioConfig.sampling).pyramidLevel}else if(p=await this.computeBestPyramidLevelForLocation(e,t),null==p)return{location:h,value:null};const y=this.identifyPixelLocation(h,p,null,d);if(null===y)return{location:h,value:null};const{row:g,col:I,rowOffset:k,colOffset:v,blockWidth:T}=y,b=l??t.sliceId,P=R(this.rasterId,b),B=`${p}/${g}/${I}`;let M=w(P,null,B);null==M&&(M=this.fetchRawTile(p,g,I,t),S(P,null,B,M));const _=await M;if(!_?.pixels?.length)return{location:h,value:null};const C=k*T+v;return this._processIdentifyResult(_,{srcLocation:h,position:C,pyramidLevel:p,useTransposedTile:!!d,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,i,o={}){e=z(e),o=this._getRequestOptionsWithSliceId(o);const{_hasNoneOrGCSShiftTransform:r}=this;if(o.requestRawData&&r)return this._fetchPixels(e,t,i,o);const n=C(e.spatialReference),s=H(e);if(null==n||0===s||1===s&&this._isGlobalWrappableSource&&r)return this._fetchPixels(e,t,i,o);if(s>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,m=Math.round(n/(c-a)*t),f=m-Math.round((n/2-a)/(c-a)*t);let u=0;const h=[];for(let y=0;y<=s;y++){const r=new q({xmin:0===y?a:-n/2,xmax:y===s?c-n*y:n/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),p=0===y?m-f:y===s?t-u:m;u+=p,h.push(p);const d=o.disableWrapAround&&y>0?null:this._fetchPixels(r,p,i,o);l.push(d)}const p=(await Promise.all(l)).map((e=>e?.pixelBlock));let d=null;const x={width:t,height:i};if(this.rasterJobHandler){d=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:x,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:h},o)).pixelBlock}else d=P(p,x,{blockWidths:h});return{extent:e,srcExtent:L(e,this.rasterInfo.spatialReference,o.datumTransformation),pixelBlock:d}}async fetchRawPixels(e,t,i,o={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const r=await this._fetchRawTiles(e,t,i,o),{nativeExtent:n,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,m=s.y*a,f=new q({xmin:n.xmin+c*t.x,xmax:n.xmin+c*(t.x+i.width-1),ymin:n.ymax-m*(t.y+i.height-1),ymax:n.ymax-m*t.y,spatialReference:n.spatialReference});if(!r)return{extent:f,srcExtent:f,pixelBlock:null};const{pixelBlocks:u,mosaicSize:h}=r;if(1===u.length&&null!=u[0]&&u[0].width===i.width&&u[0].height===i.height)return{extent:f,srcExtent:f,pixelBlock:r.pixelBlocks[0]};const p=e>0?l.pyramidBlockWidth:l.blockWidth,d=e>0?l.pyramidBlockHeight:l.blockHeight,x={x:t.x%p,y:t.y%d};let y;if(this.rasterJobHandler){y=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:u,srcMosaicSize:h,destDimension:i,clipOffset:x,clipSize:i,coefs:null,sampleSpacing:null,interpolation:o.interpolation,alignmentInfo:null,blockWidths:null},o)).pixelBlock}else y=P(u,h,{clipOffset:x,clipSize:i});return{extent:f,srcExtent:f,pixelBlock:y}}fetchRawTile(e,t,o,r){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return L(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?b(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,i,o=0){const{customFetchParameters:r}=this.ioConfig,{range:n,query:s,headers:l}=i;o=o??i.retryCount??this.ioConfig.retryCount;const a=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await t(e,{...i,query:{...s,...r},headers:{...l,...a}})}catch(c){if(o>0)return o--,this.request(e,i,o);throw c}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:y(e,t)}getTileExtentFromTileInfo(e,t,i,o){const r=o.lodAt(e);return this.getTileExtent({x:r.resolution,y:r.resolution},t,i,o.origin,o.spatialReference,o.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:o}=this.rasterInfo;if(!e.tileInfo){const r=[],n=e.maximumPyramidLevel||0;let s=Math.max(o.x,o.y),l=1/.0254*96*s;for(let e=0;e<=n;e++)r.unshift(new h({level:n-e,resolution:s,scale:l})),s*=2,l*=2;const a=new J({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new d({origin:a,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:r}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,o){const{width:r,height:n,nativeExtent:s,pixelSize:l,spatialReference:a}=e,c=new J({x:s.xmin,y:s.ymax,spatialReference:a});null==o&&(o=Math.max(0,Math.round(Math.log(Math.max(r,n))/Math.LN2-8)));const m=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],o);e.storageInfo=new p({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:o,blockBoundary:m})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,o,r,n=0,s=2){if(1===r.length&&n>0){r=[...r];let{x:e,y:t}=r[0];for(let i=0;i<n;i++)e*=s,t*=s,r.push({x:e,y:t})}const l=[],{x:a,y:c}=o;for(let m=0;m<r.length;m++){const{x:o,y:n}=r[m];l.push({minCol:Math.floor((e.xmin-a+.1*o)/t/o),maxCol:Math.floor((e.xmax-a-.1*o)/t/o),minRow:Math.floor((c-e.ymax+.1*n)/i/n),maxRow:Math.floor((c-e.ymin-.1*n)/i/n)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:o}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const r=o**e;return{x:t.x*r,y:t.y*r}}identifyPixelLocation(e,t,i,o){const{spatialReference:r,nativeExtent:n,storageInfo:s}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=s,m=o&&null!=c?c.tileSize[0]:s.blockWidth,f=o&&null!=c?c.tileSize[1]:s.blockHeight,u=W(e,r,i);if(!n.intersects(u))return null;if(t<0||t>l)return null;const h=this.getPyramidPixelSize(t),{x:p,y:d}=h,x=(a.y-u.y)/d/f,y=(u.x-a.x)/p/m,g=Math.min(f-1,Math.floor((x-Math.floor(x))*f)),I=Math.min(m-1,Math.floor((y-Math.floor(y))*m));return{pyramidLevel:t,row:Math.floor(x),col:Math.floor(y),rowOffset:g,colOffset:I,blockWidth:m,srcLocation:u}}getTileExtent(e,t,i,o,r,n){const[s,l]=n,a=o.x+i*s*e.x,c=a+s*e.x,m=o.y-t*l*e.y,f=m-l*e.y;return new q({xmin:a,xmax:c,ymin:f,ymax:m,spatialReference:r})}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,i){const o=this.rasterInfo.storageInfo.blockBoundary[e];return!o||o.maxRow<t||o.maxCol<i||o.minRow>t||o.minCol>i}updateImageSpaceRasterInfo(e){const{extent:t,pixelSize:i}=e;if(-.5===t.xmin&&.5===t.ymax&&1===i.x&&1===i.y&&null==e.transform)return;const{width:o,height:r}=e,n=N.WebMercator;e.spatialReference=n,e.extent=e.nativeExtent=new q({xmin:-.5,ymax:.5,xmax:o-.5,ymin:.5-r,spatialReference:n}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new J({x:1,y:1,spatialReference:n});const{extent:s,storageInfo:l}=e;if(l){l.origin=new J({x:s.xmin,y:s.ymax,spatialReference:n});const{tileInfo:t}=l;if(t){t.origin=l.origin;const i=(e.nativePixelSize.x+e.nativePixelSize.y)/2;t.lods.forEach(((e,t)=>{e.resolution=i*2**t,e.scale=96*e.resolution/.0254}))}}}async _fetchPixels(e,t,i,o={}){let r=H(e);if(r>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,o),{pyramidLevel:s,srcResolution:l,srcExtent:a,srcWidth:c,srcHeight:m,ul:f}=n;if(0===c||0===m)return{extent:e,srcExtent:a,pixelBlock:null};const{rasterInfo:u}=this,h=u.transform,p="gcs-shift"===h?.type,d=null!=C(e.spatialReference);!p&&d||(r=H(n.srcExtent,p));const x=await this._fetchRawTiles(s,f,{width:c,height:m,wrapCount:r},o);if(!x)return{extent:e,srcExtent:a,pixelBlock:null};const y=u.storageInfo,g=s>0?y.pyramidBlockWidth:y.blockWidth,I=s>0?y.pyramidBlockHeight:y.blockHeight;let{x:R,y:w}=u.pixelSize;if(s>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=y;if(null!=e&&e[s-1])({x:R,y:w}=e[s-1]);else{const e=t**s;R*=e,w*=e}}const S=u.spatialReference,k=new J({x:R,y:w,spatialReference:S}),v=g===c&&I===m&&f.x%g==0&&f.y%I==0,T=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),b=!e.spatialReference.equals(S),W=S.isGeographic?1e-9:1e-4,{datumTransformation:j}=o;if(!b&&v&&1===x.pixelBlocks.length&&g===t&&I===i&&this._isSameResolution(l,T,W))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:x.pixelBlocks[0]};const z=d&&null!=C(a.spatialReference)&&this._hasNoneOrGCSShiftTransform,L=o.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");L&&!this.rasterJobHandler&&await _();const D=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:T.toJSON(),datumTransformation:j,rasterTransform:h,hasWrapAround:r>0||z,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:L},o):E({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:T,datumTransformation:j,rasterTransform:h,hasWrapAround:r>0||z,isAdaptive:!1,includeGCSGrid:L});let F;const A=!o.requestRawData,G={rows:D.spacing[0],cols:D.spacing[1]},q=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,x.extent.xmin):void 0,{pixelBlocks:N,mosaicSize:V,isPartiallyFilled:U}=x;let $=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:N,srcMosaicSize:V,destDimension:A?{width:t,height:i}:null,coefs:A?D.coefficients:null,sampleSpacing:A?G:null,projectDirections:L,gcsGrid:L?D.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:o.interpolation,alignmentInfo:q,blockWidths:null},o);({pixelBlock:F,localNorthDirections:$}=e)}else{const e=P(N,V,{alignmentInfo:q});F=A?B(e,{width:t,height:i},D.coefficients,G,o.interpolation):e,L&&D.gcsGrid&&($=M({width:t,height:i},D.gcsGrid),F=O(F,this.rasterInfo.dataType,$))}return o.requestRawData||L?{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F,transformGrid:D,localNorthDirections:$,isPartiallyFilled:U}:{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F}}async _fetchRawTiles(e,t,i,o){const{origin:r,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:m,height:f,wrapCount:u}=i;const h=this._getRasterTileAlignmentInfo(e,0);o.buffer&&(a-=o.buffer.cols,c-=o.buffer.rows,m+=2*o.buffer.cols,f+=2*o.buffer.rows);let p=0,d=0,x=0;if(u&&null!=h){({worldColumnCountFromOrigin:d,originColumnOffset:x,rightPadding:p}=h);d*h.blockWidth-p>=a+m&&(p=0)}const y=Math.floor(a/s),g=Math.floor(c/l),I=Math.floor((a+m+p-1)/s),R=Math.floor((c+f+p-1)/l),w=n[e];if(!w)return null;const{minRow:S,minCol:k,maxCol:v,maxRow:T}=w;if(0===u&&(R<S||I<k||g>T||y>v))return null;const b=new Array;let P=!1;const B=null==this.ioConfig.allowPartialFill?o.allowPartialFill:this.ioConfig.allowPartialFill;for(let H=g;H<=R;H++)for(let t=y;t<=I;t++){let i=t;if(!o.disableWrapAround&&u&&null!=h&&d<=t&&(i=t-d-x),H>=S&&i>=k&&T>=H&&v>=i){const t=this._tileFetchQueue.push({pyramidLevel:e,row:H,col:i,options:o},{signal:o.signal});B?b.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{P=!0,e(null)}))}))):b.push(t)}else b.push(Promise.resolve(null))}if(0===b.length)return null;const M=await Promise.all(b),_={height:(R-g+1)*l,width:(I-y+1)*s},{spatialReference:C}=this.rasterInfo,W=this.getPyramidPixelSize(e),{x:j,y:z}=W;return{extent:new q({xmin:r.x+y*s*j,xmax:r.x+(I+1)*s*j,ymin:r.y-(R+1)*l*z,ymax:r.y-g*l*z,spatialReference:C}),pixelBlocks:M,mosaicSize:_,isPartiallyFilled:P}}_isSameResolution(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}_fetchRawTile(e,t,i,o){const r=this.rasterInfo.storageInfo.blockBoundary[e];if(!r)return Promise.resolve(null);const{minRow:n,minCol:l,maxCol:a,maxRow:c}=r;if(t<n||i<l||t>c||i>a)return Promise.resolve(null);const m=R(this.rasterId,o.sliceId),f=`${e}/${t}/${i}`;let u=w(m,o.registryId,f);if(null==u){const r=new AbortController;u=this.fetchRawTile(e,t,i,{...o,signal:r.signal}),S(m,o.registryId,f,u,r),u.catch((()=>k(m,o.registryId,f)))}return o.signal&&s(o,(()=>{v(m,o.registryId,f)})),u}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if(!(2===t&&"vector-magdir"===i||"vector-uv"===i)||2!==e?.length||!e[0]?.length)return null;const o=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[r,n]=e,s=[],l=[];for(let a=0;a<o;a++){const[e,t]=A([r[a],n[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=D(this.rasterInfo)),null==this._rasterTileAlignmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,o={}){const r={datumTransformation:o.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};o.srcResolution&&(r.srcResolution=o.srcResolution,this._updateSourceDataInfo(e,r));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=r,c=s/t,m=l/i,f=a<n&&c*m>=16,u=a===n&&this._requireTooManySrcTiles(s,l,t,i);if(f||u||(0===s||0===l)){const s=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let l=F(s,this.rasterInfo.spatialReference,e,r.datumTransformation);const u=!l||o.srcResolution&&l.x+l.y<o.srcResolution.x+o.srcResolution.y;if(f&&o.srcResolution&&u){const e=Math.round(Math.log(Math.max(c,m))/Math.LN2)-1;if(n-a+3>=e){const t=2**e;l={x:o.srcResolution.x*t,y:o.srcResolution.y*t}}}l&&(r.srcResolution=l,this._updateSourceDataInfo(e,r))}return this._requireTooManySrcTiles(r.srcWidth,r.srcHeight,t,i)&&(r.srcWidth=0,r.srcHeight=0),r}_requireTooManySrcTiles(e,t,i,o){const{tileInfo:r}=this.rasterInfo.storageInfo,n=Math.ceil(e/r.size[0])*Math.ceil(t/r.size[1]),s=e/i,l=t/o,a=Math.max(1,(i+o)/1024);return n>=U*a||s>V||l>V}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,o=i.spatialReference,{srcResolution:r,datumTransformation:n}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=j(r,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||L(e,o,n);if(null==c)return;const m=i.transform;m&&(c=m.inverseTransform(c)),t.srcExtent=c;const{x:f,y:u}=i.storageInfo.origin,h=Math.floor((c.xmin-f)/l.x+.1),p=Math.floor((u-c.ymax)/l.y+.1),d=Math.floor((c.xmax-f)/l.x-.1),x=Math.floor((u-c.ymin)/l.y-.1),y=c.width<.1*l.x?0:d-h+1,g=c.height<.1*l.y?0:x-p+1;t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=y,t.srcHeight=g,t.ul={x:h,y:p}}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:o,pyramidLevel:r,useTransposedTile:n}=t,s=e.pixels[0].length/e.width/e.height;if(!(!e.mask||e.mask[o]))return{location:i,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!n){const t=e.pixels.map((e=>e[o])),n={location:i,value:t,pyramidLevel:r},s=this._computeMagDirValues(t.map((e=>[e])));return s?.length&&(n.magdirValue=s.map((e=>e[0]))),n}let a=e.pixels.map((e=>e.slice(o*s,o*s+s))),c=this._computeMagDirValues(a);const{requestSomeSlices:m,identifyOptions:f}=t;let h=g(l,f.transposedVariableName);if(m){const e=I(h,f.multidimensionalDefinition,f.timeExtent);a=a.map((t=>e.map((e=>t[e])))),c=c?.map((t=>e.map((e=>t[e])))),h=e.map((e=>h[e]))}const p=e.noDataValues||this.rasterInfo.noDataValue,d={pixels:a,pixelType:e.pixelType};let x;null!=p&&(T(d,p),x=d.mask);return{location:i,value:null,dataSeries:h.map(((e,t)=>{const i={value:0===x?.[t]?null:a.map((e=>e[t])),multidimensionalDefinition:e.multidimensionalDefinition.map((e=>new u({...e,isSlice:!0})))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i})),pyramidLevel:r}}};e([l()],Q.prototype,"_rasterTileAlignmentInfo",void 0),e([l()],Q.prototype,"_tileFetchQueue",void 0),e([l({readOnly:!0})],Q.prototype,"_isGlobalWrappableSource",null),e([l({readOnly:!0})],Q.prototype,"_hasNoneOrGCSShiftTransform",null),e([l()],Q.prototype,"rasterJobHandler",null),e([l({readOnly:!0})],Q.prototype,"rasterId",null),e([l(f)],Q.prototype,"url",null),e([l({type:String,json:{write:!0}})],Q.prototype,"datasetName",void 0),e([l({type:String,json:{write:!0}})],Q.prototype,"datasetFormat",void 0),e([l()],Q.prototype,"hasUniqueSourceStorageInfo",void 0),e([l()],Q.prototype,"rasterInfo",void 0),e([l()],Q.prototype,"ioConfig",void 0),e([l()],Q.prototype,"sourceJSON",void 0),Q=e([c("esri.layers.support.rasterDatasets.BaseRaster")],Q);const X=Q;export{X as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../request.js";import i from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import o from"../../../core/Logger.js";import{EsriPromiseMixin as n}from"../../../core/Promise.js";import{onAbort as s}from"../../../core/promiseUtils.js";import{property as l}from"../../../core/accessorSupport/decorators/property.js";import{ensureClass as a}from"../../../core/accessorSupport/ensureType.js";import"../../../core/RandomLCG.js";import"../../../core/has.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{sanitizeUrl as m}from"../arcgisLayerUrl.js";import{url as f}from"../commonProperties.js";import u from"../DimensionalDefinition.js";import h from"../LOD.js";import p from"../RasterStorageInfo.js";import d from"../TileInfo.js";import{isMultiSliceOrRangeDefinition as x,getSliceIndex as y,createSlices as g,getSliceIds as I}from"./multidimensionalUtils.js";import{getRasterId as R,getBlock as w,putBlock as S,deleteBlock as k,decreaseRefCount as v}from"./RawBlockCache.js";import{convertNoDataToMask as T}from"../rasterFormats/pixelRangeUtils.js";import{decode as b}from"../rasterFormats/RasterCodec.js";import{mosaic as P,approximateTransform as B,getLocalArithmeticNorthRotations as M}from"../rasterFunctions/pixelUtils.js";import{load as _,getWorldWidth as C,projectPoint as W,snapPyramid as j,shiftExtent as z,getWorldWrapCount as H,projectExtent as L,getProjectionOffsetGrid as E,getRasterDatasetAlignmentInfo as D,projectResolution as F}from"../rasterFunctions/rasterProjectionHelper.js";import{convertToLocalDirections as O,uvComponentToVector as A}from"../rasterFunctions/vectorFieldUtils.js";import{QueueProcessor as G}from"../../../views/support/QueueProcessor.js";import q from"../../../geometry/Extent.js";import J from"../../../geometry/Point.js";import N from"../../../geometry/SpatialReference.js";const V=8,U=256;let $=0,Q=class extends(n(r)){constructor(){super(...arguments),this._tileFetchQueue=new G({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"}}async init(){const e=_();this.addResolvingPromise(e),await this.when()}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:d.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=C(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),"Function"===this.datasetFormat&&this.primaryRasters?.rasters?.forEach((t=>t.rasterJobHandler=e))}get rasterId(){return this.url||"rasterId-"+$++}set url(e){this._set("url",m(e,o.getLogger(this)))}async open(e){throw new i("BaseRaster:open-not-implemented","open() is not implemented")}async fetchTile(e,t,i,r={}){const o=r.tileInfo||this.rasterInfo.storageInfo.tileInfo,n=this.getTileExtentFromTileInfo(e,t,i,o);return r={noClip:!0,...r},this.fetchPixels(n,o.size[0],o.size[1],r)}async identify(e,t={}){e=a(J,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:r}=t,{rasterInfo:o}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:s}=o;let{transposedVariableName:l}=t;const c=null!=s&&n&&(null!=r||x(i));if(c&&!l){l=null!=i&&i.length>0?i[0].variableName??void 0:s.variables[0].name,t={...t,transposedVariableName:l}}t=this._getRequestOptionsWithSliceId(t);const{spatialReference:m,extent:f}=o,{datumTransformation:u}=t;let h=W(e,m,u);if(!f.intersects(h))return{location:h,value:null};if(null!=o.transform){const e=o.transform.inverseTransform(h);if(!o.nativeExtent.intersects(e))return{location:e,value:null};h=e}let p=0;const d=null!=l&&null!=s&&o.hasMultidimensionalTranspose;if("Function"===this.datasetFormat){const e=this.primaryRasters.rasters[0];if(d)return e.identify(h,t);const{pixelSize:r}=o,n=3,s=r.x*n/2,l=r.y*n/2,a=new q({xmin:h.x-s,xmax:h.x+s,ymin:h.y-l,ymax:h.y+l,spatialReference:m}),c={interpolation:"nearest",multidimensionalDefinition:i,sliceId:t.sliceId},{pixelBlock:f}=await e.fetchPixels(a,n,n,c),{pixelBlock:u}=await this.fetchPixels(a,n,n,c);if(null==f)return{location:h,value:null};const p=Math.floor(n*n*.5),x=!f.mask||f.mask[p]?f.pixels.map((e=>e[p])):null;let y;return null!=u&&(y=!u.mask||u.mask[p]?u.pixels.map((e=>e[p])):void 0),{location:h,value:x,processedValue:y,pyramidLevel:0}}if(!d)if(t.srcResolution){p=j(t.srcResolution,o,this.ioConfig.sampling).pyramidLevel}else if(p=await this.computeBestPyramidLevelForLocation(e,t),null==p)return{location:h,value:null};const y=this.identifyPixelLocation(h,p,null,d);if(null===y)return{location:h,value:null};const{row:g,col:I,rowOffset:k,colOffset:v,blockWidth:T}=y,b=l??t.sliceId,P=R(this.rasterId,b),B=`${p}/${g}/${I}`;let M=w(P,null,B);null==M&&(M=this.fetchRawTile(p,g,I,t),S(P,null,B,M));const _=await M;if(!_?.pixels?.length)return{location:h,value:null};const C=k*T+v;return this._processIdentifyResult(_,{srcLocation:h,position:C,pyramidLevel:p,useTransposedTile:!!d,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,i,r={}){e=z(e),r=this._getRequestOptionsWithSliceId(r);const{_hasNoneOrGCSShiftTransform:o}=this;if(r.requestRawData&&o)return this._fetchPixels(e,t,i,r);const n=C(e.spatialReference),s=H(e);if(null==n||0===s||1===s&&this._isGlobalWrappableSource&&o)return this._fetchPixels(e,t,i,r);if(s>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,m=Math.round(n/(c-a)*t),f=m-Math.round((n/2-a)/(c-a)*t);let u=0;const h=[];for(let y=0;y<=s;y++){const o=new q({xmin:0===y?a:-n/2,xmax:y===s?c-n*y:n/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),p=0===y?m-f:y===s?t-u:m;u+=p,h.push(p);const d=r.disableWrapAround&&y>0?null:this._fetchPixels(o,p,i,r);l.push(d)}const p=(await Promise.all(l)).map((e=>e?.pixelBlock));let d=null;const x={width:t,height:i};if(this.rasterJobHandler){d=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:x,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:h},r)).pixelBlock}else d=P(p,x,{blockWidths:h});return{extent:e,srcExtent:L(e,this.rasterInfo.spatialReference,r.datumTransformation),pixelBlock:d}}async fetchRawPixels(e,t,i,r={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const o=await this._fetchRawTiles(e,t,i,r),{nativeExtent:n,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,m=s.y*a,f=new q({xmin:n.xmin+c*t.x,xmax:n.xmin+c*(t.x+i.width-1),ymin:n.ymax-m*(t.y+i.height-1),ymax:n.ymax-m*t.y,spatialReference:n.spatialReference});if(!o)return{extent:f,srcExtent:f,pixelBlock:null};const{pixelBlocks:u,mosaicSize:h}=o;if(1===u.length&&null!=u[0]&&u[0].width===i.width&&u[0].height===i.height)return{extent:f,srcExtent:f,pixelBlock:o.pixelBlocks[0]};const p=e>0?l.pyramidBlockWidth:l.blockWidth,d=e>0?l.pyramidBlockHeight:l.blockHeight,x={x:t.x%p,y:t.y%d};let y;if(this.rasterJobHandler){y=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:u,srcMosaicSize:h,destDimension:i,clipOffset:x,clipSize:i,coefs:null,sampleSpacing:null,interpolation:r.interpolation,alignmentInfo:null,blockWidths:null},r)).pixelBlock}else y=P(u,h,{clipOffset:x,clipSize:i});return{extent:f,srcExtent:f,pixelBlock:y}}fetchRawTile(e,t,r,o){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return L(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?b(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,i,r=0){const{customFetchParameters:o}=this.ioConfig,{range:n,query:s,headers:l}=i;r=r??i.retryCount??this.ioConfig.retryCount;const a=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await t(e,{...i,query:{...s,...o},headers:{...l,...a}})}catch(c){if(r>0)return r--,this.request(e,i,r);throw c}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:y(e,t)}getTileExtentFromTileInfo(e,t,i,r){const o=r.lodAt(e);return this.getTileExtent({x:o.resolution,y:o.resolution},t,i,r.origin,r.spatialReference,r.size)}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:r}=this.rasterInfo;if(!e.tileInfo){const o=[],n=e.maximumPyramidLevel||0;let s=Math.max(r.x,r.y),l=1/.0254*96*s;for(let e=0;e<=n;e++)o.unshift(new h({level:n-e,resolution:s,scale:l})),s*=2,l*=2;const a=new J({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new d({origin:a,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:o}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,r){const{width:o,height:n,nativeExtent:s,pixelSize:l,spatialReference:a}=e,c=new J({x:s.xmin,y:s.ymax,spatialReference:a});null==r&&(r=Math.max(0,Math.round(Math.log(Math.max(o,n))/Math.LN2-8)));const m=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],r);e.storageInfo=new p({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:r,blockBoundary:m})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,r,o,n=0,s=2){if(1===o.length&&n>0){o=[...o];let{x:e,y:t}=o[0];for(let i=0;i<n;i++)e*=s,t*=s,o.push({x:e,y:t})}const l=[],{x:a,y:c}=r;for(let m=0;m<o.length;m++){const{x:r,y:n}=o[m];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*n)/i/n),maxRow:Math.floor((c-e.ymin-.1*n)/i/n)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:r}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const o=r**e;return{x:t.x*o,y:t.y*o}}identifyPixelLocation(e,t,i,r){const{spatialReference:o,nativeExtent:n,storageInfo:s}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=s,m=r&&null!=c?c.tileSize[0]:s.blockWidth,f=r&&null!=c?c.tileSize[1]:s.blockHeight,u=W(e,o,i);if(!n.intersects(u))return null;if(t<0||t>l)return null;const h=this.getPyramidPixelSize(t),{x:p,y:d}=h,x=(a.y-u.y)/d/f,y=(u.x-a.x)/p/m,g=Math.min(f-1,Math.floor((x-Math.floor(x))*f)),I=Math.min(m-1,Math.floor((y-Math.floor(y))*m));return{pyramidLevel:t,row:Math.floor(x),col:Math.floor(y),rowOffset:g,colOffset:I,blockWidth:m,srcLocation:u}}getTileExtent(e,t,i,r,o,n){const[s,l]=n,a=r.x+i*s*e.x,c=a+s*e.x,m=r.y-t*l*e.y,f=m-l*e.y;return new q({xmin:a,xmax:c,ymin:f,ymax:m,spatialReference:o})}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,i){const r=this.rasterInfo.storageInfo.blockBoundary[e];return!r||r.maxRow<t||r.maxCol<i||r.minRow>t||r.minCol>i}updateImageSpaceRasterInfo(e){const{extent:t,pixelSize:i}=e;if(-.5===t.xmin&&.5===t.ymax&&1===i.x&&1===i.y&&null==e.transform)return;const{width:r,height:o}=e,n=N.WebMercator;e.spatialReference=n,e.extent=e.nativeExtent=new q({xmin:-.5,ymax:.5,xmax:r-.5,ymin:.5-o,spatialReference:n}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new J({x:1,y:1,spatialReference:n});const{extent:s,storageInfo:l}=e;if(l){l.origin=new J({x:s.xmin,y:s.ymax,spatialReference:n});const{tileInfo:t}=l;if(t){t.origin=l.origin;const i=(e.nativePixelSize.x+e.nativePixelSize.y)/2;t.lods.forEach(((e,t)=>{e.resolution=i*2**t,e.scale=96*e.resolution/.0254}))}}}async _fetchPixels(e,t,i,r={}){let o=H(e);if(o>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,r),{pyramidLevel:s,srcResolution:l,srcExtent:a,srcWidth:c,srcHeight:m,ul:f}=n;if(0===c||0===m)return{extent:e,srcExtent:a,pixelBlock:null};const{rasterInfo:u}=this,h=u.transform,p="gcs-shift"===h?.type,d=null!=C(e.spatialReference);!p&&d||(o=H(n.srcExtent,p));const x=await this._fetchRawTiles(s,f,{width:c,height:m,wrapCount:o},r);if(!x)return{extent:e,srcExtent:a,pixelBlock:null};const y=u.storageInfo,g=s>0?y.pyramidBlockWidth:y.blockWidth,I=s>0?y.pyramidBlockHeight:y.blockHeight;let{x:R,y:w}=u.pixelSize;if(s>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=y;if(null!=e&&e[s-1])({x:R,y:w}=e[s-1]);else{const e=t**s;R*=e,w*=e}}const S=u.spatialReference,k=new J({x:R,y:w,spatialReference:S}),v=g===c&&I===m&&f.x%g==0&&f.y%I==0,T=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),b=!e.spatialReference.equals(S),W=S.isGeographic?1e-9:1e-4,{datumTransformation:j}=r;if(!b&&v&&1===x.pixelBlocks.length&&g===t&&I===i&&X(l,T,W))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:x.pixelBlocks[0]};const z=d&&null!=C(a.spatialReference)&&this._hasNoneOrGCSShiftTransform,L=r.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");L&&!this.rasterJobHandler&&await _();const D=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:T.toJSON(),datumTransformation:j,rasterTransform:h,hasWrapAround:o>0||z,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:L},r):E({projectedExtent:e,srcBufferExtent:x.extent,pixelSize:T,datumTransformation:j,rasterTransform:h,hasWrapAround:o>0||z,isAdaptive:!1,includeGCSGrid:L});let F;const A=!r.requestRawData,G={rows:D.spacing[0],cols:D.spacing[1]},q=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,x.extent.xmin):void 0,{pixelBlocks:N,mosaicSize:V,isPartiallyFilled:U}=x;let $=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:N,srcMosaicSize:V,destDimension:A?{width:t,height:i}:null,coefs:A?D.coefficients:null,sampleSpacing:A?G:null,projectDirections:L,gcsGrid:L?D.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:r.interpolation,alignmentInfo:q,blockWidths:null},r);({pixelBlock:F,localNorthDirections:$}=e)}else{const e=P(N,V,{alignmentInfo:q});F=A?B(e,{width:t,height:i},D.coefficients,G,r.interpolation):e,L&&D.gcsGrid&&($=M({width:t,height:i},D.gcsGrid),F=O(F,this.rasterInfo.dataType,$))}return r.requestRawData||L?{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F,transformGrid:D,localNorthDirections:$,isPartiallyFilled:U}:{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:F}}async _fetchRawTiles(e,t,i,r){const{origin:o,blockBoundary:n}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:m,height:f,wrapCount:u}=i;const h=this._getRasterTileAlignmentInfo(e,0);r.buffer&&(a-=r.buffer.cols,c-=r.buffer.rows,m+=2*r.buffer.cols,f+=2*r.buffer.rows);let p=0,d=0,x=0;if(u&&null!=h){({worldColumnCountFromOrigin:d,originColumnOffset:x,rightPadding:p}=h);d*h.blockWidth-p>=a+m&&(p=0)}const y=Math.floor(a/s),g=Math.floor(c/l),I=Math.floor((a+m+p-1)/s),R=Math.floor((c+f+p-1)/l),w=n[e];if(!w)return null;const{minRow:S,minCol:k,maxCol:v,maxRow:T}=w;if(0===u&&(R<S||I<k||g>T||y>v))return null;const b=new Array;let P=!1;const B=null==this.ioConfig.allowPartialFill?r.allowPartialFill:this.ioConfig.allowPartialFill;for(let H=g;H<=R;H++)for(let t=y;t<=I;t++){let i=t;if(!r.disableWrapAround&&u&&null!=h&&d<=t&&(i=t-d-x),H>=S&&i>=k&&T>=H&&v>=i){const t=this._tileFetchQueue.push({pyramidLevel:e,row:H,col:i,options:r},{signal:r.signal});B?b.push(new Promise((e=>{t.then((t=>e(t))).catch((()=>{P=!0,e(null)}))}))):b.push(t)}else b.push(Promise.resolve(null))}if(0===b.length)return null;const M=await Promise.all(b),_={height:(R-g+1)*l,width:(I-y+1)*s},{spatialReference:C}=this.rasterInfo,W=this.getPyramidPixelSize(e),{x:j,y:z}=W;return{extent:new q({xmin:o.x+y*s*j,xmax:o.x+(I+1)*s*j,ymin:o.y-(R+1)*l*z,ymax:o.y-g*l*z,spatialReference:C}),pixelBlocks:M,mosaicSize:_,isPartiallyFilled:P}}_fetchRawTile(e,t,i,r){const o=this.rasterInfo.storageInfo.blockBoundary[e];if(!o)return Promise.resolve(null);const{minRow:n,minCol:l,maxCol:a,maxRow:c}=o;if(t<n||i<l||t>c||i>a)return Promise.resolve(null);const m=R(this.rasterId,r.sliceId),f=`${e}/${t}/${i}`;let u=w(m,r.registryId,f);if(null==u){const o=new AbortController;u=this.fetchRawTile(e,t,i,{...r,signal:o.signal}),S(m,r.registryId,f,u,o),u.catch((()=>k(m,r.registryId,f)))}return r.signal&&s(r,(()=>{v(m,r.registryId,f)})),u}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if(!(2===t&&"vector-magdir"===i||"vector-uv"===i)||2!==e?.length||!e[0]?.length)return null;const r=e[0].length;if("vector-magdir"===i){const t=e[1].map((e=>(e+360)%360));return[e[0],t]}const[o,n]=e,s=[],l=[];for(let a=0;a<r;a++){const[e,t]=A([o[a],n[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=D(this.rasterInfo)),null==this._rasterTileAlignmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,r={}){const o={datumTransformation:r.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};r.srcResolution&&(o.srcResolution=r.srcResolution,this._updateSourceDataInfo(e,o));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=o,c=s/t,m=l/i,f=a<n&&c*m>=16,u=a===n&&this._requireTooManySrcTiles(s,l,t,i);if(f||u||(0===s||0===l)){const s=new J({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let l=F(s,this.rasterInfo.spatialReference,e,o.datumTransformation);const u=!l||r.srcResolution&&l.x+l.y<r.srcResolution.x+r.srcResolution.y;if(f&&r.srcResolution&&u){const e=Math.round(Math.log(Math.max(c,m))/Math.LN2)-1;if(n-a+3>=e){const t=2**e;l={x:r.srcResolution.x*t,y:r.srcResolution.y*t}}}l&&(o.srcResolution=l,this._updateSourceDataInfo(e,o))}return this._requireTooManySrcTiles(o.srcWidth,o.srcHeight,t,i)&&(o.srcWidth=0,o.srcHeight=0),o}_requireTooManySrcTiles(e,t,i,r){const{tileInfo:o}=this.rasterInfo.storageInfo,n=Math.ceil(e/o.size[0])*Math.ceil(t/o.size[1]),s=e/i,l=t/r,a=Math.max(1,(i+r)/1024);return n>=U*a||s>V||l>V}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,r=i.spatialReference,{srcResolution:o,datumTransformation:n}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=j(o,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||L(e,r,n);if(null==c)return;const m=i.transform;m&&(c=m.inverseTransform(c)),t.srcExtent=c;const{x:f,y:u}=i.storageInfo.origin,h=Math.floor((c.xmin-f)/l.x+.1),p=Math.floor((u-c.ymax)/l.y+.1),d=Math.floor((c.xmax-f)/l.x-.1),x=Math.floor((u-c.ymin)/l.y-.1),y=c.width<.1*l.x?0:d-h+1,g=c.height<.1*l.y?0:x-p+1;t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=y,t.srcHeight=g,t.ul={x:h,y:p}}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:r,pyramidLevel:o,useTransposedTile:n}=t,s=e.pixels[0].length/e.width/e.height;if(!(!e.mask||e.mask[r]))return{location:i,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!n){const t=e.pixels.map((e=>e[r])),n={location:i,value:t,pyramidLevel:o},s=this._computeMagDirValues(t.map((e=>[e])));return s?.length&&(n.magdirValue=s.map((e=>e[0]))),n}let a=e.pixels.map((e=>e.slice(r*s,r*s+s))),c=this._computeMagDirValues(a);const{requestSomeSlices:m,identifyOptions:f}=t;let h=g(l,f.transposedVariableName);if(m){const e=I(h,f.multidimensionalDefinition,f.timeExtent);a=a.map((t=>e.map((e=>t[e])))),c=c?.map((t=>e.map((e=>t[e])))),h=e.map((e=>h[e]))}const p=e.noDataValues||this.rasterInfo.noDataValue,d={pixels:a,pixelType:e.pixelType};let x;null!=p&&(T(d,p),x=d.mask);return{location:i,value:null,dataSeries:h.map(((e,t)=>{const i={value:0===x?.[t]?null:a.map((e=>e[t])),multidimensionalDefinition:e.multidimensionalDefinition.map((e=>new u({...e,isSlice:!0})))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i})),pyramidLevel:o}}};function X(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}e([l()],Q.prototype,"_rasterTileAlignmentInfo",void 0),e([l()],Q.prototype,"_tileFetchQueue",void 0),e([l({readOnly:!0})],Q.prototype,"_isGlobalWrappableSource",null),e([l({readOnly:!0})],Q.prototype,"_hasNoneOrGCSShiftTransform",null),e([l()],Q.prototype,"rasterJobHandler",null),e([l({readOnly:!0})],Q.prototype,"rasterId",null),e([l(f)],Q.prototype,"url",null),e([l({type:String,json:{write:!0}})],Q.prototype,"datasetName",void 0),e([l({type:String,json:{write:!0}})],Q.prototype,"datasetFormat",void 0),e([l()],Q.prototype,"hasUniqueSourceStorageInfo",void 0),e([l()],Q.prototype,"rasterInfo",void 0),e([l()],Q.prototype,"ioConfig",void 0),e([l()],Q.prototype,"sourceJSON",void 0),Q=e([c("esri.layers.support.rasterDatasets.BaseRaster")],Q);const K=Q;export{K as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../LOD.js";import
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../LOD.js";import n from"../RasterInfo.js";import s from"../RasterStorageInfo.js";import a from"../TileInfo.js";import l from"./BaseRaster.js";import f from"./DBFParser.js";import{isTransformSupported as c,readTransform as m}from"../rasterTransforms/utils.js";import u from"../../../rest/support/FeatureSet.js";import p from"../../../geometry/SpatialReference.js";import d from"../../../geometry/Extent.js";import h from"../../../geometry/Point.js";const g=new Map;g.set("int16","esriFieldTypeSmallInteger"),g.set("int32","esriFieldTypeInteger"),g.set("int64","esriFieldTypeInteger"),g.set("float32","esriFieldTypeSingle"),g.set("float64","esriFieldTypeDouble"),g.set("text","esriFieldTypeString");const y=8;let x=class extends l{constructor(){super(...arguments),this.storageInfo=null,this.datasetFormat="CRF"}async open(e){await this.init();const{data:r}=await this.request(this.url+"/conf.json",{signal:e?.signal});if(!I(r))throw new t("cloudraster:open","Invalid or unsupported conf.json.");this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const{storageInfo:o,rasterInfo:i}=S(r);if("thematic"===i.dataType){const e=await this._fetchAuxiliaryInformation();i.attributeTable=e}this._set("storageInfo",o),this._set("rasterInfo",i),this.ioConfig.retryCount=this.ioConfig.retryCount||0}async fetchRawTile(e,t,r,o={}){const{transposeInfo:i}=this.rasterInfo.storageInfo,{transposedVariableName:n}=o,s=!(!i||!n),a=s?0:this.rasterInfo.storageInfo.maximumPyramidLevel-e;if(a<0)return null;const l=this._buildCacheFilePath(a,t,r,o.multidimensionalDefinition,n),f=this._getIndexRecordFromBundle(t,r,s),c=await this.request(l,{range:{from:0,to:this.storageInfo.headerSize-1},responseType:"array-buffer",signal:o.signal});if(!c)return null;const m=z(new Uint8Array(c.data),f);if(0===m.recordSize)return null;const u=await this.request(l,{range:{from:m.position,to:m.position+m.recordSize},responseType:"array-buffer",signal:o.signal});if(!u)return null;const[p,d]=this._getTileSize(s);return this.decodePixelBlock(u.data,{width:p,height:d,planes:null,pixelType:null,returnInterleaved:s})}async _fetchAuxiliaryInformation(e){const t=this.request(this.url+"/conf.vat.json",{signal:e}).then((e=>e.data)).catch((()=>null)),r=this.request(this.url+"/conf.vat.dbf",{responseType:"array-buffer",signal:e}).then((e=>e.data)).catch((()=>null)),o=await Promise.all([t,r]);let i;if(o[0]){let e=o[0].fields;const t=o[0].values;if(e&&t){e=e.map((e=>({type:"OID"===e.name?"esriFieldTypeOID":g.get(e.type),name:e.name,alias:e.alias||e.name})));const r=t.map((e=>({attributes:e})));e&&t&&(i={fields:e,features:r})}}if(!i&&o[1]){i=f.parse(o[1]).recordSet}return u.fromJSON(i)}_buildCacheFilePath(e,t,r,o,i){const n=this._getPackageSize(!!i),s=Math.floor(t/n)*n,a=Math.floor(r/n)*n,l="R"+b(s)+"C"+b(a);let f="L";f+=e>=10?e.toString():"0"+e.toString();const{multidimensionalInfo:c}=this.rasterInfo,m=o?.[0];if(null==c||!m)return`${this.url}/_alllayers/${f}/${l}.bundle`;let u="_yxs";if(!i){u=c.variables.find((e=>e.name===m.variableName)).dimensions[0].values.indexOf(m.values[0]).toString(16);const e=4-u.length;for(let t=0;t<e;t++)u="0"+u;u="S"+u}const p=v(i||m.variableName);return`${this.url}/_alllayers/${p}/${u}/${f}/${l}.bundle`}_getPackageSize(e=!1){const{transposeInfo:t}=this.rasterInfo.storageInfo;return e&&null!=t?t.packetSize??0:this.storageInfo.packetSize}_getTileSize(e=!1){const{storageInfo:t}=this.rasterInfo,{transposeInfo:r}=t;return e&&null!=r?r.tileSize:t.tileInfo.size}_getIndexRecordFromBundle(e,t,r=!1){const o=this._getPackageSize(r),i=o*(e%o)+t%o;if(i<0)throw new Error("Invalid level / row / col");return 20+i*this.storageInfo.recordSize+44}};function I(e){const t=["origin","extent","geodataXform","LODInfos","blockWidth","blockHeight","bandCount","pixelType","pixelSizeX","pixelSizeY","format","packetSize"];return e&&"RasterInfo"===e.type&&!t.some((t=>!e[t]))}function S(e){const t=["u1","u2","u4","u8","s8","u16","s16","u32","s32","f32","f64"][e.pixelType],{bandCount:r,colormap:o,blockWidth:l,blockHeight:f,firstPyramidLevel:c,maximumPyramidLevel:m}=e,u=e.statistics?.map((e=>({min:e.min,max:e.max,avg:e.mean,stddev:e.standardDeviation,median:e.median,mode:e.mode}))),g=e.histograms?.[0]?.counts?.length?e.histograms:null,x=e.extent.spatialReference,I=e.geodataXform?.spatialReference,S=new p(x?.wkid||x?.wkt||x?.wkt2?x:I);let v=new d({xmin:e.extent.xmin,ymin:e.extent.ymin,xmax:e.extent.xmax,ymax:e.extent.ymax,spatialReference:S});const z=new h({x:e.pixelSizeX,y:e.pixelSizeY,spatialReference:S}),b=Math.round((v.xmax-v.xmin)/z.x),k=Math.round((v.ymax-v.ymin)/z.y),T=w(e.geodataXform),j=T?v:null;T&&(v=T.forwardTransform(v),z.x=(v.xmax-v.xmin)/b,z.y=(v.ymax-v.ymin)/k);const R=e.properties??{},_=e.format.toLowerCase().replace("cache/",""),C=new h(e.origin.x,e.origin.y,S);let F,P,L,D;if(o?.colors)for(F=[],P=0;P<o.colors.length;P++)L=o.colors[P],D=o.values?o.values[P]:P,F.push([D,255&L,L<<16>>>24,L<<8>>>24,L>>>24]);const M=e.LODInfos,O=[];for(P=0;P<M.levels.length;P++)O.push(new i({level:M.levels[P],resolution:M.resolutions[P],scale:96/.0254*M.resolutions[P]}));const B=new a({dpi:96,lods:O,format:_,origin:C,size:[l,f],spatialReference:S}),$={recordSize:y,packetSize:e.packetSize,headerSize:e.packetSize*e.packetSize*y+64},q=[{maxCol:Math.ceil(b/l)-1,maxRow:Math.ceil(k/f)-1,minCol:0,minRow:0}];let X=2;if(m>0)for(P=0;P<m;P++)q.push({maxCol:Math.ceil(b/X/l)-1,maxRow:Math.ceil(k/X/f)-1,minCol:0,minRow:0}),X*=2;const N=e.mdInfo;let A=null;if(N&&R._yxs){const e=R._yxs;A={packetSize:e.PacketSize,tileSize:[e.TileXSize,e.TileYSize]}}return{storageInfo:$,rasterInfo:new n({width:b,height:k,pixelType:t,bandCount:r,extent:v,nativeExtent:j,transform:T,spatialReference:S,pixelSize:z,keyProperties:R,statistics:u,histograms:g,multidimensionalInfo:N,colormap:F,storageInfo:new s({blockWidth:l,blockHeight:f,pyramidBlockWidth:l,pyramidBlockHeight:f,origin:C,tileInfo:B,transposeInfo:A,firstPyramidLevel:c,maximumPyramidLevel:m,blockBoundary:q})})}}function w(e){if(!c(e))throw new t("cloudraster:open","the data contains unsupported geodata transform types");const r=m(e);if("identity"===r.type)return null;if("polynomial"!==r.type||!r.forwardCoefficients?.length||!r.inverseCoefficients?.length)throw new t("cloudraster:open","the data contains unsupported geodata transforms - both forward and inverse coefficients are required currently");return r}function v(e){return""===(e=e.trim())?"_v":e.replaceAll(/[\{|\}\-]/g,"_").replace("\\*","_v")}function z(e,t){const r=e.subarray(t,t+8);let o,i=0;for(o=0;o<5;o++)i|=(255&r[o])<<8*o;const n=0xffffffffff&i;for(i=0,o=5;o<8;o++)i|=(255&r[o])<<8*(o-5);return{position:n,recordSize:0xffffffffff&i}}function b(e){let t=e.toString(16);if(4!==t.length){let e=4-t.length;for(;e-- >0;)t="0"+t}return t}e([r({readOnly:!0})],x.prototype,"storageInfo",void 0),e([r({type:String,json:{write:!0}})],x.prototype,"datasetFormat",void 0),x=e([o("esri.layers.support.rasterDatasets.CloudRaster")],x);const k=x;export{k as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Error.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../../geometry/Polygon.js";import o from"./BaseRaster.js";import{clip as
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import e from"../../../core/Error.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import i from"../../../geometry/Polygon.js";import o from"./BaseRaster.js";import{clip as n}from"../rasterFunctions/clipUtils.js";import{approximateTransform as a}from"../rasterFunctions/pixelUtils.js";import{projectPolygon as l}from"../rasterFunctions/rasterProjectionHelper.js";import c from"../../../rest/support/FeatureSet.js";const p=40;let m=class extends o{constructor(){super(...arguments),this.datasetFormat="Function",this.tileType="Raster",this.rasterFunction=null,this._clippingGeometry=new Map}async open(t){await this.init();const{rasterFunction:r}=this;this.primaryRasters?.rasters?.length?r.sourceRasters=this.primaryRasters.rasters:(this.primaryRasters=r.getPrimaryRasters(),this.rasterJobHandler&&this.primaryRasters.rasters?.forEach((t=>t.rasterJobHandler=this.rasterJobHandler)));const{rasters:s,rasterIds:i}=this.primaryRasters,o=s.map((e=>e.rasterInfo?void 0:e.open(t)));await Promise.all(o);const n=s.map((({rasterInfo:t})=>t)),a=r.bind({rasterInfos:n,rasterIds:i});if(r.rawSourceRasterInfos=n,!a.success||0===n.length)throw new e("raster-function:open",`cannot bind the function: ${a.error??""}`);const l="Table"===r.functionName?r:r.functionArguments?.raster;"Table"===l?.functionName&&(r.rasterInfo.attributeTable=c.fromJSON(l.functionArguments.attributeTableAsRecordSet)),await this.syncJobHandler();const p=n[0];this.hasUniqueSourceStorageInfo=1===n.length||n.slice(1).every((t=>h(t,p))),this.set("sourceJSON",s[0].sourceJSON),this.set("rasterInfo",r.rasterInfo),await this._updateClipGeometry()}async syncJobHandler(){return this.rasterJobHandler?.updateRasterFunction(this.rasterFunction)}async fetchPixels(t,e,r,s={}){const{rasters:i,rasterIds:o}=this.primaryRasters;let l=!1;const{interpolation:c}=s,p=this.rasterFunction.flatWebGLFunctionChain?.hasFocalFunction;!s.requestRawData&&p&&(l=1===i.length&&!s.skipRasterFunction,s={...s,interpolation:"bilinear",requestRawData:l});const m=i.map((i=>i.fetchPixels(t,e,r,s))),u=await Promise.all(m),h=u.map((t=>t.pixelBlock)),f=l||s.requestRawData?u.map((t=>t.srcTilePixelSize)):null;if(s.skipRasterFunction||h.every((t=>null==t)))return u[0];const d=u.find((t=>null!=t.pixelBlock))?.extent??t;let y=this.rasterJobHandler?await this.rasterJobHandler.process({extent:d,primaryPixelBlocks:h,primaryPixelSizes:f,primaryRasterIds:o}):this.rasterFunction.process({extent:d,primaryPixelBlocks:h,primaryPixelSizes:f,primaryRasterIds:o});const{transformGrid:g}=u[0];if(!l||null==y||null==g){const t=s.noClip?null:this.getClippingGeometry(d.spatialReference);return s.noClip||s.requestRawData||null==y||!t||(y=await n(y,d,t)),{...u[0],pixelBlock:y}}const x={rows:g.spacing[0],cols:g.spacing[1]};let R;if(this.rasterJobHandler){R=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:[y],srcMosaicSize:{width:y.width,height:y.height},destDimension:{width:e,height:r},coefs:g.coefficients,sampleSpacing:x,projectDirections:!1,gcsGrid:null,isUV:!1,interpolation:c,alignmentInfo:void 0,blockWidths:null},s)).pixelBlock}else R=a(y,{width:e,height:r},g.coefficients,x,c);const w=s.noClip?null:this.getClippingGeometry(t.spatialReference);return s.noClip||s.requestRawData||null==R||null==w||(R=await n(R,t,w)),{extent:t,srcExtent:u[0].srcExtent,pixelBlock:R}}getClippingGeometry(t){const e=this._clippingGeometry.get("0");if(!t||!e)return e;const r=f(t);let s=this._clippingGeometry.get(r);return null!=s||(s=t.equals(e.spatialReference)?e:l(e,t),this._clippingGeometry.set(r,s)),s}async _updateClipGeometry(){const t=this.rasterFunction.getClippingGeometries()[0];let e=t?.clippingGeometry;if(e&&"inside"===t.clippingType){const{extent:t}=this.rasterInfo,{difference:r,densify:s}=await import("../../../geometry/geometryEngine.js");let o=s(i.fromExtent(t),2*(t.width+t.height)/p);o=l(o,e.spatialReference),e=r(o,e)}this._clippingGeometry.clear(),e&&this._clippingGeometry.set("0",e)}};t([r({type:String,json:{write:!0}})],m.prototype,"datasetFormat",void 0),t([r()],m.prototype,"tileType",void 0),t([r()],m.prototype,"rasterFunction",void 0),t([r()],m.prototype,"primaryRasters",void 0),m=t([s("esri.layers.support.rasterDatasets.FunctionRaster")],m);const u=m;function h(t,e){const{storageInfo:r,pixelSize:s,spatialReference:i,extent:o}=t,{storageInfo:n,pixelSize:a,spatialReference:l,extent:c}=e;return s.x===a.x&&s.y===a.y&&i.equals(l)&&o.equals(c)&&r.blockHeight===n.blockHeight&&r.blockWidth===n.blockWidth&&r.maximumPyramidLevel===n.maximumPyramidLevel}function f(t){return String(t.wkid??t.wkt??t.wkt2)}export{u as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../RasterInfo.js";import o from"../RasterStorageInfo.js";import n from"../TileInfo.js";import{TilemapCache as c}from"../TilemapCache.js";import m from"./BaseRaster.js";import{setValidBoundary as u}from"../rasterFunctions/pixelUtils.js";import h from"../rasterTransforms/GCSShiftTransform.js";import{patchServiceInfo as f,fetchServiceRasterInfo as p}from"../../../rest/imageService/fetchRasterInfo.js";import d from"../../../geometry/SpatialReference.js";import y from"../../../geometry/Point.js";import x from"../../../geometry/Extent.js";let g=class extends m{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async open(e){await this.init();const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const m=["jpg","jpeg","png","png8","png24","png32","mixed"];this.tileType=l.cacheType,null==this.tileType&&(m.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const u=await this._fetchRasterInfo({signal:r});if(null==u)throw new t("image-server-raster:open","cannot initialize image service");f(u,l);const h="Map"===this.tileType?v(l.tileInfo,l):n.fromJSON(l.tileInfo);i(h);const[p,d]=this._computeMinMaxLOD(u,h),{extent:y,pixelSize:x}=u,g=.5/u.width*x.x,
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import l from"../RasterInfo.js";import o from"../RasterStorageInfo.js";import n from"../TileInfo.js";import{TilemapCache as c}from"../TilemapCache.js";import m from"./BaseRaster.js";import{setValidBoundary as u}from"../rasterFunctions/pixelUtils.js";import h from"../rasterTransforms/GCSShiftTransform.js";import{patchServiceInfo as f,fetchServiceRasterInfo as p}from"../../../rest/imageService/fetchRasterInfo.js";import d from"../../../geometry/SpatialReference.js";import y from"../../../geometry/Point.js";import x from"../../../geometry/Extent.js";let g=class extends m{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async open(e){await this.init();const r=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:r});a.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=a.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const m=["jpg","jpeg","png","png8","png24","png32","mixed"];this.tileType=l.cacheType,null==this.tileType&&(m.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const u=await this._fetchRasterInfo({signal:r});if(null==u)throw new t("image-server-raster:open","cannot initialize image service");f(u,l);const h="Map"===this.tileType?v(l.tileInfo,l):n.fromJSON(l.tileInfo);i(h);const[p,d]=this._computeMinMaxLOD(u,h),{extent:y,pixelSize:x}=u,g=.5/u.width*x.x,I=Math.max(x.x,x.y),{lods:w}=h;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some((e=>Math.abs(e.resolution-I)<g)))&&(x.x=x.y=p.resolution,u.width=Math.ceil((y.xmax-y.xmin)/x.x-.1),u.height=Math.ceil((y.ymax-y.ymin)/x.y-.1));const j=p.level-d.level,[M,b]=h.size,T=[],_=[];w.forEach(((e,t)=>{e.level>=d.level&&e.level<=p.level&&T.push({x:e.resolution,y:e.resolution}),t<w.length-1&&_.push(Math.round(10*e.resolution/w[t+1].resolution)/10)})),T.sort(((e,t)=>e.x-t.x));const O=this.computeBlockBoundary(y,M,b,h.origin,T,j),R=T.length>1?T.slice(1):null;let z;l.transposeInfo&&(z={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:u.keyProperties?._yxs.PacketSize??0});const N=_.length<=1||_.length>=3&&_.slice(0,-1).every((e=>e===_[0]))?_[0]??2:Math.round(10/(d.resolution/p.resolution)**(-1/j))/10;if(u.storageInfo=new o({blockWidth:h.size[0],blockHeight:h.size[1],pyramidBlockWidth:h.size[0],pyramidBlockHeight:h.size[1],pyramidResolutions:R,pyramidScalingFactor:N,compression:h.format,origin:h.origin,firstPyramidLevel:1,maximumPyramidLevel:j,tileInfo:h,transposeInfo:z,blockBoundary:O}),S(u),this._set("rasterInfo",u),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:u.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new c({layer:e})}}async fetchRawTile(e,t,i,s={}){const{storageInfo:r,extent:a}=this.rasterInfo,{transposeInfo:l}=r,o=null!=l&&!!s.transposedVariableName;if(this._slices&&!o&&null==s.sliceId)return null;const n=o?0:r.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${n}/${t}/${i}`,m=this._slices?o?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null,{data:h}=await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal});if(!h)return null;const f=o?l.tileSize:r.tileInfo.size,p=await this.decodePixelBlock(h,{width:f[0],height:f[1],planes:null,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:o,noDataValue:this.rasterInfo.noDataValue});if(null==p)return null;const d=r.blockBoundary[e];if("jpg"!==r.compression||i>d.minCol&&i<d.maxCol&&t>d.minRow&&t<d.maxRow)return p;const{origin:y,blockWidth:x,blockHeight:g}=r,{x:v,y:S}=this.getPyramidPixelSize(e),I=Math.round((a.xmin-y.x)/v)%x,w=Math.round((a.xmax-y.x)/v)%x||x,j=Math.round((y.y-a.ymax)/S)%g,M=Math.round((y.y-a.ymin)/S)%g||g,b=i===d.minCol?I:0,T=t===d.minRow?j:0,_=i===d.maxCol?w:x,O=t===d.maxRow?M:g;return u(p,{x:b,y:T},{width:_-b,height:O-T}),p}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some((e=>{const i=t.find((t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName));if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])})))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.statistics)),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then((e=>e.data?.histograms)),r=await Promise.all([i,s]);return r[0]&&r[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),r[1]?.[0]?.counts?.length||(r[1]=null),{statistics:r[0]||null,histograms:r[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:r}=this.rasterInfo.storageInfo;let a=r-s+this._levelOffset;const l=i.srcLocation;for(;a>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(a,i.row,i.col,t))break}catch{}if(a--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===a||null==i?null:s}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),r=d.fromJSON(t.spatialReference||e.spatialReference),a=new y({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:r});return new l({width:i,height:s,bandCount:3,extent:x.fromJSON(e),spatialReference:r,pixelSize:a,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=p(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),r=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then((e=>e.data?.slices)).catch((()=>null)):null,a=await Promise.all([s,r]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:r}=t,a=t.lodAt(Math.max.apply(null,r.map((e=>e.level)))),l=t.lodAt(Math.min.apply(null,r.map((e=>e.level)))),{tileType:o}=this;if("Map"===o)return this._levelOffset=r[0].level,[a,l];if("Raster"===o){return[r.find((e=>e.resolution===i.x))??a,l]}const{minScale:n,maxScale:c}=this.sourceJSON;let m=a;c>0&&(m=r.find((e=>Math.abs(e.scale-c)<s)),m||(m=r.filter((e=>e.scale>c)).sort(((e,t)=>e.scale>t.scale?1:-1))[0]??a));let u=l;return n>0&&(u=r.find((e=>Math.abs(e.scale-n)<s))??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:r,maxLOD:a}=t;if(null!=r&&null!=a)return n.fromJSON({...e,lods:e.lods.filter((({level:e})=>null!=e&&e>=r&&e<=a))});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,r=i?t(i):1/0,a=s?t(s):-1/0;return n.fromJSON({...e,lods:e.lods.filter((e=>{const i=t(e.scale);return i<=r&&i>=a}))})}return n.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new h,e.extent=e.transform.forwardTransform(t))}e([r({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([r()],g.prototype,"tileType",void 0),g=e([a("esri.layers.support.rasterDatasets.ImageServerRaster")],g);const I=g;export{I as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../core/Error.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../PixelBlock.js";import i from"../RasterInfo.js";import a from"../RasterStorageInfo.js";import n from"./BaseRaster.js";import{parseSpatialReference as l,parsePAMInfo as f}from"./pamParser.js";import{getElement as c,getElementValue as
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import e from"../../../core/Error.js";import{property as r}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import o from"../PixelBlock.js";import i from"../RasterInfo.js";import a from"../RasterStorageInfo.js";import n from"./BaseRaster.js";import{parseSpatialReference as l,parsePAMInfo as f}from"./pamParser.js";import{getElement as c,getElementValue as m}from"./xmlUtilities.js";import{isPlatformLittleEndian as p}from"../rasterFormats/utils.js";import{estimateStatisticsFromHistograms as h}from"../rasterFunctions/stretchUtils.js";import u from"../../../geometry/SpatialReference.js";import g from"../../../geometry/Extent.js";import d from"../../../geometry/Point.js";const y=new Map;y.set("Int8","s8"),y.set("UInt8","u8"),y.set("Int16","s16"),y.set("UInt16","u16"),y.set("Int32","s32"),y.set("UInt32","u32"),y.set("Float32","f32"),y.set("Float64","f32"),y.set("Double64","f32");const x=new Map;x.set("none",{blobExtension:".til",isOneSegment:!0,decoderFormat:"bip"}),x.set("lerc",{blobExtension:".lrc",isOneSegment:!1,decoderFormat:"lerc"}),x.set("deflate",{blobExtension:".pzp",isOneSegment:!0,decoderFormat:"deflate"}),x.set("jpeg",{blobExtension:".pjg",isOneSegment:!0,decoderFormat:"jpg"});let w=class extends n{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this.datasetFormat="MRF"}async open(t){await this.init(),this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const e=t?t.signal:null,r=await this.request(this.url,{responseType:"xml",signal:e}),{rasterInfo:s,files:o}=this._parseHeader(r.data),{skipMapInfo:i,skipExtensions:a=[]}=this.ioConfig;if(!a.includes("aux.xml")&&!i){const e=await this._fetchAuxiliaryData(t);null!=e&&(s.statistics=e.statistics??s.statistics,s.histograms=e.histograms,e.histograms&&null==s.statistics&&(s.statistics=h(e.histograms)))}i&&this.updateImageSpaceRasterInfo(s),this._set("rasterInfo",s),this._files=o;const n=await this.request(o.index,{responseType:"array-buffer",signal:e});this._storageIndex=I(n.data);const{blockWidth:l,blockHeight:f}=this.rasterInfo.storageInfo,c=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:m,height:p}=this.rasterInfo,u=[],g=this._getBandSegmentCount();let d=0,y=-1;for(;d<this._storageIndex.length;){y++;const t=Math.ceil(m/l/c**y)-1,e=Math.ceil(p/f/c**y)-1;d+=(t+1)*(e+1)*g*4,u.push({maxRow:e,maxCol:t,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=u,y>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=y),this.updateTileInfo()}async fetchRawTile(t,e,r,s={}){const{blockWidth:i,blockHeight:a,blockBoundary:n}=this.rasterInfo.storageInfo,l=n[t];if(!l||l.maxRow<e||l.maxCol<r||l.minRow>e||l.minCol>r)return null;const{bandCount:f,pixelType:c}=this.rasterInfo,{ranges:m,actualTileWidth:p,actualTileHeight:h}=this._getTileLocation(t,e,r);if(!m||0===m.length)return null;if(0===m[0].from&&0===m[0].to){const t=new Uint8Array(i*a);return new o({width:i,height:a,pixels:void 0,mask:t,validPixelCount:0})}const{bandIds:u}=this.ioConfig,g=this._getBandSegmentCount(),d=[];let y=0;for(y=0;y<g;y++)u&&!u.includes(y)||d.push(this.request(this._files.data,{range:{from:m[y].from,to:m[y].to},responseType:"array-buffer",signal:s.signal}));const w=await Promise.all(d),I=w.map((t=>t.data.byteLength)).reduce(((t,e)=>t+e)),b=new Uint8Array(I),R=[];let A=0;for(y=0;y<g;y++)R.push(A),b.set(new Uint8Array(w[y].data),A),A+=w[y].data.byteLength;const F=x.get(this.rasterInfo.storageInfo.compression).decoderFormat,S=await this.decodePixelBlock(b.buffer,{width:i,height:a,format:F,planes:u?.length||f,offsets:R,pixelType:c});if(null==S)return null;let{noDataValue:_}=this.rasterInfo;if(null!=_&&"lerc"!==F&&!S.mask&&(_=_[0],null!=_)){const t=S.width*S.height,e=new Uint8Array(t);if(Math.abs(_)>1e24)for(y=0;y<t;y++)Math.abs((S.pixels[0][y]-_)/_)>1e-6&&(e[y]=1);else for(y=0;y<t;y++)S.pixels[0][y]!==_&&(e[y]=1);S.mask=e}let k=0,M=0;if(p!==i||h!==a){let t=S.mask;if(t)for(y=0;y<a;y++)if(M=y*i,y<h)for(k=p;k<i;k++)t[M+k]=0;else for(k=0;k<i;k++)t[M+k]=0;else for(t=new Uint8Array(i*a),S.mask=t,y=0;y<h;y++)for(M=y*i,k=0;k<p;k++)t[M+k]=1}return S}_getBandSegmentCount(){return x.get(this.rasterInfo.storageInfo.compression).isOneSegment?1:this.rasterInfo.bandCount}_getTileLocation(t,e,r){const{blockWidth:s,blockHeight:o,pyramidScalingFactor:i}=this.rasterInfo.storageInfo,{width:a,height:n}=this.rasterInfo,l=this._getBandSegmentCount();let f,c,m,p=0,h=0;for(m=0;m<t;m++)h=i**m,f=Math.ceil(a/s/h),c=Math.ceil(n/o/h),p+=f*c;h=i**t,f=Math.ceil(a/s/h),c=Math.ceil(n/o/h),p+=e*f+r,p*=4*l;const u=this._storageIndex.subarray(p,p+4*l);let g=0,d=0;const y=[];for(let x=0;x<l;x++)g=u[4*x]*2**32+u[4*x+1],d=g+u[4*x+2]*2**32+u[4*x+3],y.push({from:g,to:d});return{ranges:y,actualTileWidth:r<f-1?s:Math.ceil(a/h)-s*(f-1),actualTileHeight:e<c-1?o:Math.ceil(n/h)-o*(c-1)}}_parseHeader(t){const r=c(t,"MRF_META/Raster");if(!r)throw new e("mrf:open","not a valid MRF format");const s=c(r,"Size"),o=parseInt(s.getAttribute("x"),10),n=parseInt(s.getAttribute("y"),10),f=parseInt(s.getAttribute("c"),10),p=(m(r,"Compression")||"none").toLowerCase();if(!x.has(p))throw new e("mrf:open","currently does not support compression "+p);const h=m(r,"DataType")||"UInt8",w=y.get(h);if(null==w)throw new e("mrf:open","currently does not support pixel type "+h);const I=c(r,"PageSize"),b=parseInt(I.getAttribute("x"),10),R=parseInt(I.getAttribute("y"),10),A=c(r,"DataValues");let F,S;A&&(S=A.getAttribute("NoData"),null!=S&&(F=S.trim().split(" ").map((t=>parseFloat(t)))));if(c(t,"MRF_META/CachedSource"))throw new e("mrf:open","currently does not support MRF referencing other data files");const _=c(t,"MRF_META/GeoTags"),k=c(_,"BoundingBox");let M,j=!1;if(null!=k){const t=parseFloat(k.getAttribute("minx")),e=parseFloat(k.getAttribute("miny")),r=parseFloat(k.getAttribute("maxx")),s=parseFloat(k.getAttribute("maxy")),o=m(_,"Projection")||"";let i=u.WGS84;if("LOCAL_CS[]"!==o)if(o.toLowerCase().startsWith("epsg:")){const t=Number(o.slice(5));isNaN(t)||0===t||(i=new u({wkid:t}))}else i=l(o)??u.WGS84;else j=!0,i=new u({wkid:3857});M=new g(t,e,r,s),M.spatialReference=i}else j=!0,M=new g({xmin:-.5,ymin:.5-n,xmax:o-.5,ymax:.5,spatialReference:new u({wkid:3857})});const C=c(t,"MRF_META/Rsets"),T=parseInt(C?.getAttribute("scale")||"2",10),L=M.spatialReference,U=new a({origin:new d({x:M.xmin,y:M.ymax,spatialReference:L}),blockWidth:b,blockHeight:R,pyramidBlockWidth:b,pyramidBlockHeight:R,compression:p,pyramidScalingFactor:T}),B=new d({x:M.width/o,y:M.height/n,spatialReference:L}),E=new i({width:o,height:n,extent:M,isPseudoSpatialReference:j,spatialReference:L,bandCount:f,pixelType:w,pixelSize:B,noDataValue:F,storageInfo:U}),P=m(t,"datafile"),W=m(t,"IndexFile");return{rasterInfo:E,files:{mrf:this.url,index:W||this.url.replace(".mrf",".idx"),data:P||this.url.replace(".mrf",x.get(p).blobExtension)}}}async _fetchAuxiliaryData(t){try{const{data:e}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:t?.signal});return f(e)}catch{return null}}};function I(t){if(t.byteLength%16>0)throw new Error("invalid array buffer must be multiples of 16");let e,r,s,o,i,a;if(p){for(r=new Uint8Array(t),o=new ArrayBuffer(t.byteLength),s=new Uint8Array(o),i=0;i<t.byteLength/4;i++)for(a=0;a<4;a++)s[4*i+a]=r[4*i+3-a];e=new Uint32Array(o)}else e=new Uint32Array(t);return e}t([r()],w.prototype,"_files",void 0),t([r()],w.prototype,"_storageIndex",void 0),t([r({type:String,json:{write:!0}})],w.prototype,"datasetFormat",void 0),w=t([s("esri.layers.support.rasterDatasets.MRFRaster")],w);const b=w;export{b as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{isSome as t}from"../../../core/arrayUtils.js";import r from"../../../core/Error.js";import i from"../../../core/Logger.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import n from"../RasterInfo.js";import o from"../RasterStorageInfo.js";import f from"./BaseRaster.js";import l from"./DBFParser.js";import{
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{isSome as t}from"../../../core/arrayUtils.js";import r from"../../../core/Error.js";import i from"../../../core/Logger.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import{subclass as a}from"../../../core/accessorSupport/decorators/subclass.js";import n from"../RasterInfo.js";import o from"../RasterStorageInfo.js";import f from"./BaseRaster.js";import l from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as p}from"./pamParser.js";import{parseSignature as c,getPyramidIFDs as h,getMaskIFDs as m,parseIFD as d,parseFieldValues as y,isBSQConfig as g,getImageInfo as T}from"../rasterFormats/TiffDecoder.js";import x from"../rasterFormats/TiffTags.js";import{estimateStatisticsFromHistograms as w}from"../rasterFunctions/stretchUtils.js";import I from"../rasterTransforms/PolynomialTransform.js";import R from"../../../rest/support/FeatureSet.js";import b from"../../../geometry/SpatialReference.js";import E from"../../../geometry/Extent.js";import S from"../../../geometry/Point.js";const _=(e,t)=>e.get(t)?.values,F=(e,t)=>e.get(t)?.values?.[0];let v=class extends f{constructor(){super(...arguments),this._files=null,this._headerInfo=null,this._bufferSize=1048576,this.datasetFormat="TIFF"}async open(e){await this.init();const t=e?e.signal:null,{data:s}=await this.request(this.url,{range:{from:0,to:this._bufferSize},responseType:"array-buffer",signal:t});if(!s)throw new r("tiffraster:open","failed to open url "+this.url);this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1,this.url.lastIndexOf("."));const{littleEndian:a,firstIFDPos:n,isBigTiff:o}=c(s),f=[];await this._readIFDs(f,s,a,n,0,o?8:4,t);const{imageInfo:l,rasterInfo:u}=k(f),p=h(f),d=m(f);if(this._headerInfo={littleEndian:a,isBigTiff:o,ifds:f,pyramidIFDs:p,maskIFDs:d,...l},this._set("rasterInfo",u),!l.isSupported)throw new r("tiffraster:open","this tiff is not supported: "+l.message);if(!l.tileWidth)throw new r("tiffraster:open","none-tiled tiff is not optimized for access, convert to COG and retry.");u.isPseudoSpatialReference&&i.getLogger(this).warn("The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.");const y=f[0].get("PREDICTOR")?.values?.[0],g=f[0].get("SAMPLEFORMAT")?.values?.[0];if(3===g&&2===y)throw new r("tiffraster:open","unsupported horizontal difference encoding. Predictor=3 is supported for floating point data");const{skipMapInfo:T,skipExtensions:x=[]}=this.ioConfig;if(!x.includes("aux.xml")&&!T){const t=await this._fetchAuxiliaryMetaData(e);null!=t&&P(t,u)}x.includes("vat.dbf")||1!==u.bandCount||"u8"!==u.pixelType||T||(u.attributeTable=await this._fetchAuxiliaryTable(e),null!=u.attributeTable&&(u.keyProperties.DataType="thematic")),T&&this.updateImageSpaceRasterInfo(u),this.updateTileInfo()}async fetchRawTile(e,t,r,i={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,r))return null;const s=await this._fetchRawTiffTile(e,t,r,!1,i);if(null!=s&&this._headerInfo.hasMaskBand){const a=await this._fetchRawTiffTile(e,t,r,!0,i);null!=a&&a.pixels[0]instanceof Uint8Array&&(s.mask=a.pixels[0])}return s}async _readIFDs(e,t,r,i,s,a=4,n){if(!i)return null;if(i>=t.byteLength||i<0){t=(await this.request(this.url,{range:{from:i+s,to:i+s+this._bufferSize},responseType:"array-buffer",signal:n})).data,s=i+s,i=0}const o=await this._readIFD(t,r,i,s,x.tiffTags,a,n);if(e.push(o.ifd),!o.nextIFD)return null;await this._readIFDs(e,t,r,o.nextIFD-s,s,a,n)}async _readIFD(e,r,i,s,a=x.tiffTags,n=4,o){if(!e)return null;const f=d(e,r,i,s,a,n);if(f.success){const i=[];if(f.ifd?.forEach((e=>{e.values||i.push(e)})),i.length>0){const a=i.map((e=>e.offlineOffsetSize)).filter(t),n=Math.min.apply(null,a.map((e=>e[0])));if(Math.min.apply(null,a.map((e=>e[0]+e[1])))-n<=this._bufferSize){const{data:t}=await this.request(this.url,{range:{from:n,to:n+this._bufferSize},responseType:"array-buffer",signal:o});e=t,s=n,i.forEach((t=>y(e,r,t,s)))}}if(f.ifd?.has("GEOKEYDIRECTORY")){const t=f.ifd.get("GEOKEYDIRECTORY"),i=t?.values;if(i&&i.length>4){const a=i[0]+"."+i[1]+"."+i[2],n=await this._readIFD(e,r,t.valueOffset+6-s,s,x.geoKeys,2,o);t.data=n.ifd,t.data&&t.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[a]})}}return f}if(f.requiredBufferSize&&f.requiredBufferSize!==e.byteLength){const t=await this.request(this.url,{range:{from:s,to:s+f.requiredBufferSize+4},responseType:"array-buffer",signal:o});return(e=t.data).byteLength<f.requiredBufferSize?null:this._readIFD(e,r,0,s,x.tiffTags,4,o)}}async _fetchRawTiffTile(e,t,r,i,s={}){const a=this._getTileLocation(e,t,r,i);if(!a)return null;const{ranges:n,actualTileWidth:o,actualTileHeight:f,ifd:l}=a,u=n.map((e=>this.request(this.url,{range:e,responseType:"array-buffer",signal:s.signal}))),p=await Promise.all(u),c=p.map((e=>e.data.byteLength)).reduce(((e,t)=>e+t)),h=1===p.length?p[0].data:new ArrayBuffer(c),m=[0],d=[0];if(p.length>1){const e=new Uint8Array(h);for(let t=0,r=0;t<p.length;t++){const i=p[t].data;e.set(new Uint8Array(i),r),m[t]=r,r+=i.byteLength,d[t]=i.byteLength}}const{blockWidth:y,blockHeight:g}=this.getBlockWidthHeight(e),T=await this.decodePixelBlock(h,{format:"tiff",customOptions:{headerInfo:this._headerInfo,ifd:l,offsets:m,sizes:d},width:y,height:g,planes:null,pixelType:null});if(null==T)return null;let x,w,I;if(o!==y||f!==g){let e=T.mask;if(e)for(x=0;x<g;x++)if(I=x*y,x<f)for(w=o;w<y;w++)e[I+w]=0;else for(w=0;w<y;w++)e[I+w]=0;else for(e=new Uint8Array(y*g),T.mask=e,x=0;x<f;x++)for(I=x*y,w=0;w<o;w++)e[I+w]=1}return T}_getTileLocation(e,t,r,i=!1){const{firstPyramidLevel:s,blockBoundary:a}=this.rasterInfo.storageInfo,n=0===e?0:e-(s-1),{_headerInfo:o}=this;if(!o)return null;const f=i?o.maskIFDs[n]:0===n?o?.ifds[0]:o?.pyramidIFDs[n-1];if(!f)return null;const l=g(f,o),u=_(f,"TILEOFFSETS");if(void 0===u)return null;const p=_(f,"TILEBYTECOUNTS"),{minRow:c,minCol:h,maxRow:m,maxCol:d}=a[n];if(t>m||r>d||t<c||r<h)return null;const y=F(f,"IMAGEWIDTH"),T=F(f,"IMAGELENGTH"),x=F(f,"TILEWIDTH"),w=F(f,"TILELENGTH"),I=[];if(l){const{bandCount:e}=this.rasterInfo;for(let i=0;i<e;i++){const e=i*(m+1)*(d+1)+t*(d+1)+r;I[i]={from:u[e],to:u[e]+p[e]-1}}}else{const e=t*(d+1)+r;I.push({from:u[e],to:u[e]+p[e]-1})}for(let g=0;g<I.length;g++)if(null==I[g].from||!I[g].to||I[g].to<0)return null;return{ranges:I,ifd:f,actualTileWidth:r===d&&y%x||x,actualTileHeight:t===m&&T%w||w}}async _fetchAuxiliaryMetaData(e){try{const{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{const{data:t}=await this.request(this.url+".vat.dbf",{responseType:"array-buffer",signal:e?.signal}),r=l.parse(t);return r?.recordSet?R.fromJSON(r.recordSet):null}catch{return null}}};function k(e){const t=T(e),{width:r,height:i,tileWidth:s,tileHeight:a,planes:f,pixelType:l,compression:u,firstPyramidLevel:c,maximumPyramidLevel:h,pyramidBlockWidth:m,pyramidBlockHeight:d,tileBoundary:y,affine:g,metadata:x}=t,w=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid;let R=p(w),v=!!t.isPseudoGeographic;null==R&&(v=!0,R=new b({wkid:3857}));const k=new E({...t.extent,spatialReference:R}),P=new S(k?{x:k.xmin,y:k.ymax,spatialReference:R}:{x:0,y:0}),D=new o({blockWidth:s,blockHeight:a,pyramidBlockWidth:m,pyramidBlockHeight:d,compression:u,origin:P,firstPyramidLevel:c,maximumPyramidLevel:h,blockBoundary:y}),O=new S({x:(k.xmax-k.xmin)/r,y:(k.ymax-k.ymin)/i,spatialReference:R}),L=x?{BandProperties:x.bandProperties,DataType:x.dataType}:{};let j=null;const B=F(e[0],"PHOTOMETRICINTERPRETATION"),z=_(e[0],"COLORMAP");if(B<=3&&z?.length>3&&z.length%3==0){j=[];const e=z.length/3;for(let t=0;t<e;t++)j.push([t,z[t]>>>8,z[t+e]>>>8,z[t+2*e]>>>8])}const A=new n({width:r,height:i,bandCount:f,pixelType:l,pixelSize:O,storageInfo:D,spatialReference:R,isPseudoSpatialReference:v,keyProperties:L,extent:k,colormap:j,statistics:x?x.statistics:null});return g?.length&&(A.nativeExtent=new E({xmin:-.5,ymin:.5-i,xmax:r-.5,ymax:.5,spatialReference:R}),A.transform=new I({polynomialOrder:1,forwardCoefficients:[g[2]+g[0]/2,g[5]-g[3]/2,g[0],g[3],-g[1],-g[4]]}),A.extent=A.transform.forwardTransform(A.nativeExtent),A.pixelSize=new S({x:(k.xmax-k.xmin)/r,y:(k.ymax-k.ymin)/i,spatialReference:R}),D.origin.x=-.5,D.origin.y=.5),{imageInfo:t,rasterInfo:A}}function P(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&null==t.statistics&&(t.statistics=w(e.histograms)),e.transform&&null==t.transform){t.transform=e.transform,t.nativeExtent=t.extent;const r=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new S({x:(r.xmax-r.xmin)/t.width,y:(r.ymax-r.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=r}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}e([s()],v.prototype,"_files",void 0),e([s()],v.prototype,"_headerInfo",void 0),e([s()],v.prototype,"_bufferSize",void 0),e([s({type:String,json:{write:!0}})],v.prototype,"datasetFormat",void 0),v=e([a("esri.layers.support.rasterDatasets.TIFFRaster")],v);const D=v;export{D as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as r}from"../../ogc/crsUtils.js";import a from"../DimensionalDefinition.js";import l from"./BaseRaster.js";import{parse as c}from"./multipartParser.js";import{parseCapabilities as d}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as p,parseCoverages as h}from"./wcsCoverageParser.js";import{getFormat as u}from"../rasterFormats/RasterCodec.js";import{clip as f}from"../rasterFunctions/pixelUtils.js";import g from"../../../geometry/Extent.js";const m=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",I="server returns an exception";let C=class extends l{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const i=e?.signal,n=await this._getCapabilities(i);if(this.capabilities=n,!this.version){let e=n.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=n.capabilitiesVersion:(e=n.supportedVersions.find((e=>"2.0.1"===e))||n.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}const s=n.coverages.filter((({coverageSubType:e})=>null==e||""===e||/^rectified(grid|dataset)/i.test(e)));if(!s.length)throw new t("wcsraster-open","cannot find rectified grid coverages");null==this.coverageId&&(this.coverageId=s[0].id);const o=s.find((e=>e.id===this.coverageId));if(null==o)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const r=await this._describeCoverage(i);this.coverageInfo=r[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=o.lonLatEnvelope,this.coverageInfo.supportedInterpolations=p(n.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:o,spatialReference:r}=this.rasterInfo,a=2**e,l=o.x*a,c=o.y*a,{blockWidth:d,blockHeight:p}=this.getBlockWidthHeight(e),{origin:h}=this.rasterInfo.storageInfo.tileInfo,u=this.getTileExtent({x:l,y:c},i,n,h,r,[d,p]),g=this.rasterInfo.extent,m=u.xmax>g.xmax,w=u.ymin<g.ymin,v=m||w;let y=u,x=d,I=p;if(v&&(y=u.clone().intersection(g),null!=y&&(m&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(I=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*I))),null==y||x<=1||I<=1)return null;const C=await this._getCoverage(y,x,I,a,s);if(!C)return null;const{coverageDescription:b}=this.coverageInfo;let{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo;const{multidimensionalDefinition:T}=s;if(null!=S&&null!=T&&T.length){const e=T[0].variableName;if("2.0"===b.version){const t=b.rangeType[0].find((t=>t.name===e));$=t?.nilValue}else if("1.1"===b.version){const t=b.range.find((t=>t.identifier===e));$=t?.nullValues}}const j=await this.decodePixelBlock(C,{width:x,height:I,planes:null,pixelType:null,noDataValue:Array.isArray($)?$[0]:$});if(null==j)return null;if(j&&(j.width!==x||j.height!==I))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${j.width}, height: {pixelBlock.height}`);return v?f(j,{x:0,y:0},{width:p,height:p}):j}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return d(t)}catch(s){if(!n(s))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version?.slice(0,3);"1.0"===s?i.coverage=this.coverageId:"1.1"===s?i.identifiers=this.coverageId:"2.0"===s&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return h(t,this.version)}catch(o){if(!n(o))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw o}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:o}=this.rasterInfo,r=s.center,l=new g({xmin:r.x-n.x,xmax:r.x+n.x,ymin:r.y-n.y,ymax:r.y+n.y,spatialReference:s.spatialReference});let c=[];if(null!=o){const e=o.variables[0];c=[],e.dimensions.forEach((t=>{c.push(new a({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent[0]:t.values?.[0],isSlice:!0}))}))}const{coverageDescription:d}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:h}=d,{ioConfig:u}=this,f="2.0"===h&&null==u.allowAnyMediaType||"1.1"===h&&null==u.use2GridOffsets;let m;try{m=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!f)throw y;if("1.1"===h){if(!y.details?.isResolutionMismatch)throw y;u.use2GridOffsets=!0}}if(!m&&f&&("2.0"===h&&(u.allowAnyMediaType=!0),m=await this._getCoverage(l,2,2,1,p),m&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!m)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(m,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,o,r,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:d}=l,p="2.0"===d?this._getCoverage201Parameters(e,n,s,o,r,l):"1.1"===d?this._getCoverage110Parameters(e,n,s,r,l):this._getCoverage100Parameters(e,n,s,r),h="2.0"===d?await this.request(this._constructWCS201Url(p),{signal:r.signal,responseType:"array-buffer"}):await this.request(this.url,{query:p,signal:r.signal,responseType:"array-buffer"});if("1.0"===d)return h.data;if("2.0"===d&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===u(h.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),h.data}const f=c(h);if(f.isMultipart&&f.data){const e=f.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData));return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const g=new Uint8Array(h.data,0,Math.min(h.data.byteLength,2e3)),m=String.fromCharCode.apply(null,g).toLowerCase().includes("exception"),w=m&&String.fromCharCode.apply(null,g).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(m)throw new t("wcsraster:getcoverage",I,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=m[c],{multidimensionalDefinition:h}=n;let u;if(null!=h&&null!=this.rasterInfo.multidimensionalInfo){const e=h.find((e=>"StdTime"===e.dimensionName));let t=e?.values;t&&t.length>0&&(t[0]instanceof Array&&(t=t[0]),u=t.map((e=>this._convertToISOTime(e))).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:s,width:t,height:i,time:u,interpolation:p,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:o,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",h=this._getInterpolationIndex(l),u=w[h],f=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),g=s.domain.spatialDomain,m=g.origin.x<=g.envelope.xmin&&g.origin.y<=g.envelope.ymin,v=e.width/t,y=e.height/i*(m?1:-1),x=m?[e.xmin,e.ymin]:[e.xmin,e.ymax],I=g.useEPSGAxis&&r(c),C=I?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,b=this.ioConfig.use2GridOffsets,$=I?b?`${y},${v}`:`${y},0,0,${v}`:b?`${v},${y}`:`${v},0,0,${y}`,S=v/2,T=e.xmin+S,j=e.xmax-S,_=Math.abs(y)/2,L=e.ymin+_,R=e.ymax-_,D=I?`${L},${T},${R},${j},${d}`:`${T},${L},${j},${R},${d}`,E=s.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let P,A=E&&u&&a?f?`${E.identifier}[${E.axis[0].identifier}[${a.join(",")}]]`:`${E.identifier}:${u}[${E.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=o&&o.length)for(let r=0;r<o.length;r++){let e=o[r].values;const t=o[r].dimensionName?.toLowerCase(),i=o[r].variableName?.toLowerCase();if(e.length>0)if(e[0]instanceof Array&&(e=e[0]),"stdtime"===t)P=e.map((e=>this._convertToISOTime(e))).join(",");else{const n=s.range.find((e=>e.identifier.toLowerCase()===i));if(n){const i=n.axis.find((e=>e.identifier.toLowerCase()===t));i&&(A=f?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+u+"["+i.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:p,crs:`EPSG:${c}`,boundingbox:D,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:C,gridOffsets:$,gridBaseCRS:d,timeSequence:P,rangeSubset:A}}_convertToISOTime(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}_getCoverage201Parameters(e,t,i,n,s,o){const{multidimensionalDefinition:r,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find((e=>e.toLowerCase().includes("nearest")));break;case 1:c=d.find((e=>e.toLowerCase().includes("linear")));break;case 2:c=d.find((e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic")))}const p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:h}=this.coverageInfo,{boundedBy:u,domainSet:f,rangeType:g}=o,m=u.isEastFirst?0:1,w=1-m,{axisLabels:v}=u,y=v[m],x=v[w],I=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=I,b=[];b.push(`${y}(${e.xmin},${e.xmax})`),b.push(`${x}(${e.ymin},${e.ymax})`);const $=[];if(v.length>2)for(let R=2;R<v.length;R++){const e=f.origin[R];if(v[R].toLowerCase().includes("time")){let t=e.toString();u.uomLabels?.[R].toLowerCase().includes("ole")&&($.push(v[R]),t=this._convertToISOTime(e,!0)),b.push(v[R]+",http://www.opengis.net("+t+")")}else b.push(v[R]+",http://www.opengis.net("+e+")")}let S=null;if(null!=r&&r.length){const e=[];g.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<r.length;i++){const n=v.find((e=>e===r[i].dimensionName)),s=e.find((e=>e===r[i].variableName));if(t.includes(s)||t.push(s),n){let e=r[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map((e=>this._convertToISOTime(e))).join(","):e.join(",");const i=b.findIndex((e=>0===e.indexOf(n+",http://www.opengis.net")));-1===i&&b.push(n+",http://www.opengis.net("+t+")"),-1===i||b[i].includes("("+t+")")||b.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(S=t.join(","))}else if(h?.length>=2){S=(s.bandIds?s.bandIds.map((e=>h[e])):h).join(",")}const T=b.join("&subset="),j=!o.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,_=j?null:`${y}(${t}),${x}(${i})`,L=j?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:S,interpolation:c,scaleSize:_,scaleFactor:L,subset:T,format:p,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:I,subsettingcrs:C}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(n)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};e([s({type:String,json:{write:!0}})],C.prototype,"datasetFormat",void 0),e([s()],C.prototype,"tileType",void 0),e([s({type:String,json:{write:!0}})],C.prototype,"version",void 0),e([s({type:String,json:{write:!0}})],C.prototype,"coverageId",void 0),C=e([o("esri.layers.support.rasterDatasets.WCSRaster")],C);const b=C;export{b as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as o}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as r}from"../../ogc/crsUtils.js";import a from"../DimensionalDefinition.js";import l from"./BaseRaster.js";import{parse as c}from"./multipartParser.js";import{parseCapabilities as d}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as p,parseCoverages as u}from"./wcsCoverageParser.js";import{getFormat as f}from"../rasterFormats/RasterCodec.js";import{clip as h}from"../rasterFunctions/pixelUtils.js";import g from"../../../geometry/Extent.js";const m=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",C="server returns an exception";let b=class extends l{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const i=e?.signal,n=await this._getCapabilities(i);if(this.capabilities=n,!this.version){let e=n.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=n.capabilitiesVersion:(e=n.supportedVersions.find((e=>"2.0.1"===e))||n.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}const s=n.coverages.filter((({coverageSubType:e})=>null==e||""===e||/^rectified(grid|dataset)/i.test(e)));if(!s.length)throw new t("wcsraster-open","cannot find rectified grid coverages");null==this.coverageId&&(this.coverageId=s[0].id);const o=s.find((e=>e.id===this.coverageId));if(null==o)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const r=await this._describeCoverage(i);this.coverageInfo=r[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=o.lonLatEnvelope,this.coverageInfo.supportedInterpolations=p(n.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:o,spatialReference:r}=this.rasterInfo,a=2**e,l=o.x*a,c=o.y*a,{blockWidth:d,blockHeight:p}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,f=this.getTileExtent({x:l,y:c},i,n,u,r,[d,p]),g=this.rasterInfo.extent,m=f.xmax>g.xmax,w=f.ymin<g.ymin,v=m||w;let y=f,x=d,C=p;if(v&&(y=f.clone().intersection(g),null!=y&&(m&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(C=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*C))),null==y||x<=1||C<=1)return null;const b=await this._getCoverage(y,x,C,a,s);if(!b)return null;const{coverageDescription:I}=this.coverageInfo;let{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo;const{multidimensionalDefinition:j}=s;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===I.version){const t=I.rangeType[0].find((t=>t.name===e));$=t?.nilValue}else if("1.1"===I.version){const t=I.range.find((t=>t.identifier===e));$=t?.nullValues}}const T=await this.decodePixelBlock(b,{width:x,height:C,planes:null,pixelType:null,noDataValue:Array.isArray($)?$[0]:$});if(null==T)return null;if(T&&(T.width!==x||T.height!==C))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${T.width}, height: {pixelBlock.height}`);return v?h(T,{x:0,y:0},{width:p,height:p}):T}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return d(t)}catch(s){if(!n(s))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version?.slice(0,3);"1.0"===s?i.coverage=this.coverageId:"1.1"===s?i.identifiers=this.coverageId:"2.0"===s&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return u(t,this.version)}catch(o){if(!n(o))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw o}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:o}=this.rasterInfo,r=s.center,l=new g({xmin:r.x-n.x,xmax:r.x+n.x,ymin:r.y-n.y,ymax:r.y+n.y,spatialReference:s.spatialReference});let c=[];if(null!=o){const e=o.variables[0];c=[],e.dimensions.forEach((t=>{c.push(new a({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent[0]:t.values?.[0],isSlice:!0}))}))}const{coverageDescription:d}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:u}=d,{ioConfig:f}=this,h="2.0"===u&&null==f.allowAnyMediaType||"1.1"===u&&null==f.use2GridOffsets;let m;try{m=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!h)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;f.use2GridOffsets=!0}}if(!m&&h&&("2.0"===u&&(f.allowAnyMediaType=!0),m=await this._getCoverage(l,2,2,1,p),m&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!m)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(m,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,o,r,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:d}=l,p="2.0"===d?this._getCoverage201Parameters(e,n,s,o,r,l):"1.1"===d?this._getCoverage110Parameters(e,n,s,r,l):this._getCoverage100Parameters(e,n,s,r),u="2.0"===d?await this.request(this._constructWCS201Url(p),{signal:r.signal,responseType:"array-buffer"}):await this.request(this.url,{query:p,signal:r.signal,responseType:"array-buffer"});if("1.0"===d)return u.data;if("2.0"===d&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===f(u.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),u.data}const h=c(u);if(h.isMultipart&&h.data){const e=h.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData));return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const g=new Uint8Array(u.data,0,Math.min(u.data.byteLength,2e3)),m=String.fromCharCode.apply(null,g).toLowerCase().includes("exception"),w=m&&String.fromCharCode.apply(null,g).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(m)throw new t("wcsraster:getcoverage",C,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=m[c],{multidimensionalDefinition:u}=n;let f;if(null!=u&&null!=this.rasterInfo.multidimensionalInfo){const e=u.find((e=>"StdTime"===e.dimensionName));let t=e?.values;t&&t.length>0&&(t[0]instanceof Array&&(t=t[0]),f=t.map((e=>I(e))).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:s,width:t,height:i,time:f,interpolation:p,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:o,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",u=this._getInterpolationIndex(l),f=w[u],h=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),g=s.domain.spatialDomain,m=g.origin.x<=g.envelope.xmin&&g.origin.y<=g.envelope.ymin,v=e.width/t,y=e.height/i*(m?1:-1),x=m?[e.xmin,e.ymin]:[e.xmin,e.ymax],C=g.useEPSGAxis&&r(c),b=C?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,$=this.ioConfig.use2GridOffsets,S=C?$?`${y},${v}`:`${y},0,0,${v}`:$?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,_=Math.abs(y)/2,R=e.ymin+_,D=e.ymax-_,E=C?`${R},${T},${D},${L},${d}`:`${T},${R},${L},${D},${d}`,P=s.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let A,G=P&&f&&a?h?`${P.identifier}[${P.axis[0].identifier}[${a.join(",")}]]`:`${P.identifier}:${f}[${P.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=o&&o.length)for(let r=0;r<o.length;r++){let e=o[r].values;const t=o[r].dimensionName?.toLowerCase(),i=o[r].variableName?.toLowerCase();if(e.length>0)if(e[0]instanceof Array&&(e=e[0]),"stdtime"===t)A=e.map((e=>I(e))).join(",");else{const n=s.range.find((e=>e.identifier.toLowerCase()===i));if(n){const i=n.axis.find((e=>e.identifier.toLowerCase()===t));i&&(G=h?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+f+"["+i.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:p,crs:`EPSG:${c}`,boundingbox:E,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:b,gridOffsets:S,gridBaseCRS:d,timeSequence:A,rangeSubset:G}}_getCoverage201Parameters(e,t,i,n,s,o){const{multidimensionalDefinition:r,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find((e=>e.toLowerCase().includes("nearest")));break;case 1:c=d.find((e=>e.toLowerCase().includes("linear")));break;case 2:c=d.find((e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic")))}const p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:f,domainSet:h,rangeType:g}=o,m=f.isEastFirst?0:1,w=1-m,{axisLabels:v}=f,y=v[m],x=v[w],C=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,b=C,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let D=2;D<v.length;D++){const e=h.origin[D];if(v[D].toLowerCase().includes("time")){let t=e.toString();f.uomLabels?.[D].toLowerCase().includes("ole")&&(S.push(v[D]),t=I(e,!0)),$.push(v[D]+",http://www.opengis.net("+t+")")}else $.push(v[D]+",http://www.opengis.net("+e+")")}let j=null;if(null!=r&&r.length){const e=[];g.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<r.length;i++){const n=v.find((e=>e===r[i].dimensionName)),s=e.find((e=>e===r[i].variableName));if(t.includes(s)||t.push(s),n){let e=r[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map((e=>I(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(n+",http://www.opengis.net")));-1===i&&$.push(n+",http://www.opengis.net("+t+")"),-1===i||$[i].includes("("+t+")")||$.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length>=2){j=(s.bandIds?s.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),L=!o.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,_=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:_,scaleFactor:R,subset:T,format:p,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:C,subsettingcrs:b}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(n)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};function I(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}e([s({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([s()],b.prototype,"tileType",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),b=e([o("esri.layers.support.rasterDatasets.WCSRaster")],b);const $=b;export{$ as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.30/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import{property as
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/Logger.js";import"../../../core/RandomLCG.js";import{subclass as e}from"../../../core/accessorSupport/decorators/subclass.js";import{getBandMatrix3 as s}from"./bandIndexUtils.js";import r from"./BaseRasterFunction.js";import o from"./ExtractBandFunctionArguments.js";import{MissingBandAction as a}from"./pixelUtils.js";let i=class extends r{constructor(){super(...arguments),this.functionName="ExtractBand",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{functionArguments:t,sourceRasterInfos:n}=this,e=n[0],{method:s,bandNames:r,bandWavelengths:o,bandIds:i,missingBandAction:l}=t,h=r?.length&&("name"===s||"id"!==s&&!i?.length),m=o?.length&&("wavelength"===s||"id"!==s&&!i?.length),p=l===a.fail,g=h?u(e,r):m?d(e,o,this.functionArguments,p):c(e,i,p);if(null==g){return{success:!1,supportsGPU:!1,error:`extract-band-function: Invalid ${h?"band names":m?"band wavelengths":"band ids"} for the imagery data source`}}this.functionArguments.bandIds=g,this.functionArguments.method="id",this.outputPixelType=this._getOutputPixelType("f32");const f=e.clone();f.pixelType=this.outputPixelType,f.bandCount=g.length;const{statistics:b,histograms:x}=f;null!=b&&b.length&&(f.statistics=g.map((t=>b[t]||b[b.length-1]))),null!=x&&x.length&&(f.histograms=g.map((t=>x[t]||x[x.length-1])));let I=f.keyProperties?.BandProperties;I?.length&&(I=g.map((t=>t>=I.length?I[I.length-1]:I[t])),f.keyProperties={...f.keyProperties,BandProperties:I}),this.rasterInfo=f;return{success:!0,supportsGPU:f.bandCount<=3}}_processPixels(t){const n=t.pixelBlocks?.[0];if(null==n)return null;const e=n.pixels.length,s=this.functionArguments.bandIds.map((t=>t>=e?e-1:t));return n.extractBands(s)}_getWebGLParameters(){let t;if(this.isInputBandIdsSwizzled)t=this.swizzledBandSelection.length?this.swizzledBandSelection:[0,1,2];else{t=[...this.functionArguments.bandIds],0===t.length?t=[0,1,2]:t.length<3&&(t[1]=t[1]??t[0],t[2]=t[2]??t[1]);for(let n=0;n<3;n++)t[n]=Math.min(t[n],2)}return{bandIndexMat3:s(t)}}_getInputBandIds(t){const n=t.length;return this.functionArguments.bandIds.map((t=>t>=n?n-1:t)).map((n=>t[n]))}};t([n({json:{write:!0,name:"rasterFunction"}})],i.prototype,"functionName",void 0),t([n({type:o,json:{write:!0,name:"rasterFunctionArguments"}})],i.prototype,"functionArguments",void 0),t([n()],i.prototype,"rasterArgumentNames",void 0),i=t([e("esri.layers.support.rasterFunctions.ExtractBandFunction")],i);const l=i;function u(t,n){const e=t.bandInfos.map((({name:t})=>t.toLowerCase())),s=[];for(let r=0;r<n.length;r++){const t=n[r].toLowerCase();let o=e.indexOf(t);if(-1===o&&"nearinfrared"===t&&(o=e.findIndex((t=>t.startsWith("nearinfrared_1"))),-1===o&&(o=e.findIndex((t=>t.startsWith("nearinfrared"))))),-1===o)return null;s.push(o)}return s}function c(t,n,e){const{bandCount:s}=t;return!n?.length||e&&n.some((t=>t<0||t>=s))?null:n}function d(t,n,{wavelengthMatchTolerance:e},s){const{bandInfos:r}=t,o=[];for(let i=0;i<r.length;i++){const{minWavelength:t,maxWavelength:n}=r[i];if(!t||!n)return null;o.push({minWavelength:t,maxWavelength:n})}const a=[];for(let i=0;i<n.length;i++){const t=n[i];let r=!1,l=-1,u=Number.MAX_VALUE;for(let n=0;n<o.length;n++){const e=o[n],s=t>=e.minWavelength&&t<=e.maxWavelength,a=Math.abs(t-(e.minWavelength+e.maxWavelength)/2);s?a<u&&(r=!0,l=n,u=a):!r&&a<u&&(l=n,u=a)}if(!r&&e&&u<e&&(r=!0),!r&&s)return null;a.push(l)}return a}export{l as default};
|
package/package.json
CHANGED