@arcgis/core 5.2.0-next.29 → 5.2.0-next.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/t9n/Units_en.json +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/0af6b87a3d77bb93b893.js +1 -0
- package/assets/esri/core/workers/chunks/{7ff37a4f315f7621462b.js → 125edba5c618c6257cb8.js} +1 -1
- package/assets/esri/core/workers/chunks/{4ba4fd8fa31169760fee.js → 1282598516cd0e3056b7.js} +3 -3
- package/assets/esri/core/workers/chunks/414691f7758c78e2a704.js +1 -0
- package/assets/esri/core/workers/chunks/4452fd0c59431904d533.js +1 -0
- package/assets/esri/core/workers/chunks/451331f69d21c61ec93b.js +1 -0
- package/assets/esri/core/workers/chunks/{11f47a012dd8881e3d55.js → 4e803d12486c8de4c901.js} +23 -23
- package/assets/esri/core/workers/chunks/{992a90ecbab931198fd0.js → 4ecc345c3732f7fc130f.js} +1 -1
- package/assets/esri/core/workers/chunks/557300ec03bae84d8afc.js +1 -0
- package/assets/esri/core/workers/chunks/{b18b6bb85e52b03b85e3.js → 6df54132299b9e8f6dad.js} +18 -18
- package/assets/esri/core/workers/chunks/{c6f5688074ae89c37add.js → 7b1678dcf62481469544.js} +1 -1
- package/assets/esri/core/workers/chunks/{a90619adff41658f8057.js → 8d21f3d6edbcd7b335d0.js} +1 -1
- package/assets/esri/core/workers/chunks/b1a0eb6598309e11337f.js +1 -0
- package/assets/esri/core/workers/chunks/bd0829eb79efff5b7223.js +1 -0
- package/assets/esri/core/workers/chunks/bee56a6ac99312f03109.js +1 -0
- package/assets/esri/core/workers/chunks/c7316fd2bdb7ac9eada3.js +1 -0
- package/assets/esri/core/workers/chunks/daf539e9f88fc9e101e4.js +1 -0
- package/assets/esri/core/workers/chunks/{9fe71d49c888fd871312.js → e2d500ac1a264d09c857.js} +1 -1
- package/assets/esri/core/workers/chunks/{aded4e704e09a28edc8f.js → f63e7b01c70352538b1e.js} +1 -1
- package/assets/esri/core/workers/chunks/f71f5778e03f68f27482.js +1 -0
- package/assets/esri/core/workers/chunks/fc9664d3282b052ef40f.js +1 -0
- package/assets/esri/widgets/Features/t9n/Features_en.json +1 -1
- package/assets/esri/widgets/VideoPlayer/t9n/VideoPlayer_en.json +1 -1
- package/chunks/CutFillComposition.glsl.js +16 -10
- package/chunks/CutFillDepth.glsl.js +1 -14
- package/chunks/HUDMaterial.glsl.js +7 -7
- package/chunks/Viewshed.glsl.js +3 -3
- package/config.js +1 -1
- package/core/PooledArray.js +1 -1
- package/geometry/support/lineSegment.js +1 -1
- package/geometry/support/triangle.js +1 -1
- package/kernel.js +1 -1
- package/layers/AnnotationFeatureLayer.js +1 -1
- package/layers/DimensionFeatureLayer.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphSublayer.js +1 -1
- package/layers/knowledgeGraph/nodeMovementUtils.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/raster/datasets/pixelReader.js +1 -1
- package/layers/support/ExportImageServiceParameters.js +1 -1
- package/package.json +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/webgl/mesh/bufcut.js +1 -1
- package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
- package/views/2d/engine/webgl/util/AnnotationMatcher.js +1 -1
- package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
- package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
- package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
- package/views/2d/layers/support/annodime/MatcherGeometryOverride.js +1 -1
- package/views/2d/layers/support/annodime/annotationGraphic.js +1 -1
- package/views/2d/layers/support/annodime/cimAnnotations.js +1 -1
- package/views/2d/layers/support/annodime/dimensionSymbols.js +1 -1
- package/views/2d/layers/support/annodime/dimensionUtils.js +1 -1
- package/views/2d/layers/support/annodime/fields.js +1 -1
- package/views/2d/layers/support/annodime/utils.js +1 -1
- package/views/2d/layers/support/annodime/virtualFields.js +1 -1
- package/views/3d/FocusAreasView.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillController.js +1 -1
- package/views/3d/analysis/VolumeMeasurement/VolumeMeasurementCutFillVisualization.js +1 -1
- package/views/3d/layers/GaussianSplatLayerView3D.js +1 -1
- package/views/3d/support/hitTest.js +1 -1
- package/views/3d/webgl/RenderCamera.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderModules/FloatsDrawUniform.js +2 -0
- package/views/3d/webgl-engine/effects/focusArea/{FocusAreaMaskNode.js → FocusAreaMask.js} +1 -1
- package/views/3d/webgl-engine/effects/focusArea/{FocusAreaColorNode.js → FocusAreaVisualization.js} +1 -1
- package/views/3d/webgl-engine/effects/geometry/{ObjectAndLayerIDRenderNode.js → ObjectAndLayerID.js} +1 -1
- package/views/3d/webgl-engine/effects/geometry/{RenderOccludedRenderNode.js → RenderOccluded.js} +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/CutFillComputation.js +2 -0
- package/views/3d/webgl-engine/lib/CutFillVisualization.js +2 -0
- package/views/3d/webgl-engine/lib/{GaussianSplatRenderNode.js → GaussianSplatRenderer.js} +1 -1
- package/views/3d/webgl-engine/lib/GaussianSplatShadows.js +2 -0
- package/views/3d/webgl-engine/lib/Intersector.js +1 -1
- package/views/3d/webgl-engine/lib/Octree.js +1 -1
- package/views/3d/webgl-engine/lib/RayIntersections.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/geometryDataUtils.js +1 -1
- package/views/3d/webgl-engine/lib/intersectionConstants.js +2 -0
- package/views/3d/webgl-engine/lib/screenPolygonOverlapUtils.js +2 -0
- package/views/3d/webgl-engine/lib/screenPolygonTriangleIntersections.js +2 -0
- package/views/3d/webgl-engine/lib/triangleIntersectionUtils.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PolygonOffset.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/TriangleMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/intersectWithPolygonOffset.js +2 -0
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/CutFillComposition.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/CutFillCompositionTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/CutFillDepth.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HUDMaterial.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/Viewshed.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ViewshedTechnique.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/layers/FeatureLikeLayerView.js +1 -1
- package/views/support/euclideanAreaMeasurementUtils.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/widgets/Attachments/support/attachmentUtils.js +1 -1
- package/widgets/BatchAttributeForm/BatchAttributeFormViewModel.js +1 -1
- package/widgets/BatchAttributeForm/inputs/AttachmentElementInput.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/navigation/NavigationManager.js +1 -1
- package/widgets/PanoramicViewer/support/PanoramicTileNode.js +1 -1
- package/widgets/PanoramicViewer/utils.js +1 -1
- package/widgets/Sketch/support/OperationHandle.js +1 -1
- package/widgets/support/UtilityNetworkAssociations/FeatureUtilityNetworkAssociationsViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/0d3c9112ae07fa4a97d6.js +0 -1
- package/assets/esri/core/workers/chunks/1849f72f23b434e6c78d.js +0 -1
- package/assets/esri/core/workers/chunks/218e2d8d6cd147c769ce.js +0 -1
- package/assets/esri/core/workers/chunks/294f2803aac000c99693.js +0 -1
- package/assets/esri/core/workers/chunks/2c15c227d057292d4fa8.js +0 -1
- package/assets/esri/core/workers/chunks/38a2f34661563c7c29c1.js +0 -1
- package/assets/esri/core/workers/chunks/5468a65698931603656d.js +0 -1
- package/assets/esri/core/workers/chunks/780519b60aa674a61a74.js +0 -1
- package/assets/esri/core/workers/chunks/88827e23f8938342781c.js +0 -1
- package/assets/esri/core/workers/chunks/bfe9c8ab35d9bf7e1035.js +0 -1
- package/assets/esri/core/workers/chunks/caf150028aeac91b8d80.js +0 -1
- package/assets/esri/core/workers/chunks/e98a8f80023c6023e72c.js +0 -1
- package/views/3d/webgl-engine/lib/CutFillComputationRenderNode.js +0 -2
- package/views/3d/webgl-engine/lib/CutFillVisualizationRenderNode.js +0 -2
- package/views/3d/webgl-engine/lib/GaussianSplatShadowRenderNode.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import i from"../../request.js";import s from"../../core/Error.js";import{clone as r}from"../../core/lang.js";import n from"../../core/Logger.js";import{QueueProcessor as a}from"../../core/QueueProcessor.js";import{watch as o}from"../../core/reactiveUtils.js";import{urlToObject as l}from"../../core/urlUtils.js";import{property as u,subclass as p}from"../../core/accessorSupport/decorators.js";import{Integer as c,ensureClass as m}from"../../core/accessorSupport/ensureType.js";import{runUntracked as h}from"../../core/accessorSupport/tracking.js";import d from"../../geometry/Extent.js";import f from"../../geometry/Polygon.js";import g from"../../geometry/SpatialReference.js";import{srToRESTValue as y}from"../../geometry/support/spatialReferenceUtils.js";import{intersectMultimensionalSubset as R,getEffectiveMultidimensionalDefinition as x,getSubsetVariablesFromMdInfo as I,getDefaultMultidimensionalDefinition as w}from"../raster/datasets/multidimensionalUtils.js";import{decode as v,getFormat as b}from"../raster/formats/RasterCodec.js";import{mosaicPixelData as S}from"../raster/functions/pixelUtils.js";import{uvComponentToVector as _}from"../raster/functions/vectorFieldUtils.js";import{opacity as F,url as D}from"../support/commonProperties.js";import O from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as T}from"../support/ExportImageServiceParameters.js";import M from"../support/Field.js";import C from"../support/FieldsIndex.js";import{createBitmap as N}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as q}from"../support/imageryRendererUtils.js";import P from"../support/MosaicRule.js";import j from"../support/MultidimensionalSubset.js";import E from"../support/PixelBlock.js";import{interpolationKebab as A,noDataInterpretationKebab as Q,pixelTypeKebabDict as V}from"../support/rasterEnums.js";import{getServicePixelValueField as J,getItemPixelValueField as U,getRawServicePixelValueField as B,getProcessedServicePixelValueField as z,getMagnitudeField as L,getDirectionField as H,getMultidimensionalFields as G,getRasterAttributeTableFields as k,addMultidimensionalFieldValues as W,commonRasterFieldNames as $,rasterFieldPrefix as X}from"../support/rasterFieldUtils.js";import K from"../support/RasterFunction.js";import Y from"../support/RasterInfo.js";import{createDefaultRenderer as Z,getDefaultBandCombination as ee,getSupportedRendererTypes as te,matchPresetRenderer as ie,normalizeRendererJSON as se}from"../../renderers/support/rasterRendererHelper.js";import re from"../../renderers/support/RasterSymbolizer.js";import{rasterRendererTypes as ne,websceneRasterRendererTypes as ae,read as oe}from"../../renderers/support/rasterTypeUtils.js";import{calculateVolume as le,computeAngles as ue,computePixelSpaceLocations as pe,computeHistograms as ce,computeStatisticsHistograms as me,measureHeight as he,measureAreaAndPerimeter as de,measureDistanceAndAngle as fe,measurePointOrCentroid as ge,measureLengthFromImage as ye,measureAreaFromImage as Re,getImageSpatialReferenceQueryParameter as xe,getSamples as Ie,identify as we,imageToMap as ve,imageToMapMultiray as be,mapToImage as Se,findImages as _e,getImageUrl as Fe,queryBoundary as De,queryGPSInfo as Oe}from"../../rest/imageService.js";import{fetchServiceRasterInfo as Te,generateRasterInfo as Me,patchServiceInfo as Ce}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as Ne}from"../../rest/imageService/getCatalogItemRasterInfo.js";import{executeForCount as qe}from"../../rest/query/executeForCount.js";import{executeForExtent as Pe}from"../../rest/query/executeForExtent.js";import{executeForIds as je}from"../../rest/query/executeForIds.js";import{executeQueryJSON as Ee}from"../../rest/query/executeQueryJSON.js";import Ae from"../../rest/support/FeatureSet.js";import Qe from"../../rest/support/ImageIdentifyParameters.js";import Ve from"../../rest/support/Query.js";import{reader as Je}from"../../core/accessorSupport/decorators/reader.js";import{writer as Ue}from"../../core/accessorSupport/decorators/writer.js";const Be=512,ze=4096,Le=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]);function He(e){const t=JSON.stringify(e),i=t.includes('"rasterFunctionDefinition":{'),s=i?t.match(/"type":"(.*?FunctionArguments")/gi):t.match(/"rasterFunction":"(.*?")/gi),r=s?.map(e=>i?e.slice(8,-18):e.slice(18,-1));return r?r.join("/"):null}const Ge=Ge=>{const ke=Ge;let We=class extends ke{constructor(){super(...arguments),this._functionRasterInfos={},this._serviceSupportsMosaicRule=null,this._exportTileQueue=new a({concurrency:4,process:(e,t)=>this._fetchPixels(e.extent,e.width,e.height,{...e.options,signal:t})}),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 T({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.length<1||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.forEach(t=>{e.set(t.name.toLowerCase().replaceAll(/ /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?h(()=>P.fromJSON(t)):null}get fieldsIndex(){return this.fields?new C(this.fields):null}set format(e){e&&Le.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"}get isRenderedFormat(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}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?.mosaicMethod&&(t=P.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const i=e||t.mosaicRule;return i?P.fromJSON(i):this._isMosaicRuleSupported(t)?P.fromJSON(t):null}writeMosaicRule(e,t,i){const{mosaicRule:s}=this;this._isValidCustomizedMosaicRule(s)&&(t[i]=s.toJSON())}readObjectIdField(e,t){if(!e){const i=t.fields.find(e=>"esriFieldTypeOID"===e.type||"oid"===e.type);e=i?.name}return e}get parsedUrl(){return l(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}get renderer(){const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const i=t?.find(({name:t})=>t===e);return i?.renderer.clone()}return this.internalRenderer}set renderer(e){this.activePresetRendererName=null,this.internalRenderer=e}set internalRenderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("internalRenderer",e)}readRenderer(e,t,i){const s=t?.layerDefinition?.drawingInfo?.renderer,r=oe(s,i);return null==r?null:("vector-field"===r.type&&t.symbolTileSize&&!s.symbolTileSize&&(r.symbolTileSize=t.symbolTileSize),q(r)||n.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),r)}writeRenderer(e,t,i){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON()}get rasterFields(){const e=this.fields?.map(e=>e.clone())??[];e.push(J()),"mosaic-dataset"===this.sourceType&&this.fields?.length&&e.push(U()),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some(({name:e})=>"none"===e.toLowerCase())&&e.push(B()),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter(({name:e})=>"none"!==e.toLowerCase()).forEach(({name:t})=>e.push(z(t)));const{rasterInfo:t}=this;if(this._isVectorDataSet()){const i=t?.multidimensionalInfo?.variables[0].unit?.trim(),s=L(i),r=H();e.push(s,r)}if(t?.multidimensionalInfo&&"raster-dataset"===this.sourceType){const i=G(t.multidimensionalInfo);e.push(...i)}const i=t?.attributeTable;if(null!=i){const t=k(i);e.push(...t)}return e}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=K.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const i=t.rasterFunctionInfos,s=t.renderingRule,r=null!=s&&Object.keys(s).length>0;return r||i?.length&&"None"!==i[0].name?this._isRFTJson(s)?K.fromJSON({rasterFunctionDefinition:s}):K.fromJSON(r?s:{rasterFunctionInfos:i}):null}readSpatialReference(e,t){const i=e||t.extent.spatialReference;return i?g.fromJSON(i):null}writePixelType(e,t,i){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[i]=V.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,{renderer:s,symbolizer:r,pixelFilter:n}=this;const{isRawData:a}=e;if(a&&"lerc"!==this.format&&(s??=Z(this.rasterInfo,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}),r||(this.symbolizer=new re({rendererJSON:s.toJSON(),rasterInfo:this.rasterInfo}),r=this.symbolizer)),(a||!this.isRenderedFormat)&&s&&r&&!n){await this._updateSymbolizer(r,s);const n=this.bandIds?.length?this.bandIds:ee(this.rasterInfo);i=await this._symbolize({pixelData:e,bandIds:n,symbolizer:r},t)}return i}destroy(){this._shutdownJobHandler()}async calculateVolume(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsCalculateVolume)throw new s("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=r(e),this.mosaicRule&&null==e.mosaicRule&&(e.mosaicRule=this.mosaicRule),le(this.url,e,this._getRequestOptions(t))}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new s("imagery-layer:compute-angles","this operation is not supported on the input image service");return ue(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new s("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return pe(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new s("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=r(e),this._applyMosaicAndRenderingRules(e),ce(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new s("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=r(e),this._applyMosaicAndRenderingRules(e),me(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 s("imagery-layer:measure-height","this operation is not supported on the input image service");return e=r(e),this._applyMosaicRule(e),he(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 s("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=r(e),this._applyMosaicRule(e),de(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 s("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=r(e),this._applyMosaicRule(e),fe(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 s("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=r(e),this._applyMosaicRule(e),ge(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new s("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new s("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return ye(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new s("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new s("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return Re(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const i=this.getField(e);return i?i.domain:null}async internalFetchImage(e,t,i,s={}){await this._updateCurrentRasterInfo();const{exportImageServiceParameters:r}=this;let n=!1;s.requestRawData&&(await this._initJobHandler(),r.requestRawData||"lerc"===this.format||(n=!0,r.requestRawData=!0));const a=this.getExportImageServiceParameters(e,t,i,s.timeExtent);if(n&&(r.requestRawData=!1,a&&!this.bandIds?.length&&(null==a.bandIds||""===a.bandIds))){const e=ee(this.rasterInfo);a.bandIds=e?.join(",")}if(null==a){if(s.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=i,s.returnImageBitmap){const{bitmap:t}=await N(e,`${$e(this.parsedUrl)}/exportImage`,s);return{imageBitmap:t}}return{imageOrCanvasElement:e}}const{bandIds:r,rasterInfo:n}=this,a=(r?.length||n.bandCount)??0,o=t*i,l=n.pixelType,u=[];for(let e=0;e<a;e++)u.push(E.createEmptyBand(l,o));return{pixelData:{pixelBlock:new E({width:t,height:i,pixels:u,mask:new Uint8Array(o),pixelType:l}),extent:e}}}const o=!!s.requestAsImageElement&&!this.pixelFilter,l=o&&!!s.returnImageBitmap,u={imageServiceParameters:a,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:o,returnImageBitmap:l,signal:s.signal};return this._requestArrayBuffer(u)}async fetchPixels(e,t,i,r={}){await this._initJobHandler(),r.applyRendering&&await this._updateCurrentRasterInfo();const{imageMaxWidth:n,imageMaxHeight:a}=this;if(t<=n&&i<=a)return this._exportTileQueue.push({extent:e,width:t,height:i,options:r},{signal:r.signal});if(t>ze||i>ze||n<Be||a<Be)throw new s("imagery-layer:fetch-pixels",`The image service has a maximum export size of ${n}x${a}. The requested size of ${t}x${i} exceeds this limit.`);let{xmin:o,ymax:l,spatialReference:u}=this._projectedFullExtent??this.fullExtent;if(!u?.equals(e.spatialReference)){const t=await import("../../geometry/operators/projectOperator.js");await t.load();const i=t.execute(this.fullExtent,e.spatialReference);o=i.xmin,l=i.ymax,this._projectedFullExtent=i}const p=e.width/t,c=e.height/i,m=Math.floor((e.xmin-o)/p),h=Math.floor((l-e.ymax)/c),f=m+t,g=h+i,y=Math.floor(m/Be),R=Math.floor(h/Be),x=Math.ceil(f/Be)-1,I=Math.ceil(g/Be)-1,w=Be*p,v=Be*c,b=[];for(let s=R;s<=I;s++){const t=l-s*v,i=t-v;for(let s=y;s<=x;s++){const n=o+s*w,a=new d({xmin:n,ymin:i,xmax:n+w,ymax:t,spatialReference:e.spatialReference});b.push(this._exportTileQueue.push({extent:a,width:Be,height:Be,options:r},{signal:r.signal}))}}const _=await Promise.all(b);if(_.some(e=>null==e.pixelBlock))return{extent:e,pixelBlock:null};return{extent:e,pixelBlock:this._rasterJobHandler?await this._rasterJobHandler.mosaicPixelData({pixelBlocks:_,destExtent:e},{signal:r.signal,transferPixelsToWorker:!0}):S(_,e)?.pixelBlock}}async _fetchPixels(e,t,i,s={}){const r=s.applyRendering?void 0:new T({layer:this,requestRawData:!0,interpolation:s.interpolation??"nearest",bandIds:s.bandIds??[]}),n=this.getExportImageServiceParameters(e,t,i,s.timeExtent,r);if(null==n)return{extent:e,pixelBlock:null};delete n.pixelType,s.bandIds||delete n.bandIds,delete n.compressionQuality;const a={imageServiceParameters:n,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:!1,returnImageBitmap:!1,signal:s.signal},{pixelData:o}=await this._requestArrayBuffer(a);return o??{extent:e,pixelBlock:null}}fetchKeyProperties(e){return i($e(this.parsedUrl)+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>e.data)}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new s("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):i($e(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>Ae.fromJSON(e.data))}getCatalogItemRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return Ne($e(this.parsedUrl),e,i)}async getCatalogItemICSInfo(e,t){const{data:s}=await i($e(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),r=s?.ics;if(!r)return;let n=null;try{n=(await i($e(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!n?.spatialReference)return{ics:r,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?i($e(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then(e=>e.data).catch(()=>({})):{},o=n.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[n]}),inSR:y(o),outSR:"0:"+e},u=i($e(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then(e=>e.data).catch(()=>({})),p=5,c=(n.xmin+n.xmax)/2,m=(n.ymax-n.ymin)/(p+1),h=n.ymin+m,f=[];for(let i=0;i<p;i++)f.push({x:c,y:h+m*i});const R={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:f}),inSR:y(o),outSR:"0:"+e},x=i($e(this.parsedUrl)+"/project",{query:this._getQueryParams(R),...t}).then(e=>e.data).catch(()=>({})),I=await Promise.all([a,u,x]);let w=I[0].ipxf;if(null==w){const e=r.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(w={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const v=d.fromJSON(I[1]?.geometries?.[0]);v&&(v.spatialReference=new g({wkid:0,imageCoordinateSystem:r}));const b=I[2].geometries?I[2].geometries.filter(e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y):[],S=b.length;if(S<3)return{ics:r,icsToPixelTransform:w,icsExtent:v,northDirection:null};let _=0,F=0,D=0,O=0;for(let i=0;i<S;i++)_+=b[i].x,F+=b[i].y,D+=b[i].x*b[i].x,O+=b[i].x*b[i].y;const T=(S*O-_*F)/(S*D-_*_);let M=0;const C=b[p-1].x>b[0].x,N=b[p-1].y>b[0].y;return T===1/0?M=N?90:270:0===T?M=C?0:180:T>0?M=C?180*Math.atan(T)/Math.PI:180*Math.atan(T)/Math.PI+180:T<0&&(M=N?180+180*Math.atan(T)/Math.PI:360+180*Math.atan(T)/Math.PI),{ics:r,icsToPixelTransform:w,icsExtent:v,northDirection:M}}async generateRasterInfo(e,t){const i=m(K,e),r={...t,query:this._getQueryParams()};if(!i||"none"===i.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(i))return this.serviceRasterInfo??Te($e(this.parsedUrl),this.sourceJSON,r);const n=He(i);if(!n)throw new s("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[n])return this._functionRasterInfos[n];const a=Me($e(this.parsedUrl),i,r);this._functionRasterInfos[n]=a;try{const t=await a,{rasterFunction:i}=this;return(i===e||JSON.stringify(i)===JSON.stringify(e))&&JSON.stringify(this.rasterInfo)!==JSON.stringify(t)&&(this.rasterInfo=t),t}catch(o){throw this._functionRasterInfos[n]=null,o}}getExportImageServiceParameters(e,t,i,s,r){e=e.clone().shiftCentralMeridian();const n=xe(e.spatialReference,$e(this.parsedUrl));r??=this.exportImageServiceParameters;const a=r.toJSON(),{bandIds:o,noData:l}=a;let{renderingRule:u}=a;const p=this.rasterFunction?.rasterFunctionDefinition,c=this.renderer?.type,m=!c||"raster-stretch"===c||"raster-colormap"===c||"unique-value"===c||"class-breaks"===c||"raster-shaded-relief"===c;if(o?.length&&this._hasRasterFunction(this.rasterFunction)&&!p&&m){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===u.rasterFunction)e.rasterFunctionArguments.Raster=u.rasterFunctionArguments.Raster,u.rasterFunctionArguments.Raster=e;else if("Colormap"===u.rasterFunction){const t=u.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,u.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=u,u=e;a.bandIds=void 0}else a.bandIds=o?.join(",");Array.isArray(l)&&l.length>0&&(a.noData=l.join(","));const h=this._processMultidimensionalIntersection(null,s,r.mosaicRule);if(h.isOutSide)return null;a.mosaicRule=null!=h.mosaicRule?JSON.stringify(h.mosaicRule):null,s=h.timeExtent,a.renderingRule=this._getRenderingRuleString(K.fromJSON(u));const d={};if(null!=s){const{start:e,end:t}=s.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:n,imageSR:n,size:t+","+i,...a,...d}}async getSamples(e,t){const i=await this._fetchCapabilities(t?.signal);if(!i?.operations.supportsGetSamples)throw new s("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=r(e);const{raster:n}=this;return n&&null==e.raster&&(e.raster=n),Ie(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new s("imagery-layer:identify","identify operation is not supported on the input image service");e=r(e),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=f.fromExtent(e.geometry));const i=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(i.isOutSide)throw new s("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=i.timeExtent,e.mosaicRule=i.mosaicRule;const{raster:n,rasterFunction:a}=this;return a&&null==e.rasterFunction&&(e.rasterFunction=a),n&&null==e.raster&&(e.raster=n),we(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new s("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return ve($e(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new s("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return be($e(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new s("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return Se($e(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new s("imagery-layer:find-images","findImages operation is not supported on the input image service");return _e($e(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new s("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return Fe($e(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new Ve({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new s("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=e??{outSpatialReference:this.spatialReference},De($e(this.parsedUrl),e,this._getRequestOptions(t))}async queryExtent(e,t){({query:e,requestOptions:t}=await this._prepareForQuery(e,t));const{where:i,objectIds:s,geometry:r,timeExtent:n,start:a,num:o,pixelSize:l}=e,u=null!=i&&"1=1"!==i,p=null!=s&&s.length>0,c=null!=r&&("extent"!==r.type||!r.equals(this.fullExtent)),m=null!=l,h=null!=a||null!=o,{timeInfo:d}=this,f=null!=n&&null!=d&&!n.equals(d.fullTimeExtent);if(!(u||p||c||m||f||h)){const i=await qe(this.url,e,t),{outSpatialReference:s}=e;if(!s||s.equals(this.spatialReference))return{count:i,extent:this.fullExtent.clone()};const r=await import("../../geometry/operators/projectOperator.js");await r.load();return{count:i,extent:r.execute(this.fullExtent,s)}}return Pe(this.url,e,t)}async queryRasters(e,t){({query:e,requestOptions:t}=await this._prepareForQuery(e,t));const i=await Ee(this.url,e,t),s=this.graphicOrigin;return i.features.forEach(e=>{e.layer=this,e.origin=s}),i}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),je(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new s("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=e??{where:"1=1"},Oe($e(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),qe(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new s("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:i,returnDomainValues:r,returnTopmostRaster:n,showNoDataRecords:a}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p=$.servicePixelValue.toLowerCase(),c=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(o=e.outFields.some(e=>!e.toLowerCase().startsWith(p)),this.version>=10.4)){const t=e.outFields.filter(e=>e.toLowerCase().startsWith(p)&&e.length>p.length).map(e=>{const t=e.slice(p.length+1);return[this._updateRenderingRulesFunctionName(t,c),t]});l=t.map(e=>new K({functionName:e[0]})),u=t.map(e=>e[1]);const{rasterFunction: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 m=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:h}=this;let d=e.timeExtent||this.timeExtent;if(h){const{isOutside:t,intersection:i}=R(h,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new s("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");null!=i?.timeExtent&&(d=i.timeExtent)}const g=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,d);let y=e.geometry;this.version<10.91&&"extent"===y?.type&&(y=f.fromExtent(y));const I=this._getQueryParams({geometry:y,timeExtent:d,mosaicRule:g,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:i,returnCatalogItems:o,returnGeometry:m,raster:this.raster,maxItemCount:n?1:null});delete I.f;const w=new Qe(I);try{await this._generateRasterInfo(this.rasterFunction);const i=await we(this.url,w,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,n=null!=i.value&&i.value.toLowerCase().includes("nodata"),l=o&&!m&&i?.catalogItems?.features.length&&(a||!n),p=this.multidimensionalInfo&&"raster-dataset"===this.sourceType?x({rasterInfo:this.rasterInfo,multidimensionalDefinition:g?.multidimensionalDefinition,timeExtent:d,multidimensionalSubset:this.multidimensionalSubset}):null;if(!l)return this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:s,effectiveMultidimensionalDefinition:p});const c=this.objectIdField||"ObjectId",h=i.catalogItems?.features??[],f=h.map(e=>e.attributes?.[c]),y=new Ve({objectIds:f,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[c]}),R=await this.queryRasters(y);return R?.features?.length&&R.features.forEach(t=>{h.forEach(i=>{i.attributes[c]===t.attributes[c]&&t.geometry&&(i.geometry=t.geometry.clone(),null!=e.outSpatialReference&&(i.geometry.spatialReference=e.outSpatialReference))})}),this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:s,effectiveMultidimensionalDefinition:p})}catch{throw new s("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const s=i($e(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.statistics),r=i($e(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.histograms),n=await Promise.all([s,r]);return n[0]&&n[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),{statistics:n[0]||null,histograms:n[1]||null}}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return I(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,i=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):Te($e(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then(e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),Ce(e,t),e)),s=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,r=this._getRasterFunctionInfos();return Promise.all([i,s,r]).then(e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.internalRenderer&&!this._isSupportedRenderer(this.internalRenderer)&&(this._set("internalRenderer",null),n.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("internalRenderer",this._configRenderer(this.renderer)),this.addHandles([o(()=>this.rasterFunction,e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this._generateRasterInfo(e).then(e=>{e&&(this.rasterInfo=e)})})]);const{serviceRasterInfo:t}=this;null!=t.multidimensionalInfo&&this._updateMultidimensionalDefinition(t)})}_combineMosaicRuleWithTimeExtent(e,t){const i=this.timeInfo,{multidimensionalInfo:s}=this.serviceRasterInfo;if(null==e||null==s||null==t||null==i?.startField)return e;const{startField:r}=i,n=s.variables.some(e=>e.dimensions.some(e=>e.name===r))?r:"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 a=e.multidimensionalDefinition.filter(e=>e.dimensionName===n),o=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==o||null==l||o===l,p=u?[o||l]:[[o,l]],c=this.version>=10.8;if(a.length)a.forEach(e=>{e.dimensionName===n&&(c?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=p))});else if(!c){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=p}):e.multidimensionalDefinition.push(new O({variableName:"",dimensionName:n,isSlice:u,values:p}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return null==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 s("imagery-layer:query-rasters","query operation is not supported on the input image service");const i=null!=e?m(Ve,e):this.createQuery();return t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:i,requestOptions:t}}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:i}=this;return"unique-value"===e.type&&this._hasRasterFunction(i)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&te(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:s,ssl:r}=await i($e(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=s,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 s("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(null==e)return!1;const{functionName:t,functionArguments:i}=e,s="resample"===t?.toLowerCase(),r=i?.ResampleType||i?.resampleType;return s&&(7===r||10===r)}_configRenderer(e){const{rasterInfo:t}=this;if(!this.isRenderedFormat&&!this.pixelFilter||this._isVectorDataSet()){const i=this.mosaicRule?.multidimensionalDefinition?.[0].variableName,s=ie({variableName:i,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&t.bandCount>=3){const e=s?.bandIds??ee(t);!e||3===t.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=s?.renderer??Z(t,{bandIds:this.bandIds,variableName:this.rasterFunction?null:i}));const r=se(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=r,this.symbolizer.rasterInfo=t):this.symbolizer=new re({rendererJSON:r,rasterInfo:t}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){null!=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?this._rasterJobHandler.decode({data:e,options:t}):v(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;const s=await i($e(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e});return s.data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:r,returnImageBitmap:n,signal:a}=e;if(r&&this._canRequestImageElement(t.format)){const s=`${$e(this.parsedUrl)}/exportImage`,{data:r}=await i(s,{responseType:n?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:a});if(r instanceof Blob){const{bitmap:e}=await N(r,s,{signal:a});return{imageBitmap:e,params:t}}return{imageOrCanvasElement:r,params:t}}const o=this._initJobHandler(),l=i($e(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:a}),u=(await Promise.all([l,o]))[0].data,p=t.format||"jpgpng";let c=p;if("bsq"!==c&&"bip"!==c&&(c=b(u)),!c)throw new s("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const m={signal:a},h=this._decodePixelBlock(u,{width:t.width,height:t.height,format:p,applyJpegMask:!0},m);return{pixelData:{pixelBlock:await h,extent:t.extent},params:t}}_generateRasterInfo(e,t){return this.generateRasterInfo(e,t).catch(()=>null)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this.defaultMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;let t=w(e,{multidimensionalSubset:this.multidimensionalSubset});if(null!=t&&t.length>0){this.mosaicRule=this.mosaicRule||new P;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.rasterFunction&&"none"!==this.rasterFunction.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 s=e.value,{templateRRFunctionNames:r,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=i,l=e.processedValues;let u=e.catalogItems?.features,p=e.properties?.Values?.map(e=>e.replaceAll(/ /gi,", "))||[];const c=this.objectIdField||"ObjectId",m="string"==typeof s&&s.toLowerCase().includes("nodata"),h=[];if(s&&!u&&(!m||n)){const e={};e[c]=0;p=[s],u=[new t({geometry:this.fullExtent,attributes:e})],this.multidimensionalInfo&&"raster-dataset"===this.sourceType&&W(this.rasterFields,e,i.effectiveMultidimensionalDefinition)}if(!u)return[];this._updateResponseFieldNames(u,o),m&&!n&&(u=[]);const{itemPixelValue:d,servicePixelValue:f}=$,g=this.rasterFields.some(e=>e.name===d),y=this.graphicOrigin;for(let t=0;t<u.length;t++){const e=u[t];if(null!=s){const i=p[t],a=this.rasterFunction&&l&&l.length>0&&r&&r.length>0&&r.includes(this.rasterFunction.functionName)?l[r.indexOf(this.rasterFunction.functionName)]:s;if("nodata"===i.toLowerCase()&&!n)continue;g&&(e.attributes[d]=i),e.attributes[f]=a,this._updateFeatureWithMagDirValues(e,i);const o=this.fields&&this.fields.length>0;let u=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?o?i:s:a;this.rasterFunction||(u=o?i:s),this._updateFeatureWithRasterAttributeTableValues(e,u)}if(e.sourceLayer=e.layer=this,e.origin=y,a&&this._updateFeatureWithDomainValues(e),r&&l&&r.length===l.length)for(let t=0;t<r.length;t++){const i=`${$.servicePixelValue}.${r[t]}`;e.attributes[i]=l[t]}h.push(u[t])}return h}_processMultidimensionalIntersection(e,t,i){const{multidimensionalSubset:s}=this;if(!s)return{isOutSide:!1,timeExtent:t,mosaicRule:i=this._combineMosaicRuleWithTimeExtent(i,t)};if(s){const{isOutside:i,intersection:r}=R(s,{geometry:e,timeExtent:t});if(i)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=r?.timeExtent&&(t=r.timeExtent)}if(i=this._combineMosaicRuleWithTimeExtent(i,t),i?.multidimensionalDefinition){const{isOutside:e}=R(s,{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(null==i)return;const{features:s,fields:r}=i,n=r.map(e=>e.name).find(e=>"value"===e.toLowerCase());if(!n)return;const a=s.filter(e=>e.attributes[n]===(null!=t?parseInt(t,10):null));a&&a[0]&&r.forEach(t=>{const i=X+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)),s=i.map(e=>[e]),r=i.map(e=>({minValue:e,maxValue:e,noDataValue:null})),n=new E({height:1,width:1,pixelType:"f32",pixels:s,statistics:r});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new d(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:_([n.pixels[0][0],n.pixels[1][0]]);e.attributes[$.magnitude]=a[0],e.attributes[$.direction]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter(e=>"coded-value"===e.domain?.type);null!=t&&t.forEach(t=>{const i=e.attributes[t.name];if(null!=i){const s=t.domain.codedValues.find(e=>e.code===i);s&&(e.attributes[t.name]=s.name)}})}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const i=this.fieldsIndex;null!=i&&e.forEach(e=>{if(e?.attributes)for(const s of t){const t=i.get(s)?.name;t&&t!==s&&(e.attributes[s]=e.attributes[t],delete e.attributes[t])}})}_getRenderingRuleString(e){if(e){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRasterFunction(e){return 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().replaceAll(/ /gi,"_");return t.has(i)?t.get(i):e}_isRFTJson(e){return 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,rasterFunction:s}=this;s&&null==e.rasterFunction&&(e.rasterFunction=s),i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}async _updateCurrentRasterInfo(e){if(this.renderer||this.symbolizer){const t=await this._generateRasterInfo(this.rasterFunction,{signal:e});t&&(this.rasterInfo=t)}}_applyMosaicRule(e){const{raster:t,mosaicRule:i}=this;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,maxRecordCount:s}=e,r=t.includes("image"),n="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!(!e.spatialReference&&!e.extent?.spatialReference),o=t.includes("edit"),l=t.includes("mensuration")&&a,u=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map(e=>e.trim()),p=l&&u.includes("basic"),c=this._isMosaicDataset(e)&&t.includes("catalog"),m=t.includes("download"),h=i>=10.7&&n||i>=11.4&&(n||l&&u.includes("3d")),d=c&&e.fields&&e.fields.length>0,f=d&&e.supportsAdvancedQueries?e.advancedQueryCapabilities:void 0;return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:r,supportsExportImage:r,supportsIdentify:r,supportsImageToMap:i>=11.2&&c,supportsImageToMapMultiray:i>=11.2&&c,supportsMapToImage:i>=11.2&&c,supportsFindImages:i>=11.2&&c,supportsGetImageUrl:i>=11.3&&m,supportsMeasure:l,supportsMeasureFromImage:i>=11.2,supportsDownload:m,supportsQuery:d,supportsGetSamples:i>=10.2&&r,supportsProject:i>=10.3&&r,supportsComputeStatisticsHistograms:i>=10.4&&r,supportsQueryBoundary:i>=10.6&&r,supportsCalculateVolume:h,supportsComputePixelLocation:i>=10.7&&c,supportsComputeAngles:i>=10.91,supportsQueryGPSInfo:i>=11.2&&c,supportsAdd:o,supportsDelete:o,supportsEditing:o,supportsUpdate:o,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryTopFeatures:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,relativeTimeBinWindow:void 0,supportsStatisticsAggregatedIds:!!f?.supportsAggregateIds,supportsStatistics:!!f?.supportsStatistics,supportsOrderBy:!!f?.supportsOrderBy,supportsDistinct:!!f?.supportsDistinct,supportsPagination:!!f?.supportsPagination,supportsPaginationOnAggregatedQueries:!!f?.supportsPaginationOnAggregatedQueries,supportsStandardizedQueriesOnly:!!f?.useStandardizedQueries,supportsPercentileStatistics:!!f?.supportsPercentileStatistics,supportsCentroid:!!f?.supportsReturningGeometryCentroid,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDistance:!!f?.supportsQueryWithDistance,supportsOutDistance:!!f?.supportsOutDistance,supportsExtent:!!f?.supportsReturningQueryExtent,supportsGeometryProperties:!!f?.supportsReturningGeometryProperties,supportsHavingClause:!!f?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsReturnExceededLimitGeometries:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:f?.supportsSqlExpression??!!f,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsFormatPBFWithCurves:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!f?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,standardMaxRecordCountNoGeometry:void 0,tileMaxRecordCount:void 0,supportsTrueCurve:!1},mensuration:{supportsDistanceAndAngle:p,supportsAreaAndPerimeter:p,supportsPointOrCentroid:p,supportsHeightFromBaseAndTop:l&&u.includes("base-top height"),supportsHeightFromBaseAndTopShadow:l&&u.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:l&&u.includes("top-top shadow height"),supports3D:l&&u.includes("3d")}}}};function $e(e){return e?.path??""}return e([u({clonable:!1})],We.prototype,"_functionRasterInfos",void 0),e([u({readOnly:!0})],We.prototype,"_serviceSupportsMosaicRule",void 0),e([Je("_serviceSupportsMosaicRule",["currentVersion","fields"])],We.prototype,"readServiceSupportsMosaicRule",null),e([u({readOnly:!0})],We.prototype,"_rasterFunctionNamesIndex",null),e([u()],We.prototype,"_projectedFullExtent",void 0),e([u({clonable:!1})],We.prototype,"_exportTileQueue",void 0),e([u()],We.prototype,"adjustAspectRatio",void 0),e([u({type:[c],json:{write:!0}})],We.prototype,"bandIds",void 0),e([Je("bandIds")],We.prototype,"readBandIds",null),e([u({readOnly:!0,json:{read:!1}})],We.prototype,"capabilities",void 0),e([Je("service","capabilities",["capabilities","currentVersion","serviceDataType"])],We.prototype,"readCapabilities",null),e([u({type:Number})],We.prototype,"compressionQuality",void 0),e([Ue("compressionQuality")],We.prototype,"writeCompressionQuality",null),e([u({type:Number})],We.prototype,"compressionTolerance",void 0),e([Ue("compressionTolerance")],We.prototype,"writeCompressionTolerance",null),e([u({json:{read:{source:"copyrightText"}}})],We.prototype,"copyright",void 0),e([u({readOnly:!0})],We.prototype,"defaultMosaicRule",void 0),e([Je("defaultMosaicRule",["defaultMosaicMethod"])],We.prototype,"readDefaultMosaicRule",null),e([u({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],We.prototype,"definitionExpression",void 0),e([u({readOnly:!0,constructOnly:!0})],We.prototype,"exportImageServiceParameters",void 0),e([u()],We.prototype,"rasterInfo",void 0),e([u({readOnly:!0,type:[M]})],We.prototype,"fields",void 0),e([u({readOnly:!0})],We.prototype,"fieldsIndex",null),e([u({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff","bip","bsq"],json:{write:!0}})],We.prototype,"format",null),e([Je("service","format",["serviceDataType"])],We.prototype,"readFormat",null),e([u({type:d})],We.prototype,"fullExtent",void 0),e([u({readOnly:!0})],We.prototype,"hasMultidimensions",void 0),e([u({json:{read:{source:"maxImageHeight"}}})],We.prototype,"imageMaxHeight",void 0),e([u({json:{read:{source:"maxImageWidth"}}})],We.prototype,"imageMaxWidth",void 0),e([u({type:String,json:{type:A.jsonValues,read:A.read,write:A.write}})],We.prototype,"interpolation",void 0),e([u()],We.prototype,"minScale",void 0),e([Je("service","minScale")],We.prototype,"readMinScale",null),e([u()],We.prototype,"maxScale",void 0),e([Je("service","maxScale")],We.prototype,"readMaxScale",null),e([u({type:P})],We.prototype,"mosaicRule",null),e([Je("mosaicRule",["mosaicRule","defaultMosaicMethod"])],We.prototype,"readMosaicRule",null),e([Ue("mosaicRule")],We.prototype,"writeMosaicRule",null),e([u()],We.prototype,"multidimensionalInfo",void 0),e([u({type:j,json:{write:!0}})],We.prototype,"multidimensionalSubset",void 0),e([u({json:{type:[Number,[Number]],write:!0}})],We.prototype,"noData",void 0),e([u({type:String,json:{type:Q.jsonValues,read:Q.read,write:Q.write}})],We.prototype,"noDataInterpretation",void 0),e([u({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],We.prototype,"objectIdField",void 0),e([Je("objectIdField")],We.prototype,"readObjectIdField",null),e([u({readOnly:!0})],We.prototype,"geometryType",void 0),e([u({})],We.prototype,"typeIdField",void 0),e([u({})],We.prototype,"types",void 0),e([u({readOnly:!0})],We.prototype,"parsedUrl",null),e([u({type:Function})],We.prototype,"pixelFilter",void 0),e([u()],We.prototype,"raster",void 0),e([u({readOnly:!0})],We.prototype,"sourceType",void 0),e([Je("sourceType",["serviceSourceType","fields"])],We.prototype,"readSourceType",null),e([u()],We.prototype,"viewId",void 0),e([u({types:ne})],We.prototype,"renderer",null),e([u({types:ne,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:ae,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],We.prototype,"internalRenderer",null),e([Je("internalRenderer")],We.prototype,"readRenderer",null),e([Ue("internalRenderer")],We.prototype,"writeRenderer",null),e([u({clonable:!1})],We.prototype,"symbolizer",void 0),e([u(F)],We.prototype,"opacity",void 0),e([u({readOnly:!0})],We.prototype,"rasterFields",null),e([u({constructOnly:!0})],We.prototype,"rasterFunctionInfos",void 0),e([u({type:K,json:{name:"renderingRule"}})],We.prototype,"rasterFunction",null),e([Je("rasterFunction",["renderingRule","rasterFunctionInfos"])],We.prototype,"readRasterFunction",null),e([u({readOnly:!0})],We.prototype,"serviceDataType",void 0),e([u({readOnly:!0,type:g})],We.prototype,"spatialReference",void 0),e([Je("spatialReference",["spatialReference","extent"])],We.prototype,"readSpatialReference",null),e([u({type:V.apiValues,json:{read:V.read,type:V.jsonValues}})],We.prototype,"pixelType",void 0),e([Ue("pixelType")],We.prototype,"writePixelType",null),e([u({constructOnly:!0,type:Y})],We.prototype,"serviceRasterInfo",void 0),e([u()],We.prototype,"sourceJSON",void 0),e([u(D)],We.prototype,"url",void 0),e([u({readOnly:!0})],We.prototype,"version",void 0),e([Je("version",["currentVersion","fields","timeInfo"])],We.prototype,"readVersion",null),We=e([p("esri.layers.mixins.ArcGISImageService")],We),We};export{Ge as ArcGISImageService};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../Graphic.js";import i from"../../request.js";import r from"../../core/Error.js";import{clone as s}from"../../core/lang.js";import n from"../../core/Logger.js";import{QueueProcessor as a}from"../../core/QueueProcessor.js";import{watch as o}from"../../core/reactiveUtils.js";import{urlToObject as l}from"../../core/urlUtils.js";import{property as u,subclass as p}from"../../core/accessorSupport/decorators.js";import{Integer as c,ensureClass as m}from"../../core/accessorSupport/ensureType.js";import{runUntracked as h}from"../../core/accessorSupport/tracking.js";import d from"../../geometry/Extent.js";import f from"../../geometry/Polygon.js";import g from"../../geometry/SpatialReference.js";import{srToRESTValue as y}from"../../geometry/support/spatialReferenceUtils.js";import{intersectMultimensionalSubset as R,getEffectiveMultidimensionalDefinition as x,getSubsetVariablesFromMdInfo as I,getDefaultMultidimensionalDefinition as w}from"../raster/datasets/multidimensionalUtils.js";import{decode as v,getFormat as b}from"../raster/formats/RasterCodec.js";import{mosaicPixelData as S}from"../raster/functions/pixelUtils.js";import{uvComponentToVector as _}from"../raster/functions/vectorFieldUtils.js";import{opacity as F,url as D}from"../support/commonProperties.js";import O from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as T}from"../support/ExportImageServiceParameters.js";import M from"../support/Field.js";import C from"../support/FieldsIndex.js";import{createBitmap as q}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as N}from"../support/imageryRendererUtils.js";import P from"../support/MosaicRule.js";import j from"../support/MultidimensionalSubset.js";import E from"../support/PixelBlock.js";import{interpolationKebab as A,noDataInterpretationKebab as Q,pixelTypeKebabDict as V}from"../support/rasterEnums.js";import{getServicePixelValueField as J,getItemPixelValueField as B,getRawServicePixelValueField as U,getProcessedServicePixelValueField as z,getMagnitudeField as L,getDirectionField as H,getMultidimensionalFields as G,getRasterAttributeTableFields as k,addMultidimensionalFieldValues as W,commonRasterFieldNames as $,rasterFieldPrefix as X}from"../support/rasterFieldUtils.js";import K from"../support/RasterFunction.js";import Y from"../support/RasterInfo.js";import{createDefaultRenderer as Z,getDefaultBandCombination as ee,getSupportedRendererTypes as te,matchPresetRenderer as ie,normalizeRendererJSON as re}from"../../renderers/support/rasterRendererHelper.js";import se from"../../renderers/support/RasterSymbolizer.js";import{rasterRendererTypes as ne,websceneRasterRendererTypes as ae,read as oe}from"../../renderers/support/rasterTypeUtils.js";import{calculateVolume as le,computeAngles as ue,computePixelSpaceLocations as pe,computeHistograms as ce,computeStatisticsHistograms as me,measureHeight as he,measureAreaAndPerimeter as de,measureDistanceAndAngle as fe,measurePointOrCentroid as ge,measureLengthFromImage as ye,measureAreaFromImage as Re,getImageSpatialReferenceQueryParameter as xe,getSamples as Ie,identify as we,imageToMap as ve,imageToMapMultiray as be,mapToImage as Se,findImages as _e,getImageUrl as Fe,queryBoundary as De,queryGPSInfo as Oe}from"../../rest/imageService.js";import{fetchServiceRasterInfo as Te,generateRasterInfo as Me,patchServiceInfo as Ce}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as qe}from"../../rest/imageService/getCatalogItemRasterInfo.js";import{executeForCount as Ne}from"../../rest/query/executeForCount.js";import{executeForExtent as Pe}from"../../rest/query/executeForExtent.js";import{executeForIds as je}from"../../rest/query/executeForIds.js";import{executeQueryJSON as Ee}from"../../rest/query/executeQueryJSON.js";import Ae from"../../rest/support/FeatureSet.js";import Qe from"../../rest/support/ImageIdentifyParameters.js";import Ve from"../../rest/support/Query.js";import{reader as Je}from"../../core/accessorSupport/decorators/reader.js";import{writer as Be}from"../../core/accessorSupport/decorators/writer.js";const Ue=512,ze=4096,Le=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]);function He(e){const t=JSON.stringify(e),i=t.includes('"rasterFunctionDefinition":{'),r=i?t.match(/"type":"(.*?FunctionArguments")/gi):t.match(/"rasterFunction":"(.*?")/gi),s=r?.map(e=>i?e.slice(8,-18):e.slice(18,-1));return s?s.join("/"):null}const Ge=Ge=>{const ke=Ge;let We=class extends ke{constructor(){super(...arguments),this._functionRasterInfos={},this._serviceSupportsMosaicRule=null,this._exportTileQueue=new a({concurrency:4,process:(e,t)=>this._fetchPixels(e.extent,e.width,e.height,{...e.options,signal:t})}),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 T({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.length<1||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.forEach(t=>{e.set(t.name.toLowerCase().replaceAll(/ /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?h(()=>P.fromJSON(t)):null}get fieldsIndex(){return this.fields?new C(this.fields):null}set format(e){e&&Le.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"}get isRenderedFormat(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}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?.mosaicMethod&&(t=P.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const i=e||t.mosaicRule;return i?P.fromJSON(i):this._isMosaicRuleSupported(t)?P.fromJSON(t):null}writeMosaicRule(e,t,i){const{mosaicRule:r}=this;this._isValidCustomizedMosaicRule(r)&&(t[i]=r.toJSON())}readObjectIdField(e,t){if(!e){const i=t.fields.find(e=>"esriFieldTypeOID"===e.type||"oid"===e.type);e=i?.name}return e}get parsedUrl(){return l(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}get renderer(){const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const i=t?.find(({name:t})=>t===e);return i?.renderer.clone()}return this.internalRenderer}set renderer(e){this.activePresetRendererName=null,this.internalRenderer=e}set internalRenderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("internalRenderer",e)}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer,s=oe(r,i);return null==s?null:("vector-field"===s.type&&t.symbolTileSize&&!r.symbolTileSize&&(s.symbolTileSize=t.symbolTileSize),N(s)||n.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),s)}writeRenderer(e,t,i){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON()}get rasterFields(){const e=this.fields?.map(e=>e.clone())??[];e.push(J()),"mosaic-dataset"===this.sourceType&&this.fields?.length&&e.push(B()),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some(({name:e})=>"none"===e.toLowerCase())&&e.push(U()),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter(({name:e})=>"none"!==e.toLowerCase()).forEach(({name:t})=>e.push(z(t)));const{rasterInfo:t}=this;if(this._isVectorDataSet()){const i=t?.multidimensionalInfo?.variables[0].unit?.trim(),r=L(i),s=H();e.push(r,s)}if(t?.multidimensionalInfo&&"raster-dataset"===this.sourceType){const i=G(t.multidimensionalInfo);e.push(...i)}const i=t?.attributeTable;if(null!=i){const t=k(i);e.push(...t)}return e}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=K.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const i=t.rasterFunctionInfos,r=t.renderingRule,s=null!=r&&Object.keys(r).length>0;return s||i?.length&&"None"!==i[0].name?this._isRFTJson(r)?K.fromJSON({rasterFunctionDefinition:r}):K.fromJSON(s?r:{rasterFunctionInfos:i}):null}readSpatialReference(e,t){const i=e||t.extent.spatialReference;return i?g.fromJSON(i):null}writePixelType(e,t,i){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[i]=V.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,{renderer:r,symbolizer:s,pixelFilter:n}=this;const{isRawData:a}=e;if(a&&"lerc"!==this.format&&(r??=Z(this.rasterInfo,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}),s||(this.symbolizer=new se({rendererJSON:r.toJSON(),rasterInfo:this.rasterInfo}),s=this.symbolizer)),(a||!this.isRenderedFormat)&&r&&s&&!n){await this._updateSymbolizer(s,r);const n=this.bandIds?.length?this.bandIds:ee(this.rasterInfo);i=await this._symbolize({pixelData:e,bandIds:n,symbolizer:s},t)}return i}destroy(){this._shutdownJobHandler()}async calculateVolume(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsCalculateVolume)throw new r("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=s(e),this.mosaicRule&&null==e.mosaicRule&&(e.mosaicRule=this.mosaicRule),le(this.url,e,this._getRequestOptions(t))}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new r("imagery-layer:compute-angles","this operation is not supported on the input image service");return ue(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new r("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return pe(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new r("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=s(e),this._applyMosaicAndRenderingRules(e),ce(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new r("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=s(e),this._applyMosaicAndRenderingRules(e),me(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 r("imagery-layer:measure-height","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),he(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 r("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),de(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 r("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),fe(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 r("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=s(e),this._applyMosaicRule(e),ge(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new r("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new r("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return ye(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new r("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new r("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return Re(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const i=this.getField(e);return i?i.domain:null}async internalFetchImage(e,t,i,r={}){await this._updateCurrentRasterInfo();const{exportImageServiceParameters:s}=this;let n=!1;if(r.requestRawData&&(await this._initJobHandler(),!s.requestRawData&&"lerc"!==this.format)){n=!0,s.requestRawData=!0;let e=this.bandIds;if(!e?.length){const t=ee(this.rasterInfo),i=Array.from({length:this.rasterInfo.bandCount},(e,t)=>t);i?.join(",")!==t?.join(",")&&(e=t)}s.rawDataRequestBandIds=e}const a=this.getExportImageServiceParameters(e,t,i,r.timeExtent);if(n&&(s.requestRawData=!1,s.rawDataRequestBandIds=null),null==a){if(r.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=i,r.returnImageBitmap){const{bitmap:t}=await q(e,`${$e(this.parsedUrl)}/exportImage`,r);return{imageBitmap:t}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,a=(s?.length||n.bandCount)??0,o=t*i,l=n.pixelType,u=[];for(let e=0;e<a;e++)u.push(E.createEmptyBand(l,o));return{pixelData:{pixelBlock:new E({width:t,height:i,pixels:u,mask:new Uint8Array(o),pixelType:l}),extent:e}}}const o=!!r.requestAsImageElement&&!this.pixelFilter,l=o&&!!r.returnImageBitmap,u={imageServiceParameters:a,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:o,returnImageBitmap:l,signal:r.signal};return this._requestArrayBuffer(u)}async fetchPixels(e,t,i,s={}){await this._initJobHandler(),s.applyRendering&&await this._updateCurrentRasterInfo();const{imageMaxWidth:n,imageMaxHeight:a}=this;if(t<=n&&i<=a)return this._exportTileQueue.push({extent:e,width:t,height:i,options:s},{signal:s.signal});if(t>ze||i>ze||n<Ue||a<Ue)throw new r("imagery-layer:fetch-pixels",`The image service has a maximum export size of ${n}x${a}. The requested size of ${t}x${i} exceeds this limit.`);let{xmin:o,ymax:l,spatialReference:u}=this._projectedFullExtent??this.fullExtent;if(!u?.equals(e.spatialReference)){const t=await import("../../geometry/operators/projectOperator.js");await t.load();const i=t.execute(this.fullExtent,e.spatialReference);o=i.xmin,l=i.ymax,this._projectedFullExtent=i}const p=e.width/t,c=e.height/i,m=Math.floor((e.xmin-o)/p),h=Math.floor((l-e.ymax)/c),f=m+t,g=h+i,y=Math.floor(m/Ue),R=Math.floor(h/Ue),x=Math.ceil(f/Ue)-1,I=Math.ceil(g/Ue)-1,w=Ue*p,v=Ue*c,b=[];for(let r=R;r<=I;r++){const t=l-r*v,i=t-v;for(let r=y;r<=x;r++){const n=o+r*w,a=new d({xmin:n,ymin:i,xmax:n+w,ymax:t,spatialReference:e.spatialReference});b.push(this._exportTileQueue.push({extent:a,width:Ue,height:Ue,options:s},{signal:s.signal}))}}const _=await Promise.all(b);if(_.some(e=>null==e.pixelBlock))return{extent:e,pixelBlock:null};return{extent:e,pixelBlock:this._rasterJobHandler?await this._rasterJobHandler.mosaicPixelData({pixelBlocks:_,destExtent:e},{signal:s.signal,transferPixelsToWorker:!0}):S(_,e)?.pixelBlock}}async _fetchPixels(e,t,i,r={}){const s=r.applyRendering?void 0:new T({layer:this,requestRawData:!0,interpolation:r.interpolation??"nearest",bandIds:r.bandIds??[]}),n=this.getExportImageServiceParameters(e,t,i,r.timeExtent,s);if(null==n)return{extent:e,pixelBlock:null};delete n.pixelType,r.bandIds||delete n.bandIds,delete n.compressionQuality;const a={imageServiceParameters:n,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:!1,returnImageBitmap:!1,signal:r.signal},{pixelData:o}=await this._requestArrayBuffer(a);return o??{extent:e,pixelBlock:null}}fetchKeyProperties(e){return i($e(this.parsedUrl)+"/keyProperties",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>e.data)}fetchRasterAttributeTable(e){return this.version<10.1?Promise.reject(new r("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):i($e(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then(e=>Ae.fromJSON(e.data))}getCatalogItemRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return qe($e(this.parsedUrl),e,i)}async getCatalogItemICSInfo(e,t){const{data:r}=await i($e(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),s=r?.ics;if(!s)return;let n=null;try{n=(await i($e(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!n?.spatialReference)return{ics:s,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?i($e(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then(e=>e.data).catch(()=>({})):{},o=n.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[n]}),inSR:y(o),outSR:"0:"+e},u=i($e(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then(e=>e.data).catch(()=>({})),p=5,c=(n.xmin+n.xmax)/2,m=(n.ymax-n.ymin)/(p+1),h=n.ymin+m,f=[];for(let i=0;i<p;i++)f.push({x:c,y:h+m*i});const R={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:f}),inSR:y(o),outSR:"0:"+e},x=i($e(this.parsedUrl)+"/project",{query:this._getQueryParams(R),...t}).then(e=>e.data).catch(()=>({})),I=await Promise.all([a,u,x]);let w=I[0].ipxf;if(null==w){const e=s.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(w={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const v=d.fromJSON(I[1]?.geometries?.[0]);v&&(v.spatialReference=new g({wkid:0,imageCoordinateSystem:s}));const b=I[2].geometries?I[2].geometries.filter(e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y):[],S=b.length;if(S<3)return{ics:s,icsToPixelTransform:w,icsExtent:v,northDirection:null};let _=0,F=0,D=0,O=0;for(let i=0;i<S;i++)_+=b[i].x,F+=b[i].y,D+=b[i].x*b[i].x,O+=b[i].x*b[i].y;const T=(S*O-_*F)/(S*D-_*_);let M=0;const C=b[p-1].x>b[0].x,q=b[p-1].y>b[0].y;return T===1/0?M=q?90:270:0===T?M=C?0:180:T>0?M=C?180*Math.atan(T)/Math.PI:180*Math.atan(T)/Math.PI+180:T<0&&(M=q?180+180*Math.atan(T)/Math.PI:360+180*Math.atan(T)/Math.PI),{ics:s,icsToPixelTransform:w,icsExtent:v,northDirection:M}}async generateRasterInfo(e,t){const i=m(K,e),s={...t,query:this._getQueryParams()};if(!i||"none"===i.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(i))return this.serviceRasterInfo??Te($e(this.parsedUrl),this.sourceJSON,s);const n=He(i);if(!n)throw new r("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[n])return this._functionRasterInfos[n];const a=Me($e(this.parsedUrl),i,s);this._functionRasterInfos[n]=a;try{const t=await a,{rasterFunction:i}=this;return(i===e||JSON.stringify(i)===JSON.stringify(e))&&JSON.stringify(this.rasterInfo)!==JSON.stringify(t)&&(this.rasterInfo=t),t}catch(o){throw this._functionRasterInfos[n]=null,o}}getExportImageServiceParameters(e,t,i,r,s){e=e.clone().shiftCentralMeridian();const n=xe(e.spatialReference,$e(this.parsedUrl));s??=this.exportImageServiceParameters;const a=s.toJSON(),{bandIds:o,noData:l}=a;let{renderingRule:u}=a;const p=this.rasterFunction?.rasterFunctionDefinition,c=this.renderer?.type,m=!c||"raster-stretch"===c||"raster-colormap"===c||"unique-value"===c||"class-breaks"===c||"raster-shaded-relief"===c;if(o?.length&&this._hasRasterFunction(this.rasterFunction)&&!p&&m){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===u.rasterFunction)e.rasterFunctionArguments.Raster=u.rasterFunctionArguments.Raster,u.rasterFunctionArguments.Raster=e;else if("Colormap"===u.rasterFunction){const t=u.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,u.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=u,u=e;a.bandIds=void 0}else a.bandIds=o?.join(",");Array.isArray(l)&&l.length>0&&(a.noData=l.join(","));const h=this._processMultidimensionalIntersection(null,r,s.mosaicRule);if(h.isOutSide)return null;a.mosaicRule=null!=h.mosaicRule?JSON.stringify(h.mosaicRule):null,r=h.timeExtent,a.renderingRule=this._getRenderingRuleString(K.fromJSON(u));const d={};if(null!=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:n,imageSR:n,size:t+","+i,...a,...d}}async getSamples(e,t){const i=await this._fetchCapabilities(t?.signal);if(!i?.operations.supportsGetSamples)throw new r("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=s(e);const{raster:n}=this;return n&&null==e.raster&&(e.raster=n),Ie(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new r("imagery-layer:identify","identify operation is not supported on the input image service");e=s(e),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=f.fromExtent(e.geometry));const i=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(i.isOutSide)throw new r("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=i.timeExtent,e.mosaicRule=i.mosaicRule;const{raster:n,rasterFunction:a}=this;return a&&null==e.rasterFunction&&(e.rasterFunction=a),n&&null==e.raster&&(e.raster=n),we(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new r("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return ve($e(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new r("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return be($e(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new r("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return Se($e(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new r("imagery-layer:find-images","findImages operation is not supported on the input image service");return _e($e(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new r("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return Fe($e(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new Ve({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new r("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=e??{outSpatialReference:this.spatialReference},De($e(this.parsedUrl),e,this._getRequestOptions(t))}async queryExtent(e,t){({query:e,requestOptions:t}=await this._prepareForQuery(e,t));const{where:i,objectIds:r,geometry:s,timeExtent:n,start:a,num:o,pixelSize:l}=e,u=null!=i&&"1=1"!==i,p=null!=r&&r.length>0,c=null!=s&&("extent"!==s.type||!s.equals(this.fullExtent)),m=null!=l,h=null!=a||null!=o,{timeInfo:d}=this,f=null!=n&&null!=d&&!n.equals(d.fullTimeExtent);if(!(u||p||c||m||f||h)){const i=await Ne(this.url,e,t),{outSpatialReference:r}=e;if(!r||r.equals(this.spatialReference))return{count:i,extent:this.fullExtent.clone()};const s=await import("../../geometry/operators/projectOperator.js");await s.load();return{count:i,extent:s.execute(this.fullExtent,r)}}return Pe(this.url,e,t)}async queryRasters(e,t){({query:e,requestOptions:t}=await this._prepareForQuery(e,t));const i=await Ee(this.url,e,t),r=this.graphicOrigin;return i.features.forEach(e=>{e.layer=this,e.origin=r}),i}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),je(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new r("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=e??{where:"1=1"},Oe($e(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ne(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new r("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:i,returnDomainValues:s,returnTopmostRaster:n,showNoDataRecords:a}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p=$.servicePixelValue.toLowerCase(),c=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(o=e.outFields.some(e=>!e.toLowerCase().startsWith(p)),this.version>=10.4)){const t=e.outFields.filter(e=>e.toLowerCase().startsWith(p)&&e.length>p.length).map(e=>{const t=e.slice(p.length+1);return[this._updateRenderingRulesFunctionName(t,c),t]});l=t.map(e=>new K({functionName:e[0]})),u=t.map(e=>e[1]);const{rasterFunction: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 m=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:h}=this;let d=e.timeExtent||this.timeExtent;if(h){const{isOutside:t,intersection:i}=R(h,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new r("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");null!=i?.timeExtent&&(d=i.timeExtent)}const g=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,d);let y=e.geometry;this.version<10.91&&"extent"===y?.type&&(y=f.fromExtent(y));const I=this._getQueryParams({geometry:y,timeExtent:d,mosaicRule:g,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:i,returnCatalogItems:o,returnGeometry:m,raster:this.raster,maxItemCount:n?1:null});delete I.f;const w=new Qe(I);try{await this._generateRasterInfo(this.rasterFunction);const i=await we(this.url,w,{signal:t?.signal,query:{...this.customParameters}}),r=e.outFields,n=null!=i.value&&i.value.toLowerCase().includes("nodata"),l=o&&!m&&i?.catalogItems?.features.length&&(a||!n),p=this.multidimensionalInfo&&"raster-dataset"===this.sourceType?x({rasterInfo:this.rasterInfo,multidimensionalDefinition:g?.multidimensionalDefinition,timeExtent:d,multidimensionalSubset:this.multidimensionalSubset}):null;if(!l)return this._processVisibleRastersResponse(i,{returnDomainValues:s,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:r,effectiveMultidimensionalDefinition:p});const c=this.objectIdField||"ObjectId",h=i.catalogItems?.features??[],f=h.map(e=>e.attributes?.[c]),y=new Ve({objectIds:f,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[c]}),R=await this.queryRasters(y);return R?.features?.length&&R.features.forEach(t=>{h.forEach(i=>{i.attributes[c]===t.attributes[c]&&t.geometry&&(i.geometry=t.geometry.clone(),null!=e.outSpatialReference&&(i.geometry.spatialReference=e.outSpatialReference))})}),this._processVisibleRastersResponse(i,{returnDomainValues:s,templateRRFunctionNames:u,showNoDataRecords:a,templateFields:r,effectiveMultidimensionalDefinition:p})}catch{throw new r("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=i($e(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.statistics),s=i($e(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then(e=>e.data?.histograms),n=await Promise.all([r,s]);return n[0]&&n[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),{statistics:n[0]||null,histograms:n[1]||null}}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return I(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,i=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):Te($e(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then(e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),Ce(e,t),e)),r=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{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.internalRenderer&&!this._isSupportedRenderer(this.internalRenderer)&&(this._set("internalRenderer",null),n.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("internalRenderer",this._configRenderer(this.renderer)),this.addHandles([o(()=>this.rasterFunction,e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this._generateRasterInfo(e).then(e=>{e&&(this.rasterInfo=e)})})]);const{serviceRasterInfo:t}=this;null!=t.multidimensionalInfo&&this._updateMultidimensionalDefinition(t)})}_combineMosaicRuleWithTimeExtent(e,t){const i=this.timeInfo,{multidimensionalInfo:r}=this.serviceRasterInfo;if(null==e||null==r||null==t||null==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 a=e.multidimensionalDefinition.filter(e=>e.dimensionName===n),o=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==o||null==l||o===l,p=u?[o||l]:[[o,l]],c=this.version>=10.8;if(a.length)a.forEach(e=>{e.dimensionName===n&&(c?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=p))});else if(!c){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=p}):e.multidimensionalDefinition.push(new O({variableName:"",dimensionName:n,isSlice:u,values:p}))}return this._cleanupMultidimensionalDefinition(e)}_cleanupMultidimensionalDefinition(e){return null==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 r("imagery-layer:query-rasters","query operation is not supported on the input image service");const i=null!=e?m(Ve,e):this.createQuery();return t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:i,requestOptions:t}}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:i}=this;return"unique-value"===e.type&&this._hasRasterFunction(i)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&te(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:s}=await i($e(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,s&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map(e=>e.trim()).indexOf("tilesonly")>-1)throw new r("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(null==e)return!1;const{functionName:t,functionArguments:i}=e,r="resample"===t?.toLowerCase(),s=i?.ResampleType||i?.resampleType;return r&&(7===s||10===s)}_configRenderer(e){const{rasterInfo:t}=this;if(!this.isRenderedFormat&&!this.pixelFilter||this._isVectorDataSet()){const i=this.mosaicRule?.multidimensionalDefinition?.[0].variableName,r=ie({variableName:i,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&t.bandCount>=3){const e=r?.bandIds??ee(t);!e||3===t.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=r?.renderer??Z(t,{bandIds:this.bandIds,variableName:this.rasterFunction?null:i}));const s=re(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=s,this.symbolizer.rasterInfo=t):this.symbolizer=new se({rendererJSON:s,rasterInfo:t}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){null!=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?this._rasterJobHandler.decode({data:e,options:t}):v(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;const r=await i($e(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e});return r.data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:s,returnImageBitmap:n,signal:a}=e;if(s&&this._canRequestImageElement(t.format)){const r=`${$e(this.parsedUrl)}/exportImage`,{data:s}=await i(r,{responseType:n?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:a});if(s instanceof Blob){const{bitmap:e}=await q(s,r,{signal:a});return{imageBitmap:e,params:t}}return{imageOrCanvasElement:s,params:t}}const o=this._initJobHandler(),l=i($e(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:a}),u=(await Promise.all([l,o]))[0].data,p=t.format||"jpgpng";let c=p;if("bsq"!==c&&"bip"!==c&&(c=b(u)),!c)throw new r("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const m={signal:a},h=this._decodePixelBlock(u,{width:t.width,height:t.height,format:p,applyJpegMask:!0},m);return{pixelData:{pixelBlock:await h,extent:t.extent},params:t}}_generateRasterInfo(e,t){return this.generateRasterInfo(e,t).catch(()=>null)}_isValidCustomizedMosaicRule(e){return e&&JSON.stringify(e.toJSON())!==JSON.stringify(this.defaultMosaicRule?.toJSON())}_updateMultidimensionalDefinition(e){if(this._isValidCustomizedMosaicRule(this.mosaicRule))return;let t=w(e,{multidimensionalSubset:this.multidimensionalSubset});if(null!=t&&t.length>0){this.mosaicRule=this.mosaicRule||new P;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.rasterFunction&&"none"!==this.rasterFunction.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:a,templateFields:o}=i,l=e.processedValues;let u=e.catalogItems?.features,p=e.properties?.Values?.map(e=>e.replaceAll(/ /gi,", "))||[];const c=this.objectIdField||"ObjectId",m="string"==typeof r&&r.toLowerCase().includes("nodata"),h=[];if(r&&!u&&(!m||n)){const e={};e[c]=0;p=[r],u=[new t({geometry:this.fullExtent,attributes:e})],this.multidimensionalInfo&&"raster-dataset"===this.sourceType&&W(this.rasterFields,e,i.effectiveMultidimensionalDefinition)}if(!u)return[];this._updateResponseFieldNames(u,o),m&&!n&&(u=[]);const{itemPixelValue:d,servicePixelValue:f}=$,g=this.rasterFields.some(e=>e.name===d),y=this.graphicOrigin;for(let t=0;t<u.length;t++){const e=u[t];if(null!=r){const i=p[t],a=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:r;if("nodata"===i.toLowerCase()&&!n)continue;g&&(e.attributes[d]=i),e.attributes[f]=a,this._updateFeatureWithMagDirValues(e,i);const o=this.fields&&this.fields.length>0;let u=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?o?i:r:a;this.rasterFunction||(u=o?i:r),this._updateFeatureWithRasterAttributeTableValues(e,u)}if(e.sourceLayer=e.layer=this,e.origin=y,a&&this._updateFeatureWithDomainValues(e),s&&l&&s.length===l.length)for(let t=0;t<s.length;t++){const i=`${$.servicePixelValue}.${s[t]}`;e.attributes[i]=l[t]}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}=R(r,{geometry:e,timeExtent:t});if(i)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=s?.timeExtent&&(t=s.timeExtent)}if(i=this._combineMosaicRuleWithTimeExtent(i,t),i?.multidimensionalDefinition){const{isOutside:e}=R(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(null==i)return;const{features:r,fields:s}=i,n=s.map(e=>e.name).find(e=>"value"===e.toLowerCase());if(!n)return;const a=r.filter(e=>e.attributes[n]===(null!=t?parseInt(t,10):null));a&&a[0]&&s.forEach(t=>{const i=X+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 E({height:1,width:1,pixelType:"f32",pixels:r,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new d(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:_([n.pixels[0][0],n.pixels[1][0]]);e.attributes[$.magnitude]=a[0],e.attributes[$.direction]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter(e=>"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;null!=i&&e.forEach(e=>{if(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(e){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRasterFunction(e){return 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().replaceAll(/ /gi,"_");return t.has(i)?t.get(i):e}_isRFTJson(e){return 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,rasterFunction:r}=this;r&&null==e.rasterFunction&&(e.rasterFunction=r),i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}async _updateCurrentRasterInfo(e){if(this.renderer||this.symbolizer){const t=await this._generateRasterInfo(this.rasterFunction,{signal:e});t&&(this.rasterInfo=t)}}_applyMosaicRule(e){const{raster:t,mosaicRule:i}=this;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,maxRecordCount:r}=e,s=t.includes("image"),n="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!(!e.spatialReference&&!e.extent?.spatialReference),o=t.includes("edit"),l=t.includes("mensuration")&&a,u=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map(e=>e.trim()),p=l&&u.includes("basic"),c=this._isMosaicDataset(e)&&t.includes("catalog"),m=t.includes("download"),h=i>=10.7&&n||i>=11.4&&(n||l&&u.includes("3d")),d=c&&e.fields&&e.fields.length>0,f=d&&e.supportsAdvancedQueries?e.advancedQueryCapabilities:void 0;return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:s,supportsExportImage:s,supportsIdentify:s,supportsImageToMap:i>=11.2&&c,supportsImageToMapMultiray:i>=11.2&&c,supportsMapToImage:i>=11.2&&c,supportsFindImages:i>=11.2&&c,supportsGetImageUrl:i>=11.3&&m,supportsMeasure:l,supportsMeasureFromImage:i>=11.2,supportsDownload:m,supportsQuery:d,supportsGetSamples:i>=10.2&&s,supportsProject:i>=10.3&&s,supportsComputeStatisticsHistograms:i>=10.4&&s,supportsQueryBoundary:i>=10.6&&s,supportsCalculateVolume:h,supportsComputePixelLocation:i>=10.7&&c,supportsComputeAngles:i>=10.91,supportsQueryGPSInfo:i>=11.2&&c,supportsAdd:o,supportsDelete:o,supportsEditing:o,supportsUpdate:o,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryTopFeatures:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:r,maxRecordCountFactor:void 0,maxUniqueIDCount:void 0,relativeTimeBinWindow:void 0,supportsStatisticsAggregatedIds:!!f?.supportsAggregateIds,supportsStatistics:!!f?.supportsStatistics,supportsOrderBy:!!f?.supportsOrderBy,supportsDistinct:!!f?.supportsDistinct,supportsPagination:!!f?.supportsPagination,supportsPaginationOnAggregatedQueries:!!f?.supportsPaginationOnAggregatedQueries,supportsStandardizedQueriesOnly:!!f?.useStandardizedQueries,supportsPercentileStatistics:!!f?.supportsPercentileStatistics,supportsCentroid:!!f?.supportsReturningGeometryCentroid,supportsCentroidOnDegeneratedQuantizedGeometry:!1,supportsCurrentUser:!1,supportsDegeneratedQuantizedGeometry:!1,supportsDistance:!!f?.supportsQueryWithDistance,supportsOutDistance:!!f?.supportsOutDistance,supportsExtent:!!f?.supportsReturningQueryExtent,supportsGeometryProperties:!!f?.supportsReturningGeometryProperties,supportsHavingClause:!!f?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsReturnMesh:!1,supportsReturnExceededLimitGeometries:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:f?.supportsSqlExpression??!!f,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsFormatPBFWithCurves:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!f?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,standardMaxRecordCountNoGeometry:void 0,tileMaxRecordCount:void 0,supportsTrueCurve:!1},mensuration:{supportsDistanceAndAngle:p,supportsAreaAndPerimeter:p,supportsPointOrCentroid:p,supportsHeightFromBaseAndTop:l&&u.includes("base-top height"),supportsHeightFromBaseAndTopShadow:l&&u.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:l&&u.includes("top-top shadow height"),supports3D:l&&u.includes("3d")}}}};function $e(e){return e?.path??""}return e([u({clonable:!1})],We.prototype,"_functionRasterInfos",void 0),e([u({readOnly:!0})],We.prototype,"_serviceSupportsMosaicRule",void 0),e([Je("_serviceSupportsMosaicRule",["currentVersion","fields"])],We.prototype,"readServiceSupportsMosaicRule",null),e([u({readOnly:!0})],We.prototype,"_rasterFunctionNamesIndex",null),e([u()],We.prototype,"_projectedFullExtent",void 0),e([u({clonable:!1})],We.prototype,"_exportTileQueue",void 0),e([u()],We.prototype,"adjustAspectRatio",void 0),e([u({type:[c],json:{write:!0}})],We.prototype,"bandIds",void 0),e([Je("bandIds")],We.prototype,"readBandIds",null),e([u({readOnly:!0,json:{read:!1}})],We.prototype,"capabilities",void 0),e([Je("service","capabilities",["capabilities","currentVersion","serviceDataType"])],We.prototype,"readCapabilities",null),e([u({type:Number})],We.prototype,"compressionQuality",void 0),e([Be("compressionQuality")],We.prototype,"writeCompressionQuality",null),e([u({type:Number})],We.prototype,"compressionTolerance",void 0),e([Be("compressionTolerance")],We.prototype,"writeCompressionTolerance",null),e([u({json:{read:{source:"copyrightText"}}})],We.prototype,"copyright",void 0),e([u({readOnly:!0})],We.prototype,"defaultMosaicRule",void 0),e([Je("defaultMosaicRule",["defaultMosaicMethod"])],We.prototype,"readDefaultMosaicRule",null),e([u({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],We.prototype,"definitionExpression",void 0),e([u({readOnly:!0,constructOnly:!0})],We.prototype,"exportImageServiceParameters",void 0),e([u()],We.prototype,"rasterInfo",void 0),e([u({readOnly:!0,type:[M]})],We.prototype,"fields",void 0),e([u({readOnly:!0})],We.prototype,"fieldsIndex",null),e([u({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff","bip","bsq"],json:{write:!0}})],We.prototype,"format",null),e([Je("service","format",["serviceDataType"])],We.prototype,"readFormat",null),e([u({type:d})],We.prototype,"fullExtent",void 0),e([u({readOnly:!0})],We.prototype,"hasMultidimensions",void 0),e([u({json:{read:{source:"maxImageHeight"}}})],We.prototype,"imageMaxHeight",void 0),e([u({json:{read:{source:"maxImageWidth"}}})],We.prototype,"imageMaxWidth",void 0),e([u({type:String,json:{type:A.jsonValues,read:A.read,write:A.write}})],We.prototype,"interpolation",void 0),e([u()],We.prototype,"minScale",void 0),e([Je("service","minScale")],We.prototype,"readMinScale",null),e([u()],We.prototype,"maxScale",void 0),e([Je("service","maxScale")],We.prototype,"readMaxScale",null),e([u({type:P})],We.prototype,"mosaicRule",null),e([Je("mosaicRule",["mosaicRule","defaultMosaicMethod"])],We.prototype,"readMosaicRule",null),e([Be("mosaicRule")],We.prototype,"writeMosaicRule",null),e([u()],We.prototype,"multidimensionalInfo",void 0),e([u({type:j,json:{write:!0}})],We.prototype,"multidimensionalSubset",void 0),e([u({json:{type:[Number,[Number]],write:!0}})],We.prototype,"noData",void 0),e([u({type:String,json:{type:Q.jsonValues,read:Q.read,write:Q.write}})],We.prototype,"noDataInterpretation",void 0),e([u({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],We.prototype,"objectIdField",void 0),e([Je("objectIdField")],We.prototype,"readObjectIdField",null),e([u({readOnly:!0})],We.prototype,"geometryType",void 0),e([u({})],We.prototype,"typeIdField",void 0),e([u({})],We.prototype,"types",void 0),e([u({readOnly:!0})],We.prototype,"parsedUrl",null),e([u({type:Function})],We.prototype,"pixelFilter",void 0),e([u()],We.prototype,"raster",void 0),e([u({readOnly:!0})],We.prototype,"sourceType",void 0),e([Je("sourceType",["serviceSourceType","fields"])],We.prototype,"readSourceType",null),e([u()],We.prototype,"viewId",void 0),e([u({types:ne})],We.prototype,"renderer",null),e([u({types:ne,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:ae,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],We.prototype,"internalRenderer",null),e([Je("internalRenderer")],We.prototype,"readRenderer",null),e([Be("internalRenderer")],We.prototype,"writeRenderer",null),e([u({clonable:!1})],We.prototype,"symbolizer",void 0),e([u(F)],We.prototype,"opacity",void 0),e([u({readOnly:!0})],We.prototype,"rasterFields",null),e([u({constructOnly:!0})],We.prototype,"rasterFunctionInfos",void 0),e([u({type:K,json:{name:"renderingRule"}})],We.prototype,"rasterFunction",null),e([Je("rasterFunction",["renderingRule","rasterFunctionInfos"])],We.prototype,"readRasterFunction",null),e([u({readOnly:!0})],We.prototype,"serviceDataType",void 0),e([u({readOnly:!0,type:g})],We.prototype,"spatialReference",void 0),e([Je("spatialReference",["spatialReference","extent"])],We.prototype,"readSpatialReference",null),e([u({type:V.apiValues,json:{read:V.read,type:V.jsonValues}})],We.prototype,"pixelType",void 0),e([Be("pixelType")],We.prototype,"writePixelType",null),e([u({constructOnly:!0,type:Y})],We.prototype,"serviceRasterInfo",void 0),e([u()],We.prototype,"sourceJSON",void 0),e([u(D)],We.prototype,"url",void 0),e([u({readOnly:!0})],We.prototype,"version",void 0),e([Je("version",["currentVersion","fields","timeInfo"])],We.prototype,"readVersion",null),We=e([p("esri.layers.mixins.ArcGISImageService")],We),We};export{Ge as ArcGISImageService};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import e from"../../../core/Error.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import i from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import{getByteCount as o}from"../formats/pixelRangeUtils.js";import{convertPixelSize as r,snapToRaster as a,clip as s}from"../functions/clipUtils.js";import{transformPixels as l}from"../functions/pixelTransformUtils.js";import{mapPixelValueToAttribute as c,mosaic as p,pixelIdFieldName as u,convertPixelBlockToFeatures as f,getValidPixels as m,countCategoricalPixels as x}from"../functions/pixelUtils.js";import{load as d,projectPolygon as h}from"../functions/rasterProjectionHelper.js";import{computeBoxStatistics as y,computeStatisticsHistograms as w}from"../functions/stretchUtils.js";import g from"../../support/Field.js";import S from"../../support/PixelBlock.js";import{getBandNames as k}from"../../../renderers/support/rasterRendererHelper.js";import b from"../../../rest/support/ImageIdentifyParameters.js";const z=2**30,B=2048,P=2**20,I=20,R=100;async function j(e,t){return"imagery"===e.type?await e.generateRasterInfo(e.rasterFunction,t):e.raster.rasterInfo}function v(e){const{rasterInfo:t,geometry:i,pixelSize:o,downsampleOnly:s=!1,maxPixelCountForDownsample:l}=e;if(!o)return!0;if(!s)return!1;const c=r(o,t.spatialReference);if(c.x+c.y<=t.pixelSize.x+t.pixelSize.y)return!0;if(null==l)return!1;const p="polyline"===i?.type?i.extent:i??t.extent,u=new n({x:t.pixelSize.x,y:t.pixelSize.y,spatialReference:t.spatialReference}),f=a(t,p,u);return f.width*f.height<=l}function T(e){const t=[new g({name:u,alias:"Pixel ID",type:"oid"})],{pixelType:i}=e,n="f32"===i?"single":"f64"===i?"double":"integer";return k(e).forEach(e=>{t.push(new g({name:e,alias:e,type:n}))}),t.map(e=>e.toJSON())}async function F(t,i){if(t.spatialReference.equals(i))return t;if("polyline"===t.type){const n=(await import("../../../geometry/operators/projectOperator.js")).execute(t,i);if(null==n)throw new e("read-pixels","failed to project the geometry into the layer's spatial reference");return n}if("extent"===t.type||t.rings[0].length<I){const e=(await import("../../../geometry/operators/lengthOperator.js")).execute(t,{unit:"meters"})/R;t=(await import("../../../geometry/operators/densifyOperator.js")).execute(t,e,{unit:"meters"}),await d(),t=h(t,i)}return t}async function M(e,t,i=!1){const{spatialReference:o}=e,r=t?.geometry,s=await F(r??e.extent,o),l="extent"===s.type?s:s.extent,c=null==r||"extent"===r.type&&r.spatialReference.equals(o)?void 0:s,p=new n({x:e.pixelSize.x,y:e.pixelSize.y,spatialReference:o}),u=!!t?.autoResample,f=u?p:t?.pixelSize??p;let{extent:m,width:x,height:d}=a(e,l,f);if(!u)return{extent:m,clipGeometry:c,width:x,height:d,pixelSize:f};const h=e.storageInfo?.pyramidScalingFactor??2;let{x:y,y:w}=f;const g=t?.maxPixelCount??P;for(;x*d>g&&(!i||Math.max(x,d)>1024);)y*=h,w*=h,x/=h,d/=h;return x=Math.round(x),d=Math.round(d),{extent:m,clipGeometry:c,width:x,height:d,pixelSize:new n({x:y,y:w,spatialReference:o})}}async function*C(e,n,o=!1,r){const{extent:a,clipGeometry:l,width:c,height:p}=n,u=a.width/c,f=a.height/p,m=Math.ceil(c/B),x=Math.ceil(p/B),d=u*B,h=f*B,{xmin:y,xmax:w,ymin:g,ymax:S}=a,k=x*m,b={bandIds:n.bandIds?.length?n.bandIds:void 0,interpolation:"nearest",...r};for(let z=0;z<x;z++)for(let n=0;n<m;n++){t(b);const r=new i({xmin:y+n*d,xmax:o?Math.min(w,y+(n+1)*d):y+(n+1)*d,ymax:S-z*h,ymin:o?Math.max(g,S-(z+1)*h):S-(z+1)*h,spatialReference:a.spatialReference}),c={row:z,col:n},p=z*m+n+1;if(l&&!r.intersects(l)){yield{extent:r,pixelBlock:null,id:c,total:k,current:p};continue}const x=o?Math.round(r.width/u):B,P=o?Math.round(r.height/f):B;let{pixelBlock:I}=await e.fetchPixels(r,x,P,b).catch(()=>({pixelBlock:void 0}));I&&l&&(I=await s(I,r,l)),yield{extent:r,pixelBlock:I,id:c,total:k,current:p}}}async function*O(e,i,n){const o=await j(e,n),r=T(o),a={...i,geometry:i?.geometry??o.extent},s=C(e,await M(o,a),!0,n),l=o.width;for await(const c of s){if(!c.pixelBlock){yield{...c};continue}const a=Q(e),{pixelBlock:s}=c,{statistics:p,histograms:u}=await V({pixelBlock:s,rasterJobHandler:a},n),f=c;f.statistics=p,f.histograms=u;const m=c.id.row*o.width*B+c.id.col*B;t(n),f.featureSet=await $({pixelBlock:s,extent:c.extent,fields:r,skipFactor:i?.skipFactor??1,rasterJobHandler:a,pixelIdOffset:m,imageRowSize:l},n),t(n),yield f}}function H(t,i,n){const r=o(i),{width:a,height:s}=t;if(a*s*r>z)throw new e("fetch-pixels","failed to fetch pixels as pixel byte count exceeds the 1GB limit");if(n&&a*s>n)throw new e("fetch-pixels",`failed to fetch pixels as pixel count exceeds the ${n} limit`)}async function D(t,i,n){if(!i.geometry)throw new e("fetch-pixels","geometry is required to fetch pixel feature set");const o=await j(t),r=await M(o,i,!0);H(r,o.pixelType);const{extent:a,pixelSize:s}=r,l=Math.round(o.extent.width/s.x),c=T(o),p={fields:c,features:[]},u=p.features,{maxPixelCount:f}=i,m=!!i.autoResample&&null!=f&&r.width*r.height>f,x=m?1:i.skipFactor??1,d=r.width<=B||r.height<=B,h=C(t,r,1===x||d,n);for await(const e of h){if(!e.pixelBlock)continue;const i=Q(t),r=Math.floor((o.extent.ymax-e.extent.ymax)/s.y)*l+Math.floor((e.extent.xmin-o.extent.xmin)/s.x),a=await $({pixelBlock:e.pixelBlock,extent:e.extent,fields:c,skipFactor:x,rasterJobHandler:i,pixelIdOffset:r,imageRowSize:l},n);if(a?.features?.length){const{features:e}=a,t=e.length;for(let i=0;i<t;i++){const t=e.pop();u.push(t)}}}if(m&&f){const e=f/(i.skipFactor??1)**2;if(u.length>e){const t=u.length/e,i=[...u],n=u.length-1;u.length=0;for(let o=0,r=0;o<e-1;o++){r+=t;const e=Math.round(r);e<n&&u.push(i[e])}}}return{extent:a,featureSet:p,pixelSize:s}}async function J(e,t,i){const{geometry:n}=t;if("multipoint"===n.type)return q(e,n,i);if("polyline"===n.type)return A(e,n,i);const o=await X(e,{geometry:n},i);if(!o)return null;return y(o)}async function q(e,t,i){const n=await j(e,i),o=t.points.map((e,i)=>t.getPoint(i)).map(t=>N(e,t,i)),r=(await Promise.all(o)).filter(e=>null!=e);if(r.length<=1)return U(r[0]);const a=r[0].map((e,t)=>r.map(e=>e[t]));return y(new S({pixels:a,pixelType:n.pixelType}))}async function N(e,t,i){if("imagery"===e.type){const n=await e.identify(new b({geometry:t,returnCatalogItems:!1}),i).catch(()=>null);return null==n?.value||n.value.includes("NoData")?null:n.value.replaceAll(", "," ").split(" ").map(e=>Number(e))}const n=await e.identify(t,i).catch(()=>null);return n?.value}function U(e){return e?.map(e=>({min:e,max:e,avg:e,median:e,quartile1:e,quartile3:e}))}async function A(e,t,i){const n=await K(e,{geometry:t},i),o=await j(e,i),{bandCount:r,pixelType:a}=o,s=new Array(r).fill(0).map(()=>S.createEmptyBand(a,n.length));let l=0;for(let c=0;c<n.length;c++){const e=n[c];if(null!=e.value){l++;for(let t=0;t<r;t++)s[t][c]=e.value[t]}}l!==n.length&&s.forEach((e,t)=>{s[t]=e.subarray(0,l)});return y(new S({pixels:s,pixelType:a}))}async function E(t,i,n){const o=await j(t,n);if(!o.attributeTable||!o.pixelType.startsWith("u"))return null;const r=o.attributeTable.clone(),a=r.fields.find(e=>"value"===e.name.toLowerCase()),s=r.fields.find(e=>"count"===e.name.toLowerCase());if(!a||!s)throw new e("compute-attribute-table","Value or count field not found in attribute table");const l=2**Number(o.pixelType.slice(1)),c=new Uint32Array(l),{geometry:p,pixelSize:u,downsampleOnly:f,maxPixelCountForDownsample:m}=i,d=v({rasterInfo:o,geometry:p,pixelSize:u,downsampleOnly:f,maxPixelCountForDownsample:m})?void 0:u;return await _(t,{geometry:p,pixelSize:d},(e,t)=>x(e,c),n),r.features.forEach(e=>{const t=e.attributes[a.name];e.attributes[s.name]=c[t]}),r}async function G(e,t,i){const{geometry:n}=t;if("point"===n.type)return N(e,n,i);if("multipoint"===n.type){const t=n.points.map((e,t)=>n.getPoint(t)).map(t=>N(e,t,i)),o=(await Promise.all(t)).filter(e=>null!=e);if(0===o.length)return null;return W(o).map(e=>e/o.length)}const o=await _(e,{geometry:n},(e,t)=>L(e),i),r=o?.filter(e=>e.count>0);if(!r?.length)return null;const a=W(r.map(e=>e.bandSum)),s=r.map(e=>e.count).reduce((e,t)=>e+t);return a.map(e=>e/s)}function W(e){return e.reduce((e,t)=>e.map((e,i)=>e+t[i]))}function L(e){const{width:t,height:i,pixels:n,mask:o}=e,r=new Array(n.length).fill(0);let a=0;for(let s=0;s<i;s++)for(let e=0;e<t;e++){const i=s*t+e;if(!o||o[i]){for(let e=0;e<n.length;e++)r[e]+=n[e][i];a++}}return{bandSum:r,count:a}}async function K(e,t,i){const n=await _(e,{geometry:t.geometry},m,i);return n?.flat()??[]}async function _(i,n,o,r){const a=i.spatialReference;let{geometry:l}=n;if("polyline"===l.type&&!l.spatialReference.equals(a)){const t=(await import("../../../geometry/operators/projectOperator.js")).execute(l,a);if(null==t)throw new e("read-pixels","failed to fetch pixels");l=t}const c="polyline"===l.type?l.extent:l,p=await F(c,a),u="polyline"===l.type?l:p,f=await j(i,r),m={geometry:p,autoResample:!1,pixelSize:n?.pixelSize},x=[],d=C(i,await M(f,m),!0,r);for await(const e of d){if(!e.pixelBlock)continue;const{extent:i}=e,n=o(await s(e.pixelBlock,i,u),i);x.push(n),t(r)}return x}async function V(e,t){const{rasterJobHandler:i}=e,{pixelBlock:n}=e,{statistics:o,histograms:r}=i?await i.computeStatisticsHistograms({pixelBlock:n},t):w(n);return{statistics:o,histograms:r}}async function $(e,t){const{extent:i,fields:n,skipFactor:o,rasterJobHandler:r,pixelIdOffset:a,imageRowSize:s}=e,{pixelBlock:l}=e,c=n.map(({name:e})=>e),p=r?await r.convertPixelBlockToFeatures({pixelBlock:l,extent:i,fieldNames:c,skipFactor:o,pixelIdOffset:a,imageRowSize:s},t):f({pixelBlock:l,extent:i,fieldNames:c,skipFactor:o,pixelIdOffset:a,imageRowSize:s});return p?{fields:n,features:p}:void 0}function Q(e){return"_rasterJobHandler"in e?e._rasterJobHandler:null}async function X(e,t,i){const n=await j(e);t={...t,maxPixelCount:t.maxPixelCount??2**28};const o=await M(n,t);o.bandIds=t.bandIds?.length?t.bandIds:void 0,H(o,n.pixelType,t.maxPixelCount);const{width:r,height:a}=o;if(r<=B&&a<=B){const t=o.bandIds?.length?o.bandIds:void 0,{pixelBlock:n}=await e.fetchPixels(o.extent,r,a,{bandIds:t,interpolation:"nearest",...i});return n}const s=[],l=C(e,o,!1,i);for await(const p of l)s.push(p.pixelBlock);if(!s.some(e=>null!=e))return null;const c=Math.ceil(r/B),u=Math.ceil(a/B),f={width:c*B,height:u*B};let m;const x=Q(e);if(x){const e=await x.mosaicAndTransform({srcPixelBlocks:s,srcMosaicSize:f,destDimension:f},{...i,transferPixelsToWorker:!0});m=e?.pixelBlock}else m=p(s,f);return m}async function Y(t,i,n){if(!i.geometry)throw new e("compute-statistics-histograms","geometry is required to fetch pixel feature set");const{pixelSize:o,downsampleOnly:r,maxPixelCountForDownsample:a}=i,s=await j(t,n),p=v({rasterInfo:s,geometry:i.geometry,pixelSize:o,downsampleOnly:r,maxPixelCountForDownsample:a})?void 0:o;let u=await X(t,{...i,pixelSize:p},n);if(!u)throw new e("compute-statistics-histograms","failed to get intersecting pixels");const{valueAttributeFieldName:f}=i;f&&"value"!==f.toLowerCase()&&(u=c(u,s,f));const m=Q(t),{transformType:x}=i;if(x){const e={lambda:i.lambda,shift:i.shift};u=m?await m.transformPixels({pixelBlock:u,transformType:x,transformParameters:e},{...n,transferPixelsToWorker:!0}):l(u,x,e)}const d=i.histogramSize??void 0;return m?await m.computeStatisticsHistograms({pixelBlock:u,histogramSize:d,includeSkewnessKurtosis:!0},{...n,transferPixelsToWorker:!0}):w(u,{histogramSize:d,includeSkewnessKurtosis:!0})}export{J as computeBoxStatistics,E as computeRasterAttributeTable,Y as computeStatisticsHistograms,O as createPixelFeatureSetCursor,D as fetchPixelFeatureSet,G as identifyAveragePixelValue,K as readIntersectingPixels};
|
|
2
|
+
import e from"../../../core/Error.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import i from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import{getByteCount as o}from"../formats/pixelRangeUtils.js";import{convertPixelSize as a,snapToRaster as r,clip as s}from"../functions/clipUtils.js";import{transformPixels as l}from"../functions/pixelTransformUtils.js";import{mapPixelValueToAttribute as c,mosaic as p,pixelIdFieldName as u,convertPixelBlockToFeatures as f,getValidPixels as m,countCategoricalPixels as x}from"../functions/pixelUtils.js";import{load as d,projectPolygon as h}from"../functions/rasterProjectionHelper.js";import{computeBoxStatistics as y,computeStatisticsHistograms as w}from"../functions/stretchUtils.js";import g from"../../support/Field.js";import S from"../../support/PixelBlock.js";import{getBandNames as k}from"../../../renderers/support/rasterRendererHelper.js";import b from"../../../rest/support/ImageIdentifyParameters.js";const z=2**30,B=2048,P=2**20,I=20,R=100;async function j(e,t){return"imagery"===e.type?await e.generateRasterInfo(e.rasterFunction,t):e.raster.rasterInfo}function v(e){const{rasterInfo:t,geometry:i,pixelSize:o,downsampleOnly:s=!1,maxPixelCountForDownsample:l}=e;if(!o)return!0;if(!s)return!1;const c=a(o,t.spatialReference);if(c.x+c.y<=t.pixelSize.x+t.pixelSize.y)return!0;if(null==l)return!1;const p="polyline"===i?.type?i.extent:i??t.extent,u=new n({x:t.pixelSize.x,y:t.pixelSize.y,spatialReference:t.spatialReference}),f=r(t,p,u);return f.width*f.height<=l}function T(e){const t=[new g({name:u,alias:"Pixel ID",type:"oid"})],{pixelType:i}=e,n="f32"===i?"single":"f64"===i?"double":"integer";return k(e).forEach(e=>{t.push(new g({name:e,alias:e,type:n}))}),t.map(e=>e.toJSON())}async function F(t,i){if(t.spatialReference.equals(i))return t;if("polyline"===t.type){const n=(await import("../../../geometry/operators/projectOperator.js")).execute(t,i);if(null==n)throw new e("read-pixels","failed to project the geometry into the layer's spatial reference");return n}if("extent"===t.type||t.rings[0].length<I){const e=(await import("../../../geometry/operators/lengthOperator.js")).execute(t,{unit:"meters"})/R;t=(await import("../../../geometry/operators/densifyOperator.js")).execute(t,e,{unit:"meters"}),await d(),t=h(t,i)}return t}async function C(e,t,i=!1){const{spatialReference:o}=e,a=t?.geometry,s=await F(a??e.extent,o),l="extent"===s.type?s:s.extent,c=null==a||"extent"===a.type&&a.spatialReference.equals(o)?void 0:s,p=new n({x:e.pixelSize.x,y:e.pixelSize.y,spatialReference:o}),u=!!t?.autoResample,f=u?p:t?.pixelSize??p;let{extent:m,width:x,height:d}=r(e,l,f);if(!u)return{extent:m,clipGeometry:c,width:x,height:d,pixelSize:f};const h=e.storageInfo?.pyramidScalingFactor??2;let{x:y,y:w}=f;const g=t?.maxPixelCount??P;for(;x*d>g&&(!i||Math.max(x,d)>1024);)y*=h,w*=h,x/=h,d/=h;return x=Math.round(x),d=Math.round(d),{extent:m,clipGeometry:c,width:x,height:d,pixelSize:new n({x:y,y:w,spatialReference:o})}}async function*M(e,n,o=!1,a){const{extent:r,clipGeometry:l,width:c,height:p}=n,u=r.width/c,f=r.height/p,m=Math.ceil(c/B),x=Math.ceil(p/B),d=u*B,h=f*B,{xmin:y,xmax:w,ymin:g,ymax:S}=r,k=x*m,b={bandIds:n.bandIds?.length?n.bandIds:void 0,interpolation:"nearest",...a};for(let z=0;z<x;z++)for(let n=0;n<m;n++){t(b);const a=new i({xmin:y+n*d,xmax:o?Math.min(w,y+(n+1)*d):y+(n+1)*d,ymax:S-z*h,ymin:o?Math.max(g,S-(z+1)*h):S-(z+1)*h,spatialReference:r.spatialReference}),c={row:z,col:n},p=z*m+n+1;if(l&&!a.intersects(l)){yield{extent:a,pixelBlock:null,id:c,total:k,current:p};continue}const x=o?Math.round(a.width/u):B,P=o?Math.round(a.height/f):B;let{pixelBlock:I}=await e.fetchPixels(a,x,P,b).catch(()=>({pixelBlock:void 0}));I&&l&&(I=await s(I,a,l)),yield{extent:a,pixelBlock:I,id:c,total:k,current:p}}}async function*O(e,i,n){const o=await j(e,n),a=T(o),r={...i,geometry:i?.geometry??o.extent},s=M(e,await C(o,r),!0,n),l=o.width;for await(const c of s){if(!c.pixelBlock){yield{...c};continue}const r=Q(e),{pixelBlock:s}=c,{statistics:p,histograms:u}=await V({pixelBlock:s,rasterJobHandler:r},n),f=c;f.statistics=p,f.histograms=u;const m=c.id.row*o.width*B+c.id.col*B;t(n),f.featureSet=await $({pixelBlock:s,extent:c.extent,fields:a,skipFactor:i?.skipFactor??1,rasterJobHandler:r,pixelIdOffset:m,imageRowSize:l},n),t(n),yield f}}function H(t,i,n){const a=o(i),{width:r,height:s}=t;if(r*s*a>z)throw new e("fetch-pixels","failed to fetch pixels as pixel byte count exceeds the 1GB limit");if(n&&r*s>n)throw new e("fetch-pixels",`failed to fetch pixels as pixel count exceeds the ${n} limit`)}async function D(t,i,n){if(!i.geometry)throw new e("fetch-pixels","geometry is required to fetch pixel feature set");const o=await j(t),a=await C(o,i,!0);H(a,o.pixelType);const{extent:r,pixelSize:s}=a,l=Math.round(o.extent.width/s.x),c=T(o),p={fields:c,features:[]},u=p.features,{maxPixelCount:f}=i,m=!!i.autoResample&&null!=f&&a.width*a.height>f,x=m?1:i.skipFactor??1,d=a.width<=B||a.height<=B,h=M(t,a,1===x||d,n);for await(const e of h){if(!e.pixelBlock)continue;const i=Q(t),a=Math.floor((o.extent.ymax-e.extent.ymax)/s.y)*l+Math.floor((e.extent.xmin-o.extent.xmin)/s.x),r=await $({pixelBlock:e.pixelBlock,extent:e.extent,fields:c,skipFactor:x,rasterJobHandler:i,pixelIdOffset:a,imageRowSize:l},n);if(r?.features?.length){const{features:e}=r,t=e.length;for(let i=0;i<t;i++){const t=e.pop();u.push(t)}}}if(m&&f){const e=f/(i.skipFactor??1)**2;if(u.length>e){const t=u.length/e,i=[...u],n=u.length-1;u.length=0;for(let o=0,a=0;o<e-1;o++){a+=t;const e=Math.round(a);e<n&&u.push(i[e])}}}return{extent:r,featureSet:p,pixelSize:s}}async function J(e,t,i){const{geometry:n}=t;if("multipoint"===n.type)return q(e,n,i);if("polyline"===n.type)return U(e,n,i);const o=await X(e,{geometry:n},i);if(!o)return null;return y(o)}async function q(e,t,i){const n=await j(e,i),o=t.points.map((e,i)=>t.getPoint(i)).map(t=>E(e,t,i)),a=(await Promise.all(o)).filter(e=>null!=e);if(a.length<=1)return N(a[0]);const r=a[0].map((e,t)=>a.map(e=>e[t]));return y(new S({pixels:r,pixelType:n.pixelType}))}async function E(e,t,i){if("imagery"===e.type){const n=await e.identify(new b({geometry:t,returnCatalogItems:!1}),i).catch(()=>null);return null==n?.value||n.value.includes("NoData")?null:n.value.replaceAll(", "," ").split(" ").map(e=>Number(e))}const n=await e.identify(t,i).catch(()=>null);return n?.value}function N(e){return e?.map(e=>({min:e,max:e,avg:e,median:e,quartile1:e,quartile3:e}))}async function U(e,t,i){const n=await K(e,{geometry:t},i),o=await j(e,i),{bandCount:a,pixelType:r}=o,s=new Array(a).fill(0).map(()=>S.createEmptyBand(r,n.length));let l=0;for(let c=0;c<n.length;c++){const e=n[c];if(null!=e.value){l++;for(let t=0;t<a;t++)s[t][c]=e.value[t]}}l!==n.length&&s.forEach((e,t)=>{s[t]=e.subarray(0,l)});return y(new S({pixels:s,pixelType:r}))}async function A(t,i,n){const o=await j(t,n);if(!o.attributeTable||!o.pixelType.startsWith("u"))return null;const a=o.attributeTable.clone(),r=a.fields.find(e=>"value"===e.name.toLowerCase());let s=a.fields.find(e=>"count"===e.name.toLowerCase());if(!r)throw new e("compute-attribute-table","Value field not found in attribute table");s||(s=new g({name:"Count",alias:"Count",type:"double"}),a.fields.push(s),a.features.forEach(e=>{e.attributes[s.name]=0}));const l=2**Number(o.pixelType.slice(1)),c=new Uint32Array(l),{geometry:p,pixelSize:u,downsampleOnly:f,maxPixelCountForDownsample:m}=i,d=v({rasterInfo:o,geometry:p,pixelSize:u,downsampleOnly:f,maxPixelCountForDownsample:m})?void 0:u;return await _(t,{geometry:p,pixelSize:d},(e,t)=>x(e,c),n),a.features.forEach(e=>{const t=e.attributes[r.name];e.attributes[s.name]=c[t]}),a}async function G(e,t,i){const{geometry:n}=t;if("point"===n.type)return E(e,n,i);if("multipoint"===n.type){const t=n.points.map((e,t)=>n.getPoint(t)).map(t=>E(e,t,i)),o=(await Promise.all(t)).filter(e=>null!=e);if(0===o.length)return null;return W(o).map(e=>e/o.length)}const o=await _(e,{geometry:n},(e,t)=>L(e),i),a=o?.filter(e=>e.count>0);if(!a?.length)return null;const r=W(a.map(e=>e.bandSum)),s=a.map(e=>e.count).reduce((e,t)=>e+t);return r.map(e=>e/s)}function W(e){return e.reduce((e,t)=>e.map((e,i)=>e+t[i]))}function L(e){const{width:t,height:i,pixels:n,mask:o}=e,a=new Array(n.length).fill(0);let r=0;for(let s=0;s<i;s++)for(let e=0;e<t;e++){const i=s*t+e;if(!o||o[i]){for(let e=0;e<n.length;e++)a[e]+=n[e][i];r++}}return{bandSum:a,count:r}}async function K(e,t,i){const n=await _(e,{geometry:t.geometry},m,i);return n?.flat()??[]}async function _(i,n,o,a){const r=i.spatialReference;let{geometry:l}=n;if("polyline"===l.type&&!l.spatialReference.equals(r)){const t=(await import("../../../geometry/operators/projectOperator.js")).execute(l,r);if(null==t)throw new e("read-pixels","failed to fetch pixels");l=t}const c="polyline"===l.type?l.extent:l,p=await F(c,r),u="polyline"===l.type?l:p,f=await j(i,a),m={geometry:p,autoResample:!1,pixelSize:n?.pixelSize},x=[],d=M(i,await C(f,m),!0,a);for await(const e of d){if(!e.pixelBlock)continue;const{extent:i}=e,n=o(await s(e.pixelBlock,i,u),i);x.push(n),t(a)}return x}async function V(e,t){const{rasterJobHandler:i}=e,{pixelBlock:n}=e,{statistics:o,histograms:a}=i?await i.computeStatisticsHistograms({pixelBlock:n},t):w(n);return{statistics:o,histograms:a}}async function $(e,t){const{extent:i,fields:n,skipFactor:o,rasterJobHandler:a,pixelIdOffset:r,imageRowSize:s}=e,{pixelBlock:l}=e,c=n.map(({name:e})=>e),p=a?await a.convertPixelBlockToFeatures({pixelBlock:l,extent:i,fieldNames:c,skipFactor:o,pixelIdOffset:r,imageRowSize:s},t):f({pixelBlock:l,extent:i,fieldNames:c,skipFactor:o,pixelIdOffset:r,imageRowSize:s});return p?{fields:n,features:p}:void 0}function Q(e){return"_rasterJobHandler"in e?e._rasterJobHandler:null}async function X(e,t,i){const n=await j(e);t={...t,maxPixelCount:t.maxPixelCount??2**28};const o=await C(n,t);o.bandIds=t.bandIds?.length?t.bandIds:void 0,H(o,n.pixelType,t.maxPixelCount);const{width:a,height:r}=o;if(a<=B&&r<=B){const t=o.bandIds?.length?o.bandIds:void 0,{pixelBlock:n}=await e.fetchPixels(o.extent,a,r,{bandIds:t,interpolation:"nearest",...i});return n}const s=[],l=M(e,o,!1,i);for await(const p of l)s.push(p.pixelBlock);if(!s.some(e=>null!=e))return null;const c=Math.ceil(a/B),u=Math.ceil(r/B),f={width:c*B,height:u*B};let m;const x=Q(e);if(x){const e=await x.mosaicAndTransform({srcPixelBlocks:s,srcMosaicSize:f,destDimension:f},{...i,transferPixelsToWorker:!0});m=e?.pixelBlock}else m=p(s,f);return m}async function Y(t,i,n){if(!i.geometry)throw new e("compute-statistics-histograms","geometry is required to fetch pixel feature set");const{pixelSize:o,downsampleOnly:a,maxPixelCountForDownsample:r}=i,s=await j(t,n),p=v({rasterInfo:s,geometry:i.geometry,pixelSize:o,downsampleOnly:a,maxPixelCountForDownsample:r})?void 0:o;let u=await X(t,{...i,pixelSize:p},n);if(!u)throw new e("compute-statistics-histograms","failed to get intersecting pixels");const{valueAttributeFieldName:f}=i;f&&"value"!==f.toLowerCase()&&(u=c(u,s,f));const m=Q(t),{transformType:x}=i;if(x){const e={lambda:i.lambda,shift:i.shift};u=m?await m.transformPixels({pixelBlock:u,transformType:x,transformParameters:e},{...n,transferPixelsToWorker:!0}):l(u,x,e)}const d=i.histogramSize??void 0;return m?await m.computeStatisticsHistograms({pixelBlock:u,histogramSize:d,includeSkewnessKurtosis:!0},{...n,transferPixelsToWorker:!0}):w(u,{histogramSize:d,includeSkewnessKurtosis:!0})}export{J as computeBoxStatistics,A as computeRasterAttributeTable,Y as computeStatisticsHistograms,O as createPixelFeatureSetCursor,D as fetchPixelFeatureSet,G as identifyAveragePixelValue,K as readIntersectingPixels};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import{JSONSupport as t}from"../../core/JSONSupport.js";import{property as r,subclass as o}from"../../core/accessorSupport/decorators.js";import{getPixelValueRange as i}from"../raster/formats/pixelRangeUtils.js";import{isSupportedRendererType as n,combineRenderingRules as s,convertRendererToRenderingRule as a}from"./imageryRendererUtils.js";import p from"./MosaicRule.js";import{interpolationKebab as l,noDataInterpretationKebab as c,pixelTypeKebabDict as m}from"./rasterEnums.js";import u from"./RasterFunction.js";import{writer as y}from"../../core/accessorSupport/decorators/writer.js";let d=class extends t{constructor(){super(...arguments),this.layer=null,this.requestRawData=!1,this.compression=void 0,this.lercVersion=2}get adjustAspectRatio(){return this.layer.adjustAspectRatio}writeAdjustAspectRatio(e,t,r){this.layer.version<10.3||(t[r]=e)}get bandIds(){return this.layer.bandIds}get compressionQuality(){return this.layer.compressionQuality}writeCompressionQuality(e,t,r){this.format&&this.format.toLowerCase().includes("jpg")&&null!=e&&(t[r]=e)}get compressionTolerance(){return this.layer.compressionTolerance}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}get format(){const e=this.layer.renderer?.type;return this.requestRawData||"vector-field"===e||"flow"===e?"lerc":this.layer.format}get interpolation(){return this.layer.interpolation}get noData(){return this.layer.noData}get noDataInterpretation(){return this.layer.noDataInterpretation}get pixelType(){const{layer:e}=this;return e.pixelType!==e.serviceRasterInfo.pixelType?e.pixelType:void 0}writeLercVersion(e,t,r){"lerc"===this.format&&this.layer.version>=10.5&&(t[r]=e)}get version(){const e=this.layer;return e.commitProperty("bandIds"),e.commitProperty("format"),e.commitProperty("compressionQuality"),e.commitProperty("compressionTolerance"),e.commitProperty("interpolation"),e.commitProperty("noData"),e.commitProperty("noDataInterpretation"),e.commitProperty("mosaicRule"),e.commitProperty("rasterFunction"),e.commitProperty("adjustAspectRatio"),e.commitProperty("pixelFilter"),e.commitProperty("pixelType"),e.commitProperty("definitionExpression"),e.commitProperty("multidimensionalSubset"),(this._get("version")||0)+1}set version(e){this._set("version",e)}get mosaicRule(){const e=this.layer;let t=e.mosaicRule;const r=e.definitionExpression;return t?r&&r!==t.where&&(t=t.clone(),t.where=r):r&&(t=new p({where:r})),t}get rasterFunction(){const e=this.layer;let{rasterFunction:t,rasterInfo:r}=e;t&&"lerc"===this.format&&1===r?.bandCount&&r.colormap&&(t=
|
|
2
|
+
import{__decorate as e}from"tslib";import{JSONSupport as t}from"../../core/JSONSupport.js";import{property as r,subclass as o}from"../../core/accessorSupport/decorators.js";import{getPixelValueRange as i}from"../raster/formats/pixelRangeUtils.js";import{isSupportedRendererType as n,combineRenderingRules as s,convertRendererToRenderingRule as a}from"./imageryRendererUtils.js";import p from"./MosaicRule.js";import{interpolationKebab as l,noDataInterpretationKebab as c,pixelTypeKebabDict as m}from"./rasterEnums.js";import u from"./RasterFunction.js";import{writer as y}from"../../core/accessorSupport/decorators/writer.js";let d=class extends t{constructor(){super(...arguments),this.layer=null,this.requestRawData=!1,this.compression=void 0,this.lercVersion=2}get adjustAspectRatio(){return this.layer.adjustAspectRatio}writeAdjustAspectRatio(e,t,r){this.layer.version<10.3||(t[r]=e)}get bandIds(){return this.requestRawData?this.rawDataRequestBandIds:this.layer.bandIds}get compressionQuality(){return this.layer.compressionQuality}writeCompressionQuality(e,t,r){this.format&&this.format.toLowerCase().includes("jpg")&&null!=e&&(t[r]=e)}get compressionTolerance(){return this.layer.compressionTolerance}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}get format(){const e=this.layer.renderer?.type;return this.requestRawData||"vector-field"===e||"flow"===e?"lerc":this.layer.format}get interpolation(){return this.layer.interpolation}get noData(){return this.layer.noData}get noDataInterpretation(){return this.layer.noDataInterpretation}get pixelType(){const{layer:e}=this;return e.pixelType!==e.serviceRasterInfo.pixelType?e.pixelType:void 0}writeLercVersion(e,t,r){"lerc"===this.format&&this.layer.version>=10.5&&(t[r]=e)}get version(){const e=this.layer;return e.commitProperty("bandIds"),e.commitProperty("format"),e.commitProperty("compressionQuality"),e.commitProperty("compressionTolerance"),e.commitProperty("interpolation"),e.commitProperty("noData"),e.commitProperty("noDataInterpretation"),e.commitProperty("mosaicRule"),e.commitProperty("rasterFunction"),e.commitProperty("adjustAspectRatio"),e.commitProperty("pixelFilter"),e.commitProperty("pixelType"),e.commitProperty("definitionExpression"),e.commitProperty("multidimensionalSubset"),(this._get("version")||0)+1}set version(e){this._set("version",e)}get mosaicRule(){const e=this.layer;let t=e.mosaicRule;const r=e.definitionExpression;return t?r&&r!==t.where&&(t=t.clone(),t.where=r):r&&(t=new p({where:r})),t}get rasterFunction(){const e=this.layer;let{rasterFunction:t,rasterInfo:r}=e;t&&"lerc"===this.format&&1===r?.bandCount&&r.colormap&&(t=h(t,r.pixelType));const o=e.multidimensionalSubset?.areaOfInterest;return o&&(t=w(t,o)),this.requestRawData||!e.isRenderedFormat||e.pixelFilter||"vector-field"===e.renderer?.type||(t=this.combineRendererWithRenderingRule(t)),t}combineRendererWithRenderingRule(e){const t=this.layer,{rasterInfo:r,renderer:o}=t;if(e=e||t.rasterFunction,!o||!n(o))return e;return s(a(o,{rasterAttributeTable:r.attributeTable,pixelType:r.pixelType,dataType:r.dataType,bandNames:r.bandInfos.map(({name:e})=>e),convertColorRampToColormap:t.version<10.6,convertToRFT:!!e?.rasterFunctionDefinition,bandCount:r.bandCount}),e)}};function w(e,t){const r=new u({functionName:"Clip",functionArguments:{ClippingGeometry:t.toJSON(),ClippingType:1}});return s(r,e)}function h(e,t){const[r,o]=i(t),n=new u({functionName:"Stretch",functionArguments:{StretchType:5,UseGamma:!1,Min:r,Max:o,Statistics:[[r,o,1,1]]}});return s(n,e)}e([r()],d.prototype,"layer",void 0),e([r()],d.prototype,"requestRawData",void 0),e([r({json:{write:!0}})],d.prototype,"adjustAspectRatio",null),e([y("adjustAspectRatio")],d.prototype,"writeAdjustAspectRatio",null),e([r({json:{write:!0}})],d.prototype,"bandIds",null),e([r({json:{write:!0}})],d.prototype,"rawDataRequestBandIds",void 0),e([r({json:{write:!0}})],d.prototype,"compression",void 0),e([r({json:{write:!0}})],d.prototype,"compressionQuality",null),e([y("compressionQuality")],d.prototype,"writeCompressionQuality",null),e([r({json:{write:!0}})],d.prototype,"compressionTolerance",null),e([y("compressionTolerance")],d.prototype,"writeCompressionTolerance",null),e([r({json:{write:!0}})],d.prototype,"format",null),e([r({type:String,json:{read:{reader:l.read},write:{writer:l.write}}})],d.prototype,"interpolation",null),e([r({json:{write:!0}})],d.prototype,"noData",null),e([r({type:String,json:{read:{reader:c.read},write:{writer:c.write}}})],d.prototype,"noDataInterpretation",null),e([r({type:m.apiValues,json:{read:m.read,write:m.write}})],d.prototype,"pixelType",null),e([r({json:{write:!0}})],d.prototype,"lercVersion",void 0),e([y("lercVersion")],d.prototype,"writeLercVersion",null),e([r({type:Number})],d.prototype,"version",null),e([r({json:{write:!0}})],d.prototype,"mosaicRule",null),e([r({json:{write:!0,name:"renderingRule"}})],d.prototype,"rasterFunction",null),d=e([o("esri.layers.support.ExportImageServiceParameters")],d);export{d as ExportImageServiceParameters};
|
package/package.json
CHANGED
package/support/revision.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
const
|
|
2
|
+
const c="20260626",e="f095fce950bcdfc3fa54c6ec057024279e41b0bc";export{c as buildDate,e as commitHash};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
|
|
2
|
-
import"../../../../../core/has.js";function e(e,t,r,i,u,o,l){
|
|
2
|
+
import"../../../../../core/has.js";function e(e,t,r,i,u,o,l){H=0;const y=(i-r)*o,p=u&&u.length,c=p?(u[0]-r)*o:y;let v,s,h,d,Z,a=n(t,r,i,0,c,o,!0);if(a&&a.next!==a.prev){if(p&&(a=f(t,r,i,u,a,o)),y>80*o){v=h=t[0+r*o],s=d=t[1+r*o];for(let e=o;e<c;e+=o){const n=t[e+r*o],x=t[e+1+r*o];v=Math.min(v,n),s=Math.min(s,x),h=Math.max(h,n),d=Math.max(d,x)}Z=Math.max(h-v,d-s),Z=0!==Z?1/Z:0}x(a,e,o,v,s,Z,l,0)}}function n(e,n,t,x,r,i,l){let f;if(l===z(e,n,t,x,r,i)>0)for(let o=x;o<r;o+=i)f=u(o+n*i,e[o+n*i],e[o+1+n*i],f);else for(let o=r-i;o>=x;o-=i)f=u(o+n*i,e[o+n*i],e[o+1+n*i],f);if(f&&k(f,f.next)){const e=f.next;o(f),f=e}return f}function t(e,n=e){if(!e)return e;let t,x=e;do{if(t=!1,x.steiner||!k(x,x.next)&&0!==d(x.prev,x,x.next))x=x.next;else{const e=x.prev;if(o(x),x=n=e,x===x.next)break;t=!0}}while(t||x!==n);return n}function x(e,n,u,l,f,y,p,c){if(!e)return;!c&&y&&(e=s(e,l,f,y));let v=e;for(;e.prev!==e.next;){const s=e.prev,h=e.next;if(y?i(e,l,f,y):r(e))n.push(s.index/u+p),n.push(e.index/u+p),n.push(h.index/u+p),o(e),e=h.next,v=h.next;else if((e=h)===v){c?1===c?x(e=A(t(e),n,u,p),n,u,l,f,y,p,2):2===c&&q(e,n,u,l,f,y,p):x(t(e),n,u,l,f,y,p,1);break}}}function r(e){const n=e.prev,t=e,x=e.next;if(d(n,t,x)>=0)return!1;let r=e.next.next;const i=r;let u=0;for(;r!==e.prev&&(0===u||r!==i);){if(u++,M(n.x,n.y,t.x,t.y,x.x,x.y,r.x,r.y)&&d(r.prev,r,r.next)>=0)return!1;r=r.next}return!0}function i(e,n,t,x){const r=e.prev,i=e,u=e.next;if(d(r,i,u)>=0)return!1;const o=r.x<i.x?r.x<u.x?r.x:u.x:i.x<u.x?i.x:u.x,l=r.y<i.y?r.y<u.y?r.y:u.y:i.y<u.y?i.y:u.y,f=r.x>i.x?r.x>u.x?r.x:u.x:i.x>u.x?i.x:u.x,y=r.y>i.y?r.y>u.y?r.y:u.y:i.y>u.y?i.y:u.y,p=g(o,l,n,t,x),c=g(f,y,n,t,x);let v=e.prevZ,s=e.nextZ;for(;v&&v.z>=p&&s&&s.z<=c;){if(v!==e.prev&&v!==e.next&&M(r.x,r.y,i.x,i.y,u.x,u.y,v.x,v.y)&&d(v.prev,v,v.next)>=0)return!1;if(v=v.prevZ,s!==e.prev&&s!==e.next&&M(r.x,r.y,i.x,i.y,u.x,u.y,s.x,s.y)&&d(s.prev,s,s.next)>=0)return!1;s=s.nextZ}for(;v&&v.z>=p;){if(v!==e.prev&&v!==e.next&&M(r.x,r.y,i.x,i.y,u.x,u.y,v.x,v.y)&&d(v.prev,v,v.next)>=0)return!1;v=v.prevZ}for(;s&&s.z<=c;){if(s!==e.prev&&s!==e.next&&M(r.x,r.y,i.x,i.y,u.x,u.y,s.x,s.y)&&d(s.prev,s,s.next)>=0)return!1;s=s.nextZ}return!0}function u(e,n,t,x){const r=E.create(e,n,t);return x?(r.next=x.next,r.prev=x,x.next.prev=r,x.next=r):(r.prev=r,r.next=r),r}function o(e){e.next.prev=e.prev,e.prev.next=e.next,e.prevZ&&(e.prevZ.nextZ=e.nextZ),e.nextZ&&(e.nextZ.prevZ=e.prevZ)}function l(e){let n=e,t=e;do{(n.x<t.x||n.x===t.x&&n.y<t.y)&&(t=n),n=n.next}while(n!==e);return t}function f(e,x,r,i,u,o){const f=new Array;for(let t=0,y=i.length;t<y;t++){const u=n(e,x,r,i[t]*o,t<y-1?i[t+1]*o:r*o,o,!1);u===u.next&&(u.steiner=!0),f.push(l(u))}f.sort(j);for(const n of f)u=t(u=p(n,u),u.next);return u}function y(e){if(e.next.prev===e)return e;let n=e;for(;;){const t=n.next;if(t.prev===n||t===n||t===e)break;n=t}return n}function p(e,n){const x=c(e,n);if(!x)return n;const r=D(x,e);let i=t(x,x.next);const u=y(r);return t(u,u.next),i=y(i),y(n===x?i:n)}function c(e,n){let t=n;const x=e.x,r=e.y;let i=-1/0,u=null;do{if(r<=t.y&&r>=t.next.y&&t.next.y!==t.y){const e=t.x+(r-t.y)*(t.next.x-t.x)/(t.next.y-t.y);if(e<=x&&e>i){if(i=e,e===x){if(r===t.y)return t;if(r===t.next.y)return t.next}u=t.x<t.next.x?t:t.next}}t=t.next}while(t!==n);if(!u)return null;if(x===i)return u;const o=u,l=u.x,f=u.y;let y=1/0;t=u;do{if(x>=t.x&&t.x>=l&&x!==t.x&&M(r<f?x:i,r,l,f,r<f?i:x,r,t.x,t.y)){const n=Math.abs(r-t.y)/(x-t.x);b(t,e)&&(n<y||n===y&&(t.x>u.x||t.x===u.x&&v(u,t)))&&(u=t,y=n)}t=t.next}while(t!==o);return u}function v(e,n){return d(e.prev,e,n.prev)<0&&d(n.next,e,e.next)<0}function s(e,n,t,x){let r;for(;r!==e;r=r.next){if(r=r||e,null===r.z&&(r.z=g(r.x,r.y,n,t,x)),r.prev.next!==r||r.next.prev!==r)return r.prev.next=r,r.next.prev=r,s(e,n,t,x);r.prevZ=r.prev,r.nextZ=r.next}return e.prevZ.nextZ=null,e.prevZ=null,h(e)}function h(e){let n,t=1;for(;;){let x,r=e;e=null,n=null;let i=0;for(;r;){i++,x=r;let u=0;for(;u<t&&x;u++)x=x.nextZ;let o=t;for(;u>0||o>0&&x;){let t;0===u?(t=x,x=x.nextZ,o--):0!==o&&x?r.z<=x.z?(t=r,r=r.nextZ,u--):(t=x,x=x.nextZ,o--):(t=r,r=r.nextZ,u--),n?n.nextZ=t:e=t,t.prevZ=n,n=t}r=x}if(n.nextZ=null,t*=2,i<2)return e}}function d(e,n,t){return(n.y-e.y)*(t.x-n.x)-(n.x-e.x)*(t.y-n.y)}function Z(e,n,t,x){const r=w(d(e,n,t)),i=w(d(e,n,x)),u=w(d(t,x,e)),o=w(d(t,x,n));return r!==i&&u!==o||(!(0!==r||!a(e,t,n))||(!(0!==i||!a(e,x,n))||(!(0!==u||!a(t,e,x))||!(0!==o||!a(t,n,x)))))}function a(e,n,t){return n.x<=Math.max(e.x,t.x)&&n.x>=Math.min(e.x,t.x)&&n.y<=Math.max(e.y,t.y)&&n.y>=Math.min(e.y,t.y)}function w(e){return e>0?1:e<0?-1:0}function m(e,n){let t=e;do{if(t.index!==e.index&&t.next.index!==e.index&&t.index!==n.index&&t.next.index!==n.index&&Z(t,t.next,e,n))return!0;t=t.next}while(t!==e);return!1}function z(e,n,t,x,r,i){let u=0;for(let o=x,l=r-i;o<r;o+=i)u+=(e[l+n*i]-e[o+n*i])*(e[o+1+n*i]+e[l+1+n*i]),l=o;return u}function M(e,n,t,x,r,i,u,o){return(r-u)*(n-o)-(e-u)*(i-o)>=0&&(e-u)*(x-o)-(t-u)*(n-o)>=0&&(t-u)*(i-o)-(r-u)*(x-o)>=0}function b(e,n){return d(e.prev,e,e.next)<0?d(e,n,e.next)>=0&&d(e,e.prev,n)>=0:d(e,n,e.prev)<0||d(e,e.next,n)<0}function g(e,n,t,x,r){return(e=1431655765&((e=858993459&((e=252645135&((e=16711935&((e=32767*(e-t)*r)|e<<8))|e<<4))|e<<2))|e<<1))|(n=1431655765&((n=858993459&((n=252645135&((n=16711935&((n=32767*(n-x)*r)|n<<8))|n<<4))|n<<2))|n<<1))<<1}function k(e,n){return e.x===n.x&&e.y===n.y}function j(e,n){return e.x-n.x}function A(e,n,x,r){let i=e;do{const t=i.prev,u=i.next.next;!k(t,u)&&Z(t,i,i.next,u)&&b(t,u)&&b(u,t)&&(n.push(t.index/x+r),n.push(i.index/x+r),n.push(u.index/x+r),o(i),o(i.next),i=e=u),i=i.next}while(i!==e);return t(i)}function q(e,n,r,i,u,o,l){let f=e;do{let e=f.next.next;for(;e!==f.prev;){if(f.index!==e.index&&B(f,e)){let y=D(f,e);return f=t(f,f.next),y=t(y,y.next),x(f,n,r,i,u,o,l,0),void x(y,n,r,i,u,o,l,0)}e=e.next}f=f.next}while(f!==e)}function B(e,n){return e.next.index!==n.index&&e.prev.index!==n.index&&!m(e,n)&&(b(e,n)&&b(n,e)&&C(e,n)&&(0!==d(e.prev,e,n.prev)||0!==d(e,n.prev,n))||k(e,n)&&d(e.prev,e,e.next)>0&&d(n.prev,n,n.next)>0)}function C(e,n){let t=e,x=!1;const r=(e.x+n.x)/2,i=(e.y+n.y)/2;do{t.y>i!=t.next.y>i&&t.next.y!==t.y&&r<(t.next.x-t.x)*(i-t.y)/(t.next.y-t.y)+t.x&&(x=!x),t=t.next}while(t!==e);return x}function D(e,n){const t=E.create(e.index,e.x,e.y),x=E.create(n.index,n.x,n.y),r=e.next,i=n.prev;return e.next=n,n.prev=e,t.next=r,r.prev=t,x.next=t,t.prev=x,i.next=x,x.prev=i,x}class E{constructor(){this.index=0,this.x=0,this.y=0,this.prev=null,this.next=null,this.z=null,this.prevZ=null,this.nextZ=null,this.steiner=!1}static create(e,n,t){const x=H<F.length?F[H++]:new E;return x.index=e,x.x=n,x.y=t,x.prev=null,x.next=null,x.z=null,x.prevZ=null,x.nextZ=null,x.steiner=!1,x}}const F=[],G=8096;let H=0;for(let I=0;I<G;I++)F.push(new E);export{e as bufcut};
|