@arcgis/core 4.26.0-next.20230113 → 4.26.0-next.20230115

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.
Files changed (47) hide show
  1. package/WebMap.js +1 -1
  2. package/WebScene.js +1 -1
  3. package/assets/esri/core/workers/RemoteClient.js +1 -1
  4. package/assets/esri/core/workers/chunks/05679a6529421d546fe0.js +1 -0
  5. package/assets/esri/core/workers/chunks/2e5b61ee21fa6287cc65.js +1 -0
  6. package/assets/esri/core/workers/chunks/2e7e8b035673d90deefd.js +1 -0
  7. package/assets/esri/core/workers/chunks/4e13f84441f0b149f32e.js +1 -0
  8. package/assets/esri/core/workers/chunks/5605de870cfc1498a393.js +1 -0
  9. package/assets/esri/core/workers/chunks/5ad3a3d15831b759e758.js +1 -0
  10. package/assets/esri/core/workers/chunks/633a86e8e8ad2ab866f4.js +1 -0
  11. package/assets/esri/core/workers/chunks/86491e6269e25b1766ed.js +1 -0
  12. package/assets/esri/core/workers/chunks/c3fda4056c5eeaef1339.js +1 -0
  13. package/assets/esri/core/workers/chunks/{399c453397a1f10408bf.js → c7b23f664a2707b96daf.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{dd2e9206133d6888f33d.js → dc6bad8c0a09393834a1.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{bc3564689bd42cba97f9.js → f34c607e73757f6024eb.js} +1 -1
  16. package/core/accessorSupport/decorators/persistable.js +1 -1
  17. package/core/accessorSupport/write.js +1 -1
  18. package/layers/mixins/ArcGISImageService.js +1 -1
  19. package/layers/mixins/ImageryTileMixin.js +1 -1
  20. package/layers/mixins/SceneService.js +1 -1
  21. package/layers/support/PixelBlock.js +1 -1
  22. package/layers/support/imageryRendererUtils.js +1 -1
  23. package/layers/support/rasterDatasets/BaseRaster.js +1 -1
  24. package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
  25. package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
  26. package/layers/support/rasterFormats/Lerc.js +1 -1
  27. package/layers/support/rasterFormats/RasterCodec.js +1 -1
  28. package/layers/support/rasterFormats/TiffDecoder.js +1 -1
  29. package/layers/support/rasterFormats/pixelRangeUtils.js +5 -0
  30. package/layers/support/rasterFunctions/ConvolutionFunction.js +1 -1
  31. package/layers/support/rasterFunctions/stretchUtils.js +1 -1
  32. package/package.json +1 -1
  33. package/renderers/support/rasterRendererHelper.js +1 -1
  34. package/support/revision.js +1 -1
  35. package/views/2d/engine/Stage.js +1 -1
  36. package/views/MapView.js +1 -1
  37. package/widgets/FeatureTable/FieldColumn.js +1 -1
  38. package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
  39. package/assets/esri/core/workers/chunks/1363e647f3b0bca07e09.js +0 -1
  40. package/assets/esri/core/workers/chunks/2541edeae4b1a53b8723.js +0 -1
  41. package/assets/esri/core/workers/chunks/3b689bb038ebc301c3b2.js +0 -1
  42. package/assets/esri/core/workers/chunks/6216cd8134703fd9d9b4.js +0 -1
  43. package/assets/esri/core/workers/chunks/64f137358100a1c818f0.js +0 -1
  44. package/assets/esri/core/workers/chunks/6fba07833345b2d8d373.js +0 -1
  45. package/assets/esri/core/workers/chunks/78fd609f334a29ef39dc.js +0 -1
  46. package/assets/esri/core/workers/chunks/798cd875d64182741364.js +0 -1
  47. package/assets/esri/core/workers/chunks/8bd26c71e78698c16778.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.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{rasterRendererTypes as r,websceneRasterRendererTypes as i,read as s}from"../../rasterRenderers.js";import n from"../../request.js";import o from"../../core/Error.js";import{strict as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{isSome as p,isNone as c,unwrap as m}from"../../core/maybe.js";import{watch as d}from"../../core/reactiveUtils.js";import{urlToObject as h}from"../../core/urlUtils.js";import{property as f,ensureRange as g}from"../../core/accessorSupport/decorators/property.js";import{Integer as y,ensureClass as R,ensureNumber as b}from"../../core/accessorSupport/ensureType.js";import{reader as v}from"../../core/accessorSupport/decorators/reader.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import{writer as I}from"../../core/accessorSupport/decorators/writer.js";import{opacity as x,url as w}from"../support/commonProperties.js";import _ from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as F}from"../support/ExportImageServiceParameters.js";import D from"../support/Field.js";import T from"../support/FieldsIndex.js";import{isSupportedRendererType as j}from"../support/imageryRendererUtils.js";import P from"../support/MosaicRule.js";import N from"../support/MultidimensionalSubset.js";import O from"../support/PixelBlock.js";import{interpolationKebab as C,noDataInterpretationKebab as M}from"../support/rasterEnums.js";import A from"../support/RasterFunction.js";import J from"../support/RasterInfo.js";import q from"../support/RasterJobHandler.js";import{hasExcludedVariableOrDimension as V,getSubsetVariablesFromMdInfo as E,getDefaultMultidimensionalDefinition as H}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as Q,getFormat as U}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as L}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as z,getDefaultBandCombination as B,createDefaultRenderer as k,normalizeRendererJSON as G}from"../../renderers/support/rasterRendererHelper.js";import W from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as K,computePixelSpaceLocations as X,computeHistograms as $,computeStatisticsHistograms as Y,measureHeight as Z,measureAreaAndPerimeter as ee,measureDistanceAndAngle as te,measurePointOrCentroid as re,getImageSpatialReferenceQueryParameter as ie,getSamples as se,identify as ne}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as oe}from"../../rest/query/executeQueryJSON.js";import"../../config.js";import"../../kernel.js";import"../../core/unitUtils.js";import"../../geometry/support/spatialReferenceUtils.js";import"../graphics/featureConversionUtils.js";import ae from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import le from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import ue from"../../rest/support/FeatureSet.js";import pe from"../../rest/support/Query.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as ce}from"../../rest/query/executeForCount.js";import{executeForIds as me}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{fetchServiceRasterInfo as de,generateRasterInfo as he}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as fe}from"../../rest/imageService/getCatalogItemRasterInfo.js";import ge from"../../rest/support/ImageAngleParameters.js";import ye from"../../rest/support/ImageAreaParameters.js";import Re from"../../rest/support/ImageDistanceParameters.js";import be from"../../rest/support/ImageHeightParameters.js";import ve from"../../rest/support/ImageHistogramParameters.js";import Se from"../../rest/support/ImageIdentifyParameters.js";import Ie from"../../rest/support/ImagePixelLocationParameters.js";import xe from"../../rest/support/ImagePointParameters.js";import we from"../../rest/support/ImageSampleParameters.js";import{createFlowMesh as _e}from"../../views/2d/engine/flow/dataUtils.js";import Fe from"../../geometry/SpatialReference.js";const De=a()({U1:"u1",U2:"u2",U4:"u4",U8:"u8",S8:"s8",U16:"u16",S16:"s16",U32:"u32",S32:"s32",F32:"f32",F64:"f64",C64:"c64",C128:"c128",UNKNOWN:"unknown"}),Te=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),je=g(b,{min:0,max:255});function Pe(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi)?.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return t?t.join("/"):null}const Ne=a=>{let g=class extends a{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._cachedRendererJson=null,this._serviceSupportsMosaicRule=null,this._rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.defaultMosaicRule=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.multidimensionalSubset=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelFilter=null,this.raster=void 0,this.sourceType=null,this.viewId=void 0,this.symbolizer=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new F({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.length<1||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replace(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?P.fromJSON(t):null}get fieldsIndex(){return this.fields?new T(this.fields):null}set format(e){e&&Te.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=P.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const r=e||t.mosaicRule;return r?P.fromJSON(r):this._isMosaicRuleSupported(t)?P.fromJSON(t):null}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new P({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=je(e))}readObjectIdField(e,t){if(!e){const r=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r&&r[0]&&r[0].name}return e}get parsedUrl(){return h(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer,n=s(i,r);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!i.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),j(n)||u.getLogger(this.declaredClass).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this._rasterAttributeTableFieldPrefix||"Raster.",t=new D({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new D({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new D({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities?.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new D({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),this._isVectorDataSet()&&(s.push(new D({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new D({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const{attributeTable:n}=this.rasterInfo??{};if(p(n)){const t=n.fields.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}set renderingRule(e){let t=e;t&&t.rasterFunction&&(t=A.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("renderingRule",t)}readRenderingRule(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r&&r.length&&"None"!==r[0].name?this._isRFTJson(t.renderingRule)?A.fromJSON({rasterFunctionDefinition:t.renderingRule}):A.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}writeRenderingRule(e,t,r){const i=e.toJSON();i.rasterFunctionDefinition?t[r]=i.rasterFunctionDefinition:t[r]=i}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?Fe.fromJSON(r):null}readPixelType(e){return De.fromJSON(e)||e}writePixelType(e,t,r){(c(this.serviceRasterInfo)||this.pixelType!==this.serviceRasterInfo.pixelType)&&(t[r]=De.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;const{renderer:i,symbolizer:s,pixelFilter:n,bandIds:o}=this;if(!this._isPicture()&&i&&s&&!n){const n=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(i.toJSON()),a=this._rasterJobHandler.instance;if(a){n&&(s.bind(),await a.updateSymbolizer(s,t),this._cachedRendererJson=i.toJSON());const l=await a.symbolize({bandIds:o,...e},t);r={extent:e.extent,pixelBlock:l}}else r={extent:e.extent,pixelBlock:s.symbolize({bandIds:o,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new o("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=R(ge,e).clone(),K(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new o("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=R(Ie,e).clone(),X(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new o("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=R(ve,e).clone(),this._applyMosaicAndRenderingRules(e),$(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new o("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=R(ve,e).clone(),this._applyMosaicAndRenderingRules(e),Y(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const r=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?r.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?r.mensuration.supportsHeightFromBaseAndTopShadow:r.mensuration.supportsHeightFromTopAndTopShadow))throw new o("imagery-layer:measure-height","this operation is not supported on the input image service");return e=R(be,e).clone(),this._applyMosaicAndRenderingRules(e),Z(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsAreaAndPerimeter&&(!e.is3D||r.mensuration.supports3D)))throw new o("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=R(ye,e).clone(),this._applyMosaicAndRenderingRules(e),ee(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsDistanceAndAngle&&(!e.is3D||r.mensuration.supports3D)))throw new o("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=R(Re,e).clone(),this._applyMosaicAndRenderingRules(e),te(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsPointOrCentroid&&(!e.is3D||r.mensuration.supports3D)))throw new o("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=R(xe,e).clone(),this._applyMosaicAndRenderingRules(e),re(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return p(t)?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}async fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)throw new o("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required.");if(this.renderer||this.symbolizer){const e=await this.generateRasterInfo(this.renderingRule,{signal:i.signal});e&&(this.rasterInfo=e)}const s=this.getExportImageServiceParameters(e,t,r,i.timeExtent);if(null==s){if(i.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");return e.width=t,e.height=r,{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,o=(s?.length||n.bandCount)??0,a=t*r,l=n.pixelType,u=[];for(let e=0;e<o;e++)u.push(O.createEmptyBand(l,a));return{pixelData:{pixelBlock:new O({width:t,height:r,pixels:u,mask:new Uint8Array(a),pixelType:l}),extent:e}}}const n={imageServiceParameters:s,imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:i.requestAsImageElement&&!this.pixelFilter||!1,signal:i.signal};return this._requestArrayBuffer(n)}fetchKeyProperties(e){return n(b(this.parsedUrl)+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.renderingRule:null})}).then((e=>e.data))}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new o("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(b(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.renderingRule:null})}).then((e=>ue.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return fe(b(this.parsedUrl),e,r)}async getCatalogItemICSInfo(e,t){const{data:r}=await n(b(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r&&r.ics;if(!i)return;let s=null;try{s=(await n(b(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const o=this.version>=10.7?n(b(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},a=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},u=n(b(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},g=n(b(this.parsedUrl)+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),y=await Promise.all([o,u,g]);let R=y[0].ipxf;if(null==R){const e=i.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const v=ae.fromJSON(y[1]&&y[1].geometries&&y[1].geometries[0]);v&&(v.spatialReference=new Fe({wkid:0,imageCoordinateSystem:i}));const S=y[2].geometries?y[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],I=S.length;if(I<3)return{ics:i,icsToPixelTransform:R,icsExtent:v,northDirection:null};let x=0,w=0,_=0,F=0;for(let n=0;n<I;n++)x+=S[n].x,w+=S[n].y,_+=S[n].x*S[n].x,F+=S[n].x*S[n].y;const D=(I*F-x*w)/(I*_-x*x);let T=0;const j=S[p-1].x>S[0].x,P=S[p-1].y>S[0].y;return D===1/0?T=P?90:270:0===D?T=j?0:180:D>0?T=j?180*Math.atan(D)/Math.PI:180*Math.atan(D)/Math.PI+180:D<0&&(T=P?180+180*Math.atan(D)/Math.PI:360+180*Math.atan(D)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:v,northDirection:T}}async generateRasterInfo(e,t){if(this.serviceRasterInfo&&(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e)))return this.serviceRasterInfo;const r=Pe(e);if(!r)return null;if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const i=this._generateRasterInfo(e,t);this._functionRasterInfos[r]=i;try{return await i}catch{return this._functionRasterInfos[r]=null,null}}getExportImageServiceParameters(e,t,r,i){e=e.clone().shiftCentralMeridian();const s=ie(e.spatialReference,b(this.parsedUrl));this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:a}=n;let{renderingRule:l}=n;const u=this.renderingRule?.rasterFunctionDefinition,c=!this.renderer||"raster-stretch"===this.renderer.type;if(o?.length&&this._hasRenderingRule(this.renderingRule)&&!u&&c){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===l.rasterFunction)e.rasterFunctionArguments.Raster=l.rasterFunctionArguments.Raster,l.rasterFunctionArguments.Raster=e;else if("Colormap"===l.rasterFunction){const t=l.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,l.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=l,l=e;n.bandIds=void 0}else n.bandIds=o?.join(",");a instanceof Array&&a.length>0&&(n.noData=a.join(","));const m=this._serviceSupportsMosaicRule?this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,i):null;n.mosaicRule=p(m)?JSON.stringify(m):null;const{multidimensionalSubset:d}=this;if(d&&p(m)&&m.multidimensionalDefinition&&V(m.multidimensionalDefinition,d,!0))return null;n.renderingRule=this._getRenderingRuleString(A.fromJSON(l));const h={};if(i){const{start:e,end:t}=i.toJSON();let r;if(e&&t&&e===t?(h.time=""+e,r=[e]):null==e&&null==t||(h.time=`${e??"null"},${t??"null"}`,r=null!=e&&null!=t?[e,t]:[e??t]),r&&d){const e=d.dimensions.find((({name:e})=>"StdTime"===e));if(2===r.length&&e?.extent.length){if(r[0]=Math.max(r[0],e.extent[0]),r[1]=Math.min(r[1],e.extent[1]??e.extent[0]),r[1]<r[0])return null;h.time=r.join()}const t=new _({variableName:"",dimensionName:"StdTime",isSlice:1===r.length,values:r});if(V([t],d,!0))return null}}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+r,...n,...h}}async getSamples(e,t){if(!(await this._fetchCapabilities(t?.signal))?.operations.supportsGetSamples)throw new o("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=R(we,e).clone();const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),se(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new o("imagery-layer:query-rasters","query operation is not supported on the input image service");e=R(Se,e).clone();const{raster:r,mosaicRule:i,renderingRule:s}=this;if(s&&null==e.renderingRule&&(e.renderingRule=s),i&&null==e.mosaicRule){const t=this._combineMosaicRuleWithTimeExtent(i,e.timeExtent);e.mosaicRule=m(t)}return r&&null==e.raster&&(e.raster=r),ne(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new pe;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),oe(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),me(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ce(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new o("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let a=!1,l=null,u=null;const m="raster.servicepixelvalue",d=this._rasterFunctionNamesIndex;if(p(e.outFields)&&(a=e.outFields.some((e=>!e.toLowerCase().includes(m))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().includes(m)&&e.length>m.length)).map((e=>{const t=e.slice(m.length+1);return[this._updateRenderingRulesFunctionName(t,d),t]}));l=t.map((e=>new A({functionName:e[0]}))),u=t.map((e=>e[1]));const{renderingRule:r}=this;0===l.length?r?.functionName?(l.push(r),u.push(r.functionName)):l=null:r?.functionName&&!l.some((e=>e.functionName===r.functionName))&&(l.push(r),u.push(r.functionName))}const h=c(e.outSpatialReference)||e.outSpatialReference.equals(this.spatialReference),f=e.timeExtent||this.timeExtent,g=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,f),y=this._getQueryParams({geometry:e.geometry,timeExtent:f,mosaicRule:g,renderingRule:this.version<10.4?this.renderingRule:null,renderingRules:l,pixelSize:r,returnCatalogItems:a,returnGeometry:h,raster:this.raster,maxItemCount:s?1:null});delete y.f;const R=new Se(y);try{await this.generateRasterInfo(this.renderingRule);const r=await ne(this.url,R,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,o=null!=r.value&&r.value.toLowerCase().includes("nodata");if(!(a&&!h&&r?.catalogItems?.features.length&&(n||!o)))return this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",c=r.catalogItems?.features??[],m=c.map((e=>e.attributes?.[l])),d=new pe({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),f=await this.queryRasters(d);return f?.features?.length&&f.features.forEach((t=>{c.forEach((r=>{r.attributes[l]===t.attributes[l]&&(r.geometry=new le(t.geometry),p(e.outSpatialReference)&&(r.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new o("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=n(b(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),i=n(b(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(e,t):_e(e.meshType,e.simulationSettings,e.flowData,p(t.signal)?t.signal:(new AbortController).signal)}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return E(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=p(this.serviceRasterInfo)?Promise.resolve(this.serviceRasterInfo):de(b(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),e))),i=this._hasRenderingRule(this.renderingRule)?this.generateRasterInfo(this.renderingRule,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([r,i,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),u.getLogger(this.declaredClass).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.addHandles([d((()=>this.renderingRule),(e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this.generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))}))]);const{serviceRasterInfo:t}=this;p(t.multidimensionalInfo)&&this._updateMultidimensionalDefinition(t)}))}_combineMosaicRuleWithTimeExtent(e,t){const r=this.timeInfo,{multidimensionalInfo:i}=this.serviceRasterInfo;if(c(e)||c(i)||c(t)||c(r?.startField))return e;const{startField:s}=r,n=i.variables.some((e=>e.dimensions.some((e=>e.name===s))))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter((e=>e.dimensionName!==n)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const o=e.multidimensionalDefinition.filter((e=>e.dimensionName===n)),a=p(t.start)?t.start.getTime():null,l=p(t.end)?t.end.getTime():null,u=null==a||null==l||a===l,m=u?[a||l]:[[a,l]],d=this.version>=10.8;if(o.length)o.forEach((e=>{e.dimensionName===n&&(d?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=m))}));else if(!d){const t=e.multidimensionalDefinition.filter((e=>null!=e.variableName&&null==e.dimensionName));t.length?t.forEach((e=>{e.dimensionName=n,e.isSlice=u,e.values=m})):e.multidimensionalDefinition.push(new _({variableName:"",dimensionName:n,isSlice:u,values:m}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return c(e)?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter((e=>!(!e.variableName&&!e.dimensionName))),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this.sourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQuery)throw new o("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=p(e)?R(pe,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new q;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>{})),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null}_isSupportedRenderer(e){const{rasterInfo:t,renderingRule:r}=this;return"unique-value"===e.type&&this._hasRenderingRule(r)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&z(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:r,ssl:i}=await n(b(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new o("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),r=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||r}_isVectorFieldResampleFunction(e){if(c(e))return!1;const{functionName:t,functionArguments:r}=e,i="resample"===t?.toLowerCase(),s=r?.ResampleType||r?.resampleType;return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:r}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){if(!this.bandIds&&r.bandCount>=3){const e=B(r);!e||3===r.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=k(r,{bandIds:this.bandIds,variableName:this.renderingRule?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=G(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=r):this.symbolizer=new W({rendererJSON:t,rasterInfo:r}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:p(e.pixelBlock)?e.pixelBlock.clone():null}}_getQueryParams(e){e&&p(e.renderingRule)&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):Q(e,t,r)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;return(await n(b(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e})).data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:r,signal:i}=e;if(r&&this._canRequestImageElement(t.format)){return{imageOrCanvasElement:(await n(b(this.parsedUrl)+"/exportImage",{responseType:"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:i})).data,params:t}}const s=this._initJobHandler(),a=n(b(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:i}),l=(await Promise.all([a,s]))[0].data,u=t.format||"jpgpng";let p=u;if("bsq"!==p&&"bip"!==p&&(p=U(l)),!p)throw new o("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(l)));const c={signal:i},m="gif"===u||"bmp"===u||u.includes("png")&&("png"===p||"jpg"===p)?Q(l,{useCanvas:!0,...t},c):this._decodePixelBlock(l,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:u},c);return{pixelData:{pixelBlock:await m,extent:t.extent},params:t}}_generateRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return he(b(this.parsedUrl),e,r)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this.defaultMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;let t=H(e,{multidimensionalSubset:this.multidimensionalSubset});if(p(t)&&t.length>0){this.mosaicRule=this.mosaicRule||new P;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.renderingRule&&"none"!==this.renderingRule.functionName?.toLowerCase()&&t.forEach((e=>e.variableName="")),t=t.filter((({variableName:e,dimensionName:t})=>e&&"*"!==e||t)),!e?.length&&t.length&&(this.mosaicRule.multidimensionalDefinition=t)}}_processVisibleRastersResponse(e,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:o,templateFields:a}=r,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,c=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replace(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",d="string"==typeof i&&i.toLowerCase().includes("nodata"),h=[];if(i&&!u&&!d){const e={};e[m]=0;c=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let f,g,y;this._updateResponseFieldNames(u,a),d&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(f=u[t],null!=i){if(g=c[t],y=this.renderingRule&&l&&l.length>0&&s&&s.length>0&&s.includes(this.renderingRule.functionName)?l[s.indexOf(this.renderingRule.functionName)]:i,"nodata"===g.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";f.attributes[e]=g,f.attributes[r]=y,this._updateFeatureWithMagDirValues(f,g);const o=this.fields&&this.fields.length>0;let a=this.renderingRule&&p(this.serviceRasterInfo.attributeTable)?o?g:i:y;this.renderingRule||(a=o?g:i),this._updateFeatureWithRasterAttributeTableValues(f,a)}if(f.sourceLayer=f.layer=this,o&&this._updateFeatureWithDomainValues(f),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];f.attributes[t]=l[e]}h.push(u[t])}return h}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(c(r))return;const{features:i,fields:s}=r,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),o=n&&n[0];if(!o)return;const a=i.filter((e=>e.attributes[o]===(null!=t?parseInt(t,10):null)));a&&a[0]&&s.forEach((t=>{const r=this._rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=a[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new O({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new ae(0,0,0,0,this.spatialReference)});const o="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:L([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=o[0],e.attributes["Raster.Direction"]=o[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.find((e=>e.code===r));i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;c(r)||e.forEach((e=>{if(e&&e.attributes)for(const i of t){const t=r.get(i)?.name;t&&t!==i&&(e.attributes[i]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(this._hasRenderingRule(e)){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRenderingRule(e){return null!=e&&null!=e.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const r=e.toLowerCase().replace(/ /gi,"_");return t.has(r)?t.get(r):e}_isRFTJson(e){return e&&e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:r,renderingRule:i}=this;i&&null==e.renderingRule&&(e.renderingRule=i),r&&null==e.mosaicRule&&(e.mosaicRule=r),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.includes("image"),o="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit"),u=t.includes("mensuration")&&a,p=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map((e=>e.trim())),c=u&&p.includes("basic");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:u,supportsDownload:t.includes("download"),supportsQuery:t.includes("catalog")&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&o,supportsComputePixelLocation:r>=10.7&&t.includes("catalog"),supportsComputeAngles:r>=10.91,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryTopFeatures:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!!i?.supportsStatistics,supportsOrderBy:!!i?.supportsOrderBy,supportsDistinct:!!i?.supportsDistinct,supportsPagination:!!i?.supportsPagination,supportsStandardizedQueriesOnly:!!i?.useStandardizedQueries,supportsPercentileStatistics:!!i?.supportsPercentileStatistics,supportsCentroid:!!i?.supportsReturningGeometryCentroid,supportsDistance:!!i?.supportsQueryWithDistance,supportsExtent:!!i?.supportsReturningQueryExtent,supportsGeometryProperties:!!i?.supportsReturningGeometryProperties,supportsHavingClause:!!i?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!i?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0},mensuration:{supportsDistanceAndAngle:c,supportsAreaAndPerimeter:c,supportsPointOrCentroid:c,supportsHeightFromBaseAndTop:u&&p.includes("base-top height"),supportsHeightFromBaseAndTopShadow:u&&p.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:u&&p.includes("top-top shadow height"),supports3D:u&&p.includes("3d")}}}};function b(e){return e?.path??""}return e([f()],g.prototype,"_functionRasterInfos",void 0),e([f()],g.prototype,"_rasterJobHandler",void 0),e([f()],g.prototype,"_cachedRendererJson",void 0),e([f({readOnly:!0})],g.prototype,"_serviceSupportsMosaicRule",void 0),e([v("_serviceSupportsMosaicRule",["currentVersion","fields"])],g.prototype,"readServiceSupportsMosaicRule",null),e([f()],g.prototype,"_rasterAttributeTableFieldPrefix",void 0),e([f({readOnly:!0})],g.prototype,"_rasterFunctionNamesIndex",null),e([f()],g.prototype,"adjustAspectRatio",void 0),e([f({type:[y],json:{write:!0}})],g.prototype,"bandIds",void 0),e([v("bandIds")],g.prototype,"readBandIds",null),e([f({readOnly:!0,json:{read:!1}})],g.prototype,"capabilities",void 0),e([v("service","capabilities",["capabilities","currentVersion","serviceDataType"])],g.prototype,"readCapabilities",null),e([f({type:Number})],g.prototype,"compressionQuality",void 0),e([I("compressionQuality")],g.prototype,"writeCompressionQuality",null),e([f({type:Number})],g.prototype,"compressionTolerance",void 0),e([I("compressionTolerance")],g.prototype,"writeCompressionTolerance",null),e([f({json:{read:{source:"copyrightText"}}})],g.prototype,"copyright",void 0),e([f({readOnly:!0,dependsOn:["_serviceSupportsMosaicRule"]})],g.prototype,"defaultMosaicRule",void 0),e([v("defaultMosaicRule",["defaultMosaicMethod"])],g.prototype,"readDefaultMosaicRule",null),e([f({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],g.prototype,"definitionExpression",void 0),e([f({readOnly:!0,constructOnly:!0})],g.prototype,"exportImageServiceParameters",void 0),e([f()],g.prototype,"rasterInfo",void 0),e([f({readOnly:!0,type:[D]})],g.prototype,"fields",void 0),e([f({readOnly:!0})],g.prototype,"fieldsIndex",null),e([f({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],g.prototype,"format",null),e([v("service","format",["serviceDataType"])],g.prototype,"readFormat",null),e([f({type:ae})],g.prototype,"fullExtent",void 0),e([f({readOnly:!0})],g.prototype,"hasMultidimensions",void 0),e([f({json:{read:{source:"maxImageHeight"}}})],g.prototype,"imageMaxHeight",void 0),e([f({json:{read:{source:"maxImageWidth"}}})],g.prototype,"imageMaxWidth",void 0),e([f({type:String,json:{type:C.jsonValues,read:C.read,write:C.write}})],g.prototype,"interpolation",void 0),e([f()],g.prototype,"minScale",void 0),e([v("service","minScale")],g.prototype,"readMinScale",null),e([f()],g.prototype,"maxScale",void 0),e([v("service","maxScale")],g.prototype,"readMaxScale",null),e([f({type:P})],g.prototype,"mosaicRule",null),e([v("mosaicRule",["mosaicRule","defaultMosaicMethod"])],g.prototype,"readMosaicRule",null),e([I("mosaicRule")],g.prototype,"writeMosaicRule",null),e([f()],g.prototype,"multidimensionalInfo",void 0),e([f({type:N,json:{write:!0}})],g.prototype,"multidimensionalSubset",void 0),e([f({json:{type:y}})],g.prototype,"noData",void 0),e([I("noData")],g.prototype,"writeNoData",null),e([f({type:String,json:{type:M.jsonValues,read:M.read,write:M.write}})],g.prototype,"noDataInterpretation",void 0),e([f({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],g.prototype,"objectIdField",void 0),e([v("objectIdField")],g.prototype,"readObjectIdField",null),e([f({})],g.prototype,"geometryType",void 0),e([f({})],g.prototype,"typeIdField",void 0),e([f({})],g.prototype,"types",void 0),e([f({readOnly:!0})],g.prototype,"parsedUrl",null),e([f({type:Function})],g.prototype,"pixelFilter",void 0),e([f()],g.prototype,"raster",void 0),e([f({readOnly:!0})],g.prototype,"sourceType",void 0),e([v("sourceType",["serviceSourceType","fields"])],g.prototype,"readSourceType",null),e([f()],g.prototype,"viewId",void 0),e([f({types:r,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],g.prototype,"renderer",null),e([v("renderer")],g.prototype,"readRenderer",null),e([I("renderer")],g.prototype,"writeRenderer",null),e([f()],g.prototype,"symbolizer",void 0),e([f(x)],g.prototype,"opacity",void 0),e([f({readOnly:!0})],g.prototype,"rasterFields",null),e([f({constructOnly:!0})],g.prototype,"rasterFunctionInfos",void 0),e([f({type:A})],g.prototype,"renderingRule",null),e([v("renderingRule",["renderingRule","rasterFunctionInfos"])],g.prototype,"readRenderingRule",null),e([I("renderingRule")],g.prototype,"writeRenderingRule",null),e([f()],g.prototype,"serviceDataType",void 0),e([f({readOnly:!0,type:Fe})],g.prototype,"spatialReference",void 0),e([v("spatialReference",["spatialReference","extent"])],g.prototype,"readSpatialReference",null),e([f({json:{type:De.jsonValues}})],g.prototype,"pixelType",void 0),e([v("pixelType")],g.prototype,"readPixelType",null),e([I("pixelType")],g.prototype,"writePixelType",null),e([f({constructOnly:!0,type:J})],g.prototype,"serviceRasterInfo",void 0),e([f()],g.prototype,"sourceJSON",void 0),e([f(w)],g.prototype,"url",void 0),e([f({readOnly:!0})],g.prototype,"version",void 0),e([v("version",["currentVersion","fields","timeInfo"])],g.prototype,"readVersion",null),g=e([S("esri.layers.mixins.ArcGISImageService")],g),g};export{Ne as ArcGISImageService};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{rasterRendererTypes as i,websceneRasterRendererTypes as r,read as s}from"../../rasterRenderers.js";import n from"../../request.js";import o from"../../core/Error.js";import{strict as a}from"../../core/jsonMap.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{isSome as p,isNone as c,unwrap as m}from"../../core/maybe.js";import{watch as d}from"../../core/reactiveUtils.js";import{urlToObject as h}from"../../core/urlUtils.js";import{property as f,ensureRange as g}from"../../core/accessorSupport/decorators/property.js";import{Integer as y,ensureClass as R,ensureNumber as b}from"../../core/accessorSupport/ensureType.js";import{reader as S}from"../../core/accessorSupport/decorators/reader.js";import{subclass as v}from"../../core/accessorSupport/decorators/subclass.js";import{writer as x}from"../../core/accessorSupport/decorators/writer.js";import{opacity as I,url as w}from"../support/commonProperties.js";import _ from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as F}from"../support/ExportImageServiceParameters.js";import D from"../support/Field.js";import P from"../support/FieldsIndex.js";import{isSupportedRendererType as j}from"../support/imageryRendererUtils.js";import T from"../support/MosaicRule.js";import O from"../support/MultidimensionalSubset.js";import N from"../support/PixelBlock.js";import{interpolationKebab as C,noDataInterpretationKebab as M}from"../support/rasterEnums.js";import A from"../support/RasterFunction.js";import J from"../support/RasterInfo.js";import q from"../support/RasterJobHandler.js";import{intersectMultimensionalSubset as E,getSubsetVariablesFromMdInfo as V,getDefaultMultidimensionalDefinition as H}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as Q,getFormat as U}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as L}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as z,getDefaultBandCombination as B,createDefaultRenderer as k,normalizeRendererJSON as G}from"../../renderers/support/rasterRendererHelper.js";import W from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as K,computePixelSpaceLocations as X,computeHistograms as $,computeStatisticsHistograms as Y,measureHeight as Z,measureAreaAndPerimeter as ee,measureDistanceAndAngle as te,measurePointOrCentroid as ie,getImageSpatialReferenceQueryParameter as re,getSamples as se,identify as ne}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as oe}from"../../rest/query/executeQueryJSON.js";import"../../config.js";import"../../kernel.js";import"../../core/unitUtils.js";import"../../geometry/support/spatialReferenceUtils.js";import"../graphics/featureConversionUtils.js";import ae from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import le from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import ue from"../../rest/support/FeatureSet.js";import pe from"../../rest/support/Query.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as ce}from"../../rest/query/executeForCount.js";import{executeForIds as me}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{fetchServiceRasterInfo as de,generateRasterInfo as he}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as fe}from"../../rest/imageService/getCatalogItemRasterInfo.js";import ge from"../../rest/support/ImageAngleParameters.js";import ye from"../../rest/support/ImageAreaParameters.js";import Re from"../../rest/support/ImageDistanceParameters.js";import be from"../../rest/support/ImageHeightParameters.js";import Se from"../../rest/support/ImageHistogramParameters.js";import ve from"../../rest/support/ImageIdentifyParameters.js";import xe from"../../rest/support/ImagePixelLocationParameters.js";import Ie from"../../rest/support/ImagePointParameters.js";import we from"../../rest/support/ImageSampleParameters.js";import{createFlowMesh as _e}from"../../views/2d/engine/flow/dataUtils.js";import Fe from"../../geometry/SpatialReference.js";const De=a()({U1:"u1",U2:"u2",U4:"u4",U8:"u8",S8:"s8",U16:"u16",S16:"s16",U32:"u32",S32:"s32",F32:"f32",F64:"f64",C64:"c64",C128:"c128",UNKNOWN:"unknown"}),Pe=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),je=g(b,{min:0,max:255});function Te(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi)?.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return t?t.join("/"):null}const Oe=a=>{let g=class extends a{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._cachedRendererJson=null,this._serviceSupportsMosaicRule=null,this._rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.defaultMosaicRule=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.multidimensionalSubset=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelFilter=null,this.raster=void 0,this.sourceType=null,this.viewId=void 0,this.symbolizer=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new F({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.length<1||p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replace(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,i){null!=e&&"lerc"!==this.format&&(t[i]=e)}writeCompressionTolerance(e,t,i){"lerc"===this.format&&null!=e&&(t[i]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?T.fromJSON(t):null}get fieldsIndex(){return this.fields?new P(this.fields):null}set format(e){e&&Pe.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=T.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const i=e||t.mosaicRule;return i?T.fromJSON(i):this._isMosaicRuleSupported(t)?T.fromJSON(t):null}writeMosaicRule(e,t,i){let r=this.mosaicRule;const s=this.definitionExpression;r?s&&s!==r.where&&(r=r.clone(),r.where=s):s&&(r=new T({where:s})),this._isValidCustomizedMosaicRule(r)&&(t[i]=r.toJSON())}writeNoData(e,t,i){null!=e&&"number"==typeof e&&(t[i]=je(e))}readObjectIdField(e,t){if(!e){const i=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=i&&i[0]&&i[0].name}return e}get parsedUrl(){return h(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer,n=s(r,i);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!r.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),j(n)||u.getLogger(this.declaredClass).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,i){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this._rasterAttributeTableFieldPrefix||"Raster.",t=new D({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new D({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new D({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(i),this.capabilities?.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(r),p(this.rasterFunctionInfos)&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new D({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),this._isVectorDataSet()&&(s.push(new D({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new D({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const{attributeTable:n}=this.rasterInfo??{};if(p(n)){const t=n.fields.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const i=l(t);return i.name=e+t.name,i}));s=s.concat(t)}return s}set renderingRule(e){let t=e;t&&t.rasterFunction&&(t=A.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("renderingRule",t)}readRenderingRule(e,t){const i=t.rasterFunctionInfos;return t.renderingRule||i&&i.length&&"None"!==i[0].name?this._isRFTJson(t.renderingRule)?A.fromJSON({rasterFunctionDefinition:t.renderingRule}):A.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}writeRenderingRule(e,t,i){const r=e.toJSON();r.rasterFunctionDefinition?t[i]=r.rasterFunctionDefinition:t[i]=r}readSpatialReference(e,t){const i=e||t.extent.spatialReference;return i?Fe.fromJSON(i):null}readPixelType(e){return De.fromJSON(e)||e}writePixelType(e,t,i){(c(this.serviceRasterInfo)||this.pixelType!==this.serviceRasterInfo.pixelType)&&(t[i]=De.toJSON(e))}readVersion(e,t){let i=t.currentVersion;return i||(i=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),i}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let i=e;const{renderer:r,symbolizer:s,pixelFilter:n,bandIds:o}=this;if(!this._isPicture()&&r&&s&&!n){const n=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(r.toJSON()),a=this._rasterJobHandler.instance;if(a){n&&(s.bind(),await a.updateSymbolizer(s,t),this._cachedRendererJson=r.toJSON());const l=await a.symbolize({bandIds:o,...e},t);i={extent:e.extent,pixelBlock:l}}else i={extent:e.extent,pixelBlock:s.symbolize({bandIds:o,...e})}}return i}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new o("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=R(ge,e).clone(),K(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new o("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=R(xe,e).clone(),X(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new o("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=R(Se,e).clone(),this._applyMosaicAndRenderingRules(e),$(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new o("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=R(Se,e).clone(),this._applyMosaicAndRenderingRules(e),Y(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const i=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?i.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?i.mensuration.supportsHeightFromBaseAndTopShadow:i.mensuration.supportsHeightFromTopAndTopShadow))throw new o("imagery-layer:measure-height","this operation is not supported on the input image service");return e=R(be,e).clone(),this._applyMosaicAndRenderingRules(e),Z(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsAreaAndPerimeter&&(!e.is3D||i.mensuration.supports3D)))throw new o("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=R(ye,e).clone(),this._applyMosaicAndRenderingRules(e),ee(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsDistanceAndAngle&&(!e.is3D||i.mensuration.supports3D)))throw new o("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=R(Re,e).clone(),this._applyMosaicAndRenderingRules(e),te(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsPointOrCentroid&&(!e.is3D||i.mensuration.supports3D)))throw new o("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=R(Ie,e).clone(),this._applyMosaicAndRenderingRules(e),ie(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return p(t)?t.get(e):void 0}getFieldDomain(e,t){const i=this.getField(e);return i?i.domain:null}async fetchImage(e,t,i,r={}){if(null==e||null==t||null==i)throw new o("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required.");if(this.renderer||this.symbolizer){const e=await this.generateRasterInfo(this.renderingRule,{signal:r.signal});e&&(this.rasterInfo=e)}const s=this.getExportImageServiceParameters(e,t,i,r.timeExtent);if(null==s){if(r.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");return e.width=t,e.height=i,{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,o=(s?.length||n.bandCount)??0,a=t*i,l=n.pixelType,u=[];for(let e=0;e<o;e++)u.push(N.createEmptyBand(l,a));return{pixelData:{pixelBlock:new N({width:t,height:i,pixels:u,mask:new Uint8Array(a),pixelType:l}),extent:e}}}const n={imageServiceParameters:s,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:r.requestAsImageElement&&!this.pixelFilter||!1,signal:r.signal};return this._requestArrayBuffer(n)}fetchKeyProperties(e){return n(b(this.parsedUrl)+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.renderingRule:null})}).then((e=>e.data))}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new o("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(b(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.renderingRule:null})}).then((e=>ue.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return fe(b(this.parsedUrl),e,i)}async getCatalogItemICSInfo(e,t){const{data:i}=await n(b(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),r=i&&i.ics;if(!r)return;let s=null;try{s=(await n(b(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:r,icsToPixelTransform:null,icsExtent:null,northDirection:null};const o=this.version>=10.7?n(b(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},a=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},u=n(b(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},g=n(b(this.parsedUrl)+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),y=await Promise.all([o,u,g]);let R=y[0].ipxf;if(null==R){const e=r.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const S=ae.fromJSON(y[1]&&y[1].geometries&&y[1].geometries[0]);S&&(S.spatialReference=new Fe({wkid:0,imageCoordinateSystem:r}));const v=y[2].geometries?y[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],x=v.length;if(x<3)return{ics:r,icsToPixelTransform:R,icsExtent:S,northDirection:null};let I=0,w=0,_=0,F=0;for(let n=0;n<x;n++)I+=v[n].x,w+=v[n].y,_+=v[n].x*v[n].x,F+=v[n].x*v[n].y;const D=(x*F-I*w)/(x*_-I*I);let P=0;const j=v[p-1].x>v[0].x,T=v[p-1].y>v[0].y;return D===1/0?P=T?90:270:0===D?P=j?0:180:D>0?P=j?180*Math.atan(D)/Math.PI:180*Math.atan(D)/Math.PI+180:D<0&&(P=T?180+180*Math.atan(D)/Math.PI:360+180*Math.atan(D)/Math.PI),{ics:r,icsToPixelTransform:R,icsExtent:S,northDirection:P}}async generateRasterInfo(e,t){if(this.serviceRasterInfo&&(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e)))return this.serviceRasterInfo;const i=Te(e);if(!i)return null;if(this._functionRasterInfos[i])return this._functionRasterInfos[i];const r=this._generateRasterInfo(e,t);this._functionRasterInfos[i]=r;try{return await r}catch{return this._functionRasterInfos[i]=null,null}}getExportImageServiceParameters(e,t,i,r){e=e.clone().shiftCentralMeridian();const s=re(e.spatialReference,b(this.parsedUrl));this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:a}=n;let{renderingRule:l}=n;const u=this.renderingRule?.rasterFunctionDefinition,c=!this.renderer||"raster-stretch"===this.renderer.type;if(o?.length&&this._hasRenderingRule(this.renderingRule)&&!u&&c){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===l.rasterFunction)e.rasterFunctionArguments.Raster=l.rasterFunctionArguments.Raster,l.rasterFunctionArguments.Raster=e;else if("Colormap"===l.rasterFunction){const t=l.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,l.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=l,l=e;n.bandIds=void 0}else n.bandIds=o?.join(",");a instanceof Array&&a.length>0&&(n.noData=a.join(","));const m=this._processMultidimensionalIntersection(null,r,this.exportImageServiceParameters.mosaicRule);if(m.isOutSide)return null;n.mosaicRule=p(m.mosaicRule)?JSON.stringify(m.mosaicRule):null,r=m.timeExtent,n.renderingRule=this._getRenderingRuleString(A.fromJSON(l));const d={};if(p(r)){const{start:e,end:t}=r.toJSON();e&&t&&e===t?d.time=""+e:null==e&&null==t||(d.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+i,...n,...d}}async getSamples(e,t){if(!(await this._fetchCapabilities(t?.signal))?.operations.supportsGetSamples)throw new o("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=R(we,e).clone();const{raster:i}=this;return i&&null==e.raster&&(e.raster=i),se(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new o("imagery-layer:identify","identify operation is not supported on the input image service");e=R(ve,e).clone();const i=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(i.isOutSide)throw new o("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=m(i.timeExtent),e.mosaicRule=m(i.mosaicRule);const{raster:r,renderingRule:s}=this;return s&&null==e.renderingRule&&(e.renderingRule=s),r&&null==e.raster&&(e.raster=r),ne(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new pe;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),oe(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),me(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ce(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new o("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:i,returnDomainValues:r,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let a=!1,l=null,u=null;const d="raster.servicepixelvalue",h=this._rasterFunctionNamesIndex;if(p(e.outFields)&&(a=e.outFields.some((e=>!e.toLowerCase().includes(d))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().includes(d)&&e.length>d.length)).map((e=>{const t=e.slice(d.length+1);return[this._updateRenderingRulesFunctionName(t,h),t]}));l=t.map((e=>new A({functionName:e[0]}))),u=t.map((e=>e[1]));const{renderingRule:i}=this;0===l.length?i?.functionName?(l.push(i),u.push(i.functionName)):l=null:i?.functionName&&!l.some((e=>e.functionName===i.functionName))&&(l.push(i),u.push(i.functionName))}const f=c(e.outSpatialReference)||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:g}=this;let y=e.timeExtent||this.timeExtent;if(g){const{isOutside:t,intersection:i}=E(g,{geometry:m(e.geometry),timeExtent:m(e.timeExtent),multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new o("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");i&&p(i.timeExtent)&&(y=i.timeExtent)}const R=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,y),b=this._getQueryParams({geometry:e.geometry,timeExtent:y,mosaicRule:R,renderingRule:this.version<10.4?this.renderingRule:null,renderingRules:l,pixelSize:i,returnCatalogItems:a,returnGeometry:f,raster:this.raster,maxItemCount:s?1:null});delete b.f;const S=new ve(b);try{await this.generateRasterInfo(this.renderingRule);const i=await ne(this.url,S,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,o=null!=i.value&&i.value.toLowerCase().includes("nodata");if(!(a&&!f&&i?.catalogItems?.features.length&&(n||!o)))return this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",c=i.catalogItems?.features??[],m=c.map((e=>e.attributes?.[l])),d=new pe({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),h=await this.queryRasters(d);return h?.features?.length&&h.features.forEach((t=>{c.forEach((i=>{i.attributes[l]===t.attributes[l]&&(i.geometry=new le(t.geometry),p(e.outSpatialReference)&&(i.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new o("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const i=n(b(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),r=n(b(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([i,r]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const i=this._rasterJobHandler.instance;return i?i.createFlowMesh(e,t):_e(e.meshType,e.simulationSettings,e.flowData,p(t.signal)?t.signal:(new AbortController).signal)}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return V(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,i=p(this.serviceRasterInfo)?Promise.resolve(this.serviceRasterInfo):de(b(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),e))),r=this._hasRenderingRule(this.renderingRule)?this.generateRasterInfo(this.renderingRule,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([i,r,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),u.getLogger(this.declaredClass).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.addHandles([d((()=>this.renderingRule),(e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this.generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))}))]);const{serviceRasterInfo:t}=this;p(t.multidimensionalInfo)&&this._updateMultidimensionalDefinition(t)}))}_combineMosaicRuleWithTimeExtent(e,t){const i=this.timeInfo,{multidimensionalInfo:r}=this.serviceRasterInfo;if(c(e)||c(r)||c(t)||c(i?.startField))return e;const{startField:s}=i,n=r.variables.some((e=>e.dimensions.some((e=>e.name===s))))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter((e=>e.dimensionName!==n)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const o=e.multidimensionalDefinition.filter((e=>e.dimensionName===n)),a=p(t.start)?t.start.getTime():null,l=p(t.end)?t.end.getTime():null,u=null==a||null==l||a===l,m=u?[a||l]:[[a,l]],d=this.version>=10.8;if(o.length)o.forEach((e=>{e.dimensionName===n&&(d?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=m))}));else if(!d){const t=e.multidimensionalDefinition.filter((e=>null!=e.variableName&&null==e.dimensionName));t.length?t.forEach((e=>{e.dimensionName=n,e.isSlice=u,e.values=m})):e.multidimensionalDefinition.push(new _({variableName:"",dimensionName:n,isSlice:u,values:m}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return c(e)?null:(e.multidimensionalDefinition&&(e.multidimensionalDefinition=e.multidimensionalDefinition.filter((e=>!(!e.variableName&&!e.dimensionName))),0===e.multidimensionalDefinition.length&&(e.multidimensionalDefinition=null)),"mosaic-dataset"!==this.sourceType&&null==e.multidimensionalDefinition?null:e)}async _prepareForQuery(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQuery)throw new o("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=p(e)?R(pe,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new q;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>{})),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null}_isSupportedRenderer(e){const{rasterInfo:t,renderingRule:i}=this;return"unique-value"===e.type&&this._hasRenderingRule(i)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&z(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:i,ssl:r}=await n(b(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=i,this.sourceJSON=t,r&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new o("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),i=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||i}_isVectorFieldResampleFunction(e){if(c(e))return!1;const{functionName:t,functionArguments:i}=e,r="resample"===t?.toLowerCase(),s=i?.ResampleType||i?.resampleType;return r&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:i}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){if(!this.bandIds&&i.bandCount>=3){const e=B(i);!e||3===i.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=k(i,{bandIds:this.bandIds,variableName:this.renderingRule?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=G(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=i):this.symbolizer=new W({rendererJSON:t,rasterInfo:i}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:p(e.pixelBlock)?e.pixelBlock.clone():null}}_getQueryParams(e){e&&p(e.renderingRule)&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:i}=this;return{raster:t,viewId:i,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,i){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):Q(e,t,i)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;return(await n(b(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e})).data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:i,signal:r}=e;if(i&&this._canRequestImageElement(t.format)){return{imageOrCanvasElement:(await n(b(this.parsedUrl)+"/exportImage",{responseType:"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:r})).data,params:t}}const s=this._initJobHandler(),a=n(b(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:r}),l=(await Promise.all([a,s]))[0].data,u=t.format||"jpgpng";let p=u;if("bsq"!==p&&"bip"!==p&&(p=U(l)),!p)throw new o("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(l)));const c={signal:r},m="gif"===u||"bmp"===u||u.includes("png")&&("png"===p||"jpg"===p)?Q(l,{useCanvas:!0,...t},c):this._decodePixelBlock(l,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:u},c);return{pixelData:{pixelBlock:await m,extent:t.extent},params:t}}_generateRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return he(b(this.parsedUrl),e,i)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this.defaultMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;let t=H(e,{multidimensionalSubset:this.multidimensionalSubset});if(p(t)&&t.length>0){this.mosaicRule=this.mosaicRule||new T;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.renderingRule&&"none"!==this.renderingRule.functionName?.toLowerCase()&&t.forEach((e=>e.variableName="")),t=t.filter((({variableName:e,dimensionName:t})=>e&&"*"!==e||t)),!e?.length&&t.length&&(this.mosaicRule.multidimensionalDefinition=t)}}_processVisibleRastersResponse(e,i){i=i||{};const r=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:o,templateFields:a}=i,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,c=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replace(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",d="string"==typeof r&&r.toLowerCase().includes("nodata"),h=[];if(r&&!u&&!d){const e={};e[m]=0;c=[r],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let f,g,y;this._updateResponseFieldNames(u,a),d&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(f=u[t],null!=r){if(g=c[t],y=this.renderingRule&&l&&l.length>0&&s&&s.length>0&&s.includes(this.renderingRule.functionName)?l[s.indexOf(this.renderingRule.functionName)]:r,"nodata"===g.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",i="Raster.ServicePixelValue";f.attributes[e]=g,f.attributes[i]=y,this._updateFeatureWithMagDirValues(f,g);const o=this.fields&&this.fields.length>0;let a=this.renderingRule&&p(this.serviceRasterInfo.attributeTable)?o?g:r:y;this.renderingRule||(a=o?g:r),this._updateFeatureWithRasterAttributeTableValues(f,a)}if(f.sourceLayer=f.layer=this,o&&this._updateFeatureWithDomainValues(f),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];f.attributes[t]=l[e]}h.push(u[t])}return h}_processMultidimensionalIntersection(e,t,i){const{multidimensionalSubset:r}=this;if(!r)return{isOutSide:!1,timeExtent:t,mosaicRule:i=this._combineMosaicRuleWithTimeExtent(i,t)};if(r){const{isOutside:i,intersection:s}=E(r,{geometry:e,timeExtent:t});if(i)return{isOutSide:!0,timeExtent:null,mosaicRule:null};s&&p(s.timeExtent)&&(t=s.timeExtent)}if(i=this._combineMosaicRuleWithTimeExtent(i,t),p(i)&&i.multidimensionalDefinition){const{isOutside:e}=E(r,{multidimensionalDefinition:i.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:i}}_updateFeatureWithRasterAttributeTableValues(e,t){const i=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(c(i))return;const{features:r,fields:s}=i,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),o=n&&n[0];if(!o)return;const a=r.filter((e=>e.attributes[o]===(null!=t?parseInt(t,10):null)));a&&a[0]&&s.forEach((t=>{const i=this._rasterAttributeTableFieldPrefix+t.name;e.attributes[i]=a[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const i=t.split(/,\s*/).map((e=>parseFloat(e))),r=i.map((e=>[e])),s=i.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new N({height:1,width:1,pixelType:"f32",pixels:r,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new ae(0,0,0,0,this.spatialReference)});const o="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:L([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=o[0],e.attributes["Raster.Direction"]=o[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const i=e.attributes[t.name];if(null!=i){const r=t.domain.codedValues.find((e=>e.code===i));r&&(e.attributes[t.name]=r.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const i=this.fieldsIndex;c(i)||e.forEach((e=>{if(e&&e.attributes)for(const r of t){const t=i.get(r)?.name;t&&t!==r&&(e.attributes[r]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(this._hasRenderingRule(e)){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRenderingRule(e){return null!=e&&null!=e.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const i=e.toLowerCase().replace(/ /gi,"_");return t.has(i)?t.get(i):e}_isRFTJson(e){return e&&e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:i,renderingRule:r}=this;r&&null==e.renderingRule&&(e.renderingRule=r),i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:i,advancedQueryCapabilities:r,maxRecordCount:s}=e,n=t.includes("image"),o="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit"),u=t.includes("mensuration")&&a,p=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map((e=>e.trim())),c=u&&p.includes("basic");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:u,supportsDownload:t.includes("download"),supportsQuery:t.includes("catalog")&&e.fields&&e.fields.length>0,supportsGetSamples:i>=10.2&&n,supportsProject:i>=10.3&&n,supportsComputeStatisticsHistograms:i>=10.4&&n,supportsQueryBoundary:i>=10.6&&n,supportsCalculateVolume:i>=10.7&&o,supportsComputePixelLocation:i>=10.7&&t.includes("catalog"),supportsComputeAngles:i>=10.91,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryTopFeatures:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!!r?.supportsStatistics,supportsOrderBy:!!r?.supportsOrderBy,supportsDistinct:!!r?.supportsDistinct,supportsPagination:!!r?.supportsPagination,supportsStandardizedQueriesOnly:!!r?.useStandardizedQueries,supportsPercentileStatistics:!!r?.supportsPercentileStatistics,supportsCentroid:!!r?.supportsReturningGeometryCentroid,supportsDistance:!!r?.supportsQueryWithDistance,supportsExtent:!!r?.supportsReturningQueryExtent,supportsGeometryProperties:!!r?.supportsReturningGeometryProperties,supportsHavingClause:!!r?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!r?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0},mensuration:{supportsDistanceAndAngle:c,supportsAreaAndPerimeter:c,supportsPointOrCentroid:c,supportsHeightFromBaseAndTop:u&&p.includes("base-top height"),supportsHeightFromBaseAndTopShadow:u&&p.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:u&&p.includes("top-top shadow height"),supports3D:u&&p.includes("3d")}}}};function b(e){return e?.path??""}return e([f()],g.prototype,"_functionRasterInfos",void 0),e([f()],g.prototype,"_rasterJobHandler",void 0),e([f()],g.prototype,"_cachedRendererJson",void 0),e([f({readOnly:!0})],g.prototype,"_serviceSupportsMosaicRule",void 0),e([S("_serviceSupportsMosaicRule",["currentVersion","fields"])],g.prototype,"readServiceSupportsMosaicRule",null),e([f()],g.prototype,"_rasterAttributeTableFieldPrefix",void 0),e([f({readOnly:!0})],g.prototype,"_rasterFunctionNamesIndex",null),e([f()],g.prototype,"adjustAspectRatio",void 0),e([f({type:[y],json:{write:!0}})],g.prototype,"bandIds",void 0),e([S("bandIds")],g.prototype,"readBandIds",null),e([f({readOnly:!0,json:{read:!1}})],g.prototype,"capabilities",void 0),e([S("service","capabilities",["capabilities","currentVersion","serviceDataType"])],g.prototype,"readCapabilities",null),e([f({type:Number})],g.prototype,"compressionQuality",void 0),e([x("compressionQuality")],g.prototype,"writeCompressionQuality",null),e([f({type:Number})],g.prototype,"compressionTolerance",void 0),e([x("compressionTolerance")],g.prototype,"writeCompressionTolerance",null),e([f({json:{read:{source:"copyrightText"}}})],g.prototype,"copyright",void 0),e([f({readOnly:!0,dependsOn:["_serviceSupportsMosaicRule"]})],g.prototype,"defaultMosaicRule",void 0),e([S("defaultMosaicRule",["defaultMosaicMethod"])],g.prototype,"readDefaultMosaicRule",null),e([f({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],g.prototype,"definitionExpression",void 0),e([f({readOnly:!0,constructOnly:!0})],g.prototype,"exportImageServiceParameters",void 0),e([f()],g.prototype,"rasterInfo",void 0),e([f({readOnly:!0,type:[D]})],g.prototype,"fields",void 0),e([f({readOnly:!0})],g.prototype,"fieldsIndex",null),e([f({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],g.prototype,"format",null),e([S("service","format",["serviceDataType"])],g.prototype,"readFormat",null),e([f({type:ae})],g.prototype,"fullExtent",void 0),e([f({readOnly:!0})],g.prototype,"hasMultidimensions",void 0),e([f({json:{read:{source:"maxImageHeight"}}})],g.prototype,"imageMaxHeight",void 0),e([f({json:{read:{source:"maxImageWidth"}}})],g.prototype,"imageMaxWidth",void 0),e([f({type:String,json:{type:C.jsonValues,read:C.read,write:C.write}})],g.prototype,"interpolation",void 0),e([f()],g.prototype,"minScale",void 0),e([S("service","minScale")],g.prototype,"readMinScale",null),e([f()],g.prototype,"maxScale",void 0),e([S("service","maxScale")],g.prototype,"readMaxScale",null),e([f({type:T})],g.prototype,"mosaicRule",null),e([S("mosaicRule",["mosaicRule","defaultMosaicMethod"])],g.prototype,"readMosaicRule",null),e([x("mosaicRule")],g.prototype,"writeMosaicRule",null),e([f()],g.prototype,"multidimensionalInfo",void 0),e([f({type:O,json:{write:!0}})],g.prototype,"multidimensionalSubset",void 0),e([f({json:{type:y}})],g.prototype,"noData",void 0),e([x("noData")],g.prototype,"writeNoData",null),e([f({type:String,json:{type:M.jsonValues,read:M.read,write:M.write}})],g.prototype,"noDataInterpretation",void 0),e([f({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],g.prototype,"objectIdField",void 0),e([S("objectIdField")],g.prototype,"readObjectIdField",null),e([f({})],g.prototype,"geometryType",void 0),e([f({})],g.prototype,"typeIdField",void 0),e([f({})],g.prototype,"types",void 0),e([f({readOnly:!0})],g.prototype,"parsedUrl",null),e([f({type:Function})],g.prototype,"pixelFilter",void 0),e([f()],g.prototype,"raster",void 0),e([f({readOnly:!0})],g.prototype,"sourceType",void 0),e([S("sourceType",["serviceSourceType","fields"])],g.prototype,"readSourceType",null),e([f()],g.prototype,"viewId",void 0),e([f({types:i,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:r,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],g.prototype,"renderer",null),e([S("renderer")],g.prototype,"readRenderer",null),e([x("renderer")],g.prototype,"writeRenderer",null),e([f()],g.prototype,"symbolizer",void 0),e([f(I)],g.prototype,"opacity",void 0),e([f({readOnly:!0})],g.prototype,"rasterFields",null),e([f({constructOnly:!0})],g.prototype,"rasterFunctionInfos",void 0),e([f({type:A})],g.prototype,"renderingRule",null),e([S("renderingRule",["renderingRule","rasterFunctionInfos"])],g.prototype,"readRenderingRule",null),e([x("renderingRule")],g.prototype,"writeRenderingRule",null),e([f()],g.prototype,"serviceDataType",void 0),e([f({readOnly:!0,type:Fe})],g.prototype,"spatialReference",void 0),e([S("spatialReference",["spatialReference","extent"])],g.prototype,"readSpatialReference",null),e([f({json:{type:De.jsonValues}})],g.prototype,"pixelType",void 0),e([S("pixelType")],g.prototype,"readPixelType",null),e([x("pixelType")],g.prototype,"writePixelType",null),e([f({constructOnly:!0,type:J})],g.prototype,"serviceRasterInfo",void 0),e([f()],g.prototype,"sourceJSON",void 0),e([f(w)],g.prototype,"url",void 0),e([f({readOnly:!0})],g.prototype,"version",void 0),e([S("version",["currentVersion","fields","timeInfo"])],g.prototype,"readVersion",null),g=e([v("esri.layers.mixins.ArcGISImageService")],g),g};export{Oe as ArcGISImageService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{rasterRendererTypes as e}from"../../rasterRenderers.js";import r from"../../request.js";import i from"../../core/Error.js";import n from"../../core/Logger.js";import{isNone as s,isSome as o}from"../../core/maybe.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{getInfo as u}from"../../geometry/support/spatialReferenceUtils.js";import{sanitizeUrl as m}from"../support/arcgisLayerUrl.js";import{url as d}from"../support/commonProperties.js";import c from"../support/DimensionalDefinition.js";import h from"../support/MultidimensionalSubset.js";import p from"../support/RasterFunction.js";import f from"../support/RasterJobHandler.js";import b from"../support/TileInfo.js";import y from"../support/rasterDatasets/FunctionRaster.js";import{getDefaultMultidimensionalDefinition as g,hasExcludedVariableOrDimension as I,getDefaultVariablInfo as J,isMultiSliceOrRangeDefinition as _,getSubsetVariablesFromMdInfo as R}from"../support/rasterDatasets/multidimensionalUtils.js";import{create as S}from"../support/rasterFunctions/rasterFunctionHelper.js";import{convertVectorFieldData as F}from"../support/rasterFunctions/vectorFieldUtils.js";import{normalizeRendererJSON as x,getVariableRasterInfo as v,getDefaultInterpolation as D,getDefaultBandCombination as j,createDefaultRenderer as H}from"../../renderers/support/rasterRendererHelper.js";import T from"../../renderers/support/RasterSymbolizer.js";import{createFlowMesh as w}from"../../views/2d/engine/flow/dataUtils.js";import N from"../../geometry/SpatialReference.js";const z=n.getLogger("esri.layers.mixins.ImageryTileMixin"),O=n=>{let O=class extends n{constructor(){super(...arguments),this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.interpolation="nearest",this.multidimensionalSubset=null,this.raster=null,this.rasterFunction=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null}get fullExtent(){return this.rasterInfo?.extent}set multidimensionalDefinition(t){this._set("multidimensionalDefinition",t),this.updateRenderer()}get tileInfo(){return this.rasterInfo?.storageInfo.tileInfo}set url(t){this._set("url",m(t,z))}set renderer(t){this._set("renderer",t),this.updateRenderer()}async convertVectorFieldData(t,e){if(s(t)||!this.rasterInfo)return null;const r=this._rasterJobHandler.instance,i=this.rasterInfo.dataType;return r?r.convertVectorFieldData({pixelBlock:t,dataType:i},e):F(t,i)}async createFlowMesh(t,e){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(t,e):w(t.meshType,t.simulationSettings,t.flowData,o(e.signal)?e.signal:(new AbortController).signal)}normalizeRasterFetchOptions(t){const{multidimensionalInfo:e}=this.rasterInfo??{};if(s(e))return t;let r=t.multidimensionalDefinition||this.multidimensionalDefinition;!s(r)&&r.length||(r=g(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const i=t.timeExtent||this.timeExtent;if(o(r)&&o(i)&&(o(i.start)||o(i.end))){r=r.map((t=>t.clone()));const n=e.variables.find((({name:t})=>t===r[0].variableName))?.dimensions?.find((({name:t})=>"StdTime"===t)),a=r.find((({dimensionName:t})=>"StdTime"===t));if(!n||!a)return{...t,multidimensionalDefinition:null};const{start:l,end:u}=i,m=s(l)?null:l.getTime(),d=s(u)?null:u.getTime(),c=m??d,h=d??m;if(o(n.values)){const t=n.values.filter((t=>{if(Array.isArray(t)){if(c===h)return t[0]<=c&&t[1]>=c;const e=t[0]<=c&&t[1]>c||t[0]<h&&t[1]>=h,r=t[0]>=c&&t[1]<=h||t[0]<c&&t[1]>h;return e||r}return c===h?t===c:t>=c&&t<=h}));if(t.length){const e=t.sort(((t,e)=>{if(c===h)return(t[0]??t)-(e[0]??e);return Math.abs((t[1]??t)-h)-Math.abs((e[1]??e)-h)}))[0];a.values=[e]}else r=null}else if(n.hasRegularIntervals&&n.extent){const[t,e]=n.extent;c>e||h<t?r=null:a.values=c===h?[c]:[Math.max(t,c),Math.min(e,h)]}}return o(r)&&I(r,this.multidimensionalSubset)?{...t,multidimensionalDefinition:null}:{...t,multidimensionalDefinition:r}}async updateRasterFunction(){if("imagery-tile"!==this.type||JSON.stringify(this.rasterFunction)===JSON.stringify(this._cachedRasterFunctionJson))return;let t=this.raster;const{bandCount:e}=t.rasterInfo;if("Function"===t.datasetFormat){const e=t.rasterFunction.getPrimaryRasters();t=e.rasters[0]}const{rasterFunction:r}=this;let i=!1;if(r){const e=S(r.rasterFunctionDefinition??r.toJSON(),{raster:t}),i=new y({rasterFunction:e});i.rasterJobHandler=this._rasterJobHandler.instance,await i.open(),this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this.raster=i}else i="Function"===this.raster?.datasetFormat,this.raster=t,this._cachedRasterFunctionJson=null;this._cachedRendererJson=null;const{bandCount:n}=this.raster.rasterInfo,{bandIds:s}=this;(s?.length?s.some((t=>t>=n))||1===s.length&&e>=3!=n>=3:n>=3)?(this._set("bandIds",null),this._configDefaultRenderer("auto")):i&&this._configDefaultRenderer("auto")}async updateRenderer(){const{loaded:t,symbolizer:e}=this;if(!t||!e)return;const{rasterInfo:r}=this.raster,i=J(r,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset})?.name,n=x({...this.renderer.toJSON(),variableName:i});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(n))return;const s=this._rasterJobHandler.instance;s&&(e.rasterInfo=v(r,i),e.rendererJSON=n,e.bind(),await s.updateSymbolizer(e),this._cachedRendererJson=n)}async applyRenderer(t,e){const r=t&&t.pixelBlock;if(!(o(r)&&r.pixels&&r.pixels.length>0))return null;let i;await this.updateRenderer();const n=this._rasterJobHandler.instance,s=this.bandIds??[];return i=n?await n.symbolize({...t,simpleStretchParams:e,bandIds:s}):this.symbolizer.symbolize({...t,simpleStretchParams:e,bandIds:s}),i}getTileUrl(t,e,r){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${t}/${e}/${r}`:""}getCompatibleTileInfo(t,e,r=!1){if(!this.loaded||s(e))return null;if(r&&t.equals(this.spatialReference))return this.tileInfo;const i=u(t);return b.create({size:256,spatialReference:t,origin:i?{x:i.origin[0],y:i.origin[1]}:{x:e.xmin,y:e.ymax}})}getCompatibleFullExtent(t){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(t)||(this._compatibleFullExtent=this.raster.computeExtent(t)),this._compatibleFullExtent):null}async fetchTile(t,e,i,n={}){if(E(this),n.requestAsImageElement){const s=this.getTileUrl(t,e,i);return r(s,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:n.signal}).then((t=>t.data))}const{rasterInfo:a}=this;if(o(a.multidimensionalInfo)&&(n=this.normalizeRasterFetchOptions(n),s(n.multidimensionalDefinition))){const r=n.tileInfo||a.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(t,e,i,r),pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer.type&&(n={...n,buffer:{cols:1,rows:1}}),this.raster.fetchTile(t,e,i,n)}async fetchPixels(t,e,r,i={}){return o(this.rasterInfo.multidimensionalInfo)&&(i=this.normalizeRasterFetchOptions(i),s(i.multidimensionalDefinition))?{extent:t,pixelBlock:null}:(await this._initJobHandler(),await this.updateRasterFunction(),this.raster.fetchPixels(t,e,r,i))}async identify(t,e={}){const{raster:r,rasterInfo:i}=this;if(o(i.multidimensionalInfo)){if(!(i.hasMultidimensionalTranspose&&!!(_(e.multidimensionalDefinition)||e.transposedVariableName||e.timeExtent))&&(e=this.normalizeRasterFetchOptions(e),s(e.multidimensionalDefinition)))return{location:t,value:null}}return r.identify(t,e)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){const t=this.rasterInfo?.multidimensionalInfo;if(s(t)||"standard-time"!==this.rasterInfo?.dataType)return!1;const e=this.multidimensionalDefinition,r=e?.[0]?.variableName;return t.variables.some((t=>t.name===r&&(!e?.[0].dimensionName||t.dimensions.some((t=>"StdTime"===t.name)))))}getStandardTimeValue(t){return new Date(24*(t-25569)*3600*1e3).toString()}getMultidimensionalSubsetVariables(t){const e=t??this.rasterInfo?.multidimensionalInfo;return R(this.multidimensionalSubset,e)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=g(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const t=new f;return this._rasterJobHandler.connectionPromise=t.initialize().then((()=>{E(this),this._rasterJobHandler.instance=t,this.raster.rasterJobHandler=t,this.renderer&&this.updateRenderer(),"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler()})).catch((()=>{})),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null,this.raster&&(this.raster.rasterJobHandler=null)}_configDefaultInterpolation(){if(null==this.interpolation){E(this);const{raster:t}=this,e=D(t.rasterInfo,t.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",e)}}_configDefaultRenderer(t="no"){E(this);const{rasterInfo:e}=this.raster;this.bandIds||(this.bandIds=j(e));const r=J(e,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset})?.name;if(!this.renderer||"override"===t){const t=H(e,{bandIds:this.bandIds,variableName:r});"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===t.type&&((e.statistics?.[0].max??0)>1e24||(e.statistics?.[0].min??0)<-1e24)&&(t.dynamicRangeAdjustment=!0,t.statistics=null,"none"===t.stretchType&&(t.stretchType="min-max")),this.renderer=t}const i=x({...this.renderer.toJSON(),variableName:r}),n=v(e,r);this.symbolizer?(this.symbolizer.rendererJSON=i,this.symbolizer.rasterInfo=n):this.symbolizer=new T({rendererJSON:i,rasterInfo:n});const s=this.symbolizer.bind();s.success||(z.warn("imagery-tile-mixin",s.error||"The given renderer is not supported by the layer."),"auto"===t&&this._configDefaultRenderer("override"))}};function E(t){if(!t.raster||!t.rasterInfo)throw new i("imagery-tile","no raster")}return t([a()],O.prototype,"_cachedRendererJson",void 0),t([a()],O.prototype,"_cachedRasterFunctionJson",void 0),t([a()],O.prototype,"_compatibleFullExtent",void 0),t([a()],O.prototype,"_rasterJobHandler",void 0),t([a()],O.prototype,"bandIds",void 0),t([a({json:{origins:{service:{read:{source:"copyrightText"}}}}})],O.prototype,"copyright",void 0),t([a({json:{read:!1}})],O.prototype,"fullExtent",null),t([a()],O.prototype,"interpolation",void 0),t([a()],O.prototype,"ioConfig",void 0),t([a({type:[c],json:{write:!0}})],O.prototype,"multidimensionalDefinition",null),t([a({type:h,json:{write:!0}})],O.prototype,"multidimensionalSubset",void 0),t([a()],O.prototype,"raster",void 0),t([a({type:p})],O.prototype,"rasterFunction",void 0),t([a()],O.prototype,"rasterInfo",void 0),t([a()],O.prototype,"sourceJSON",void 0),t([a({readOnly:!0,type:N,json:{read:!1}})],O.prototype,"spatialReference",void 0),t([a({json:{read:!1}})],O.prototype,"tileInfo",null),t([a(d)],O.prototype,"url",null),t([a({types:e})],O.prototype,"renderer",null),t([a()],O.prototype,"symbolizer",void 0),O=t([l("esri.layers.ImageryTileMixin")],O),O};export{O as ImageryTileMixin};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{rasterRendererTypes as e}from"../../rasterRenderers.js";import i from"../../request.js";import r from"../../core/Error.js";import n from"../../core/Logger.js";import{isNone as s,isSome as o}from"../../core/maybe.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{subclass as l}from"../../core/accessorSupport/decorators/subclass.js";import{getInfo as u}from"../../geometry/support/spatialReferenceUtils.js";import{sanitizeUrl as m}from"../support/arcgisLayerUrl.js";import{url as d}from"../support/commonProperties.js";import c from"../support/DimensionalDefinition.js";import h from"../support/MultidimensionalSubset.js";import p from"../support/RasterFunction.js";import f from"../support/RasterJobHandler.js";import b from"../support/TileInfo.js";import y from"../support/rasterDatasets/FunctionRaster.js";import{getDefaultMultidimensionalDefinition as g,hasExcludedVariableOrDimension as I,getDefaultVariablInfo as J,isMultiSliceOrRangeDefinition as _,getSubsetVariablesFromMdInfo as S}from"../support/rasterDatasets/multidimensionalUtils.js";import{create as R}from"../support/rasterFunctions/rasterFunctionHelper.js";import{convertVectorFieldData as F}from"../support/rasterFunctions/vectorFieldUtils.js";import{normalizeRendererJSON as x,getVariableRasterInfo as v,getDefaultInterpolation as D,getDefaultBandCombination as j,createDefaultRenderer as H}from"../../renderers/support/rasterRendererHelper.js";import T from"../../renderers/support/RasterSymbolizer.js";import{createFlowMesh as w}from"../../views/2d/engine/flow/dataUtils.js";import N from"../../geometry/SpatialReference.js";const O=n.getLogger("esri.layers.mixins.ImageryTileMixin"),z=n=>{let z=class extends n{constructor(){super(...arguments),this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.interpolation="nearest",this.multidimensionalSubset=null,this.raster=null,this.rasterFunction=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null}get fullExtent(){return this.rasterInfo?.extent}set multidimensionalDefinition(t){this._set("multidimensionalDefinition",t),this.updateRenderer()}get tileInfo(){return this.rasterInfo?.storageInfo.tileInfo}set url(t){this._set("url",m(t,O))}set renderer(t){this._set("renderer",t),this.updateRenderer()}async convertVectorFieldData(t,e){if(s(t)||!this.rasterInfo)return null;const i=this._rasterJobHandler.instance,r=this.rasterInfo.dataType;return i?i.convertVectorFieldData({pixelBlock:t,dataType:r},e):F(t,r)}async createFlowMesh(t,e){const i=this._rasterJobHandler.instance;return i?i.createFlowMesh(t,e):w(t.meshType,t.simulationSettings,t.flowData,o(e.signal)?e.signal:(new AbortController).signal)}normalizeRasterFetchOptions(t){const{multidimensionalInfo:e}=this.rasterInfo??{};if(s(e))return t;let i=t.multidimensionalDefinition||this.multidimensionalDefinition;!s(i)&&i.length||(i=g(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const r=t.timeExtent||this.timeExtent;if(o(i)&&o(r)&&(o(r.start)||o(r.end))){i=i.map((t=>t.clone()));const n=e.variables.find((({name:t})=>t===i[0].variableName))?.dimensions?.find((({name:t})=>"StdTime"===t)),a=i.find((({dimensionName:t})=>"StdTime"===t));if(!n||!a)return{...t,multidimensionalDefinition:null};const{start:l,end:u}=r,m=s(l)?null:l.getTime(),d=s(u)?null:u.getTime(),c=m??d,h=d??m;if(o(n.values)){const t=n.values.filter((t=>{if(Array.isArray(t)){if(c===h)return t[0]<=c&&t[1]>=c;const e=t[0]<=c&&t[1]>c||t[0]<h&&t[1]>=h,i=t[0]>=c&&t[1]<=h||t[0]<c&&t[1]>h;return e||i}return c===h?t===c:t>=c&&t<=h}));if(t.length){const e=t.sort(((t,e)=>{if(c===h)return(t[0]??t)-(e[0]??e);return Math.abs((t[1]??t)-h)-Math.abs((e[1]??e)-h)}))[0];a.values=[e]}else i=null}else if(n.hasRegularIntervals&&n.extent){const[t,e]=n.extent;c>e||h<t?i=null:a.values=c===h?[c]:[Math.max(t,c),Math.min(e,h)]}}return o(i)&&I(i,this.multidimensionalSubset)?{...t,multidimensionalDefinition:null}:{...t,multidimensionalDefinition:i}}async updateRasterFunction(){if("imagery-tile"!==this.type||JSON.stringify(this.rasterFunction)===JSON.stringify(this._cachedRasterFunctionJson))return;let t=this.raster;const{bandCount:e}=t.rasterInfo;if("Function"===t.datasetFormat){const e=t.rasterFunction.getPrimaryRasters();t=e.rasters[0]}const{rasterFunction:i}=this;let r=!1;if(i){const e=R(i.rasterFunctionDefinition??i.toJSON(),{raster:t}),r=new y({rasterFunction:e});r.rasterJobHandler=this._rasterJobHandler.instance,await r.open(),this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this.raster=r}else r="Function"===this.raster?.datasetFormat,this.raster=t,this._cachedRasterFunctionJson=null;this._cachedRendererJson=null;const{bandCount:n}=this.raster.rasterInfo,{bandIds:s}=this;(s?.length?s.some((t=>t>=n))||1===s.length&&e>=3!=n>=3:n>=3)?(this._set("bandIds",null),this._configDefaultRenderer("auto")):r&&this._configDefaultRenderer("auto")}async updateRenderer(){const{loaded:t,symbolizer:e}=this;if(!t||!e)return;const{rasterInfo:i}=this.raster,r=J(i,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset})?.name,n=x({...this.renderer.toJSON(),variableName:r});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(n))return;const s=this._rasterJobHandler.instance;s&&(e.rasterInfo=v(i,r),e.rendererJSON=n,e.bind(),await s.updateSymbolizer(e),this._cachedRendererJson=n)}async applyRenderer(t,e){const i=t&&t.pixelBlock;if(!(o(i)&&i.pixels&&i.pixels.length>0))return null;let r;await this.updateRenderer();const n=this._rasterJobHandler.instance,s=this.bandIds??[];return r=n?await n.symbolize({...t,simpleStretchParams:e,bandIds:s}):this.symbolizer.symbolize({...t,simpleStretchParams:e,bandIds:s}),r}getTileUrl(t,e,i){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${t}/${e}/${i}`:""}getCompatibleTileInfo(t,e,i=!1){if(!this.loaded||s(e))return null;if(i&&t.equals(this.spatialReference))return this.tileInfo;const r=u(t);return b.create({size:256,spatialReference:t,origin:r?{x:r.origin[0],y:r.origin[1]}:{x:e.xmin,y:e.ymax}})}getCompatibleFullExtent(t){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(t)||(this._compatibleFullExtent=this.raster.computeExtent(t)),this._compatibleFullExtent):null}async fetchTile(t,e,r,n={}){if(E(this),n.requestAsImageElement){const s=this.getTileUrl(t,e,r);return i(s,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:n.signal}).then((t=>t.data))}const{rasterInfo:a}=this;if(o(a.multidimensionalInfo)&&(n=this.normalizeRasterFetchOptions(n),s(n.multidimensionalDefinition))){const i=n.tileInfo||a.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(t,e,r,i),pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer.type&&(n={...n,buffer:{cols:1,rows:1}}),this.raster.fetchTile(t,e,r,n)}async fetchPixels(t,e,i,r={}){return o(this.rasterInfo.multidimensionalInfo)&&(r=this.normalizeRasterFetchOptions(r),s(r.multidimensionalDefinition))?{extent:t,pixelBlock:null}:(await this._initJobHandler(),await this.updateRasterFunction(),this.raster.fetchPixels(t,e,i,r))}async identify(t,e={}){const{raster:i,rasterInfo:n}=this;if(o(n.multidimensionalInfo)){if(!(n.hasMultidimensionalTranspose&&!!(_(e.multidimensionalDefinition)||e.transposedVariableName||e.timeExtent))&&(e=this.normalizeRasterFetchOptions(e),s(e.multidimensionalDefinition)))return{location:t,value:null}}const a=this.multidimensionalSubset?.areaOfInterest;if(a&&!a.contains(t))throw new r("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");return i.identify(t,e)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){const t=this.rasterInfo?.multidimensionalInfo;if(s(t)||"standard-time"!==this.rasterInfo?.dataType)return!1;const e=this.multidimensionalDefinition,i=e?.[0]?.variableName;return t.variables.some((t=>t.name===i&&(!e?.[0].dimensionName||t.dimensions.some((t=>"StdTime"===t.name)))))}getStandardTimeValue(t){return new Date(24*(t-25569)*3600*1e3).toString()}getMultidimensionalSubsetVariables(t){const e=t??this.rasterInfo?.multidimensionalInfo;return S(this.multidimensionalSubset,e)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=g(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const t=new f;return this._rasterJobHandler.connectionPromise=t.initialize().then((()=>{E(this),this._rasterJobHandler.instance=t,this.raster.rasterJobHandler=t,this.renderer&&this.updateRenderer(),"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler()})).catch((()=>{})),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null,this.raster&&(this.raster.rasterJobHandler=null)}_configDefaultInterpolation(){if(null==this.interpolation){E(this);const{raster:t}=this,e=D(t.rasterInfo,t.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",e)}}_configDefaultRenderer(t="no"){E(this);const{rasterInfo:e}=this.raster;this.bandIds||(this.bandIds=j(e));const i=J(e,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset})?.name;if(!this.renderer||"override"===t){const t=H(e,{bandIds:this.bandIds,variableName:i});"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===t.type&&((e.statistics?.[0].max??0)>1e24||(e.statistics?.[0].min??0)<-1e24)&&(t.dynamicRangeAdjustment=!0,t.statistics=null,"none"===t.stretchType&&(t.stretchType="min-max")),this.renderer=t}const r=x({...this.renderer.toJSON(),variableName:i}),n=v(e,i);this.symbolizer?(this.symbolizer.rendererJSON=r,this.symbolizer.rasterInfo=n):this.symbolizer=new T({rendererJSON:r,rasterInfo:n});const s=this.symbolizer.bind();s.success||(O.warn("imagery-tile-mixin",s.error||"The given renderer is not supported by the layer."),"auto"===t&&this._configDefaultRenderer("override"))}};function E(t){if(!t.raster||!t.rasterInfo)throw new r("imagery-tile","no raster")}return t([a()],z.prototype,"_cachedRendererJson",void 0),t([a()],z.prototype,"_cachedRasterFunctionJson",void 0),t([a()],z.prototype,"_compatibleFullExtent",void 0),t([a()],z.prototype,"_rasterJobHandler",void 0),t([a()],z.prototype,"bandIds",void 0),t([a({json:{origins:{service:{read:{source:"copyrightText"}}}}})],z.prototype,"copyright",void 0),t([a({json:{read:!1}})],z.prototype,"fullExtent",null),t([a()],z.prototype,"interpolation",void 0),t([a()],z.prototype,"ioConfig",void 0),t([a({type:[c],json:{write:!0}})],z.prototype,"multidimensionalDefinition",null),t([a({type:h,json:{write:!0}})],z.prototype,"multidimensionalSubset",void 0),t([a()],z.prototype,"raster",void 0),t([a({type:p})],z.prototype,"rasterFunction",void 0),t([a()],z.prototype,"rasterInfo",void 0),t([a()],z.prototype,"sourceJSON",void 0),t([a({readOnly:!0,type:N,json:{read:!1}})],z.prototype,"spatialReference",void 0),t([a({json:{read:!1}})],z.prototype,"tileInfo",null),t([a(d)],z.prototype,"url",null),t([a({types:e})],z.prototype,"renderer",null),t([a()],z.prototype,"symbolizer",void 0),z=t([l("esri.layers.ImageryTileMixin")],z),z};export{z as ImageryTileMixin};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import r from"../../core/Error.js";import"../../core/has.js";import o from"../../core/Logger.js";import{isSome as i}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{urlToObject as a}from"../../core/urlUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{reader as l}from"../../core/accessorSupport/decorators/reader.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{writer as c}from"../../core/accessorSupport/decorators/writer.js";import{updateOrigins as d}from"../../core/accessorSupport/originUtils.js";import u from"../../geometry/Extent.js";import m from"../../geometry/HeightModelInfo.js";import h from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as y,parse as f,cleanTitle as v,sanitizeUrlWithLayerId as S,writeUrlWithLayerId as g}from"../support/arcgisLayerUrl.js";import{id as w,url as I}from"../support/commonProperties.js";import{fetchIndexInfo as x}from"../support/I3SIndexInfo.js";import b from"../../portal/Portal.js";import j from"../../portal/PortalItem.js";import{saveResources as _}from"../../webdoc/support/saveUtils.js";const R="esri.layers.mixins.SceneService",A=o.getLogger(R),N=o=>{let N=class extends o{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.indexInfo=null,this._debouncedSaveOperations=s((async(e,t,r)=>{switch(e){case L.SAVE:return this._save(t);case L.SAVE_AS:return this._saveAs(r,t)}}))}readSpatialReference(e,t){return this._readSpatialReference(t)}_readSpatialReference(e){if(null!=e.spatialReference)return h.fromJSON(e.spatialReference);{const t=e.store,r=t.indexCRS||t.geographicCRS,o=r&&parseInt(r.substring(r.lastIndexOf("/")+1,r.length),10);return null!=o?new h(o):null}}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const o=null==e.spatialReference?{...e,spatialReference:this._readSpatialReference(t)}:e;return u.fromJSON(o,r)}const o=t.store,i=this._readSpatialReference(t);return null==i||null==o||null==o.extent||!Array.isArray(o.extent)||o.extent.some((e=>e<E))?null:new u({xmin:o.extent[0],ymin:o.extent[1],xmax:o.extent[2],ymax:o.extent[3],spatialReference:i})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,o=null!=r.version?r.version.toString():"";return this.parseVersionString(o)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){const r=this.portalItem&&this.portalItem.title;if("item-title"===this.sublayerTitleMode)return y(this.url,t.name);let o=t.name;if(!o&&this.url){const e=f(this.url);i(e)&&(o=e.title)}return"item-title-and-service-name"===this.sublayerTitleMode&&r&&(o=r+" - "+o),v(o)}set url(e){const t=S({layer:this,url:e,nonStandardUrlAllowed:!1,logger:A});this._set("url",t.url),null!=t.layerId&&this._set("layerId",t.layerId)}writeUrl(e,t,r,o){g(this,e,"layers",t,o)}get parsedUrl(){const e=this._get("url"),t=a(e);return null!=this.layerId&&(t.path=`${t.path}/layers/${this.layerId}`),t}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=x(this.parsedUrl.path,this.rootNode,e,this.apiKey,A,t),null==this.fullExtent||this.fullExtent.hasZ||this._updateExtent(await this.indexInfo)}_updateExtent(e){if("page"===e?.type){const t=e.rootIndex%e.pageSize,o=e.rootPage?.nodes?.[t];if(null==o||null==o.obb||null==o.obb.center||null==o.obb.halfSize)throw new r("sceneservice:invalid-node-page","Invalid node page.");if(o.obb.center[0]<E||null==this.fullExtent||this.fullExtent.hasZ)return;const i=o.obb.halfSize,s=o.obb.center[2],a=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);this.fullExtent.zmin=s-a,this.fullExtent.zmax=s+a}else if("node"===e?.type){const t=e.rootNode?.mbs;if(!Array.isArray(t)||4!==t.length||t[0]<E)return;const r=t[2],o=t[3],{fullExtent:i}=this;i&&(i.zmin=r-o,i.zmax=r+o)}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url,{query:{f:"json",token:this.apiKey},responseType:"json",signal:e});if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",token:this.apiKey},responseType:"json",signal:e});r.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));let o=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(o=!0),o)return this._fetchVoxelServiceLayer();const i=r.data;this.read(i,this._getServiceContext()),this.validateLayer(i)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}_updateTypeKeywords(e,t,r){e.typeKeywords||(e.typeKeywords=[]);const o=t.getTypeKeywords();for(const i of o)e.typeKeywords.push(i);e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)),r===T.newItem&&(e.typeKeywords=e.typeKeywords.filter((e=>"Hosted Service"!==e))))}async _saveAs(e,t){const o={...K,...t};let i=j.from(e);i||(A.error("_saveAs(): requires a portal item parameter"),await Promise.reject(new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to"))),i.id&&(i=i.clone(),i.id=null);const s=i.portal||b.getDefault();await this._ensureLoadBeforeSave(),i.type=O,i.portal=s;const a={origin:"portal-item",url:null,messages:[],portal:s,portalItem:i,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},n={layers:[this.write({},a)]};return await Promise.all(a.resources?.pendingOperations??[]),await this._validateAgainstJSONSchema(n,a,o),i.url=this.url,i.title||(i.title=this.title),this._updateTypeKeywords(i,o,T.newItem),await s.signIn(),await(s.user?.addItem({item:i,folder:o&&o.folder,data:n})),await _(this.resourceReferences,a,null),this.portalItem=i,d(a),a.portalItem=i,i}async _save(e){const t={...K,...e};if(!this.portalItem)throw A.error("_save(): requires the .portalItem property to be set"),new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==O)throw A.error("_save(): Non-matching portal item type. Got "+this.portalItem.type+", expected "+O),new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type "${O}"`);await this._ensureLoadBeforeSave();const o={origin:"portal-item",url:this.portalItem.itemUrl&&a(this.portalItem.itemUrl),messages:[],portal:this.portalItem.portal||b.getDefault(),portalItem:this.portalItem,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],pendingOperations:[]}},i={layers:[this.write({},o)]};return await Promise.all(o.resources?.pendingOperations??[]),await this._validateAgainstJSONSchema(i,o,t),this.portalItem.url=this.url,this.portalItem.title||(this.portalItem.title=this.title),this._updateTypeKeywords(this.portalItem,t,T.existingItem),await this.portalItem.update({data:i}),await _(this.resourceReferences,o,null),d(o),this.portalItem}async _validateAgainstJSONSchema(e,t,o){let i=t.messages?.filter((e=>"error"===e.type)).map((e=>new r(e.name,e.message,e.details)))??[];if(o&&o.validationOptions?.ignoreUnsupported&&(i=i.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name&&"scenemodification:unsupported"!==e.name))),o.validationOptions?.enabled||U){const t=(await import("../support/schemaValidator.js")).validate(e,o.portalItemLayerType);if(t.length>0){const e=`Layer item did not validate:\n${t.join("\n")}`;if(A.error(`_validateAgainstJSONSchema(): ${e}`),"throw"===o.validationOptions?.failPolicy){const e=t.map((e=>new r("sceneservice:schema-validation",e))).concat(i);throw new r("sceneservice-validate:error","Failed to save layer item due to schema validation, see `details.errors`.",{combined:e})}}}if(i.length>0)throw new r("sceneservice:save","Failed to save SceneService due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:i})}};return e([n(w)],N.prototype,"id",void 0),e([n({type:h})],N.prototype,"spatialReference",void 0),e([l("spatialReference",["spatialReference","store.indexCRS","store.geographicCRS"])],N.prototype,"readSpatialReference",null),e([n({type:u})],N.prototype,"fullExtent",void 0),e([l("fullExtent",["fullExtent","store.extent","spatialReference","store.indexCRS","store.geographicCRS"])],N.prototype,"readFullExtent",null),e([n({readOnly:!0,type:m})],N.prototype,"heightModelInfo",void 0),e([n({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:{source:"minScale"},write:!1}}}})],N.prototype,"minScale",void 0),e([n({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:{source:"maxScale"},write:!1}}}})],N.prototype,"maxScale",void 0),e([n({readOnly:!0})],N.prototype,"version",void 0),e([l("version",["store.version"])],N.prototype,"readVersion",null),e([n({type:String,json:{read:{source:"copyrightText"}}})],N.prototype,"copyright",void 0),e([n({type:String,json:{read:!1}})],N.prototype,"sublayerTitleMode",void 0),e([n({type:String})],N.prototype,"title",void 0),e([l("portal-item","title")],N.prototype,"readTitlePortalItem",null),e([l("service","title",["name"])],N.prototype,"readTitleService",null),e([n({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{write:{target:"id",isRequired:!0,ignoreOrigin:!0},read:!1}}}})],N.prototype,"layerId",void 0),e([n(I)],N.prototype,"url",null),e([c("url")],N.prototype,"writeUrl",null),e([n()],N.prototype,"parsedUrl",null),e([n({readOnly:!0})],N.prototype,"store",void 0),e([n({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],N.prototype,"rootNode",void 0),N=e([p(R)],N),N},E=-1e38,U=!1;var T;!function(e){e[e.existingItem=0]="existingItem",e[e.newItem=1]="newItem"}(T||(T={}));const O="Scene Service",K={getTypeKeywords:()=>[],portalItemLayerType:"unknown",validationOptions:{enabled:!0,ignoreUnsupported:!1,failPolicy:"throw"}};var L;!function(e){e[e.SAVE=0]="SAVE",e[e.SAVE_AS=1]="SAVE_AS"}(L||(L={}));export{O as SCENE_SERVICE_ITEM_TYPE,L as SaveOperationType,N as SceneService};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../request.js";import r from"../../core/Error.js";import"../../core/has.js";import o from"../../core/Logger.js";import{isSome as i}from"../../core/maybe.js";import{debounce as s}from"../../core/promiseUtils.js";import{urlToObject as a}from"../../core/urlUtils.js";import{property as n}from"../../core/accessorSupport/decorators/property.js";import"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import{reader as l}from"../../core/accessorSupport/decorators/reader.js";import{subclass as p}from"../../core/accessorSupport/decorators/subclass.js";import{writer as d}from"../../core/accessorSupport/decorators/writer.js";import{updateOrigins as c}from"../../core/accessorSupport/originUtils.js";import u from"../../geometry/Extent.js";import m from"../../geometry/HeightModelInfo.js";import y from"../../geometry/SpatialReference.js";import{titleFromUrlAndName as h,parse as f,cleanTitle as v,sanitizeUrlWithLayerId as S,writeUrlWithLayerId as g}from"../support/arcgisLayerUrl.js";import{id as w,url as I}from"../support/commonProperties.js";import{fetchIndexInfo as x}from"../support/I3SIndexInfo.js";import b from"../../portal/Portal.js";import j from"../../portal/PortalItem.js";import{saveResources as _}from"../../webdoc/support/saveUtils.js";const R="esri.layers.mixins.SceneService",A=o.getLogger(R),N=o=>{let N=class extends o{constructor(){super(...arguments),this.spatialReference=null,this.fullExtent=null,this.heightModelInfo=null,this.minScale=0,this.maxScale=0,this.version={major:Number.NaN,minor:Number.NaN,versionString:""},this.copyright=null,this.sublayerTitleMode="item-title",this.title=null,this.layerId=null,this.indexInfo=null,this._debouncedSaveOperations=s((async(e,t,r)=>{switch(e){case L.SAVE:return this._save(t);case L.SAVE_AS:return this._saveAs(r,t)}}))}readSpatialReference(e,t){return this._readSpatialReference(t)}_readSpatialReference(e){if(null!=e.spatialReference)return y.fromJSON(e.spatialReference);{const t=e.store,r=t.indexCRS||t.geographicCRS,o=r&&parseInt(r.substring(r.lastIndexOf("/")+1,r.length),10);return null!=o?new y(o):null}}readFullExtent(e,t,r){if(null!=e&&"object"==typeof e){const o=null==e.spatialReference?{...e,spatialReference:this._readSpatialReference(t)}:e;return u.fromJSON(o,r)}const o=t.store,i=this._readSpatialReference(t);return null==i||null==o||null==o.extent||!Array.isArray(o.extent)||o.extent.some((e=>e<E))?null:new u({xmin:o.extent[0],ymin:o.extent[1],xmax:o.extent[2],ymax:o.extent[3],spatialReference:i})}parseVersionString(e){const t={major:Number.NaN,minor:Number.NaN,versionString:e},r=e.split(".");return r.length>=2&&(t.major=parseInt(r[0],10),t.minor=parseInt(r[1],10)),t}readVersion(e,t){const r=t.store,o=null!=r.version?r.version.toString():"";return this.parseVersionString(o)}readTitlePortalItem(e){return"item-title"!==this.sublayerTitleMode?void 0:e}readTitleService(e,t){const r=this.portalItem&&this.portalItem.title;if("item-title"===this.sublayerTitleMode)return h(this.url,t.name);let o=t.name;if(!o&&this.url){const e=f(this.url);i(e)&&(o=e.title)}return"item-title-and-service-name"===this.sublayerTitleMode&&r&&(o=r+" - "+o),v(o)}set url(e){const t=S({layer:this,url:e,nonStandardUrlAllowed:!1,logger:A});this._set("url",t.url),null!=t.layerId&&this._set("layerId",t.layerId)}writeUrl(e,t,r,o){g(this,e,"layers",t,o)}get parsedUrl(){const e=this._get("url"),t=a(e);return null!=this.layerId&&(t.path=`${t.path}/layers/${this.layerId}`),t}async _fetchIndexAndUpdateExtent(e,t){this.indexInfo=x(this.parsedUrl.path,this.rootNode,e,this.apiKey,A,t),null==this.fullExtent||this.fullExtent.hasZ||this._updateExtent(await this.indexInfo)}_updateExtent(e){if("page"===e?.type){const t=e.rootIndex%e.pageSize,o=e.rootPage?.nodes?.[t];if(null==o||null==o.obb||null==o.obb.center||null==o.obb.halfSize)throw new r("sceneservice:invalid-node-page","Invalid node page.");if(o.obb.center[0]<E||null==this.fullExtent||this.fullExtent.hasZ)return;const i=o.obb.halfSize,s=o.obb.center[2],a=Math.sqrt(i[0]*i[0]+i[1]*i[1]+i[2]*i[2]);this.fullExtent.zmin=s-a,this.fullExtent.zmax=s+a}else if("node"===e?.type){const t=e.rootNode?.mbs;if(!Array.isArray(t)||4!==t.length||t[0]<E)return;const r=t[2],o=t[3],{fullExtent:i}=this;i&&(i.zmin=r-o,i.zmax=r+o)}}async _fetchService(e){if(null==this.url)throw new r("sceneservice:url-not-set","Scene service can not be loaded without valid portal item or url");if(null==this.layerId&&/SceneServer\/*$/i.test(this.url)){const t=await this._fetchFirstLayerId(e);null!=t&&(this.layerId=t)}return this._fetchServiceLayer(e)}async _fetchFirstLayerId(e){const r=await t(this.url,{query:{f:"json",token:this.apiKey},responseType:"json",signal:e});if(r.data&&Array.isArray(r.data.layers)&&r.data.layers.length>0)return r.data.layers[0].id}async _fetchServiceLayer(e){const r=await t(this.parsedUrl?.path??"",{query:{f:"json",token:this.apiKey},responseType:"json",signal:e});r.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));let o=!1;if(r.data.layerType&&"Voxel"===r.data.layerType&&(o=!0),o)return this._fetchVoxelServiceLayer();const i=r.data;this.read(i,this._getServiceContext()),this.validateLayer(i)}async _fetchVoxelServiceLayer(e){const r=(await t(this.parsedUrl?.path+"/layer",{query:{f:"json",token:this.apiKey},responseType:"json",signal:e})).data;this.read(r,this._getServiceContext()),this.validateLayer(r)}_getServiceContext(){return{origin:"service",portalItem:this.portalItem,portal:this.portalItem?.portal,url:this.parsedUrl}}async _ensureLoadBeforeSave(){await this.load(),"beforeSave"in this&&"function"==typeof this.beforeSave&&await this.beforeSave()}validateLayer(e){}_updateTypeKeywords(e,t,r){e.typeKeywords||(e.typeKeywords=[]);const o=t.getTypeKeywords();for(const i of o)e.typeKeywords.push(i);e.typeKeywords&&(e.typeKeywords=e.typeKeywords.filter(((e,t,r)=>r.indexOf(e)===t)),r===U.newItem&&(e.typeKeywords=e.typeKeywords.filter((e=>"Hosted Service"!==e))))}async _saveAs(e,t){const o={...K,...t};let i=j.from(e);i||(A.error("_saveAs(): requires a portal item parameter"),await Promise.reject(new r("sceneservice:portal-item-required","_saveAs() requires a portal item to save to"))),i.id&&(i=i.clone(),i.id=null);const s=i.portal||b.getDefault();await this._ensureLoadBeforeSave(),i.type=T,i.portal=s;const a={origin:"portal-item",url:null,messages:[],portal:s,portalItem:i,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],propertyPendingOperations:[],pendingOperations:[]}},n={layers:[this.write({},a)]};return await Promise.all(a.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(n,a,o),i.url=this.url,i.title||(i.title=this.title),this._updateTypeKeywords(i,o,U.newItem),await s.signIn(),await(s.user?.addItem({item:i,folder:o&&o.folder,data:n})),await _(this.resourceReferences,a,null),this.portalItem=i,c(a),a.portalItem=i,i}async _save(e){const t={...K,...e};if(!this.portalItem)throw A.error("_save(): requires the .portalItem property to be set"),new r("sceneservice:portal-item-not-set","Portal item to save to has not been set on this SceneService");if(this.portalItem.type!==T)throw A.error("_save(): Non-matching portal item type. Got "+this.portalItem.type+", expected "+T),new r("sceneservice:portal-item-wrong-type",`Portal item needs to have type "${T}"`);await this._ensureLoadBeforeSave();const o={origin:"portal-item",url:this.portalItem.itemUrl&&a(this.portalItem.itemUrl),messages:[],portal:this.portalItem.portal||b.getDefault(),portalItem:this.portalItem,writtenProperties:[],blockedRelativeUrls:[],resources:{toAdd:[],toUpdate:[],toKeep:[],propertyPendingOperations:[],pendingOperations:[]}},i={layers:[this.write({},o)]};return await Promise.all(o.resources.pendingOperations??[]),await this._validateAgainstJSONSchema(i,o,t),this.portalItem.url=this.url,this.portalItem.title||(this.portalItem.title=this.title),this._updateTypeKeywords(this.portalItem,t,U.existingItem),await this.portalItem.update({data:i}),await _(this.resourceReferences,o,null),c(o),this.portalItem}async _validateAgainstJSONSchema(e,t,o){let i=t.messages?.filter((e=>"error"===e.type)).map((e=>new r(e.name,e.message,e.details)))??[];if(o&&o.validationOptions?.ignoreUnsupported&&(i=i.filter((e=>"layer:unsupported"!==e.name&&"symbol:unsupported"!==e.name&&"symbol-layer:unsupported"!==e.name&&"property:unsupported"!==e.name&&"url:unsupported"!==e.name&&"scenemodification:unsupported"!==e.name))),o.validationOptions?.enabled||O){const t=(await import("../support/schemaValidator.js")).validate(e,o.portalItemLayerType);if(t.length>0){const e=`Layer item did not validate:\n${t.join("\n")}`;if(A.error(`_validateAgainstJSONSchema(): ${e}`),"throw"===o.validationOptions?.failPolicy){const e=t.map((e=>new r("sceneservice:schema-validation",e))).concat(i);throw new r("sceneservice-validate:error","Failed to save layer item due to schema validation, see `details.errors`.",{combined:e})}}}if(i.length>0)throw new r("sceneservice:save","Failed to save SceneService due to unsupported or invalid content. See 'details.errors' for more detailed information",{errors:i})}};return e([n(w)],N.prototype,"id",void 0),e([n({type:y})],N.prototype,"spatialReference",void 0),e([l("spatialReference",["spatialReference","store.indexCRS","store.geographicCRS"])],N.prototype,"readSpatialReference",null),e([n({type:u})],N.prototype,"fullExtent",void 0),e([l("fullExtent",["fullExtent","store.extent","spatialReference","store.indexCRS","store.geographicCRS"])],N.prototype,"readFullExtent",null),e([n({readOnly:!0,type:m})],N.prototype,"heightModelInfo",void 0),e([n({type:Number,json:{name:"layerDefinition.minScale",write:!0,origins:{service:{read:{source:"minScale"},write:!1}}}})],N.prototype,"minScale",void 0),e([n({type:Number,json:{name:"layerDefinition.maxScale",write:!0,origins:{service:{read:{source:"maxScale"},write:!1}}}})],N.prototype,"maxScale",void 0),e([n({readOnly:!0})],N.prototype,"version",void 0),e([l("version",["store.version"])],N.prototype,"readVersion",null),e([n({type:String,json:{read:{source:"copyrightText"}}})],N.prototype,"copyright",void 0),e([n({type:String,json:{read:!1}})],N.prototype,"sublayerTitleMode",void 0),e([n({type:String})],N.prototype,"title",void 0),e([l("portal-item","title")],N.prototype,"readTitlePortalItem",null),e([l("service","title",["name"])],N.prototype,"readTitleService",null),e([n({type:Number,json:{origins:{service:{read:{source:"id"}},"portal-item":{write:{target:"id",isRequired:!0,ignoreOrigin:!0},read:!1}}}})],N.prototype,"layerId",void 0),e([n(I)],N.prototype,"url",null),e([d("url")],N.prototype,"writeUrl",null),e([n()],N.prototype,"parsedUrl",null),e([n({readOnly:!0})],N.prototype,"store",void 0),e([n({type:String,readOnly:!0,json:{read:{source:"store.rootNode"}}})],N.prototype,"rootNode",void 0),N=e([p(R)],N),N},E=-1e38,O=!1;var U;!function(e){e[e.existingItem=0]="existingItem",e[e.newItem=1]="newItem"}(U||(U={}));const T="Scene Service",K={getTypeKeywords:()=>[],portalItemLayerType:"unknown",validationOptions:{enabled:!0,ignoreUnsupported:!1,failPolicy:"throw"}};var L;!function(e){e[e.SAVE=0]="SAVE",e[e.SAVE_AS=1]="SAVE_AS"}(L||(L={}));export{T as SCENE_SERVICE_ITEM_TYPE,L as SaveOperationType,N as SceneService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.26/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 r from"../../core/Logger.js";import{isSome as l,isNone as a}from"../../core/maybe.js";import{property as o}from"../../core/accessorSupport/decorators/property.js";import{cast as h}from"../../core/accessorSupport/decorators/cast.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{SimpleBandStatistics as c}from"./SimpleBandStatistics.js";var p;let u=p=class extends s{static createEmptyBand(t,e){return new(p.getPixelArrayConstructor(t))(e)}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.statistics=null}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 c)}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=>this._calculateBandStatistics(t,this.mask)));const t=this.mask;let e=0;if(l(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;let e;switch(t){case"u8":e=[0,255];break;case"u16":e=[0,65535];break;case"u32":e=[0,4294967295];break;case"s8":e=[-128,127];break;case"s16":e=[-32768,32767];break;case"s32":e=[-2147483648,2147483647];break;default:e=[-34e38,34e38]}const[s,i]=e,r=this.pixels,l=this.width*this.height,a=r.length;let o,h,n;const c=[];for(let u=0;u<a;u++){n=p.createEmptyBand(t,l),o=r[u];for(let t=0;t<l;t++)h=o[t],n[t]=h>i?i:h<s?s:h;c.push(n)}this.pixels=c,this.pixelType=t}extractBands(t){const{pixels:e,statistics:s}=this;if(a(t)||0===t.length||!e||0===e.length)return this;const i=e.length,r=t.some((t=>t>=e.length)),l=i===t.length&&!t.some(((t,e)=>t!==e));return r||l?this:new p({pixelType:this.pixelType,width:this.width,height:this.height,mask:this.mask,validPixelCount:this.validPixelCount,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;l(this.mask)&&(this.mask instanceof Uint8Array?t.mask=new Uint8Array(this.mask):t.mask=this.mask.slice(0));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}_fillFrom8Bit(t){const{mask:e,maskIsAlpha:s,pixels:i}=this;if(!t||!i||!i.length)return void r.getLogger(this.declaredClass).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");let a,o,h,n;a=o=h=i[0],i.length>=3?(o=i[1],h=i[2]):2===i.length&&(o=i[1]);const c=new Uint32Array(t),p=this.width*this.height;if(a.length===p)if(l(e)&&e.length===p)if(s)for(n=0;n<p;n++)e[n]&&(c[n]=e[n]<<24|h[n]<<16|o[n]<<8|a[n]);else for(n=0;n<p;n++)e[n]&&(c[n]=255<<24|h[n]<<16|o[n]<<8|a[n]);else for(n=0;n<p;n++)c[n]=255<<24|h[n]<<16|o[n]<<8|a[n];else r.getLogger(this.declaredClass).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.")}_fillFromNon8Bit(t){const{pixels:e,mask:s,statistics:i}=this;if(!t||!e||!e.length)return void r.getLogger(this.declaredClass).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");const a=this.pixelType;let o=1,h=0,n=1;if(i&&i.length>0){for(const t of i)if(null!=t.minValue&&(h=Math.min(h,t.minValue)),null!=t.maxValue&&null!=t.minValue){const e=t.maxValue-t.minValue;n=Math.max(n,e)}o=255/n}else{let t=255;"s8"===a?(h=-128,t=127):"u16"===a?t=65535:"s16"===a?(h=-32768,t=32767):"u32"===a?t=4294967295:"s32"===a?(h=-2147483648,t=2147483647):"f32"===a?(h=-34e38,t=34e38):"f64"===a&&(h=-Number.MAX_VALUE,t=Number.MAX_VALUE),o=255/(t-h)}const c=new Uint32Array(t),p=this.width*this.height;let u,g,f,m,d;if(u=g=f=e[0],u.length!==p)return r.getLogger(this.declaredClass).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.");if(e.length>=2)if(g=e[1],e.length>=3&&(f=e[2]),l(s)&&s.length===p)for(m=0;m<p;m++)s[m]&&(c[m]=255<<24|(f[m]-h)*o<<16|(g[m]-h)*o<<8|(u[m]-h)*o);else for(m=0;m<p;m++)c[m]=255<<24|(f[m]-h)*o<<16|(g[m]-h)*o<<8|(u[m]-h)*o;else if(l(s)&&s.length===p)for(m=0;m<p;m++)d=(u[m]-h)*o,s[m]&&(c[m]=255<<24|d<<16|d<<8|d);else for(m=0;m<p;m++)d=(u[m]-h)*o,c[m]=255<<24|d<<16|d<<8|d}_fillFrom32Bit(t){const{pixels:e,mask:s}=this;if(!t||!e||!e.length)return r.getLogger(this.declaredClass).error("getAsRGBAFloat()","Unable to convert to RGBA. The input pixel block is empty.");let i,a,o,h;i=a=o=e[0],e.length>=3?(a=e[1],o=e[2]):2===e.length&&(a=e[1]);const n=this.width*this.height;if(i.length!==n)return r.getLogger(this.declaredClass).error("getAsRGBAFloat()","Unable to convert to RGBA. The pixelblock is invalid.");let c=0;if(l(s)&&s.length===n)for(h=0;h<n;h++)t[c++]=i[h],t[c++]=a[h],t[c++]=o[h],t[c++]=1&s[h];else for(h=0;h<n;h++)t[c++]=i[h],t[c++]=a[h],t[c++]=o[h],t[c++]=1}_calculateBandStatistics(t,e){let s=1/0,i=-1/0;const r=t.length;let a,o=0;if(l(e))for(a=0;a<r;a++)e[a]&&(o=t[a],s=o<s?o:s,i=o>i?o:i);else for(a=0;a<r;a++)o=t[a],s=o<s?o:s,i=o>i?o:i;return new c(s,i)}};t([o({json:{write:!0}})],u.prototype,"width",void 0),t([o({json:{write:!0}})],u.prototype,"height",void 0),t([o({json:{write:!0}})],u.prototype,"pixelType",void 0),t([h("pixelType")],u.prototype,"castPixelType",null),t([o({json:{write:!0}})],u.prototype,"validPixelCount",void 0),t([o({json:{write:!0}})],u.prototype,"mask",void 0),t([o({json:{write:!0}})],u.prototype,"maskIsAlpha",void 0),t([o({json:{write:!0}})],u.prototype,"pixels",void 0),t([o({json:{write:!0}})],u.prototype,"statistics",void 0),u=p=t([n("esri.layers.support.PixelBlock")],u);const g=u;export{g as default};
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 r from"../../core/Logger.js";import{isSome as l,isNone as o}from"../../core/maybe.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{cast as h}from"../../core/accessorSupport/decorators/cast.js";import{subclass as n}from"../../core/accessorSupport/decorators/subclass.js";import{SimpleBandStatistics as p}from"./SimpleBandStatistics.js";import{getPixelValueRange as c}from"./rasterFormats/pixelRangeUtils.js";var u;let g=u=class extends s{static createEmptyBand(t,e){return new(u.getPixelArrayConstructor(t))(e)}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.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 p)}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=>this._calculateBandStatistics(t,this.mask)));const t=this.mask;let e=0;if(l(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]=c(t),i=this.pixels,r=this.width*this.height,l=i.length;let o,a,h;const n=[];for(let p=0;p<l;p++){h=u.createEmptyBand(t,r),o=i[p];for(let t=0;t<r;t++)a=o[t],h[t]=a>s?s:a<e?e:a;n.push(h)}this.pixels=n,this.pixelType=t}extractBands(t){const{pixels:e,statistics:s}=this;if(o(t)||0===t.length||!e||0===e.length)return this;const i=e.length,r=t.some((t=>t>=e.length)),l=i===t.length&&!t.some(((t,e)=>t!==e));return r||l?this:new u({pixelType:this.pixelType,width:this.width,height:this.height,mask:this.mask,validPixelCount:this.validPixelCount,maskIsAlpha:this.maskIsAlpha,pixels:t.map((t=>e[t])),statistics:s&&t.map((t=>s[t]))})}clone(){const t=new u({width:this.width,height:this.height,pixelType:this.pixelType,maskIsAlpha:this.maskIsAlpha,validPixelCount:this.validPixelCount});let e;l(this.mask)&&(this.mask instanceof Uint8Array?t.mask=new Uint8Array(this.mask):t.mask=this.mask.slice(0));const s=u.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}_fillFrom8Bit(t){const{mask:e,maskIsAlpha:s,pixels:i}=this;if(!t||!i||!i.length)return void r.getLogger(this.declaredClass).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");let o,a,h,n;o=a=h=i[0],i.length>=3?(a=i[1],h=i[2]):2===i.length&&(a=i[1]);const p=new Uint32Array(t),c=this.width*this.height;if(o.length===c)if(l(e)&&e.length===c)if(s)for(n=0;n<c;n++)e[n]&&(p[n]=e[n]<<24|h[n]<<16|a[n]<<8|o[n]);else for(n=0;n<c;n++)e[n]&&(p[n]=255<<24|h[n]<<16|a[n]<<8|o[n]);else for(n=0;n<c;n++)p[n]=255<<24|h[n]<<16|a[n]<<8|o[n];else r.getLogger(this.declaredClass).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.")}_fillFromNon8Bit(t){const{pixels:e,mask:s,statistics:i}=this;if(!t||!e||!e.length)return void r.getLogger(this.declaredClass).error("getAsRGBA()","Unable to convert to RGBA. The input pixel block is empty.");const o=this.pixelType;let a=1,h=0,n=1;if(i&&i.length>0){for(const t of i)if(null!=t.minValue&&(h=Math.min(h,t.minValue)),null!=t.maxValue&&null!=t.minValue){const e=t.maxValue-t.minValue;n=Math.max(n,e)}a=255/n}else{let t=255;"s8"===o?(h=-128,t=127):"u16"===o?t=65535:"s16"===o?(h=-32768,t=32767):"u32"===o?t=4294967295:"s32"===o?(h=-2147483648,t=2147483647):"f32"===o?(h=-34e38,t=34e38):"f64"===o&&(h=-Number.MAX_VALUE,t=Number.MAX_VALUE),a=255/(t-h)}const p=new Uint32Array(t),c=this.width*this.height;let u,g,d,f,m;if(u=g=d=e[0],u.length!==c)return r.getLogger(this.declaredClass).error("getAsRGBA()","Unable to convert to RGBA. The pixelblock is invalid.");if(e.length>=2)if(g=e[1],e.length>=3&&(d=e[2]),l(s)&&s.length===c)for(f=0;f<c;f++)s[f]&&(p[f]=255<<24|(d[f]-h)*a<<16|(g[f]-h)*a<<8|(u[f]-h)*a);else for(f=0;f<c;f++)p[f]=255<<24|(d[f]-h)*a<<16|(g[f]-h)*a<<8|(u[f]-h)*a;else if(l(s)&&s.length===c)for(f=0;f<c;f++)m=(u[f]-h)*a,s[f]&&(p[f]=255<<24|m<<16|m<<8|m);else for(f=0;f<c;f++)m=(u[f]-h)*a,p[f]=255<<24|m<<16|m<<8|m}_fillFrom32Bit(t){const{pixels:e,mask:s}=this;if(!t||!e||!e.length)return r.getLogger(this.declaredClass).error("getAsRGBAFloat()","Unable to convert to RGBA. The input pixel block is empty.");let i,o,a,h;i=o=a=e[0],e.length>=3?(o=e[1],a=e[2]):2===e.length&&(o=e[1]);const n=this.width*this.height;if(i.length!==n)return r.getLogger(this.declaredClass).error("getAsRGBAFloat()","Unable to convert to RGBA. The pixelblock is invalid.");let p=0;if(l(s)&&s.length===n)for(h=0;h<n;h++)t[p++]=i[h],t[p++]=o[h],t[p++]=a[h],t[p++]=1&s[h];else for(h=0;h<n;h++)t[p++]=i[h],t[p++]=o[h],t[p++]=a[h],t[p++]=1}_calculateBandStatistics(t,e){let s=1/0,i=-1/0;const r=t.length;let o,a=0;if(l(e))for(o=0;o<r;o++)e[o]&&(a=t[o],s=a<s?a:s,i=a>i?a:i);else for(o=0;o<r;o++)a=t[o],s=a<s?a:s,i=a>i?a:i;return new p(s,i)}};t([a({json:{write:!0}})],g.prototype,"width",void 0),t([a({json:{write:!0}})],g.prototype,"height",void 0),t([a({json:{write:!0}})],g.prototype,"pixelType",void 0),t([h("pixelType")],g.prototype,"castPixelType",null),t([a({json:{write:!0}})],g.prototype,"validPixelCount",void 0),t([a({json:{write:!0}})],g.prototype,"mask",void 0),t([a({json:{write:!0}})],g.prototype,"maskIsAlpha",void 0),t([a({json:{write:!0}})],g.prototype,"pixels",void 0),t([a({json:{write:!0}})],g.prototype,"statistics",void 0),t([a({json:{write:!0}})],g.prototype,"depthCount",void 0),t([a({json:{write:!0}})],g.prototype,"noDataValues",void 0),t([a({json:{write:!0}})],g.prototype,"bandMasks",void 0),g=u=t([n("esri.layers.support.PixelBlock")],g);const d=g;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.26/esri/copyright.txt for details.
4
4
  */
5
- import{clone as e}from"../../core/lang.js";import{isNone as n}from"../../core/maybe.js";import t from"./RasterFunction.js";import{schema as r}from"./rasterFunctionUtils.js";import{getRFxArgColorRampValue as o,convertColorRampToColormap as a,getColorRampName as i,rgbaConvertTo32Bit as s}from"../../renderers/support/colorRampUtils.js";import{stretchTypeJSONDict as u}from"../../renderers/support/stretchRendererUtils.js";import l from"../../renderers/visualVariables/SizeVariable.js";const c={u1:[0,1],u2:[0,3],u4:[0,15],u8:[0,255],s8:[-128,127],u16:[0,65535],s16:[-32768,32767]},m={simple_scalar:"Simple Scalar",wind_barb:"Wind Barb",single_arrow:"Single Arrow",beaufort_kn:"Beaufort Wind (Knots)",beaufort_m:"Beaufort Wind (MetersPerSecond)",ocean_current_m:"Ocean Current (MetersPerSecond)",ocean_current_kn:"Ocean Current (Knots)"},p=new Set(["raster-stretch","unique-value","class-breaks","raster-shaded-relief","vector-field","raster-colormap"]);function f(e){return p.has(e.type)}function g(n,t){if(!n||!t)return e(n||t);const r=e(n);if(r.rasterFunctionDefinition&&t.rasterFunctionDefinition){const e=t.rasterFunctionDefinition;(e.thumbnail||e.thumbnailEx)&&(e.thumbnail=e.thumbnailEx=void 0),d(r.rasterFunctionDefinition.arguments,t)}else if("none"!==t.functionName?.toLowerCase()){b(r.functionArguments).Raster=t}return r}function d(e,n){for(const t in e)"raster"===t.toLowerCase()&&("RasterFunctionVariable"===e[t].type?(e[t]=n.rasterFunctionDefinition,e[t].type="RasterFunctionTemplate"):"RasterFunctionTemplate"===e[t].type&&d(e[t].arguments,n))}function h(n){const t=e(r[n.functionName+"Function"]),o=n.functionArguments;for(const e in o)"raster"===e.toLowerCase()?(t.arguments[e]=h(o[e]),t.arguments[e].type="RasterFunctionTemplate"):"colormap"===e.toLowerCase()?(t.arguments[e].value=V(o[e]),t.arguments.ColorSchemeType.value=0):t.arguments[e].value=o[e];return t}function y(e,n){switch(n=n||{},e.type){case"raster-stretch":return v(e,n);case"class-breaks":return x(e,n);case"unique-value":return A(e,n);case"raster-colormap":return F(e,n);case"vector-field":return T(e,n);case"raster-shaded-relief":return w(e,n);case"flow":throw new Error("Unsupported rendering rule.")}}function b(e){const n=e?.Raster;return n&&"esri.layers.support.RasterFunction"===n.declaredClass?b(n.functionArguments):e}const R={none:0,standardDeviation:3,histogramEqualization:4,minMax:5,percentClip:6,sigmoid:9};function T(e,n){const r=new t;r.functionName="VectorFieldRenderer";const{dataType:o,bandProperties:a}=n,i="vector-uv"===o;let s,u;a&&2===a.length&&(s=a.map((e=>e.BandName.toLowerCase())).indexOf("magnitude"),u=a.map((e=>e.BandName.toLowerCase())).indexOf("direction")),-1!==s&&null!==s||(s=0,u=1);const c="arithmetic"===e.rotationType?1:2,p="flow-from"===e.flowRepresentation?0:1,f=e.visualVariables?e.visualVariables.find((e=>"Magnitude"===e.field)):new l,g={magnitudeBandID:s,directionBandID:u,isUVComponents:i,referenceSystem:c,massFlowAngleRepresentation:p,symbolTileSize:50,symbolTileSizeUnits:100,calculationMethod:"Vector Average",symbologyName:m[e.style.toLowerCase().replace("-","_")],minimumMagnitude:f.minDataValue,maximumMagnitude:f.maxDataValue,minimumSymbolSize:f.minSize,maximumSymbolSize:f.maxSize};return r.functionArguments=g,n.convertToRFT?new t({rasterFunctionDefinition:h(r)}):r}function w(e,n){const r=n.convertToRFT;if("elevation"!==n.dataType&&("generic"!==n.dataType||1!==n.bandCount||"s16"!==n.pixelType&&"s32"!==n.pixelType&&"f32"!==n.pixelType&&"f64"!==n.pixelType))return new t;const i=new t;i.functionName="Hillshade";const s="traditional"===e.hillshadeType?0:1,u="none"===e.scalingType?1:3,l={HillshadeType:s,SlopeType:u,ZFactor:e.zFactor};return 0===s&&(l.Azimuth=e.azimuth,l.Altitude=e.altitude),3===u&&(l.PSPower=e.pixelSizePower,l.PSZFactor=e.pixelSizeFactor),i.functionArguments=l,i.variableName="Raster",e.colorRamp&&(i.functionName="ShadedRelief",r?l.ColorRamp=o(e.colorRamp):l.Colormap=a(e.colorRamp)),r?new t({rasterFunctionDefinition:h(i)}):i}function v(e,n){const r=n.convertToRFT,s=new t;s.functionName="Stretch";const l=R[u.toJSON(e.stretchType)],c="u8",m={StretchType:l,Statistics:N(e.statistics??[]),DRA:e.dynamicRangeAdjustment,UseGamma:e.useGamma,Gamma:e.gamma,ComputeGamma:e.computeGamma};if(null!=e.outputMin&&(m.Min=e.outputMin),null!=e.outputMax&&(m.Max=e.outputMax),l===R.standardDeviation?(m.NumberOfStandardDeviations=e.numberOfStandardDeviations,s.outputPixelType=c):l===R.percentClip?(m.MinPercent=e.minPercent,m.MaxPercent=e.maxPercent,s.outputPixelType=c):l===R.minMax?s.outputPixelType=c:l===R.sigmoid&&(m.SigmoidStrengthLevel=e.sigmoidStrengthLevel),s.functionArguments=m,s.variableName="Raster",e.colorRamp){const u=e.colorRamp,l=new t;if(r)l.functionArguments={ColorRamp:o(u)};else{const t=i(u);if(t)l.functionArguments={colorRamp:t};else if(!n.convertColorRampToColormap||"algorithmic"!==u.type&&"multipart"!==u.type){const n=e.colorRamp.toJSON();"algorithmic"===n.type?n.algorithm=n.algorithm||"esriCIELabAlgorithm":"multipart"===n.type&&n.colorRamps?.length&&n.colorRamps.forEach((e=>e.algorithm=e.algorithm||"esriCIELabAlgorithm")),l.functionArguments={colorRamp:n}}else l.functionArguments={Colormap:a(u)}}return l.variableName="Raster",l.functionName="Colormap",l.functionArguments.Raster=s,r?new t({rasterFunctionDefinition:h(l)}):l}return r?new t({rasterFunctionDefinition:h(s)}):s}function x(e,r){const o=[],a=[],i=[],s=[],u=1e-6,{pixelType:l,rasterAttributeTable:c}=r,m=n(c)?null:c.features,p=S(c);if(p&&m&&Array.isArray(m)&&e.classBreakInfos){e.classBreakInfos.forEach(((n,t)=>{const r=n.symbol?.color;let o;r?.a&&null!=n.minValue&&null!=n.maxValue&&m.forEach((a=>{null!=n.minValue&&null!=n.maxValue&&(o=a.attributes[e.field],(o>=n.minValue&&o<n.maxValue||t===e.classBreakInfos.length-1&&o>=n.minValue)&&s.push([a.attributes[p],r.r,r.g,r.b]))}))}));const n=l?C(s,l):s,o=new t;return o.functionName="Colormap",o.functionArguments={},o.functionArguments.Colormap=n,o.variableName="Raster",r.convertToRFT?new t({rasterFunctionDefinition:h(o)}):o}e.classBreakInfos.forEach(((e,n)=>{if(null==e.minValue||null==e.maxValue)return;const t=e.symbol&&e.symbol.color;t?.a?(0===n?o.push(e.minValue,e.maxValue+u):o.push(e.minValue+u,e.maxValue+u),a.push(n),s.push([n,t.r,t.g,t.b])):i.push(e.minValue,e.maxValue)}));const f=l?C(s,l):s,g=new t;g.functionName="Remap",g.functionArguments={InputRanges:o,OutputValues:a,NoDataRanges:i},g.variableName="Raster";const d=new t;return d.functionName="Colormap",d.functionArguments={Colormap:f,Raster:g},r.convertToRFT?new t({rasterFunctionDefinition:h(d)}):d}function C(e,n){const t=c[String(n).toLowerCase()];return t&&e.push([Math.floor(t[0]-1),0,0,0],[Math.ceil(t[1]+1),0,0,0]),e}function S(e){if(n(e))return;const{fields:t}=e,r=t&&t.find((e=>e&&e.name&&"value"===e.name.toLowerCase()));return r&&r.name}function A(e,r){const o=[],{pixelType:a,rasterAttributeTable:i}=r,s=n(i)?null:i.features,u=S(i),l=e.defaultSymbol?.color?.toRgb(),c=e.uniqueValueInfos;if(c)if(s){if(u){const n=new Map;c.forEach((e=>{const t=e.value,r=e.symbol?.color;null!=t&&r&&r.a&&n.set(String(t),r.toRgb())}));const t=e.field;s.forEach((({attributes:e})=>{const r=String(e[t]),a=e[u],i=n.get(r);i?o.push([a,...i]):l&&o.push([a,...l])}))}}else for(let n=0;n<c.length;n++){const e=c[n],t=e.symbol?.color,r=+e.value;if(t?.a){if(isNaN(r))return null;o.push([r,t.r,t.g,t.b])}}const m=a&&o.length>0?C(o,a):o,p=new t;return p.functionName="Colormap",p.functionArguments={},p.functionArguments.Colormap=m,p.variableName="Raster",r.convertToRFT?new t({rasterFunctionDefinition:h(p)}):p}function F(e,n){const r=e.extractColormap();if(!r||0===r.length)return null;const{pixelType:o}=n,a=o?C(r,o):r,i=new t;return i.functionName="Colormap",i.functionArguments={},i.functionArguments.Colormap=a,n.convertToRFT?new t({rasterFunctionDefinition:h(i)}):i}function N(e){const n=[];return e?.forEach((e=>{const t=e;if(Array.isArray(t))n.push(t);else{if(null==t.min||null==t.max)return;const e=[t.min,t.max,t.avg||0,t.stddev||0];n.push(e)}})),n}function V(e){const n=[],t=[];return e.forEach((e=>{n.push(e[0]),t.push(s([...e.slice(1),255]))})),{type:"RasterColormap",values:n,colors:t}}export{g as combineRenderingRules,y as convertRendererToRenderingRule,h as convertRenderingRuleToRFT,f as isSupportedRendererType,c as pixelTypeRanges};
5
+ import{clone as e}from"../../core/lang.js";import{isNone as n}from"../../core/maybe.js";import t from"./RasterFunction.js";import{schema as r}from"./rasterFunctionUtils.js";import{getPixelValueRange as o}from"./rasterFormats/pixelRangeUtils.js";import{getRFxArgColorRampValue as a,convertColorRampToColormap as i,getColorRampName as s,rgbaConvertTo32Bit as u}from"../../renderers/support/colorRampUtils.js";import{stretchTypeJSONDict as l}from"../../renderers/support/stretchRendererUtils.js";import c from"../../renderers/visualVariables/SizeVariable.js";const m=new Set(["u1","u2","u4","u8","s8","u16","s16"]),p={simple_scalar:"Simple Scalar",wind_barb:"Wind Barb",single_arrow:"Single Arrow",beaufort_kn:"Beaufort Wind (Knots)",beaufort_m:"Beaufort Wind (MetersPerSecond)",ocean_current_m:"Ocean Current (MetersPerSecond)",ocean_current_kn:"Ocean Current (Knots)"},f=new Set(["raster-stretch","unique-value","class-breaks","raster-shaded-relief","vector-field","raster-colormap"]);function g(e){return f.has(e.type)}function d(n,t){if(!n||!t)return e(n||t);const r=e(n);if(r.rasterFunctionDefinition&&t.rasterFunctionDefinition){const e=t.rasterFunctionDefinition;(e.thumbnail||e.thumbnailEx)&&(e.thumbnail=e.thumbnailEx=void 0),h(r.rasterFunctionDefinition.arguments,t)}else if("none"!==t.functionName?.toLowerCase()){R(r.functionArguments).Raster=t}return r}function h(e,n){for(const t in e)"raster"===t.toLowerCase()&&("RasterFunctionVariable"===e[t].type?(e[t]=n.rasterFunctionDefinition,e[t].type="RasterFunctionTemplate"):"RasterFunctionTemplate"===e[t].type&&h(e[t].arguments,n))}function y(n){const t=e(r[n.functionName+"Function"]),o=n.functionArguments;for(const e in o)"raster"===e.toLowerCase()?(t.arguments[e]=y(o[e]),t.arguments[e].type="RasterFunctionTemplate"):"colormap"===e.toLowerCase()?(t.arguments[e].value=D(o[e]),t.arguments.ColorSchemeType.value=0):t.arguments[e].value=o[e];return t}function b(e,n){switch(n=n||{},e.type){case"raster-stretch":return x(e,n);case"class-breaks":return S(e,n);case"unique-value":return A(e,n);case"raster-colormap":return N(e,n);case"vector-field":return w(e,n);case"raster-shaded-relief":return v(e,n);case"flow":throw new Error("Unsupported rendering rule.")}}function R(e){const n=e?.Raster;return n&&"esri.layers.support.RasterFunction"===n.declaredClass?R(n.functionArguments):e}const T={none:0,standardDeviation:3,histogramEqualization:4,minMax:5,percentClip:6,sigmoid:9};function w(e,n){const r=new t;r.functionName="VectorFieldRenderer";const{dataType:o,bandProperties:a}=n,i="vector-uv"===o;let s,u;a&&2===a.length&&(s=a.map((e=>e.BandName.toLowerCase())).indexOf("magnitude"),u=a.map((e=>e.BandName.toLowerCase())).indexOf("direction")),-1!==s&&null!==s||(s=0,u=1);const l="arithmetic"===e.rotationType?1:2,m="flow-from"===e.flowRepresentation?0:1,f=e.visualVariables?e.visualVariables.find((e=>"Magnitude"===e.field)):new c,g={magnitudeBandID:s,directionBandID:u,isUVComponents:i,referenceSystem:l,massFlowAngleRepresentation:m,symbolTileSize:50,symbolTileSizeUnits:100,calculationMethod:"Vector Average",symbologyName:p[e.style.toLowerCase().replace("-","_")],minimumMagnitude:f.minDataValue,maximumMagnitude:f.maxDataValue,minimumSymbolSize:f.minSize,maximumSymbolSize:f.maxSize};return r.functionArguments=g,n.convertToRFT?new t({rasterFunctionDefinition:y(r)}):r}function v(e,n){const r=n.convertToRFT;if("elevation"!==n.dataType&&("generic"!==n.dataType||1!==n.bandCount||"s16"!==n.pixelType&&"s32"!==n.pixelType&&"f32"!==n.pixelType&&"f64"!==n.pixelType))return new t;const o=new t;o.functionName="Hillshade";const s="traditional"===e.hillshadeType?0:1,u="none"===e.scalingType?1:3,l={HillshadeType:s,SlopeType:u,ZFactor:e.zFactor};return 0===s&&(l.Azimuth=e.azimuth,l.Altitude=e.altitude),3===u&&(l.PSPower=e.pixelSizePower,l.PSZFactor=e.pixelSizeFactor),o.functionArguments=l,o.variableName="Raster",e.colorRamp&&(o.functionName="ShadedRelief",r?l.ColorRamp=a(e.colorRamp):l.Colormap=i(e.colorRamp)),r?new t({rasterFunctionDefinition:y(o)}):o}function x(e,n){const r=n.convertToRFT,o=new t;o.functionName="Stretch";const u=T[l.toJSON(e.stretchType)],c="u8",m={StretchType:u,Statistics:V(e.statistics??[]),DRA:e.dynamicRangeAdjustment,UseGamma:e.useGamma,Gamma:e.gamma,ComputeGamma:e.computeGamma};if(null!=e.outputMin&&(m.Min=e.outputMin),null!=e.outputMax&&(m.Max=e.outputMax),u===T.standardDeviation?(m.NumberOfStandardDeviations=e.numberOfStandardDeviations,o.outputPixelType=c):u===T.percentClip?(m.MinPercent=e.minPercent,m.MaxPercent=e.maxPercent,o.outputPixelType=c):u===T.minMax?o.outputPixelType=c:u===T.sigmoid&&(m.SigmoidStrengthLevel=e.sigmoidStrengthLevel),o.functionArguments=m,o.variableName="Raster",e.colorRamp){const u=e.colorRamp,l=new t;if(r)l.functionArguments={ColorRamp:a(u)};else{const t=s(u);if(t)l.functionArguments={colorRamp:t};else if(!n.convertColorRampToColormap||"algorithmic"!==u.type&&"multipart"!==u.type){const n=e.colorRamp.toJSON();"algorithmic"===n.type?n.algorithm=n.algorithm||"esriCIELabAlgorithm":"multipart"===n.type&&n.colorRamps?.length&&n.colorRamps.forEach((e=>e.algorithm=e.algorithm||"esriCIELabAlgorithm")),l.functionArguments={colorRamp:n}}else l.functionArguments={Colormap:i(u)}}return l.variableName="Raster",l.functionName="Colormap",l.functionArguments.Raster=o,r?new t({rasterFunctionDefinition:y(l)}):l}return r?new t({rasterFunctionDefinition:y(o)}):o}function S(e,r){const o=[],a=[],i=[],s=[],u=1e-6,{pixelType:l,rasterAttributeTable:c}=r,m=n(c)?null:c.features,p=F(c);if(p&&m&&Array.isArray(m)&&e.classBreakInfos){e.classBreakInfos.forEach(((n,t)=>{const r=n.symbol?.color;let o;r?.a&&null!=n.minValue&&null!=n.maxValue&&m.forEach((a=>{null!=n.minValue&&null!=n.maxValue&&(o=a.attributes[e.field],(o>=n.minValue&&o<n.maxValue||t===e.classBreakInfos.length-1&&o>=n.minValue)&&s.push([a.attributes[p],r.r,r.g,r.b]))}))}));const n=l?C(s,l):s,o=new t;return o.functionName="Colormap",o.functionArguments={},o.functionArguments.Colormap=n,o.variableName="Raster",r.convertToRFT?new t({rasterFunctionDefinition:y(o)}):o}e.classBreakInfos.forEach(((e,n)=>{if(null==e.minValue||null==e.maxValue)return;const t=e.symbol&&e.symbol.color;t?.a?(0===n?o.push(e.minValue,e.maxValue+u):o.push(e.minValue+u,e.maxValue+u),a.push(n),s.push([n,t.r,t.g,t.b])):i.push(e.minValue,e.maxValue)}));const f=l?C(s,l):s,g=new t;g.functionName="Remap",g.functionArguments={InputRanges:o,OutputValues:a,NoDataRanges:i},g.variableName="Raster";const d=new t;return d.functionName="Colormap",d.functionArguments={Colormap:f,Raster:g},r.convertToRFT?new t({rasterFunctionDefinition:y(d)}):d}function C(e,n){const t=m.has(n)?o(n):null;return t&&e.push([Math.floor(t[0]-1),0,0,0],[Math.ceil(t[1]+1),0,0,0]),e}function F(e){if(n(e))return;const{fields:t}=e,r=t&&t.find((e=>e&&e.name&&"value"===e.name.toLowerCase()));return r&&r.name}function A(e,r){const o=[],{pixelType:a,rasterAttributeTable:i}=r,s=n(i)?null:i.features,u=F(i),l=e.defaultSymbol?.color?.toRgb(),c=e.uniqueValueInfos;if(c)if(s){if(u){const n=new Map;c.forEach((e=>{const t=e.value,r=e.symbol?.color;null!=t&&r&&r.a&&n.set(String(t),r.toRgb())}));const t=e.field;s.forEach((({attributes:e})=>{const r=String(e[t]),a=e[u],i=n.get(r);i?o.push([a,...i]):l&&o.push([a,...l])}))}}else for(let n=0;n<c.length;n++){const e=c[n],t=e.symbol?.color,r=+e.value;if(t?.a){if(isNaN(r))return null;o.push([r,t.r,t.g,t.b])}}const m=a&&o.length>0?C(o,a):o,p=new t;return p.functionName="Colormap",p.functionArguments={},p.functionArguments.Colormap=m,p.variableName="Raster",r.convertToRFT?new t({rasterFunctionDefinition:y(p)}):p}function N(e,n){const r=e.extractColormap();if(!r||0===r.length)return null;const{pixelType:o}=n,a=o?C(r,o):r,i=new t;return i.functionName="Colormap",i.functionArguments={},i.functionArguments.Colormap=a,n.convertToRFT?new t({rasterFunctionDefinition:y(i)}):i}function V(e){const n=[];return e?.forEach((e=>{const t=e;if(Array.isArray(t))n.push(t);else{if(null==t.min||null==t.max)return;const e=[t.min,t.max,t.avg||0,t.stddev||0];n.push(e)}})),n}function D(e){const n=[],t=[];return e.forEach((e=>{n.push(e[0]),t.push(u([...e.slice(1),255]))})),{type:"RasterColormap",values:n,colors:t}}export{d as combineRenderingRules,b as convertRendererToRenderingRule,y as convertRenderingRuleToRFT,g as isSupportedRendererType};