@arcgis/core 5.2.0-next.20 → 5.2.0-next.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (149) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/057d288d795b853295f1.js +2 -0
  3. package/assets/esri/core/workers/chunks/{595bc41ff36c77324d01.js → 19493c9c7e1d2ac0f80f.js} +8 -8
  4. package/assets/esri/core/workers/chunks/2ef80e003b4f0393ac2e.js +1 -0
  5. package/assets/esri/core/workers/chunks/{4fdd38d7362bf09a994b.js → 33866e6e6de1bab64599.js} +1 -1
  6. package/assets/esri/core/workers/chunks/360fd810d70d21c092d9.js +1 -0
  7. package/assets/esri/core/workers/chunks/{4517630bf869205bab87.js → 38a76bc4ef5c10ab0488.js} +1 -1
  8. package/assets/esri/core/workers/chunks/5468a65698931603656d.js +1 -0
  9. package/assets/esri/core/workers/chunks/{c9e5d3f496cefb8e3934.js → 5aa375b0c6a205134703.js} +1 -1
  10. package/assets/esri/core/workers/chunks/{db26cf2c2735183294b8.js → 6649acaceab00ad30e7f.js} +1 -1
  11. package/assets/esri/core/workers/chunks/7175f0c6a6e56b685d20.js +680 -0
  12. package/assets/esri/core/workers/chunks/{501fa9b029df2e7b73c3.js → 754f7ed62afc4e0a1972.js} +2 -2
  13. package/assets/esri/core/workers/chunks/{6ac09f4e85c664a17365.js → 8331e04ebe0a54b04ab6.js} +1 -1
  14. package/assets/esri/core/workers/chunks/{72edd08a2ff08970ba38.js → 87011d2fe14c54e296af.js} +1 -1
  15. package/assets/esri/core/workers/chunks/{5216dd0544e901039c84.js → 8c64c6b8d7376a9d1c91.js} +1 -1
  16. package/assets/esri/core/workers/chunks/{8ce4fe00328173224ed2.js → 909e67dee8c30e391d69.js} +1 -1
  17. package/assets/esri/core/workers/chunks/93b40245378ced43ca08.js +1 -0
  18. package/assets/esri/core/workers/chunks/98dfe31e8ed9b522eaff.js +1 -0
  19. package/assets/esri/core/workers/chunks/{4104a0585969f8cd524c.js → a40ede4d3375184f21fe.js} +1 -1
  20. package/assets/esri/core/workers/chunks/a533d066cac26124c5ce.js +1 -0
  21. package/assets/esri/core/workers/chunks/a536904fe6f3b16fdbdc.js +1 -0
  22. package/assets/esri/core/workers/chunks/a8167ab9fd846d699be5.js +1 -0
  23. package/assets/esri/core/workers/chunks/{dd0c1cf921369e2bc48b.js → a90619adff41658f8057.js} +1 -1
  24. package/assets/esri/core/workers/chunks/{6e8b9c03240ec372b587.js → c30ca771dd3f7198142b.js} +1 -1
  25. package/assets/esri/core/workers/chunks/{e8d65900eefff1152207.js → c593539c2cce7a2b9d44.js} +1 -1
  26. package/assets/esri/core/workers/chunks/da47fdffb5969694a2ae.js +1 -0
  27. package/assets/esri/core/workers/chunks/{764c8ba14ab74b66b391.js → e5fcd8e7a4a660ef6ad6.js} +1 -1
  28. package/assets/esri/core/workers/chunks/f0519b06987471456b69.js +1 -0
  29. package/assets/esri/core/workers/chunks/{5f63077ec5ba3560491b.js → f1ff33584680d8718400.js} +1 -1
  30. package/assets/esri/core/workers/chunks/f47319d36f1527277923.js +1 -0
  31. package/assets/esri/libs/parquet/pkg/bundle_bg.wasm +0 -0
  32. package/assets/esri/themes/dark/main.css +1 -1
  33. package/assets/esri/themes/light/main.css +1 -1
  34. package/assets/esri/themes/light/view.css +1 -1
  35. package/chunks/Pattern.glsl.js +17 -17
  36. package/chunks/RibbonLine.glsl.js +45 -43
  37. package/chunks/bundle2.js +1 -1
  38. package/config.js +1 -1
  39. package/geometry/support/geometryUtils.js +1 -1
  40. package/geometry/support/intersects.js +1 -1
  41. package/geometry/support/intersectsBase.js +1 -1
  42. package/kernel.js +1 -1
  43. package/layers/AnnotationFeatureLayer.d.ts +43 -0
  44. package/layers/AnnotationFeatureLayer.js +1 -1
  45. package/layers/DimensionFeatureLayer.d.ts +39 -0
  46. package/layers/DimensionFeatureLayer.js +1 -1
  47. package/layers/DimensionLayer.d.ts +1 -0
  48. package/layers/FeatureLayer.js +1 -1
  49. package/layers/IntegratedMesh3DTilesLayer.d.ts +9 -1
  50. package/layers/ParquetLayer.d.ts +6 -10
  51. package/layers/graphics/data/attributeSupport.js +1 -1
  52. package/layers/graphics/data/queryValidationUtils.js +1 -1
  53. package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
  54. package/layers/mixins/ArcGISImageService.js +1 -1
  55. package/layers/raster/datasets/WCSRaster.js +1 -1
  56. package/layers/support/AnnotationFeatureSublayer.d.ts +5 -3
  57. package/layers/support/SymbolLayerDrawing.js +1 -1
  58. package/package.json +2 -2
  59. package/support/revision.js +1 -1
  60. package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
  61. package/views/2d/engine/transitions/FadeTransition.js +1 -1
  62. package/views/2d/engine/webgl/FeatureTile.js +1 -1
  63. package/views/2d/engine/webgl/TileCpuState.js +1 -1
  64. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerMeshWriter.js +1 -1
  65. package/views/2d/engine/webgl/shaderGraph/techniques/markers/MarkerShader.js +1 -1
  66. package/views/2d/engine/webgl/shaderGraph/techniques/mesh/MeshWriter.js +1 -1
  67. package/views/2d/engine/webgl/shaderGraph/techniques/shaders/LineShader.js +1 -1
  68. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextMeshWriter.js +1 -1
  69. package/views/2d/engine/webgl/shaderGraph/techniques/text/TextShader.js +1 -1
  70. package/views/2d/engine/webgl/shaders/sources/shaderRepository.js +1 -1
  71. package/views/2d/layers/LayerView2D.js +1 -1
  72. package/views/2d/layers/MediaLayerView2D.js +1 -1
  73. package/views/2d/layers/features/FeatureContainer.js +1 -1
  74. package/views/2d/layers/features/RenderState.js +1 -1
  75. package/views/2d/layers/features/aggregation/GeohashSpatialIndex.js +1 -1
  76. package/views/2d/layers/features/aggregation/GridSpatialIndex.js +1 -1
  77. package/views/2d/layers/features/layerAdapters/AnnotationLayerAdapter.js +1 -1
  78. package/views/2d/layers/features/layerAdapters/DimensionLayerAdapter.js +1 -1
  79. package/views/2d/layers/features/schema/processor/SimpleProcessorSchema.js +1 -1
  80. package/views/2d/layers/features/sources/strategies/support/queryAdapters.js +1 -1
  81. package/views/2d/layers/features/support/FeatureSetReaderParquet.js +1 -1
  82. package/views/2d/layers/support/annodime/DimensionInfo.js +1 -1
  83. package/views/3d/analysis/LineOfSight/LineOfSightDrawToolRenderer.js +1 -1
  84. package/views/3d/analysis/LineOfSight/LineOfSightInteractionVisuals.js +2 -0
  85. package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
  86. package/views/3d/analysis/LineOfSight/LineOfSightReshapeTool3D.js +1 -1
  87. package/views/3d/analysis/LineOfSight/LineOfSightTool2.js +1 -1
  88. package/views/3d/analysis/LineOfSight/lineOfSightPlacementUtils.js +1 -1
  89. package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
  90. package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
  91. package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
  92. package/views/3d/layers/graphics/Graphics3DPathSymbolLayerConstants.js +1 -1
  93. package/views/3d/layers/graphics/tessellationUtils.js +1 -1
  94. package/views/3d/support/pointsOfInterest/CenterOnSurface.js +1 -1
  95. package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +11 -11
  96. package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +6 -9
  97. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathEvaluate.glsl.js +46 -46
  98. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexInfo.glsl.js +46 -18
  99. package/views/3d/webgl-engine/core/shaderLibrary/attributes/PathVertexPosition.glsl.js +22 -22
  100. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizer.js +1 -1
  101. package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
  102. package/views/3d/webgl-engine/effects/transparency/OITBlend.js +1 -1
  103. package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
  104. package/views/3d/webgl-engine/lib/PathCapBuilder.js +1 -1
  105. package/views/3d/webgl-engine/lib/PathEvaluator.js +1 -1
  106. package/views/3d/webgl-engine/lib/PathGeometry.js +1 -1
  107. package/views/3d/webgl-engine/lib/PathGeometryData.js +1 -1
  108. package/views/3d/webgl-engine/lib/PathVertexInfo.js +1 -1
  109. package/views/3d/webgl-engine/lib/Renderer.js +1 -1
  110. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferUtils.js +1 -1
  111. package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBuffer.js +1 -1
  112. package/views/3d/webgl-engine/materials/PathLayouts.js +1 -1
  113. package/views/3d/webgl-engine/materials/PathMaterial.js +1 -1
  114. package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
  115. package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
  116. package/views/3d/webgl-engine/shaders/PatternTextureBuffer.glsl.js +1 -1
  117. package/views/3d/webgl-engine/shaders/RibbonLine.glsl.js +1 -1
  118. package/views/3d/webgl-engine/shaders/RibbonLineLayouts.js +1 -1
  119. package/views/3d/webgl-engine/shaders/RibbonLineTextureBuffer.glsl.js +2 -0
  120. package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +10 -10
  121. package/views/analysis/ElevationProfile/ElevationProfileChart.js +1 -1
  122. package/views/webgl/ShaderBuilder.js +1 -1
  123. package/widgets/BatchAttributeForm.js +1 -1
  124. package/widgets/BuildingExplorer/BuildingPhasePicker/BuildingPhasePicker.js +1 -1
  125. package/widgets/Editor/components/UpdateFeaturePanelContent.js +1 -1
  126. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  127. package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
  128. package/widgets/OrientedImageryViewer/components/OrientedImageryVideoViewModel.js +1 -1
  129. package/widgets/OrientedImageryViewer/components/VideoEnhancementTools.js +1 -1
  130. package/widgets/OrientedImageryViewer/constants.js +1 -1
  131. package/widgets/OrientedImageryViewer/support/panConstraint.js +2 -0
  132. package/widgets/OrientedImageryViewer.js +1 -1
  133. package/widgets/Print/CustomTemplate.d.ts +7 -0
  134. package/widgets/Search/LayerSearchSource.d.ts +3 -0
  135. package/assets/esri/core/workers/chunks/0a259137932211b80f0e.js +0 -1
  136. package/assets/esri/core/workers/chunks/35a508a9311689d8df52.js +0 -1
  137. package/assets/esri/core/workers/chunks/74922daaedb479ec6f03.js +0 -1
  138. package/assets/esri/core/workers/chunks/912a8743a02f467b63b0.js +0 -2
  139. package/assets/esri/core/workers/chunks/9def4619d102f1d41578.js +0 -1
  140. package/assets/esri/core/workers/chunks/a0876a52a3c2ad849370.js +0 -1
  141. package/assets/esri/core/workers/chunks/a3c5b754a6fa0f4250bf.js +0 -1
  142. package/assets/esri/core/workers/chunks/a98905bf6050ad3b8721.js +0 -633
  143. package/assets/esri/core/workers/chunks/bf67e0f6064fb9d94ac8.js +0 -1
  144. package/assets/esri/core/workers/chunks/cd892f429d5ffe8de99e.js +0 -1
  145. package/assets/esri/core/workers/chunks/d34d41a350facfa9b7c0.js +0 -1
  146. package/assets/esri/core/workers/chunks/d5a0e3a73df827dc7b06.js +0 -1
  147. package/assets/esri/core/workers/chunks/e5471373f89fd7cb9844.js +0 -1
  148. /package/assets/esri/core/workers/chunks/{912a8743a02f467b63b0.js.LICENSE.txt → 057d288d795b853295f1.js.LICENSE.txt} +0 -0
  149. /package/assets/esri/core/workers/chunks/{501fa9b029df2e7b73c3.js.LICENSE.txt → 754f7ed62afc4e0a1972.js.LICENSE.txt} +0 -0
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{toConst as r}from"../../../../core/compilerUtils.js";import s from"../../../../core/Error.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{onAbortOrThrow as a,throwIfAborted as n}from"../../../../core/promiseUtils.js";import{QueueProcessor as o}from"../../../../core/QueueProcessor.js";import{parseWhereClause as u}from"../../../../core/sql.js";import l from"../../../../geometry/SpatialReference.js";import{set as c,create as p,expandWithAABB as d,expandWithRect as f,negativeInfinity as m}from"../../../../geometry/support/aaBoundingBox.js";import{copy as y,negativeInfinity as h,create as g,expandWithRect as _}from"../../../../geometry/support/aaBoundingRect.js";import{getScaleForResolution as w}from"../../../../geometry/support/scaleUtils.js";import{isWebMercator as x,isWGS84 as F}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertToGeometry as S}from"../../featureConversionUtils.js";import{getQueryResultExtent as I,getQueryBoundingRects as v,QueryEngine as q}from"../../data/QueryEngine.js";import{queryCapabilities as R}from"../../data/QueryEngineCapabilities.js";import{QueryEngineResult as b}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as C}from"../../data/queryUtils.js";import{createFileProvider as E}from"../parquet/createFileProvider.js";import{createDrawingInfo as O}from"./clientSideDefaults.js";import{getParquetFileId as T,getParquetRowId as P,getParquetObjectId as j}from"./parquetIdUtils.js";import Q from"../../../support/Field.js";import N from"../../../support/FieldsIndex.js";import{isNumericField as A}from"../../../support/fieldUtils.js";import{fromParquetGeometryEncodingJSON as G}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as B,fromParquetJSONGeometryType as M,toParquetJSONGeometryType as z}from"../../../support/parquetUtils.js";import{loadParquetModule as D}from"../../../../libs/parquet/loadParquetModule.js";import{FeatureStoreQueryAdapter as k}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as V}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as U}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as W}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as J}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const Z=new k,L=4,H="__OBJECTID",Y=new TextDecoder,X=8e3,$=2e7,K=8,ee=2,te=20;class re{constructor(e,t){this._files=e,this._createFileStream=t,this._fileIndex=0,this._streamIndex=0,this._streams=[],this._pending=new Set,this._resolvedCount=0}async next(e){for(await this._fill(e);this._pending.size>0;){n(e),await this._fill(e);const t=await se(this._pending);if(this._pending.delete(t.read),this._resolvedCount++,null!=t.chunk)return t.chunk}return null}async _fill(e){for(this._removeDone();this._pending.size<K;){const t=this._getOrCreateNextStream(e);if(null==t)return;this._pending.add(t.read(e))}}_getOrCreateNextStream(e){const t=this._resolvedCount>=K?K:ee;if(this._fileIndex<this._files.length&&this._streams.length<t){const t=this._files[this._fileIndex++],r=new ie(t.id,this._createFileStream(t,e));return this._streams.push(r),r}return this._getNextStream()}_getNextStream(){const e=this._streams.length;for(let t=0;t<e;t++){const r=(this._streamIndex+t)%e,s=this._streams[r];if(s.canRead)return this._streamIndex=(r+1)%e,s}return null}_removeDone(){let e=this._streamIndex;for(let t=this._streams.length-1;t>=0;t--)this._streams[t].done&&(this._streams.splice(t,1),t<e&&e--);this._streamIndex=this._streams.length>0?e%this._streams.length:0}}function se(e){return Promise.race(Array.from(e,async e=>({read:e,chunk:await e})))}class ie{constructor(e,t){this._fileId=e,this._stream=t,this._readCount=0,this._reachedEnd=!1}get canRead(){return!this._reachedEnd}get done(){return this._reachedEnd&&0===this._readCount}async read(e){this._readCount++;try{const t=await this._stream,r=await t.next(e);return null==r?(this._reachedEnd=!0,null):{fileId:this._fileId,chunk:r}}finally{this._readCount--}}}class ae{constructor(){this._queue=new o({concurrency:L,process:(e,t)=>this._executeQuery(e,t)}),this._streams=new Map,this._streamIdCounter=0,this._indexMap={}}async load(e){const t=e.spatialReference?l.fromJSON(e.spatialReference):void 0;if(t&&!t.isWGS84&&!t.isWebMercator)throw new s("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");this._customParameters=e.customParameters,this._provider=E(e.provider,null,()=>this._customParameters);const r=await this._provider.getMetadata(),a=await B(r,{fields:e.fields?.map(e=>Q.fromJSON(e)),geometryEncoding:e.geometryEncoding?G(e.geometryEncoding):null,geometryType:e.geometryType?M(e.geometryType):null,displayOptimization:e.displayOptimization,spatialReference:t});if(!a.fields)throw new s("parquet:unsupported","Fields must be defined");let n;if(a.spatialReference&&a.geometryType){if(!a.spatialReference)throw new s("parquet:unsupported","SpatialReference must be defined");if(!a.spatialReference.isGeographic&&!a.spatialReference.isWebMercator)throw new s("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");a.spatialReference.isGeographic&&!a.spatialReference.isWGS84&&(i.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:a.spatialReference}),a.spatialReference=l.WGS84),n={geometry:a.geometryEncoding?{geometryType:z(a.geometryType),spatialReference:a.spatialReference.toJSON(),encoding:a.geometryEncoding.toJSON()}:null,displayOptimization:a.displayOptimization}}this.setCustomParameters(e.customParameters),this._displayOptimization=a.displayOptimization,await this._provider.updateGeometryInfo(n),this._capabilities=Se(await this._getFileStatistics());const o=await this._provider.getFiles();if(!o.length)return{layerDefinition:{},capabilities:Se(null)};const u=await o[0].file;a.file=u;const{fields:c}=a;if(null==c)throw new s("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",c);c.push(new Q({name:H,type:"oid",alias:H}));for(const s of c){const e=u.getColumnId(s.name);null!=e&&(this._indexMap[s.name]=e)}const p=new N(c.map(e=>e.toJSON()));this._fieldsIndex=p;const d=z(a.geometryType??"point");return this._metadata=W.createFeature({fieldsIndex:p.toJSON(),geometryType:d,hasZ:!1,hasM:!1,featureIdInfo:{type:"object-id",fieldName:H},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:a.spatialReference,outSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:d,featureIdInfo:{type:"object-id",fieldName:H},hasM:!1,hasZ:!1,spatialReference:a.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},this._fullExtent=r?.extent?r.extent:await this._tryDeriveParquetFullExtent(a),{capabilities:this._capabilities,layerDefinition:{fields:a.fields?.map(e=>e.toJSON()),drawingInfo:O(d),extent:this._fullExtent??void 0,geometryType:d,geometryEncoding:a.geometryEncoding?.toJSON(),displayOptimization:a.displayOptimization}}}destroy(){this._provider.destroy(),this._queue.destroy();for(const{handle:e}of this._streams.values())e.remove();this._streams.clear()}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async updateFileProvider(e){this._provider=E(e,this._provider.getGeometryInfo(),()=>this._customParameters)}async queryFeatures(e,t){const r=await C(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),Ie(r)||(r.resultRecordCount=r.resultRecordCount?Math.min(r.resultRecordCount,X):X,r.resultOffset=r.resultOffset??0),r.outStatistics)return this._queryStatistics(r,t);r.returnDistinctValues&&(r.returnGeometry=void 0);return(await this._enqueueQuery(r,t)).createQueryResponse()}async queryFeatureCount(e,t){const r=await C(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!ne(r))return this._getFeatureCount();r.outFields=void 0,r.returnGeometry=void 0;return(await this._enqueueQuery(r,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const r=await C(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!ne(r))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);r.resultRecordCount=r.resultRecordCount?Math.min(r.resultRecordCount,8e3):8e3,r.resultOffset=r.resultOffset??0,r.returnGeometry=void 0,r.outFields=void 0;return(await this._enqueueQuery(r,t)).items.map(e=>e.getObjectId())}async queryAttributeBins(e,t={}){throw new s("parquet:unsupported","queryAttributeBins not supported.")}async queryExtent(e,t){const s=await C(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),this._fullExtent&&!ne(s))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=r(this._metadata.spatialReference);s.returnGeometry=!0,s.outFields=void 0;const a=c(p(),m),n=p(),o=await this._enqueueQuery(s,t);let u=0;for(const r of o.items)r.getBounds(n)&&(d(a,n),u+=1);return{count:u,extent:I(a,i,s.outSR?r(s.outSR):i.toJSON(),i,!1)}}async queryStream(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const r=await this._getCandidateFiles(e),s=new re(r,async(t,r)=>{const s=await t.file,i=await this._createParquetQuery(s,t.id,e);return s.executeQuery(i,r)}),i=this._streamIdCounter++,n=a(t.signal,e=>{const t=this._streams.get(i);null!=t&&(t.handle.remove(),this._streams.delete(i))});return this._streams.set(i,{stream:s,handle:n}),i}async getStreamNext(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const r=this._streams.get(e);if(!r)return{result:null};const s=await r.stream.next(t.signal);if(null==s)return r.handle.remove(),this._streams.delete(e),{result:null};const i=s.chunk.serialize().buffer,a={fileId:s.fileId,buffer:i};return i instanceof ArrayBuffer?{result:a,transferList:[i]}:{result:a}}async getStreamNextFeatures(e,t){const{result:r}=await this.getStreamNext(e,t);if(null==r)return null;const s=(await D()).ParquetChunk.deserialize(new Uint8Array(r.buffer)),i=new J(this._metadata,this._indexMap,s,r.fileId),a=[];for(;i.next();){const e=S(i.readGeometryWorldSpace(),i.geometryType,i.hasZ,i.hasM),t=i.readAttributes();a.push({attributes:t,geometry:e})}return{features:a}}async createPatch(e,t,r,s,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const a=await this._getFileInfoById(e),n=await a.file;return(await n.createChunkPatch(t,r,s,i.signal)).serialize().buffer}async _getCandidateFiles(e){const t=await this._provider.getFiles(),r=await this._getSpatialFilePruning(e);if(null==r)return t;const s=t.filter(e=>this._mayIncludeFileForSpatialPruning(e,r));return"xz"===r.type?he(s,r):s}async _queryStatistics(e,t){const r=await C({...e},null,this._queryEngineParams.spatialReference);if(r.returnGeometry=void 0,oe(r,this._fieldsIndex)){const e=await this._getStatisticsFromFiles(r);if(e)return e}return(await this._enqueueQuery(r,t)).createQueryResponse()}async _getStatisticsFromFiles(e){const t=await this._provider.getFiles(),r={},s=[];for(const i of e.outStatistics??[]){const e=ce(i,t);if(!e.available)return null;r[i.outStatisticFieldName]=e.value,s.push(le(i,this._fieldsIndex))}return{fields:s,features:[{attributes:r}]}}async _getSpatialFilePruning(e){if("tile"!==e.type&&("arcade"!==e.type||null==e.extent))return null;const t=this._displayOptimization,r=t?.index;if(null==r)return null;const s=e.outSpatialReference.wkid;if(null==r.wkid||null==s)return null;const i=r.wkid,a=await D();switch(r.type){case"xz":return{type:"xz",fieldName:r.code,intersects:(t,n)=>a.queryIntersectsXZStatistics(r.fullExtent,e.extent,s,i,te,t,n)};case"z":return{type:"xy",xFieldName:r.xColumn,yFieldName:r.yColumn,intersects:(t,r,n,o)=>a.queryIntersectsXYStatistics(e.extent,s,i,t,r,n,o)}}}_mayIncludeFileForSpatialPruning(e,t){switch(t.type){case"xz":{const r=ye(e,t);return null==r||we(r,t)}case"xy":{const{xStatistics:r,yStatistics:s}=_e(e,t);return null==r||null==s||xe(r,s,t)}}}async _tryDeriveParquetFullExtent(r){if(!r.spatialReference)return null;if(null==this._fullExtent&&"location"===r.geometryEncoding?.type){const i=await this._provider.getFiles(),{xField:a,yField:n}=r.geometryEncoding,o=c(p(),m);for(const r of i){const i=await r.file;for(const r of i.rowGroups()){const i={stack:[],error:void 0,hasError:!1};try{const t=e(i,r.columnDescriptorForAttribute(a),!1),s=e(i,r.columnDescriptorForAttribute(n),!1),u=[t.minValue(),s.minValue(),t.maxValue(),s.maxValue()];f(o,u),r.free()}catch(s){i.error=s,i.hasError=!0}finally{t(i)}}}return{xmin:o[0],ymin:o[1],xmax:o[3],ymax:o[4],spatialReference:r.spatialReference?.toJSON()}}return null}async _getFileInfoById(e){const t=await this._provider.getFiles();for(const r of t)if(r.id===e)return r;throw new Error(`InternalError: File ${e} does not exist`)}async _getFileStatistics(){return{featureCount:await this._getFeatureCount(),byteLength:await this._getByteLength()}}async _getFile(e){return(await this._getFileInfoById(e)).file}async _createParquetQuery(e,t,r){const s=(await D()).Query.new();return"tile"===r.type?(s.setExtent(r.extent),s.setQuantizationTransform(r.transform),s.setScale(r.scale)):"arcade"===r.type&&null!=r.extent&&s.setExtent(r.extent),s.setOutFields(r.outFields.filter(e=>null!=this._indexMap[e])),s.setOutSpatialReference(r.outSpatialReference.wkid),s.setReturnGeometry(r.returnGeometry),r.where&&await this._setWhereClause(s,e,t,r.where),s}async _getFeatureCount(){return(await this._provider.getFiles()).map(e=>e.statistics.rowCount).reduce((e,t)=>e+t,0)}async _getByteLength(){return(await this._provider.getFiles()).map(e=>e.statistics.byteSize).reduce((e,t)=>e+t,0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new s("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new s("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new s("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,r,i){const a=this._indexMap,n=this._fieldsIndex,o={getAttribute(e,s){const i=a[s];if(null==i){const t=n.get(s);if("__OBJECTID"===t?.name){const t=e.row+e.rowGroupStart;return j(r,t)}return null}const o=t.readAttribute(e.rowGroup,e.row,i);if(null==o)return null;const u=n.get(s);return"esriFieldTypeString"===u.type||"esriFieldTypeDateOnly"===u.type||"esriFieldTypeTimeOnly"===u.type||"esriFieldTypeTimestampOffset"===u.type?Y.decode(o):o}},l=await u(i,this._fieldsIndex);if(!l.isStandardized)throw new s("sql-parse-error","expression is not standardized");const c=(e,t,r)=>l.testFeatureCompiled({rowGroup:e,row:t,rowGroupStart:r},o,null),p=l.fieldNames.map(e=>n.get(e)).filter(e=>e&&null!=this._indexMap[e?.name]);e.setWhere(i),e.setWhereEvaluator(c),e.setWhereFields(p.map(e=>e.name))}async*_queryChunks(e,t){const r=await D(),s=await this._provider.getFiles(),i=await this._getRequiredFields(e),a=this._tryGetGeneralizedGeometryScale(e);for(const o of s){const s=await o.file,u=r.Query.new();u.setOutFields(i),(e.geometry||e.returnGeometry)&&u.setReturnGeometry(!0),null!=a&&u.setScale(a);const l=e.geometry?.spatialReference??this._queryEngineParams.spatialReference,c=l.wkid;if(e.geometry&&(x(l)||F(l))){const t=y(g(),h);for(const r of v(e.geometry))_(t,r);u.setOutSpatialReference(c),u.setExtent({xmin:t[0],ymin:t[1],xmax:t[2],ymax:t[3]})}e.where&&await this._setWhereClause(u,s,o.id,e.where);const p=await s.executeQuery(u),d=[],f=p.next(t);for(let e=0;e<L;e++)d.push(p.next(t));let m=await f;for(;null!=m;){n(t);const e=new J(this._metadata,this._indexMap,m,o.id),r=me([new V(e,null,0,!1)],this._queryEngineParams),s=d.shift();d.push(p.next(t)),yield r,m=await s}}}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){if(e.objectIds?.length){const r=new Map;for(const t of e.objectIds){const e=T(t),s=P(t);let i=r.get(e);i||(i=[],r.set(e,i)),i.push(s)}const s=[];for(const[i,a]of r.entries()){const r=await this._executeFileIdQuery(e,i,a,t);for(const e of r)s.push(e)}return new b(s,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:!1,hasZ:!1,featureAdapter:Z,featureIdInfo:this._queryEngineParams.featureIdInfo})}let r=e.resultRecordCount??await this._getFeatureCount(),i=e.resultOffset??0;if(r>$)throw new s("parquet:cannot-execute-query","Unable to execute query, dataset is too large.");const a={...e};e.where=void 0,e.resultRecordCount=void 0,e.resultOffset=void 0;const n=[];for await(const s of this._queryChunks(a,t)){const a=await s.executeQueryForOpaqueFeatures(e,t);if(a.length>i){const t=a.slice(i,Math.min(i+r,a.length));for(const e of t)n.push(e);if(i=0,r-=t.length,0===r)return new b(n,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:!1,hasZ:!1,featureAdapter:Z,featureIdInfo:this._queryEngineParams.featureIdInfo})}else i-=a.length}return new b(n,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:!1,hasZ:!1,featureAdapter:Z,featureIdInfo:this._queryEngineParams.featureIdInfo})}async _executeFileIdQuery(e,t,r,s){const i=await this._getRequiredFields(e),a=(await D()).Query.new();a.setOutFields(i),a.setReturnGeometry(!!e.returnGeometry),a.setIds(new Uint32Array(r));const n=await this._getFile(t),o=await n.executeQuery(a,s);let u=await o.next(s),l=0;const c=[];for(;null!=u;){const e=new J(this._metadata,this._indexMap,u,t),r=new V(e,null,l++,!1);c.push(r),u=await o.next(s)}return me(c,this._queryEngineParams).executeQueryForOpaqueFeatures(e,s)}async _getRequiredFields(e){const t=new Set;if(e.outStatistics)for(const r of e.outStatistics)null!=r.onStatisticField&&t.add(r.onStatisticField);else if(e.outFields)for(const r of e.outFields)t.add(r);return(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e])}_tryGetGeneralizedGeometryScale(e){if(!this._displayOptimization)return null;const t=e.outSR??this._queryEngineParams.spatialReference;if(!x(t)&&!F(t))return null;const r=e.quantizationParameters?.tolerance??e.maxAllowableOffset;return r?w(r,t):null}}function ne(e){for(const t in e){const r=t;switch(r){case"resultOffset":case"resultRecordCount":case"aggregateIds":case"distance":case"gdbVersion":case"geometry":case"having":case"timeExtent":case"objectIds":case"historicMoment":case"where":return null!=e[r]}}return!1}function oe(e,t){return!!e.outStatistics?.length&&!ne(e)&&!e.groupByFieldsForStatistics?.length&&!e.orderByFields?.length&&!e.returnDistinctValues&&!e.returnAggIds&&e.outStatistics.every(e=>ue(e,t))}function ue(e,t){switch(e.statisticType){case"count":return"1"===e.onStatisticField||null!=t.get(e.onStatisticField);case"min":case"max":{const r=t.get(e.onStatisticField);return null!=r&&A(r)}default:return!1}}function le(e,t){const r="exceedslimit"!==e.statisticType?t.get(e.onStatisticField):null,s="min"!==e.statisticType&&"max"!==e.statisticType||"esriFieldTypeDate"!==r?.type?"esriFieldTypeDouble":r.type;return{name:e.outStatisticFieldName,alias:e.outStatisticFieldName,type:s}}function ce(e,t){switch(e.statisticType){case"count":return pe(e,t);case"min":return de(e,t,Math.min);case"max":return de(e,t,Math.max);default:return{available:!1,value:null}}}function pe(e,t){if("count"!==e.statisticType)return{available:!1,value:null};if("1"===e.onStatisticField)return{available:!0,value:t.reduce((e,t)=>e+t.statistics.rowCount,0)};let r=0;for(const s of t){const t=s.statistics.statistics.get(e.onStatisticField);if(null==t||null==t.nullCount)return{available:!1,value:null};r+=s.statistics.rowCount-t.nullCount}return{available:!0,value:r}}function de(e,t,r){if("min"!==e.statisticType&&"max"!==e.statisticType)return{available:!1,value:null};let s=null;const i="min"===e.statisticType?"minValue":"maxValue";for(const a of t){const t=a.statistics.statistics.get(e.onStatisticField);if(null==t)return{available:!1,value:null};const n=fe(t[i]);null!=n&&(s=null==s?n:r(s,n))}return{available:!0,value:s}}function fe(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function me(e,t){const r=new U;for(const s of e)r.insert(s);return new q({...t,featureStore:r})}function ye(e,t){return e.statistics.statistics.get(t.fieldName)??null}function he(e,t){return e.slice().sort((e,r)=>{const s=ge(e,t),i=ge(r,t);return s===i?0:s<i?-1:1})}function ge(e,t){const r=ye(e,t);if(null==r)return Number.POSITIVE_INFINITY;const s=Fe(r.minValue),i=Fe(r.maxValue);return null==s||null==i||i<s?Number.POSITIVE_INFINITY:i-s}function _e(e,t){return{xStatistics:e.statistics.statistics.get(t.xFieldName)??null,yStatistics:e.statistics.statistics.get(t.yFieldName)??null}}function we(e,t){const r=Fe(e.minValue),s=Fe(e.maxValue);return null==r||null==s||t.intersects(r,s)}function xe(e,t,r){const s=Fe(e.minValue),i=Fe(e.maxValue),a=Fe(t.minValue),n=Fe(t.maxValue);return null==s||null==i||null==a||null==n||r.intersects(s,i,a,n)}function Fe(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function Se(e){const t=e?.featureCount;let r=!1;return null!=t&&t<has("parquetlayer-full-query-feature-count")&&(r=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{...R,maxRecordCount:X,supportsOrderBy:r,supportsDistinct:!0,supportsStatistics:!0,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1}},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function Ie(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{ae as default};
2
+ import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{toConst as r}from"../../../../core/compilerUtils.js";import s from"../../../../core/Error.js";import has from"../../../../core/has.js";import i from"../../../../core/Logger.js";import{onAbortOrThrow as n,throwIfAborted as a}from"../../../../core/promiseUtils.js";import{QueueProcessor as u}from"../../../../core/QueueProcessor.js";import{parseWhereClause as o}from"../../../../core/sql.js";import l from"../../../../geometry/SpatialReference.js";import{set as c,create as p,expandWithAABB as d,expandWithRect as f,negativeInfinity as m}from"../../../../geometry/support/aaBoundingBox.js";import{copy as y,negativeInfinity as h,create as g,expandWithRect as _}from"../../../../geometry/support/aaBoundingRect.js";import{getScaleForResolution as w}from"../../../../geometry/support/scaleUtils.js";import{isWebMercator as x,isWGS84 as F}from"../../../../geometry/support/spatialReferenceUtils.js";import{convertToGeometry as S}from"../../featureConversionUtils.js";import{getFieldNamesFromStatistics as I}from"../../data/attributeSupport.js";import{getQueryResultExtent as q,getQueryBoundingRects as v,QueryEngine as R}from"../../data/QueryEngine.js";import{queryCapabilities as b}from"../../data/QueryEngineCapabilities.js";import{QueryEngineResult as C}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as E}from"../../data/queryUtils.js";import{createFileProvider as O}from"../parquet/createFileProvider.js";import{createDrawingInfo as P}from"./clientSideDefaults.js";import{getParquetFileId as T,getParquetRowId as Q,getParquetObjectId as j}from"./parquetIdUtils.js";import N from"../../../support/Field.js";import M from"../../../support/FieldsIndex.js";import{isNumericField as A}from"../../../support/fieldUtils.js";import{fromParquetGeometryEncodingJSON as B}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as G,fromParquetJSONGeometryType as D,toParquetJSONGeometryType as z}from"../../../support/parquetUtils.js";import{loadParquetModule as V}from"../../../../libs/parquet/loadParquetModule.js";import{FeatureStoreQueryAdapter as W}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as U}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as k}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as J}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as Z}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const L=new W,H=4,Y="__OBJECTID",X=new TextDecoder,$=8e3,K=2e7,ee=8,te=2,re=20;class se{constructor(e,t){this._files=e,this._createFileStream=t,this._fileIndex=0,this._streamIndex=0,this._streams=[],this._pending=new Set,this._resolvedCount=0}async next(e){for(await this._fill(e);this._pending.size>0;){a(e),await this._fill(e);const t=await ie(this._pending);if(this._pending.delete(t.read),this._resolvedCount++,null!=t.chunk)return t.chunk}return null}async _fill(e){for(this._removeDone();this._pending.size<ee;){const t=this._getOrCreateNextStream(e);if(null==t)return;this._pending.add(t.read(e))}}_getOrCreateNextStream(e){const t=this._resolvedCount>=ee?ee:te;if(this._fileIndex<this._files.length&&this._streams.length<t){const t=this._files[this._fileIndex++],r=new ne(t.id,this._createFileStream(t,e));return this._streams.push(r),r}return this._getNextStream()}_getNextStream(){const e=this._streams.length;for(let t=0;t<e;t++){const r=(this._streamIndex+t)%e,s=this._streams[r];if(s.canRead)return this._streamIndex=(r+1)%e,s}return null}_removeDone(){let e=this._streamIndex;for(let t=this._streams.length-1;t>=0;t--)this._streams[t].done&&(this._streams.splice(t,1),t<e&&e--);this._streamIndex=this._streams.length>0?e%this._streams.length:0}}function ie(e){return Promise.race(Array.from(e,async e=>({read:e,chunk:await e})))}class ne{constructor(e,t){this._fileId=e,this._stream=t,this._readCount=0,this._reachedEnd=!1}get canRead(){return!this._reachedEnd}get done(){return this._reachedEnd&&0===this._readCount}async read(e){this._readCount++;try{const t=await this._stream,r=await t.next(e);return null==r?(this._reachedEnd=!0,null):{fileId:this._fileId,chunk:r}}finally{this._readCount--}}}class ae{constructor(){this._queue=new u({concurrency:H,process:(e,t)=>this._executeQuery(e,t)}),this._streams=new Map,this._streamIdCounter=0,this._indexMap={}}async load(e){const t=e.spatialReference?l.fromJSON(e.spatialReference):void 0;if(t&&!t.isWGS84&&!t.isWebMercator)throw new s("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");this._customParameters=e.customParameters,this._provider=O(e.provider,null,()=>this._customParameters);const r=await this._provider.getMetadata(),n=await G(r,{fields:e.fields?.map(e=>N.fromJSON(e)),geometryEncoding:e.geometryEncoding?B(e.geometryEncoding):null,geometryType:e.geometryType?D(e.geometryType):null,displayOptimization:e.displayOptimization,spatialReference:t});if(!n.fields)throw new s("parquet:unsupported","Fields must be defined");let a;if(n.spatialReference&&n.geometryType){if(!n.spatialReference)throw new s("parquet:unsupported","SpatialReference must be defined");if(!n.spatialReference.isGeographic&&!n.spatialReference.isWebMercator)throw new s("parquet:unsupported-projection","Only WGS84 and Web Mercator are supported");n.spatialReference.isGeographic&&!n.spatialReference.isWGS84&&(i.getLogger("parquet:unsupported-projection").warn("Found a geographic projection that is not WGS84. Handling as WGS84.",{spatialReference:n.spatialReference}),n.spatialReference=l.WGS84),a={geometry:n.geometryEncoding?{geometryType:z(n.geometryType),spatialReference:n.spatialReference.toJSON(),encoding:n.geometryEncoding.toJSON()}:null,displayOptimization:n.displayOptimization}}this.setCustomParameters(e.customParameters),this._displayOptimization=n.displayOptimization,await this._provider.updateGeometryInfo(a),this._capabilities=Ce(await this._getFileStatistics());const u=await this._provider.getFiles();if(!u.length)return{layerDefinition:{},capabilities:Ce(null)};const o=await u[0].file;n.file=o;const{fields:c}=n;if(null==c)throw new s("parquet-layer:missing-metadata","Unable to create parquet source: cannot infer fields",c);c.push(new N({name:Y,type:"oid",alias:Y}));for(const s of c){const e=o.getColumnId(s.name);null!=e&&(this._indexMap[s.name]=e)}const p=new M(c.map(e=>e.toJSON()));this._fieldsIndex=p;const d=z(n.geometryType??"point");return this._metadata=J.createFeature({fieldsIndex:p.toJSON(),geometryType:d,hasZ:!1,hasM:!1,featureIdInfo:{type:"object-id",fieldName:Y},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:n.spatialReference,outSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:null}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:d,featureIdInfo:{type:"object-id",fieldName:Y},hasM:!1,hasZ:!1,spatialReference:n.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},this._fullExtent=r?.extent?r.extent:await this._tryDeriveParquetFullExtent(n),{capabilities:this._capabilities,layerDefinition:{fields:n.fields?.map(e=>e.toJSON()),drawingInfo:P(d),extent:this._fullExtent??void 0,geometryType:d,geometryEncoding:n.geometryEncoding?.toJSON(),displayOptimization:n.displayOptimization}}}destroy(){this._provider.destroy(),this._queue.destroy();for(const{handle:e}of this._streams.values())e.remove();this._streams.clear()}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async updateFileProvider(e){this._provider=O(e,this._provider.getGeometryInfo(),()=>this._customParameters)}async queryFeatures(e,t){const r=await E(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),Ee(r)||(r.resultRecordCount=r.resultRecordCount?Math.min(r.resultRecordCount,$):$,r.resultOffset=r.resultOffset??0),r.outStatistics)return this._queryStatistics(r,t);r.returnDistinctValues&&(r.returnGeometry=void 0);return(await this._enqueueQuery(r,t)).createQueryResponse()}async queryFeatureCount(e,t){const r=await E(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!ce(r))return this._getFeatureCount();r.outFields=void 0,r.returnGeometry=void 0;return(await this._enqueueQuery(r,t)).createQueryResponseForCount()}async queryObjectIds(e,t){const r=await E(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),!ce(r))return Array.from({length:await this._getFeatureCount()},(e,t)=>t);r.resultRecordCount=r.resultRecordCount?Math.min(r.resultRecordCount,8e3):8e3,r.resultOffset=r.resultOffset??0,r.returnGeometry=void 0,r.outFields=void 0;return(await this._enqueueQuery(r,t)).items.map(e=>e.getObjectId())}async queryAttributeBins(e,t={}){throw new s("parquet:unsupported","queryAttributeBins not supported.")}async queryExtent(e,t){const s=await E(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(s),this._fullExtent&&!ce(s))return{count:await this._getFeatureCount(),extent:this._fullExtent};const i=r(this._metadata.spatialReference);s.returnGeometry=!0,s.outFields=void 0;const n=c(p(),m),a=p(),u=await this._enqueueQuery(s,t);let o=0;for(const r of u.items)r.getBounds(a)&&(d(n,a),o+=1);return{count:o,extent:q(n,i,s.outSR?r(s.outSR):i.toJSON(),i,!1)}}async queryStream(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const r=await this._getCandidateFiles(e),s=new se(r,async(t,r)=>{const s=await t.file,i=await this._createParquetDisplayQuery(s,t.id,e);return s.executeQuery(i,$,r)}),i=this._streamIdCounter++,a=n(t.signal,e=>{const t=this._streams.get(i);null!=t&&(t.handle.remove(),this._streams.delete(i))});return this._streams.set(i,{stream:s,handle:a}),i}async getStreamNext(e,t){if(!t.signal)throw new Error("InternalError: AbortSignal must be passed");const r=this._streams.get(e);if(!r)return{result:null};const s=await r.stream.next(t.signal);if(null==s)return r.handle.remove(),this._streams.delete(e),{result:null};const i=s.chunk.serialize().buffer,n={fileId:s.fileId,buffer:i};return i instanceof ArrayBuffer?{result:n,transferList:[i]}:{result:n}}async getStreamNextFeatures(e,t){const{result:r}=await this.getStreamNext(e,t);if(null==r)return null;const s=(await V()).ParquetChunk.deserialize(new Uint8Array(r.buffer)),i=new Z(this._metadata,this._indexMap,s,r.fileId),n=[];for(;i.next();){const e=S(i.readGeometryWorldSpace(),i.geometryType,i.hasZ,i.hasM),t=i.readAttributes();n.push({attributes:t,geometry:e})}return{features:n}}async createPatch(e,t,r,s,i){if(!i.signal)throw new Error("InternalError: AbortSignal must be passed");const n=await this._getFileInfoById(e),a=await n.file;return(await a.createChunkPatch(t,r,s,i.signal)).serialize().buffer}async _getCandidateFiles(e){const t=await this._provider.getFiles(),r=await this._getSpatialFilePruning(e);if(null==r)return t;const s=t.filter(e=>this._mayIncludeFileForSpatialPruning(e,r));return"xz"===r.type?Se(s,r):s}async _queryStatistics(e,t){const r=await E({...e},null,this._queryEngineParams.spatialReference);if(r.returnGeometry=void 0,fe(r,this._fieldsIndex)){const e=await this._getStatisticsFromFiles(r);if(e)return e}return(await this._enqueueQuery(r,t)).createQueryResponse()}async _getStatisticsFromFiles(e){const t=await this._provider.getFiles(),r={},s=[];for(const i of e.outStatistics??[]){const e=he(i,t);if(!e.available)return null;r[i.outStatisticFieldName]=e.value,s.push(ye(i,this._fieldsIndex))}return{fields:s,features:[{attributes:r}]}}async _getSpatialFilePruning(e){if("tile"!==e.type&&("arcade"!==e.type||null==e.extent))return null;const t=this._displayOptimization,r=t?.index;if(null==r)return null;const s=e.outSpatialReference.wkid;if(null==r.wkid||null==s)return null;const i=r.wkid,n=await V();switch(r.type){case"xz":return{type:"xz",fieldName:r.code,intersects:(t,a)=>n.queryIntersectsXZStatistics(r.fullExtent,e.extent,s,i,re,t,a)};case"z":return{type:"xy",xFieldName:r.xColumn,yFieldName:r.yColumn,intersects:(t,r,a,u)=>n.queryIntersectsXYStatistics(e.extent,s,i,t,r,a,u)}}}_mayIncludeFileForSpatialPruning(e,t){switch(t.type){case"xz":{const r=Fe(e,t);return null==r||ve(r,t)}case"xy":{const{xStatistics:r,yStatistics:s}=qe(e,t);return null==r||null==s||Re(r,s,t)}}}async _tryDeriveParquetFullExtent(r){if(!r.spatialReference)return null;if(null==this._fullExtent&&"location"===r.geometryEncoding?.type){const i=await this._provider.getFiles(),{xField:n,yField:a}=r.geometryEncoding,u=c(p(),m);for(const r of i){const i=await r.file;for(const r of i.rowGroups()){const i={stack:[],error:void 0,hasError:!1};try{const t=e(i,r.columnDescriptorForAttribute(n),!1),s=e(i,r.columnDescriptorForAttribute(a),!1),o=[t.minValue(),s.minValue(),t.maxValue(),s.maxValue()];f(u,o),r.free()}catch(s){i.error=s,i.hasError=!0}finally{t(i)}}}return{xmin:u[0],ymin:u[1],xmax:u[3],ymax:u[4],spatialReference:r.spatialReference?.toJSON()}}return null}async _getFileInfoById(e){const t=await this._provider.getFiles();for(const r of t)if(r.id===e)return r;throw new Error(`InternalError: File ${e} does not exist`)}async _getFileStatistics(){return{featureCount:await this._getFeatureCount(),byteLength:await this._getByteLength()}}async _getFile(e){return(await this._getFileInfoById(e)).file}async _createParquetQuery(e,t,r,s,i){const n=(await V()).Query.new();null!=r&&n.setPreFilterStart(r),null!=s&&n.setPreFilterCount(s),null!=i&&n.setPostFilterCount(i);const a=await this._getRequiredFields(e);n.setOutFields(a),(e.geometry||e.returnGeometry)&&n.setReturnGeometry(!0);const u=this._tryGetGeneralizedGeometryScale(e);null!=u&&n.setScale(u);const o=e.geometry?.spatialReference??this._queryEngineParams.spatialReference,l=o.wkid;if(e.geometry&&(x(o)||F(o))){const t=y(g(),h);for(const r of v(e.geometry))_(t,r);n.setOutSpatialReference(l),n.setExtent({xmin:t[0],ymin:t[1],xmax:t[2],ymax:t[3]})}if(e.where){const{id:r,file:s}=t;await this._setWhereClause(n,await s,r,e.where)}return n}async _createParquetDisplayQuery(e,t,r){const s=(await V()).Query.new();return"tile"===r.type?(s.setExtent(r.extent),s.setQuantizationTransform(r.transform),s.setScale(r.scale)):"arcade"===r.type&&null!=r.extent&&s.setExtent(r.extent),s.setOutFields(r.outFields.filter(e=>null!=this._indexMap[e])),s.setOutSpatialReference(r.outSpatialReference.wkid),s.setReturnGeometry(r.returnGeometry),r.where&&await this._setWhereClause(s,e,t,r.where),s}async _getFeatureCount(){return(await this._provider.getFiles()).map(e=>e.statistics.rowCount).reduce((e,t)=>e+t,0)}async _getByteLength(){return(await this._provider.getFiles()).map(e=>e.statistics.byteSize).reduce((e,t)=>e+t,0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new s("parquet:unsupported","Statistics queries are not supported",{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new s("parquet:unsupported","Queries using orderBy are not supported",{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new s("parquet:unsupported","Queries using returnDistinctValues are not supported",{query:e})}async _setWhereClause(e,t,r,i){const n=this._indexMap,a=this._fieldsIndex,u={getAttribute(e,s){const i=n[s];if(null==i){const t=a.get(s);if("__OBJECTID"===t?.name){const t=e.row+e.rowGroupStart;return j(r,t)}return null}const u=t.readAttribute(e.rowGroup,e.row,i);if(null==u)return null;const o=a.get(s);return"esriFieldTypeString"===o.type||"esriFieldTypeDateOnly"===o.type||"esriFieldTypeTimeOnly"===o.type||"esriFieldTypeTimestampOffset"===o.type?X.decode(u):u}},l=await o(i,this._fieldsIndex);if(!l.isStandardized)throw new s("sql-parse-error","expression is not standardized");const c=(e,t,r)=>l.testFeatureCompiled({rowGroup:e,row:t,rowGroupStart:r},u,null),p=l.fieldNames.map(e=>a.get(e)).filter(e=>e&&null!=this._indexMap[e?.name]);e.setWhere(i),e.setWhereEvaluator(c),e.setWhereFields(p.map(e=>e.name))}async*_streamFeatures(e,t,r,s,i){const n=await this._provider.getFiles();let a=0;for(const u of n){const n=a,o=a+u.statistics.rowCount;if(a+=u.statistics.rowCount,null!=t&&t>=o)continue;const l=null!=t?Math.max(t-n,0):null;let c=r;if(null!=r){const e=t??0,s=e+r,i=Math.max(e,n),a=Math.min(s,o);c=Math.max(a-i,0)}if(0===c)continue;const p=await this._createParquetQuery(e,u,l,c,s),d=await u.file,f=await d.executeQuery(p,$),m=async()=>{const e=await f.next(i);if(!e)return null;const t=new Z(this._metadata,this._indexMap,e,u.id);return xe([new U(t,null,0,!1)],this._queryEngineParams)};let y=await m();for(;null!=y;)yield y,y=await m()}}async _queryFeaturesWithQueryEnginePagination(e,t){const r=[],s=this._streamFeatures(e,null,null,null,t);let i=await s.next();for(;!i.done;){const n=await i.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of n)r.push(e);i=await s.next()}return r}async _queryFeaturesWithUpfrontPagination(e,t){let r,s,i,n=e.resultOffset??0,a=e.resultRecordCount??$;pe(e)?de(e)||(i=n+a):(n&&(r=n,n=0),s=e.resultRecordCount);const u=[],o=this._streamFeatures(e,r,s,i,t);let l=await o.next();for(;!l.done&&a>0;){const r=await l.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(const e of r)if(n>0)n--;else if(u.push(e),--a<=0)return u;l=await o.next()}return u}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){if(e.objectIds?.length){const r=new Map;for(const t of e.objectIds){const e=T(t),s=Q(t);let i=r.get(e);i||(i=[],r.set(e,i)),i.push(s)}const s=[];for(const[i,n]of r.entries()){const r=await this._executeFileIdQuery(e,i,n,t);for(const e of r)s.push(e)}return new C(s,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:!1,hasZ:!1,featureAdapter:L,featureIdInfo:this._queryEngineParams.featureIdInfo})}if("1=1"===e.where&&(e.where=null),e.resultOffset??=0,e.resultRecordCount??=await this._getFeatureCount(),e.resultRecordCount>K){if(!(this._displayOptimization&&e.geometry))throw new s("parquet:cannot-execute-query","Unable to execute query, dataset is too large.")}const r=!!e.orderByFields?.length||!!e.outStatistics?.length||!!e.returnDistinctValues,i=r?await this._queryFeaturesWithQueryEnginePagination(e,t):await this._queryFeaturesWithUpfrontPagination(e,t);return r||(e.resultOffset=0),new C(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:!1,hasZ:!1,featureAdapter:L,featureIdInfo:this._queryEngineParams.featureIdInfo})}async _executeFileIdQuery(e,t,r,s){const i=await this._getRequiredFields(e),n=(await V()).Query.new();n.setOutFields(i),n.setReturnGeometry(!!e.returnGeometry),n.setIds(new Uint32Array(r));const a=await this._getFile(t),u=await a.executeQuery(n,$,s);let o=await u.next(s),l=0;const c=[];for(;null!=o;){const e=new Z(this._metadata,this._indexMap,o,t),r=new U(e,null,l++,!1);c.push(r),o=await u.next(s)}return xe(c,this._queryEngineParams).executeQueryForOpaqueFeatures(e,s)}async _getRequiredFields(e){const t=new Set;if(e.outStatistics)for(const r of I(this._fieldsIndex,e.outStatistics,e.groupByFieldsForStatistics))t.add(r);else if(e.outFields)for(const r of e.outFields)t.add(r);return(t.has("*")?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>null!=this._indexMap[e])}_tryGetGeneralizedGeometryScale(e){if(!this._displayOptimization)return null;const t=e.outSR??this._queryEngineParams.spatialReference;if(!x(t)&&!F(t))return null;const r=e.quantizationParameters?.tolerance??e.maxAllowableOffset;return r?w(r,t):null}}function ue(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":case"resultOffset":case"resultRecordCount":return!0;default:return!1}}function oe(e){switch(e){case"fullText":case"having":case"timeExtent":case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"geometry":return!0;default:return!1}}function le(e){switch(e){case"fullText":case"having":case"timeExtent":return!0;case"historicMoment":case"aggregateIds":case"uniqueIds":case"gdbVersion":case"objectIds":case"where":case"resultOffset":case"geometry":case"resultRecordCount":return!1}return!1}function ce(e){for(const t in e){const r=t;if(ue(r)&&null!==e[r])return!0}return!1}function pe(e){for(const t in e){const r=t;if(oe(r)&&null!==e[r])return!0}return!1}function de(e){for(const t in e){const r=t;if(le(r)&&null!==e[r])return!0}return!1}function fe(e,t){return!!e.outStatistics?.length&&!ce(e)&&!e.groupByFieldsForStatistics?.length&&!e.orderByFields?.length&&!e.returnDistinctValues&&!e.returnAggIds&&e.outStatistics.every(e=>me(e,t))}function me(e,t){switch(e.statisticType){case"count":return"1"===e.onStatisticField||null!=t.get(e.onStatisticField);case"min":case"max":{const r=t.get(e.onStatisticField);return null!=r&&A(r)}default:return!1}}function ye(e,t){const r="exceedslimit"!==e.statisticType?t.get(e.onStatisticField):null,s="min"!==e.statisticType&&"max"!==e.statisticType||"esriFieldTypeDate"!==r?.type?"esriFieldTypeDouble":r.type;return{name:e.outStatisticFieldName,alias:e.outStatisticFieldName,type:s}}function he(e,t){switch(e.statisticType){case"count":return ge(e,t);case"min":return _e(e,t,Math.min);case"max":return _e(e,t,Math.max);default:return{available:!1,value:null}}}function ge(e,t){if("count"!==e.statisticType)return{available:!1,value:null};if("1"===e.onStatisticField)return{available:!0,value:t.reduce((e,t)=>e+t.statistics.rowCount,0)};let r=0;for(const s of t){const t=s.statistics.statistics.get(e.onStatisticField);if(null==t||null==t.nullCount)return{available:!1,value:null};r+=s.statistics.rowCount-t.nullCount}return{available:!0,value:r}}function _e(e,t,r){if("min"!==e.statisticType&&"max"!==e.statisticType)return{available:!1,value:null};let s=null;const i="min"===e.statisticType?"minValue":"maxValue";for(const n of t){const t=n.statistics.statistics.get(e.onStatisticField);if(null==t)return{available:!1,value:null};const a=we(t[i]);null!=a&&(s=null==s?a:r(s,a))}return{available:!0,value:s}}function we(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function xe(e,t){const r=new k;for(const s of e)r.insert(s);return new R({...t,featureStore:r})}function Fe(e,t){return e.statistics.statistics.get(t.fieldName)??null}function Se(e,t){return e.slice().sort((e,r)=>{const s=Ie(e,t),i=Ie(r,t);return s===i?0:s<i?-1:1})}function Ie(e,t){const r=Fe(e,t);if(null==r)return Number.POSITIVE_INFINITY;const s=be(r.minValue),i=be(r.maxValue);return null==s||null==i||i<s?Number.POSITIVE_INFINITY:i-s}function qe(e,t){return{xStatistics:e.statistics.statistics.get(t.xFieldName)??null,yStatistics:e.statistics.statistics.get(t.yFieldName)??null}}function ve(e,t){const r=be(e.minValue),s=be(e.maxValue);return null==r||null==s||t.intersects(r,s)}function Re(e,t,r){const s=be(e.minValue),i=be(e.maxValue),n=be(t.minValue),a=be(t.maxValue);return null==s||null==i||null==n||null==a||r.intersects(s,i,n,a)}function be(e){return"number"==typeof e&&Number.isFinite(e)?e:null}function Ce(e){const t=e?.featureCount;let r=!1;return null!=t&&t<has("parquetlayer-full-query-feature-count")&&(r=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:!1,supportsTrueCurve:!1,supportsZ:!1},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{...b,maxRecordCount:$,supportsOrderBy:r,supportsDistinct:!0,supportsStatistics:!0,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1}},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function Ee(e){return!!(e.objectIds?.length||e.outStatistics||e.orderByFields?.length||e.returnDistinctValues)}export{ae as default};
@@ -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 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 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 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 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":{'),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),q(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(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(),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;return t.renderingRule||i?.length&&"None"!==i[0].name?this._isRFTJson(t.renderingRule)?K.fromJSON({rasterFunctionDefinition:t.renderingRule}):K.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):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;r.requestRawData&&(await this._initJobHandler(),s.requestRawData||"lerc"===this.format||(n=!0,s.requestRawData=!0));const a=this.getExportImageServiceParameters(e,t,i,r.timeExtent);if(n&&(s.requestRawData=!1,a&&!this.bandIds?.length&&(null==a.bandIds||""===a.bandIds))){const e=ee(this.rasterInfo);a.bandIds=e?.join(",")}if(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 N(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<Be||a<Be)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/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 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:Be,height:Be,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 Ne($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,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: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 qe(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)),qe(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 N(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([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 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};
@@ -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"../../../core/Error.js";import i from"../../../core/Logger.js";import{property as n,subclass as s}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as r}from"../../ogc/crsUtils.js";import{getCapabilities as a,describeCoverage as l}from"../../ogc/wcsUtils.js";import c from"./BaseRaster.js";import{convertOleDateTimeToEpoch as d}from"./multidimensionalUtils.js";import{parse as f}from"./multipartParser.js";import{standardizeInterpolations as u}from"./wcsCoverageParser.js";import{getFormat as h}from"../formats/RasterCodec.js";import{clip as p}from"../functions/pixelUtils.js";import m from"../../support/DimensionalDefinition.js";const g=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",I="server returns an exception",C=new Set(["1.0.0","1.1.0","1.1.1","1.1.2","2.0.1"]);let b=class extends c{constructor(){super(...arguments),this.datasetFormat="WCSServer",this.tileType="Raster"}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:o,spatialReference:r}=this.rasterInfo,a=2**e,l=o.x*a,c=o.y*a,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:c},i,n,u,r,[d,f]),m=this.rasterInfo.extent,g=h.xmax>m.xmax,w=h.ymin<m.ymin,v=g||w;let y=h,x=d,I=f;if(v&&(y=h.clone().intersection(m),null!=y&&(g&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(I=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*I))),null==y||x<=1||I<=1)return null;const C=await this._getCoverage(y,x,I,a,s);if(!C)return null;const{coverageDescription:b}=this.coverageInfo,{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo,{multidimensionalDefinition:j}=s;let T;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===b.version){const t=b.rangeType[0].find(t=>t.name===e);T=t?.nilValue}else if("1.1"===b.version){const t=b.range.find(t=>t.identifier===e);T=t?.nullValues}}const L=T??$,P=await this.decodePixelBlock(C,{width:x,height:I,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(L)?L[0]:L,matchAllNoData:!0});if(null==P)return null;if(P&&(P.width!==x||P.height!==I))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${P.width}, height: {pixelBlock.height}`);return v?p(P,{x:0,y:0},{width:f,height:f}):P}async _open(e){const{customFetchParameters:i}=this.ioConfig,n=e?.signal,s=await a(this.url,{version:i?.version??this.version,customParameters:i,signal:n});if(this.capabilities=s,!this.version){let e=s.version.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.version:(e=s.supportedVersions.find(e=>"2.0.1"===e)||s.supportedVersions.find(e=>e.startsWith("2.0"))||s.supportedVersions.find(e=>e.startsWith("1.1"))||s.supportedVersions.find(e=>e.startsWith("1.0"))||"1.0.0",this.version=e)}const{version:o}=this;if(!C.has(o))throw new t("wcsraster-open",`unsupported WCS version ${o}`);const{gridCoverages:r}=s;if(!r.length)throw new t("wcsraster-open","cannot find rectified grid coverages");this.coverageId??=r[0].id;const{coverageId:c}=this,d=r.find(e=>e.id===c);if(null==d)throw new t("wcsraster-open",`the coverageId ${c} does not exist in capabilities`);const f=await l(this.url,{coverageIds:[c],version:o,customParameters:i,signal:n});if(this.coverageInfo=f[0],o.startsWith("2.0")){const{coverageInfo:e}=this;e.lonLatEnvelope=d.lonLatEnvelope,e.supportedInterpolations=u(s.supportedInterpolations),this._patchDimensionValues201(c,n)}this.datasetName=this.coverageInfo.title;const{rasterInfo:h}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(h,512,512),this._set("rasterInfo",h),null==h.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${c}`);const{pixelType:p,bandCount:m}=await this._getPixelTypeAndBandCount(n);h.pixelType=p,1===h.bandCount&&m>1&&(h.bandCount=m),this.updateTileInfo()}async _patchDimensionValues201(e,t){const{coverageInfo:i}=this,n=i.rasterInfo.multidimensionalInfo?.variables,s=C.has("1.1.2")?"1.1.2":C.has("1.1.1")?"1.1.1":C.has("1.1.0")?"1.1.0":null,{customFetchParameters:o}=this.ioConfig;if(n&&s)try{const i=this.url.includes("/ImageServer/"),r=e.length>8&&e.startsWith("Coverage")&&i?e.slice(8):e,a=await l(this.url,{coverageIds:[r??e],version:s,customParameters:o,signal:t}).catch(()=>{if(r)return l(this.url,{coverageIds:[e],version:s,customParameters:o,signal:t})}),c=a?.[0].rasterInfo.multidimensionalInfo?.variables;if(c)for(const e of n){const t=c.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let n=e.dimensions.length-1;n>=0;n--){const s=e.dimensions[n],o=t.dimensions.find(({name:e})=>e===s.name);o?o.values&&o.extent?.join(",")===s.extent?.join(",")&&(e.dimensions[n]={...s,values:o.values}):i&&e.dimensions.splice(n,1)}}}catch{}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:r}=this.rasterInfo,a=s.center,l=new o({xmin:a.x-n.x,xmax:a.x+n.x,ymin:a.y-n.y,ymax:a.y+n.y,spatialReference:s.spatialReference});let c=[];if(null!=r){const e=r.variables[0];c=[],e.dimensions.forEach(t=>{c.push(new m({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}const{coverageDescription:d}=this.coverageInfo,f={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:u}=d,{ioConfig:h}=this,p="2.0"===u&&null==h.allowAnyMediaType||"1.1"===u&&null==h.use2GridOffsets;let g;try{g=await this._getCoverage(l,2,2,1,f,!0)}catch(y){if(!p)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;h.use2GridOffsets=!0}}if(!g&&p&&("2.0"===u&&(h.allowAnyMediaType=!0),g=await this._getCoverage(l,2,2,1,f),g&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!g)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,o,r,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:c}=l,d="2.0"===c?this._getCoverage201Parameters(e,n,s,o,r,l):"1.1"===c?this._getCoverage110Parameters(e,n,s,r,l):this._getCoverage100Parameters(e,n,s,r),u="2.0"===c?await this.request(this._constructWCS201Url(d),{signal:r.signal,responseType:"array-buffer"}):await this.request(this.url,{query:d,signal:r.signal,responseType:"array-buffer"});if("1.0"===c)return u.data;if("2.0"===c&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===h(u.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),u.data}const p=f(u);if(p.isMultipart&&p.data){const e=p.data.find(e=>e.isValidImage);return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const m=new Uint8Array(u.data,0,Math.min(u.data.byteLength,2e3)),g=String.fromCharCode.apply(null,m).toLowerCase().includes("exception"),w=g&&String.fromCharCode.apply(null,m).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(g)throw new t("wcsraster:getcoverage",I,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map(e=>this.coverageInfo.bandNames[e]):null,f=g[c],{multidimensionalDefinition:u}=n;let h;if(null!=u&&null!=this.rasterInfo.multidimensionalInfo){const e=u.find(e=>"StdTime"===e.dimensionName);let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),h=t.map(e=>$(e)).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:s,width:t,height:i,time:h,interpolation:f,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:o,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",u=this._getInterpolationIndex(l),h=w[u],p=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),m=s.domain.spatialDomain,g=m.origin.x<=m.envelope.xmin&&m.origin.y<=m.envelope.ymin,v=e.width/t,y=e.height/i*(g?1:-1),x=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],I=m.useEPSGAxis&&r(c),C=I?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,b=this.ioConfig.use2GridOffsets,S=I?b?`${y},${v}`:`${y},0,0,${v}`:b?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,P=Math.abs(y)/2,R=e.ymin+P,_=e.ymax-P,A=I?`${R},${T},${_},${L},${d}`:`${T},${R},${L},${_},${d}`,D=s.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes("band")));let E,W=D&&h&&a?p?`${D.identifier}[${D.axis[0].identifier}[${a.join(",")}]]`:`${D.identifier}:${h}[${D.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=o&&o.length)for(let r=0;r<o.length;r++){let e=o[r].values;const t=o[r].dimensionName?.toLowerCase(),i=o[r].variableName?.toLowerCase(),n=s.range.find(e=>e.identifier.toLowerCase()===i);if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)E=e.map(e=>$(e)).join(",");else if(n){const i=n.axis.find(e=>e.identifier.toLowerCase()===t);i&&(W=p?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+h+"["+i.identifier+"["+e.join(",")+"]]")}r===o.length-1&&n&&!W&&(W=p?n.identifier:n.identifier+":"+h)}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:f,crs:`EPSG:${c}`,boundingbox:A,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:C,gridOffsets:S,gridBaseCRS:d,timeSequence:E,rangeSubset:W}}_getCoverage201Parameters(e,t,i,n,s,o){const{multidimensionalDefinition:r,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find(e=>e.toLowerCase().includes("nearest"));break;case 1:c=d.find(e=>e.toLowerCase().includes("linear"));break;case 2:c=d.find(e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic"))}const f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:h,domainSet:p,rangeType:m}=o,g=h.isEastFirst?0:1,w=1-g,{axisLabels:v}=h,y=v[g],x=v[w],I=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=I,b=[];b.push(`${y}(${e.xmin},${e.xmax})`),b.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let _=2;_<v.length;_++){const e=p.origin[_];if(v[_].toLowerCase().includes("time")){let t=e.toString();h.uomLabels?.[_].toLowerCase().includes("ole")&&(S.push(v[_]),t=$(e,!0)),b.push(v[_]+",http://www.opengis.net("+t+")")}else b.push(v[_]+",http://www.opengis.net("+e+")")}let j=null;if(null!=r&&r.length){const e=[];m.forEach(t=>t.forEach(t=>e.push(t.name)));const t=[];for(let i=0;i<r.length;i++){const n=v.find(e=>e===r[i].dimensionName),s=e.find(e=>e===r[i].variableName);if(t.includes(s)||t.push(s),n){let e=r[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map(e=>$(e)).join(","):e.join(",");const i=b.findIndex(e=>e.startsWith(n+",http://www.opengis.net"));-1===i&&b.push(n+",http://www.opengis.net("+t+")"),-1===i||b[i].includes("("+t+")")||b.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length>=2){j=(s.bandIds?s.bandIds.map(e=>u[e]):u).join(",")}const T=b.join("&subset="),L=!o.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,P=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:P,scaleFactor:R,subset:T,format:f,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:I,subsettingcrs:C}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach(e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach(e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)}):i.push(`${e}=${encodeURIComponent(n)}`))});return`${encodeURI(this.url)}?${i.join("&")}`}};function $(e,t=!1){return(t?new Date(d(e)):new Date(e)).toISOString()}e([n({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([n({readOnly:!0})],b.prototype,"tileType",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),e([n({readOnly:!0})],b.prototype,"rasterId",null),b=e([s("esri.layers.raster.datasets.WCSRaster")],b);export{b as default};
2
+ import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{property as n,subclass as s}from"../../../core/accessorSupport/decorators.js";import r from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import{getCapabilities as a,describeCoverage as l}from"../../ogc/wcsUtils.js";import c from"./BaseRaster.js";import{convertOleDateTimeToEpoch as d}from"./multidimensionalUtils.js";import{parse as f}from"./multipartParser.js";import{standardizeInterpolations as h}from"./wcsCoverageParser.js";import{getFormat as u}from"../formats/RasterCodec.js";import{clip as p}from"../functions/pixelUtils.js";import g from"../../support/DimensionalDefinition.js";const m=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",I="server returns an exception",C=new Set(["1.0.0","1.1.0","1.1.1","1.1.2","2.0.1"]);let b=class extends c{constructor(){super(...arguments),this.datasetFormat="WCSServer",this.tileType="Raster"}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,n,s,r={}){if(this.isBlockOutside(e,n,s))return null;const{nativePixelSize:o,spatialReference:a}=this.rasterInfo,l=2**e,c=o.x*l,d=o.y*l,{blockWidth:f,blockHeight:h}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,g=this.getTileExtent({x:c,y:d},n,s,u,a,[f,h]),m=this.rasterInfo.extent,w=g.xmax>m.xmax,v=g.ymin<m.ymin,y=w||v;let x=g,I=f,C=h;if(y&&(x=g.clone().intersection(m),null!=x&&(w&&(I=Math.floor((x.xmax-x.xmin)/c),x.xmax=x.xmin+c*I),v&&(C=Math.floor((x.ymax-x.ymin)/d),x.ymin=x.ymax-d*C))),null==x||I<=1||C<=1)return null;const b=await this._getCoverage(x,I,C,l,r);if(!b)return null;const{coverageDescription:$}=this.coverageInfo,{noDataValue:S,multidimensionalInfo:j}=this.rasterInfo,{multidimensionalDefinition:T}=r;let L;if(null!=j&&null!=T&&T.length){const e=T[0].variableName;if("2.0"===$.version){const t=$.rangeType[0].find(t=>t.name===e);L=t?.nilValue}else if("1.1"===$.version){const t=$.range.find(t=>t.identifier===e);L=t?.nullValues}}const P=L??S,R=await this.decodePixelBlock(b,{width:I,height:C,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(P)?P[0]:P,matchAllNoData:!0});if(null==R)return null;if(R&&(R.width!==I||R.height!==C)){const e=`The tiff coverage response has unexpected width: ${R.width}, height: ${R.height}, expecting width: ${I}, height: ${C}`;throw i.getLogger(this).error("wcsraster-fetch",e),new t("wcsraster-fetch",e)}return y?p(R,{x:0,y:0},{width:h,height:h}):R}async _open(e){const{customFetchParameters:i}=this.ioConfig,n=e?.signal,s=await a(this.url,{version:i?.version??this.version,customParameters:i,signal:n});if(this.capabilities=s,!this.version){let e=s.version.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.version:(e=s.supportedVersions.find(e=>"2.0.1"===e)||s.supportedVersions.find(e=>e.startsWith("2.0"))||s.supportedVersions.find(e=>e.startsWith("1.1"))||s.supportedVersions.find(e=>e.startsWith("1.0"))||"1.0.0",this.version=e)}const{version:r}=this;if(!C.has(r))throw new t("wcsraster-open",`unsupported WCS version ${r}`);const{gridCoverages:o}=s;if(!o.length)throw new t("wcsraster-open","cannot find rectified grid coverages");this.coverageId??=o[0].id;const{coverageId:c}=this,d=o.find(e=>e.id===c);if(null==d)throw new t("wcsraster-open",`the coverageId ${c} does not exist in capabilities`);const f=await l(this.url,{coverageIds:[c],version:r,customParameters:i,signal:n});if(this.coverageInfo=f[0],r.startsWith("2.0")){const{coverageInfo:e}=this;e.lonLatEnvelope=d.lonLatEnvelope,e.supportedInterpolations=h(s.supportedInterpolations),this._patchDimensionValues201(c,n)}this.datasetName=this.coverageInfo.title;const{rasterInfo:u}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(u,512,512),this._set("rasterInfo",u),null==u.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${c}`);const{pixelType:p,bandCount:g}=await this._getPixelTypeAndBandCount(n);u.pixelType=p,1===u.bandCount&&g>1&&(u.bandCount=g),this.updateTileInfo()}async _patchDimensionValues201(e,t){const{coverageInfo:i}=this,n=i.rasterInfo.multidimensionalInfo?.variables,s=C.has("1.1.2")?"1.1.2":C.has("1.1.1")?"1.1.1":C.has("1.1.0")?"1.1.0":null,{customFetchParameters:r}=this.ioConfig;if(n&&s)try{const i=this.url.includes("/ImageServer/"),o=e.length>8&&e.startsWith("Coverage")&&i?e.slice(8):e,a=await l(this.url,{coverageIds:[o??e],version:s,customParameters:r,signal:t}).catch(()=>{if(o)return l(this.url,{coverageIds:[e],version:s,customParameters:r,signal:t})}),c=a?.[0].rasterInfo.multidimensionalInfo?.variables;if(c)for(const e of n){const t=c.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let n=e.dimensions.length-1;n>=0;n--){const s=e.dimensions[n],r=t.dimensions.find(({name:e})=>e===s.name);r?r.values&&r.extent?.join(",")===s.extent?.join(",")&&(e.dimensions[n]={...s,values:r.values}):i&&e.dimensions.splice(n,1)}}}catch{}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:o}=this.rasterInfo,a=s.center,l=new r({xmin:a.x-n.x,xmax:a.x+n.x,ymin:a.y-n.y,ymax:a.y+n.y,spatialReference:s.spatialReference});let c=[];if(null!=o){const e=o.variables[0];c=[],e.dimensions.forEach(t=>{c.push(new g({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}const{coverageDescription:d}=this.coverageInfo,f={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:h}=d,{ioConfig:u}=this,p="2.0"===h&&null==u.allowAnyMediaType||"1.1"===h&&null==u.use2GridOffsets;let m;try{m=await this._getCoverage(l,2,2,1,f,!0)}catch(y){if(!p)throw y;if("1.1"===h){if(!y.details?.isResolutionMismatch)throw y;u.use2GridOffsets=!0}}if(!m&&p&&("2.0"===h&&(u.allowAnyMediaType=!0),m=await this._getCoverage(l,2,2,1,f),m&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!m)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(m,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,r,o,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:c}=l,d="2.0"===c?this._getCoverage201Parameters(e,n,s,r,o,l):"1.1"===c?this._getCoverage110Parameters(e,n,s,o,l):this._getCoverage100Parameters(e,n,s,o),h="2.0"===c?await this.request(this._constructWCS201Url(d),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:d,signal:o.signal,responseType:"array-buffer"});if("1.0"===c)return h.data;if("2.0"===c&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===u(h.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),h.data}const p=f(h);if(p.isMultipart&&p.data){const e=p.data.find(e=>e.isValidImage);return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const g=new Uint8Array(h.data,0,Math.min(h.data.byteLength,2e3)),m=String.fromCharCode.apply(null,g).toLowerCase().includes("exception"),w=m&&String.fromCharCode.apply(null,g).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(m)throw new t("wcsraster:getcoverage",I,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,r=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map(e=>this.coverageInfo.bandNames[e]):null,f=m[c],{multidimensionalDefinition:h}=n;let u;if(null!=h&&null!=this.rasterInfo.multidimensionalInfo){const e=h.find(e=>"StdTime"===e.dimensionName);let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),u=t.map(e=>$(e)).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${r}`,bbox:s,width:t,height:i,time:u,interpolation:f,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:r,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",h=this._getInterpolationIndex(l),u=w[h],p=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),g=s.domain.spatialDomain,m=g.origin.x<=g.envelope.xmin&&g.origin.y<=g.envelope.ymin,v=e.width/t,y=e.height/i*(m?1:-1),x=m?[e.xmin,e.ymin]:[e.xmin,e.ymax],I=g.useEPSGAxis&&o(c),C=I?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,b=this.ioConfig.use2GridOffsets,S=I?b?`${y},${v}`:`${y},0,0,${v}`:b?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,P=Math.abs(y)/2,R=e.ymin+P,_=e.ymax-P,A=I?`${R},${T},${_},${L},${d}`:`${T},${R},${L},${_},${d}`,D=s.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes("band")));let E,W=D&&u&&a?p?`${D.identifier}[${D.axis[0].identifier}[${a.join(",")}]]`:`${D.identifier}:${u}[${D.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=r&&r.length)for(let o=0;o<r.length;o++){let e=r[o].values;const t=r[o].dimensionName?.toLowerCase(),i=r[o].variableName?.toLowerCase(),n=s.range.find(e=>e.identifier.toLowerCase()===i);if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)E=e.map(e=>$(e)).join(",");else if(n){const i=n.axis.find(e=>e.identifier.toLowerCase()===t);i&&(W=p?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+u+"["+i.identifier+"["+e.join(",")+"]]")}o===r.length-1&&n&&!W&&(W=p?n.identifier:n.identifier+":"+u)}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:f,crs:`EPSG:${c}`,boundingbox:A,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:C,gridOffsets:S,gridBaseCRS:d,timeSequence:E,rangeSubset:W}}_getCoverage201Parameters(e,t,i,n,s,r){const{multidimensionalDefinition:o,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find(e=>e.toLowerCase().includes("nearest"));break;case 1:c=d.find(e=>e.toLowerCase().includes("linear"));break;case 2:c=d.find(e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic"))}const f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",{bandNames:h}=this.coverageInfo,{boundedBy:u,domainSet:p,rangeType:g}=r,m=u.isEastFirst?0:1,w=1-m,{axisLabels:v}=u,y=v[m],x=v[w],I=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=I,b=[];b.push(`${y}(${e.xmin},${e.xmax})`),b.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let _=2;_<v.length;_++){const e=p.origin[_];if(v[_].toLowerCase().includes("time")){let t=e.toString();u.uomLabels?.[_].toLowerCase().includes("ole")&&(S.push(v[_]),t=$(e,!0)),b.push(v[_]+",http://www.opengis.net("+t+")")}else b.push(v[_]+",http://www.opengis.net("+e+")")}let j=null;if(null!=o&&o.length){const e=[];g.forEach(t=>t.forEach(t=>e.push(t.name)));const t=[];for(let i=0;i<o.length;i++){const n=v.find(e=>e===o[i].dimensionName),s=e.find(e=>e===o[i].variableName);if(t.includes(s)||t.push(s),n){let e=o[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map(e=>$(e)).join(","):e.join(",");const i=b.findIndex(e=>e.startsWith(n+",http://www.opengis.net"));-1===i&&b.push(n+",http://www.opengis.net("+t+")"),-1===i||b[i].includes("("+t+")")||b.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(h?.length>=2){j=(s.bandIds?s.bandIds.map(e=>h[e]):h).join(",")}const T=b.join("&subset="),L=!r.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,P=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:P,scaleFactor:R,subset:T,format:f,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:I,subsettingcrs:C}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach(e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach(e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)}):i.push(`${e}=${encodeURIComponent(n)}`))});return`${encodeURI(this.url)}?${i.join("&")}`}};function $(e,t=!1){return(t?new Date(d(e)):new Date(e)).toISOString()}e([n({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([n({readOnly:!0})],b.prototype,"tileType",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),e([n({readOnly:!0})],b.prototype,"rasterId",null),b=e([s("esri.layers.raster.datasets.WCSRaster")],b);export{b as default};
@@ -6,14 +6,16 @@ import type { Loadable, LoadableMixinProperties } from "../../core/Loadable.js";
6
6
  export interface AnnotationFeatureSublayerProperties extends LoadableMixinProperties, IdentifiableMixinProperties, Partial<Pick<AnnotationFeatureSublayer, "parent" | "subtypeCode" | "visible">> {}
7
7
 
8
8
  /**
9
- * Represents a sublayer in a [AnnotationFeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/AnnotationFeatureLayer/). Each AnnotationFeatureSublayer
9
+ * Represents a sublayer in a [AnnotationFeatureLayer (beta)](https://developers.arcgis.com/javascript/latest/references/core/layers/AnnotationFeatureLayer/). Each AnnotationFeatureSublayer
10
10
  * is not a standalone service, but rather each sublayer corresponds to one subtype in the source feature service.
11
11
  *
12
12
  * The AnnotationFeatureSublayers are identified by their unique [subtypeCode](https://developers.arcgis.com/javascript/latest/references/core/layers/support/AnnotationFeatureSublayer/#subtypeCode). You can configure the visibility of each sublayer while
13
- * initializing the AnnotationFeatureLayer
13
+ * initializing the AnnotationFeatureLayer.
14
14
  *
15
+ * @beta
15
16
  * @since 5.1
16
- * @see [AnnotationFeatureLayer.sublayers](https://developers.arcgis.com/javascript/latest/references/core/layers/AnnotationFeatureLayer/#sublayers)
17
+ * @see [AnnotationFeatureLayer (beta)](https://developers.arcgis.com/javascript/latest/references/core/layers/AnnotationFeatureLayer/)
18
+ * @see [Annotation in ArcGIS Pro](https://doc.esri.com/en/arcgis-pro/latest/help/data/annotation/annotation.html).
17
19
  */
18
20
  export default class AnnotationFeatureSublayer extends AnnotationFeatureSublayerSuperclass {
19
21
  constructor(properties?: AnnotationFeatureSublayerProperties);
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- import{__decorate as r}from"tslib";import{ClonableMixin as e}from"../../core/Clonable.js";import{JSONSupport as o}from"../../core/JSONSupport.js";import{property as t,subclass as s}from"../../core/accessorSupport/decorators.js";let i=class extends(e(o)){constructor(r){super(r),this.enabled=!1,this.drawOrder=[]}};r([t({type:Boolean,json:{write:!0,origins:{"web-scene":{write:!1}}}})],i.prototype,"enabled",void 0),r([t({type:[String],json:{write:!0,origins:{"web-scene":{write:!1}}}})],i.prototype,"drawOrder",void 0),i=r([s("esri.layers.support.SymbolLayerDrawing")],i);const p=i;export{p as default};
2
+ import{__decorate as r}from"tslib";import{ClonableMixin as e}from"../../core/Clonable.js";import{JSONSupport as o}from"../../core/JSONSupport.js";import{property as t,subclass as s}from"../../core/accessorSupport/decorators.js";let i=class extends(e(o)){constructor(r){super(r),this.enabled=!1,this.drawOrder=[]}};r([t({type:Boolean,json:{write:!0,origins:{"web-scene":{write:!1}}}})],i.prototype,"enabled",void 0),r([t({type:[String],json:{write:!0,origins:{"web-scene":{write:!1}}}})],i.prototype,"drawOrder",void 0),i=r([s("esri.layers.support.SymbolLayerDrawing")],i);export{i as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcgis/core",
3
- "version": "5.2.0-next.20",
3
+ "version": "5.2.0-next.21",
4
4
  "homepage": "https://js.arcgis.com",
5
5
  "description": "ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API",
6
6
  "keywords": [
@@ -19,7 +19,7 @@
19
19
  "license": "SEE LICENSE IN LICENSE.md",
20
20
  "dependencies": {
21
21
  "@amcharts/amcharts5": "~5.18.0",
22
- "@arcgis/toolkit": "^5.1.0-next.136",
22
+ "@arcgis/toolkit": "^5.1.0-next.137",
23
23
  "@esri/arcgis-html-sanitizer": "~4.1.0",
24
24
  "@esri/calcite-components": "^5.1.1",
25
25
  "@vaadin/grid": "~25.1.4",
@@ -1,2 +1,2 @@
1
1
  /* COPYRIGHT Esri - https://js.arcgis.com/5.2/LICENSE.txt */
2
- const b="20260616",e="48e2c2801b67421d1e7f3313117bb22ab217e906";export{b as buildDate,e as commitHash};
2
+ const a="20260617",e="5c30ed300866e2ab140a1fa8acb193438e584ffa";export{a as buildDate,e as commitHash};