@arcgis/core 4.27.0-rc.3 → 4.27.0-rc.4

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 (134) hide show
  1. package/assets/esri/core/workers/RemoteClient.js +1 -1
  2. package/assets/esri/core/workers/chunks/{0e65e00173b66c7fec2e.js → 09e677ca7532a281d262.js} +1 -1
  3. package/assets/esri/core/workers/chunks/{89001ee8d3f69fa03cc1.js → 0f7ddb063ee0664f2fca.js} +1 -1
  4. package/assets/esri/core/workers/chunks/17ab08f60764244b2cf8.js +1 -0
  5. package/assets/esri/core/workers/chunks/{2446e336b1f7256d4fde.js → 2c587ed66e2586cccb8d.js} +1 -1
  6. package/assets/esri/core/workers/chunks/{00c7b9fb375c9a934158.js → 38c6452dc9cf18e8bca8.js} +1 -1
  7. package/assets/esri/core/workers/chunks/{16db0bc87d87a7313dc4.js → 4806df402845c717c842.js} +1 -1
  8. package/assets/esri/core/workers/chunks/4884432d80e9af947449.js +1 -0
  9. package/assets/esri/core/workers/chunks/588cd91d08cec5207be1.js +1 -0
  10. package/assets/esri/core/workers/chunks/{83e3d104886b48f00397.js → 633c00c02a81397fc8df.js} +1 -1
  11. package/assets/esri/core/workers/chunks/{efb96aefe979a0f5c632.js → 640e8ac3498be30c6614.js} +1 -1
  12. package/assets/esri/core/workers/chunks/{33901eb1574e46abd9af.js → 6c213768715c52625855.js} +1 -1
  13. package/assets/esri/core/workers/chunks/{5e6471dd2a08e66b47d0.js → 6e4940fe3bba014c921b.js} +57 -58
  14. package/assets/esri/core/workers/chunks/{3160af63b860b52db389.js → 6f724f75f85dc3989d60.js} +1 -1
  15. package/assets/esri/core/workers/chunks/8b05fb365336cc42fecc.js +1 -0
  16. package/assets/esri/core/workers/chunks/8eec6da5e862cc33ea2b.js +1 -0
  17. package/assets/esri/core/workers/chunks/90d8f297d9cb359e071d.js +1 -0
  18. package/assets/esri/core/workers/chunks/91785144901dfe56c5e2.js +1 -0
  19. package/assets/esri/core/workers/chunks/{471f6eba213412b82840.js → 927417abea79c955b216.js} +1 -1
  20. package/assets/esri/core/workers/chunks/{adaa9d4239f4e905d011.js → 9d4bd73dd50400e9d328.js} +1 -1
  21. package/assets/esri/core/workers/chunks/a324cc07d486061d0d8e.js +1 -0
  22. package/assets/esri/core/workers/chunks/a40130579791293cefa2.js +1 -0
  23. package/assets/esri/core/workers/chunks/{50f910797c17c3028521.js → a49718c74053314ed741.js} +1 -1
  24. package/assets/esri/core/workers/chunks/ad2891985e0fe45aa8d2.js +1 -0
  25. package/assets/esri/core/workers/chunks/afcba35eea836aea98ca.js +1 -0
  26. package/assets/esri/core/workers/chunks/b3d2e397ea74ebef4423.js +1 -0
  27. package/assets/esri/core/workers/chunks/b5fb9da45cc9dee286f8.js +1 -0
  28. package/assets/esri/core/workers/chunks/b846d4215210aac9f6ef.js +1 -0
  29. package/assets/esri/core/workers/chunks/c7dc821db8c14fec24a7.js +1 -0
  30. package/assets/esri/core/workers/chunks/c9df9a0a4a45f9a53ce9.js +1 -0
  31. package/assets/esri/core/workers/chunks/{45a4041881e6235d73a2.js → d0a9711f48dfa5fee68a.js} +1 -1
  32. package/assets/esri/core/workers/chunks/e23ec4f867c4735eec20.js +1 -0
  33. package/assets/esri/core/workers/chunks/{ff42585e1b1d0c5497af.js → ea16230a0edfc9f756bd.js} +1 -1
  34. package/assets/esri/core/workers/chunks/ef900614353505afb210.js +1 -0
  35. package/assets/esri/themes/base/_View.scss +2 -5
  36. package/assets/esri/themes/base/widgets/_Feature.scss +12 -4
  37. package/assets/esri/themes/dark/main.css +1 -1
  38. package/assets/esri/themes/light/main.css +1 -1
  39. package/assets/esri/themes/light/view.css +1 -1
  40. package/chunks/DefaultMaterial.glsl.js +42 -42
  41. package/chunks/Terrain.glsl.js +7 -7
  42. package/copyright.txt +1 -1
  43. package/geometry/Mesh.js +1 -1
  44. package/geometry/support/meshUtils/bounds.js +1 -1
  45. package/geometry/support/meshUtils/georeference.js +1 -1
  46. package/interfaces.d.ts +3 -3
  47. package/kernel.js +1 -1
  48. package/layers/OrientedImageryLayer.js +1 -1
  49. package/layers/SceneLayer.js +1 -1
  50. package/layers/VideoLayer.js +1 -1
  51. package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
  52. package/layers/graphics/editingSupport.js +1 -1
  53. package/layers/graphics/sources/FeatureLayerSource.js +1 -1
  54. package/layers/graphics/sources/OGCFeatureSource.js +1 -1
  55. package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
  56. package/layers/graphics/sources/support/uploadAssets.js +1 -1
  57. package/layers/mixins/ArcGISImageService.js +1 -1
  58. package/layers/mixins/ImageryTileMixin.js +1 -1
  59. package/layers/orientedImagery/core/ExposurePoint.js +1 -1
  60. package/layers/orientedImagery/core/bestImageUtils.js +1 -1
  61. package/layers/orientedImagery/core/coverageUtils.js +1 -1
  62. package/layers/orientedImagery/transformations/groundToImageUtils.js +1 -1
  63. package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
  64. package/layers/support/SubtypeSublayer.js +1 -1
  65. package/layers/support/capabilities.js +1 -1
  66. package/layers/support/layerUtils.js +1 -1
  67. package/layers/support/serviceCapabilitiesUtils.js +1 -1
  68. package/layers/video/VideoCameraSensorModel.js +5 -0
  69. package/layers/video/VideoController.js +1 -1
  70. package/layers/video/videoUtils.js +1 -1
  71. package/package.json +1 -1
  72. package/portal/PortalItem.js +1 -1
  73. package/renderers/support/colorRampUtils.js +1 -1
  74. package/rest/support/meshFeatureSet.js +1 -1
  75. package/smartMapping/labels/bins.js +5 -0
  76. package/smartMapping/labels/clusters.js +1 -1
  77. package/smartMapping/labels/support/utils.js +5 -0
  78. package/smartMapping/support/binningUtils.js +1 -1
  79. package/support/revision.js +1 -1
  80. package/views/2d/layers/features/schemaUtils.js +1 -1
  81. package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
  82. package/views/3d/layers/I3SMeshView3D.js +1 -1
  83. package/views/3d/layers/I3SMeshViewLabeler.js +1 -1
  84. package/views/3d/layers/I3SMeshWorkerHandle.js +1 -1
  85. package/views/3d/layers/SceneLayerWorker.js +1 -1
  86. package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
  87. package/views/3d/layers/i3s/I3SClientMaterialUtil.js +5 -0
  88. package/views/3d/layers/i3s/I3SClientNodeLoader.js +1 -1
  89. package/views/3d/layers/i3s/I3SGeometryUtil.js +1 -1
  90. package/views/3d/layers/i3s/I3SOverrides.js +1 -1
  91. package/views/3d/terrain/TerrainRenderer.js +1 -1
  92. package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +19 -20
  93. package/views/3d/webgl-engine/core/shaderLibrary/shading/ReadShadowMap.glsl.js +2 -2
  94. package/views/3d/webgl-engine/core/shaderLibrary/terrain/TerrainTexture.glsl.js +9 -9
  95. package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
  96. package/views/3d/webgl-engine/shaders/DefaultMaterial.glsl.js +1 -1
  97. package/views/DOMContainer.js +1 -1
  98. package/views/PopupView.js +1 -1
  99. package/views/ui/DefaultUI.js +1 -1
  100. package/views/ui/UI.js +1 -1
  101. package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
  102. package/widgets/Editor/EditorViewModel.js +1 -1
  103. package/widgets/Editor/UpdateWorkflow.js +1 -1
  104. package/widgets/Editor/workflowUtils.js +1 -1
  105. package/widgets/Feature/support/featureUtils.js +1 -1
  106. package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
  107. package/widgets/FeatureForm/RelationshipInput.js +1 -1
  108. package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
  109. package/widgets/OrientedImageryViewer.js +1 -1
  110. package/widgets/Popup.js +1 -1
  111. package/widgets/UtilityNetworkValidateTopology/UtilityNetworkValidateTopologyViewModel.js +1 -1
  112. package/assets/esri/core/workers/chunks/013de5c2955801b329b3.js +0 -1
  113. package/assets/esri/core/workers/chunks/0618fb0058f39ecd363f.js +0 -1
  114. package/assets/esri/core/workers/chunks/07163dcbb871f927a580.js +0 -1
  115. package/assets/esri/core/workers/chunks/0e46687004392c493c06.js +0 -1
  116. package/assets/esri/core/workers/chunks/21328f3dd26abe84a10d.js +0 -1
  117. package/assets/esri/core/workers/chunks/2faa8f08f2fdaac3f4af.js +0 -1
  118. package/assets/esri/core/workers/chunks/624521961fe1f2c4f2c5.js +0 -1
  119. package/assets/esri/core/workers/chunks/6f510f28526c73ab453c.js +0 -1
  120. package/assets/esri/core/workers/chunks/7479dc0c790337af7597.js +0 -1
  121. package/assets/esri/core/workers/chunks/a6ddf80eb324c35076e1.js +0 -1
  122. package/assets/esri/core/workers/chunks/a7fd2a95fde197c06828.js +0 -1
  123. package/assets/esri/core/workers/chunks/b8e6c64792a512df4c4d.js +0 -1
  124. package/assets/esri/core/workers/chunks/bf9e1fde9f6b2b4f10c0.js +0 -1
  125. package/assets/esri/core/workers/chunks/c96db6b7ce47bd343fdb.js +0 -1
  126. package/assets/esri/core/workers/chunks/cfa3b2b1e184681e9af4.js +0 -1
  127. package/assets/esri/core/workers/chunks/d95ca50ca7af4c222036.js +0 -1
  128. package/assets/esri/core/workers/chunks/ee5ee03dd2c7dc940272.js +0 -1
  129. package/assets/esri/core/workers/chunks/f720967ba8c5486a26a2.js +0 -1
  130. package/layers/orientedImagery/core/Affixes.js +0 -5
  131. package/layers/orientedImagery/core/CameraProperties.js +0 -5
  132. package/layers/orientedImagery/core/ImageProperties.js +0 -5
  133. package/layers/orientedImagery/core/ImageryTypes.js +0 -5
  134. package/layers/orientedImagery/core/imageryUtils.js +0 -5
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{rasterRendererTypes as r,websceneRasterRendererTypes as i,read as s}from"../../rasterRenderers.js";import n from"../../request.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import a from"../../core/Error.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{watch as p}from"../../core/reactiveUtils.js";import{urlToObject as c}from"../../core/urlUtils.js";import{property as m,ensureRange as d}from"../../core/accessorSupport/decorators/property.js";import{Integer as h,ensureClass as f,ensureNumber as y}from"../../core/accessorSupport/ensureType.js";import{reader as g}from"../../core/accessorSupport/decorators/reader.js";import{subclass as R}from"../../core/accessorSupport/decorators/subclass.js";import{writer as b}from"../../core/accessorSupport/decorators/writer.js";import{opacity as v,url as S}from"../support/commonProperties.js";import x from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as I}from"../support/ExportImageServiceParameters.js";import w from"../support/Field.js";import _ from"../support/FieldsIndex.js";import{createBitmap as F}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as D}from"../support/imageryRendererUtils.js";import P from"../support/MosaicRule.js";import j from"../support/MultidimensionalSubset.js";import T from"../support/PixelBlock.js";import{interpolationKebab as O,noDataInterpretationKebab as N,pixelTypeKebabDict as C}from"../support/rasterEnums.js";import M from"../support/RasterFunction.js";import A from"../support/RasterInfo.js";import J from"../support/RasterJobHandler.js";import{intersectMultimensionalSubset as q,getSubsetVariablesFromMdInfo as E,getDefaultMultidimensionalDefinition as V}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as H,getFormat as Q}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as L}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as U,getDefaultBandCombination as z,createDefaultRenderer as B,normalizeRendererJSON as k}from"../../renderers/support/rasterRendererHelper.js";import G from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as W,computePixelSpaceLocations as $,computeHistograms as X,computeStatisticsHistograms as K,measureHeight as Y,measureAreaAndPerimeter as Z,measureDistanceAndAngle as ee,measurePointOrCentroid as te,getImageSpatialReferenceQueryParameter as re,getSamples as ie,identify as se}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as ne}from"../../rest/query/executeQueryJSON.js";import"../../config.js";import"../../kernel.js";import"../../core/unitUtils.js";import"../../geometry/support/spatialReferenceUtils.js";import"../graphics/featureConversionUtils.js";import oe from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import ae from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import le from"../../rest/support/FeatureSet.js";import ue from"../../rest/support/Query.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as pe}from"../../rest/query/executeForCount.js";import{executeForIds as ce}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{generateRasterInfo as me,fetchServiceRasterInfo as de}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as he}from"../../rest/imageService/getCatalogItemRasterInfo.js";import fe from"../../rest/support/ImageAngleParameters.js";import ye from"../../rest/support/ImageAreaParameters.js";import ge from"../../rest/support/ImageDistanceParameters.js";import Re from"../../rest/support/ImageHeightParameters.js";import be from"../../rest/support/ImageHistogramParameters.js";import ve from"../../rest/support/ImageIdentifyParameters.js";import Se from"../../rest/support/ImagePixelLocationParameters.js";import xe from"../../rest/support/ImagePointParameters.js";import Ie from"../../rest/support/ImageSampleParameters.js";import{createFlowMesh as we}from"../../views/2d/engine/flow/dataUtils.js";import _e from"../../geometry/SpatialReference.js";const Fe=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),De=d(y,{min:0,max:255});function Pe(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),r=t?.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return r?r.join("/"):null}const je=d=>{let y=class extends d{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._cachedRendererJson=null,this._serviceSupportsMosaicRule=null,this._rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.defaultMosaicRule=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.multidimensionalSubset=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelFilter=null,this.raster=void 0,this.sourceType=null,this.viewId=void 0,this.symbolizer=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new I({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,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?P.fromJSON(t):null}get fieldsIndex(){return this.fields?new _(this.fields):null}set format(e){e&&Fe.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=P.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const r=e||t.mosaicRule;return r?P.fromJSON(r):this._isMosaicRuleSupported(t)?P.fromJSON(t):null}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new P({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=De(e))}readObjectIdField(e,t){if(!e){const r=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r&&r[0]&&r[0].name}return e}get parsedUrl(){return c(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer,n=s(i,r);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!i.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),D(n)||u.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this._rasterAttributeTableFieldPrefix||"Raster.",t=new w({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new w({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new w({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities?.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new w({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),this._isVectorDataSet()&&(s.push(new w({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new w({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const{attributeTable:n}=this.rasterInfo??{};if(null!=n){const t=n.fields.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}get renderingRule(){return o(u.getLogger(this),"renderingRule",{replacement:"rasterFunction",version:"4.27",warnOnce:!0}),this._get("rasterFunction")}set renderingRule(e){o(u.getLogger(this),"renderingRule",{replacement:"rasterFunction",version:"4.27",warnOnce:!0}),this._set("rasterFunction",e)}set rasterFunction(e){let t=e;t&&t.rasterFunction&&(t=M.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r&&r.length&&"None"!==r[0].name?this._isRFTJson(t.renderingRule)?M.fromJSON({rasterFunctionDefinition:t.renderingRule}):M.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?_e.fromJSON(r):null}readPixelType(e){return C.fromJSON(e)||e}writePixelType(e,t,r){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[r]=C.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;const{renderer:i,symbolizer:s,pixelFilter:n,bandIds:o}=this;if(!this._isPicture()&&i&&s&&!n){const n=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(i.toJSON()),a=this._rasterJobHandler.instance;if(a){n&&(s.bind(),await a.updateSymbolizer(s,t),this._cachedRendererJson=i.toJSON());const l=await a.symbolize({bandIds:o,...e},t);r={extent:e.extent,pixelBlock:l}}else r={extent:e.extent,pixelBlock:s.symbolize({bandIds:o,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new a("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=f(fe,e).clone(),W(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new a("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=f(Se,e).clone(),$(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new a("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=f(be,e).clone(),this._applyMosaicAndRenderingRules(e),X(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new a("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=f(be,e).clone(),this._applyMosaicAndRenderingRules(e),K(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const r=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?r.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?r.mensuration.supportsHeightFromBaseAndTopShadow:r.mensuration.supportsHeightFromTopAndTopShadow))throw new a("imagery-layer:measure-height","this operation is not supported on the input image service");return e=f(Re,e).clone(),this._applyMosaicAndRenderingRules(e),Y(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsAreaAndPerimeter&&(!e.is3D||r.mensuration.supports3D)))throw new a("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=f(ye,e).clone(),this._applyMosaicAndRenderingRules(e),Z(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsDistanceAndAngle&&(!e.is3D||r.mensuration.supports3D)))throw new a("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=f(ge,e).clone(),this._applyMosaicAndRenderingRules(e),ee(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsPointOrCentroid&&(!e.is3D||r.mensuration.supports3D)))throw new a("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=f(xe,e).clone(),this._applyMosaicAndRenderingRules(e),te(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}async fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)throw new a("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required.");if(this.renderer||this.symbolizer){const e=await this._generateRasterInfo(this.rasterFunction,{signal:i.signal});e&&(this.rasterInfo=e)}const s=this.getExportImageServiceParameters(e,t,r,i.timeExtent);if(null==s){if(i.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=r,i.returnImageBitmap){return{imageBitmap:await F(e,`${je(this.parsedUrl)}/exportImage`,i.signal)}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,o=(s?.length||n.bandCount)??0,a=t*r,l=n.pixelType,u=[];for(let e=0;e<o;e++)u.push(T.createEmptyBand(l,a));return{pixelData:{pixelBlock:new T({width:t,height:r,pixels:u,mask:new Uint8Array(a),pixelType:l}),extent:e}}}const n=!!i.requestAsImageElement&&!this.pixelFilter,o=n&&!!i.returnImageBitmap,l={imageServiceParameters:s,imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:n,returnImageBitmap:o,signal:i.signal};return this._requestArrayBuffer(l)}fetchKeyProperties(e){return n(je(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 a("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(je(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then((e=>le.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return he(je(this.parsedUrl),e,r)}async getCatalogItemICSInfo(e,t){const{data:r}=await n(je(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r&&r.ics;if(!i)return;let s=null;try{s=(await n(je(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const o=this.version>=10.7?n(je(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},a=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},u=n(je(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},y=n(je(this.parsedUrl)+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([o,u,y]);let R=g[0].ipxf;if(null==R){const e=i.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const b=oe.fromJSON(g[1]&&g[1].geometries&&g[1].geometries[0]);b&&(b.spatialReference=new _e({wkid:0,imageCoordinateSystem:i}));const v=g[2].geometries?g[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],S=v.length;if(S<3)return{ics:i,icsToPixelTransform:R,icsExtent:b,northDirection:null};let x=0,I=0,w=0,_=0;for(let n=0;n<S;n++)x+=v[n].x,I+=v[n].y,w+=v[n].x*v[n].x,_+=v[n].x*v[n].y;const F=(S*_-x*I)/(S*w-x*x);let D=0;const P=v[p-1].x>v[0].x,j=v[p-1].y>v[0].y;return F===1/0?D=j?90:270:0===F?D=P?0:180:F>0?D=P?180*Math.atan(F)/Math.PI:180*Math.atan(F)/Math.PI+180:F<0&&(D=j?180+180*Math.atan(F)/Math.PI:360+180*Math.atan(F)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:b,northDirection:D}}async generateRasterInfo(e,t){if(e=f(M,e),this.serviceRasterInfo&&(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e)))return this.serviceRasterInfo;const r=Pe(e);if(!r)throw new a("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const i={...t,query:this._getQueryParams()},s=me(je(this.parsedUrl),e,i);this._functionRasterInfos[r]=s;try{return await s}catch(n){throw this._functionRasterInfos[r]=null,n}}getExportImageServiceParameters(e,t,r,i){e=e.clone().shiftCentralMeridian();const s=re(e.spatialReference,je(this.parsedUrl));this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:a}=n;let{renderingRule:l}=n;const u=this.rasterFunction?.rasterFunctionDefinition,p=!this.renderer||"raster-stretch"===this.renderer.type;if(o?.length&&this._hasRasterFunction(this.rasterFunction)&&!u&&p){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===l.rasterFunction)e.rasterFunctionArguments.Raster=l.rasterFunctionArguments.Raster,l.rasterFunctionArguments.Raster=e;else if("Colormap"===l.rasterFunction){const t=l.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,l.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=l,l=e;n.bandIds=void 0}else n.bandIds=o?.join(",");a instanceof Array&&a.length>0&&(n.noData=a.join(","));const c=this._processMultidimensionalIntersection(null,i,this.exportImageServiceParameters.mosaicRule);if(c.isOutSide)return null;n.mosaicRule=null!=c.mosaicRule?JSON.stringify(c.mosaicRule):null,i=c.timeExtent,n.renderingRule=this._getRenderingRuleString(M.fromJSON(l));const m={};if(null!=i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?m.time=""+e:null==e&&null==t||(m.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+r,...n,...m}}async getSamples(e,t){const r=await this._fetchCapabilities(t?.signal);if(!r?.operations.supportsGetSamples)throw new a("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=f(Ie,e).clone();const{raster:i}=this;return i&&null==e.raster&&(e.raster=i),ie(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new a("imagery-layer:identify","identify operation is not supported on the input image service");e=f(ve,e).clone();const r=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(r.isOutSide)throw new a("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=r.timeExtent,e.mosaicRule=r.mosaicRule;const{raster:i,rasterFunction:s}=this;return s&&null==e.rasterFunction&&(e.rasterFunction=s),i&&null==e.raster&&(e.raster=i),se(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new ue;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ne(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ce(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),pe(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new a("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p="raster.servicepixelvalue",c=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(o=e.outFields.some((e=>!e.toLowerCase().includes(p))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().includes(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 M({functionName:e[0]}))),u=t.map((e=>e[1]));const{rasterFunction:r}=this;0===l.length?r?.functionName?(l.push(r),u.push(r.functionName)):l=null:r?.functionName&&!l.some((e=>e.functionName===r.functionName))&&(l.push(r),u.push(r.functionName))}const m=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:d}=this;let h=e.timeExtent||this.timeExtent;if(d){const{isOutside:t,intersection:r}=q(d,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new a("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");r&&null!=r.timeExtent&&(h=r.timeExtent)}const f=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,h),y=this._getQueryParams({geometry:e.geometry,timeExtent:h,mosaicRule:f,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:r,returnCatalogItems:o,returnGeometry:m,raster:this.raster,maxItemCount:s?1:null});delete y.f;const g=new ve(y);try{await this._generateRasterInfo(this.rasterFunction);const r=await se(this.url,g,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,a=null!=r.value&&r.value.toLowerCase().includes("nodata");if(!(o&&!m&&r?.catalogItems?.features.length&&(n||!a)))return this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",p=r.catalogItems?.features??[],c=p.map((e=>e.attributes?.[l])),d=new ue({objectIds:c,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),h=await this.queryRasters(d);return h?.features?.length&&h.features.forEach((t=>{p.forEach((r=>{r.attributes[l]===t.attributes[l]&&(r.geometry=new ae(t.geometry),null!=e.outSpatialReference&&(r.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new a("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=n(je(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),i=n(je(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(e,t):we(e.meshType,e.simulationSettings,e.flowData,null!=t.signal?t.signal:(new AbortController).signal)}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return E(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):de(je(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),e))),i=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([r,i,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),u.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.addHandles([p((()=>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 r=this.timeInfo,{multidimensionalInfo:i}=this.serviceRasterInfo;if(null==e||null==i||null==t||null==r?.startField)return e;const{startField:s}=r,n=i.variables.some((e=>e.dimensions.some((e=>e.name===s))))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter((e=>e.dimensionName!==n)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const o=e.multidimensionalDefinition.filter((e=>e.dimensionName===n)),a=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==a||null==l||a===l,p=u?[a||l]:[[a,l]],c=this.version>=10.8;if(o.length)o.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 x({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 a("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=null!=e?f(ue,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new J;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>{})),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:r}=this;return"unique-value"===e.type&&this._hasRasterFunction(r)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&U(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:r,ssl:i}=await n(je(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new a("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),r=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||r}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:r}=e,i="resample"===t?.toLowerCase(),s=r?.ResampleType||r?.resampleType;return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:r}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){if(!this.bandIds&&r.bandCount>=3){const e=z(r);!e||3===r.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=B(r,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=k(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=r):this.symbolizer=new G({rendererJSON:t,rasterInfo:r}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){e&&null!=e.renderingRule&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):H(e,t,r)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;const r=await n(je(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:r,returnImageBitmap:i,signal:s}=e;if(r&&this._canRequestImageElement(t.format)){const r=`${je(this.parsedUrl)}/exportImage`,{data:o}=await n(r,{responseType:i?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:s});if(o instanceof Blob){return{imageBitmap:await F(o,r,s),params:t}}return{imageOrCanvasElement:o,params:t}}const o=this._initJobHandler(),l=n(je(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:s}),u=(await Promise.all([l,o]))[0].data,p=t.format||"jpgpng";let c=p;if("bsq"!==c&&"bip"!==c&&(c=Q(u)),!c)throw new a("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const m={signal:s},d="gif"===p||"bmp"===p||p.includes("png")&&("png"===c||"jpg"===c)?H(u,{useCanvas:!0,...t},m):this._decodePixelBlock(u,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:p},m);return{pixelData:{pixelBlock:await d,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=V(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,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:o,templateFields:a}=r,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,p=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replaceAll(/ /gi,", ")))||[];const c=this.objectIdField||"ObjectId",m="string"==typeof i&&i.toLowerCase().includes("nodata"),d=[];if(i&&!u&&!m){const e={};e[c]=0;p=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let h,f,y;this._updateResponseFieldNames(u,a),m&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(h=u[t],null!=i){if(f=p[t],y=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:i,"nodata"===f.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";h.attributes[e]=f,h.attributes[r]=y,this._updateFeatureWithMagDirValues(h,f);const o=this.fields&&this.fields.length>0;let a=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?o?f:i:y;this.rasterFunction||(a=o?f:i),this._updateFeatureWithRasterAttributeTableValues(h,a)}if(h.sourceLayer=h.layer=this,o&&this._updateFeatureWithDomainValues(h),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];h.attributes[t]=l[e]}d.push(u[t])}return d}_processMultidimensionalIntersection(e,t,r){const{multidimensionalSubset:i}=this;if(!i)return{isOutSide:!1,timeExtent:t,mosaicRule:r=this._combineMosaicRuleWithTimeExtent(r,t)};if(i){const{isOutside:r,intersection:s}=q(i,{geometry:e,timeExtent:t});if(r)return{isOutSide:!0,timeExtent:null,mosaicRule:null};s&&null!=s.timeExtent&&(t=s.timeExtent)}if(null!=(r=this._combineMosaicRuleWithTimeExtent(r,t))&&r.multidimensionalDefinition){const{isOutside:e}=q(i,{multidimensionalDefinition:r.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:r}}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==r)return;const{features:i,fields:s}=r,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),o=n&&n[0];if(!o)return;const a=i.filter((e=>e.attributes[o]===(null!=t?parseInt(t,10):null)));a&&a[0]&&s.forEach((t=>{const r=this._rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=a[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new T({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new oe(0,0,0,0,this.spatialReference)});const o="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:L([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=o[0],e.attributes["Raster.Direction"]=o[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.find((e=>e.code===r));i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;null!=r&&e.forEach((e=>{if(e&&e.attributes)for(const i of t){const t=r.get(i)?.name;t&&t!==i&&(e.attributes[i]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(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&&null!=e.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const r=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(r)?t.get(r):e}_isRFTJson(e){return e&&e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:r,rasterFunction:i}=this;i&&e instanceof be&&null==e.rasterFunction&&(e.rasterFunction=i),r&&null==e.mosaicRule&&(e.mosaicRule=r),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.includes("image"),o="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit"),u=t.includes("mensuration")&&a,p=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map((e=>e.trim())),c=u&&p.includes("basic");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:u,supportsDownload:t.includes("download"),supportsQuery:t.includes("catalog")&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&o,supportsComputePixelLocation:r>=10.7&&t.includes("catalog"),supportsComputeAngles:r>=10.91,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryTopFeatures:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!!i?.supportsStatistics,supportsOrderBy:!!i?.supportsOrderBy,supportsDistinct:!!i?.supportsDistinct,supportsPagination:!!i?.supportsPagination,supportsStandardizedQueriesOnly:!!i?.useStandardizedQueries,supportsPercentileStatistics:!!i?.supportsPercentileStatistics,supportsCentroid:!!i?.supportsReturningGeometryCentroid,supportsDistance:!!i?.supportsQueryWithDistance,supportsExtent:!!i?.supportsReturningQueryExtent,supportsGeometryProperties:!!i?.supportsReturningGeometryProperties,supportsHavingClause:!!i?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!i?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0},mensuration:{supportsDistanceAndAngle:c,supportsAreaAndPerimeter:c,supportsPointOrCentroid:c,supportsHeightFromBaseAndTop:u&&p.includes("base-top height"),supportsHeightFromBaseAndTopShadow:u&&p.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:u&&p.includes("top-top shadow height"),supports3D:u&&p.includes("3d")}}}};function je(e){return e?.path??""}return e([m()],y.prototype,"_functionRasterInfos",void 0),e([m()],y.prototype,"_rasterJobHandler",void 0),e([m()],y.prototype,"_cachedRendererJson",void 0),e([m({readOnly:!0})],y.prototype,"_serviceSupportsMosaicRule",void 0),e([g("_serviceSupportsMosaicRule",["currentVersion","fields"])],y.prototype,"readServiceSupportsMosaicRule",null),e([m()],y.prototype,"_rasterAttributeTableFieldPrefix",void 0),e([m({readOnly:!0})],y.prototype,"_rasterFunctionNamesIndex",null),e([m()],y.prototype,"adjustAspectRatio",void 0),e([m({type:[h],json:{write:!0}})],y.prototype,"bandIds",void 0),e([g("bandIds")],y.prototype,"readBandIds",null),e([m({readOnly:!0,json:{read:!1}})],y.prototype,"capabilities",void 0),e([g("service","capabilities",["capabilities","currentVersion","serviceDataType"])],y.prototype,"readCapabilities",null),e([m({type:Number})],y.prototype,"compressionQuality",void 0),e([b("compressionQuality")],y.prototype,"writeCompressionQuality",null),e([m({type:Number})],y.prototype,"compressionTolerance",void 0),e([b("compressionTolerance")],y.prototype,"writeCompressionTolerance",null),e([m({json:{read:{source:"copyrightText"}}})],y.prototype,"copyright",void 0),e([m({readOnly:!0,dependsOn:["_serviceSupportsMosaicRule"]})],y.prototype,"defaultMosaicRule",void 0),e([g("defaultMosaicRule",["defaultMosaicMethod"])],y.prototype,"readDefaultMosaicRule",null),e([m({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],y.prototype,"definitionExpression",void 0),e([m({readOnly:!0,constructOnly:!0})],y.prototype,"exportImageServiceParameters",void 0),e([m()],y.prototype,"rasterInfo",void 0),e([m({readOnly:!0,type:[w]})],y.prototype,"fields",void 0),e([m({readOnly:!0})],y.prototype,"fieldsIndex",null),e([m({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],y.prototype,"format",null),e([g("service","format",["serviceDataType"])],y.prototype,"readFormat",null),e([m({type:oe})],y.prototype,"fullExtent",void 0),e([m({readOnly:!0})],y.prototype,"hasMultidimensions",void 0),e([m({json:{read:{source:"maxImageHeight"}}})],y.prototype,"imageMaxHeight",void 0),e([m({json:{read:{source:"maxImageWidth"}}})],y.prototype,"imageMaxWidth",void 0),e([m({type:String,json:{type:O.jsonValues,read:O.read,write:O.write}})],y.prototype,"interpolation",void 0),e([m()],y.prototype,"minScale",void 0),e([g("service","minScale")],y.prototype,"readMinScale",null),e([m()],y.prototype,"maxScale",void 0),e([g("service","maxScale")],y.prototype,"readMaxScale",null),e([m({type:P})],y.prototype,"mosaicRule",null),e([g("mosaicRule",["mosaicRule","defaultMosaicMethod"])],y.prototype,"readMosaicRule",null),e([b("mosaicRule")],y.prototype,"writeMosaicRule",null),e([m()],y.prototype,"multidimensionalInfo",void 0),e([m({type:j,json:{write:!0}})],y.prototype,"multidimensionalSubset",void 0),e([m({json:{type:h}})],y.prototype,"noData",void 0),e([b("noData")],y.prototype,"writeNoData",null),e([m({type:String,json:{type:N.jsonValues,read:N.read,write:N.write}})],y.prototype,"noDataInterpretation",void 0),e([m({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],y.prototype,"objectIdField",void 0),e([g("objectIdField")],y.prototype,"readObjectIdField",null),e([m({})],y.prototype,"geometryType",void 0),e([m({})],y.prototype,"typeIdField",void 0),e([m({})],y.prototype,"types",void 0),e([m({readOnly:!0})],y.prototype,"parsedUrl",null),e([m({type:Function})],y.prototype,"pixelFilter",void 0),e([m()],y.prototype,"raster",void 0),e([m({readOnly:!0})],y.prototype,"sourceType",void 0),e([g("sourceType",["serviceSourceType","fields"])],y.prototype,"readSourceType",null),e([m()],y.prototype,"viewId",void 0),e([m({types:r,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],y.prototype,"renderer",null),e([g("renderer")],y.prototype,"readRenderer",null),e([b("renderer")],y.prototype,"writeRenderer",null),e([m()],y.prototype,"symbolizer",void 0),e([m(v)],y.prototype,"opacity",void 0),e([m({readOnly:!0})],y.prototype,"rasterFields",null),e([m({constructOnly:!0})],y.prototype,"rasterFunctionInfos",void 0),e([m({type:M})],y.prototype,"renderingRule",null),e([m({type:M,json:{name:"renderingRule"}})],y.prototype,"rasterFunction",null),e([g("rasterFunction",["renderingRule","rasterFunctionInfos"])],y.prototype,"readRasterFunction",null),e([m()],y.prototype,"serviceDataType",void 0),e([m({readOnly:!0,type:_e})],y.prototype,"spatialReference",void 0),e([g("spatialReference",["spatialReference","extent"])],y.prototype,"readSpatialReference",null),e([m({json:{type:C.jsonValues}})],y.prototype,"pixelType",void 0),e([g("pixelType")],y.prototype,"readPixelType",null),e([b("pixelType")],y.prototype,"writePixelType",null),e([m({constructOnly:!0,type:A})],y.prototype,"serviceRasterInfo",void 0),e([m()],y.prototype,"sourceJSON",void 0),e([m(S)],y.prototype,"url",void 0),e([m({readOnly:!0})],y.prototype,"version",void 0),e([g("version",["currentVersion","fields","timeInfo"])],y.prototype,"readVersion",null),y=e([R("esri.layers.mixins.ArcGISImageService")],y),y};export{je as ArcGISImageService};
5
+ import{_ as e}from"../../chunks/tslib.es6.js";import"../../geometry.js";import t from"../../Graphic.js";import{rasterRendererTypes as r,websceneRasterRendererTypes as i,read as s}from"../../rasterRenderers.js";import n from"../../request.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import a from"../../core/Error.js";import{clone as l}from"../../core/lang.js";import u from"../../core/Logger.js";import{watch as p}from"../../core/reactiveUtils.js";import{urlToObject as c}from"../../core/urlUtils.js";import{property as m,ensureRange as d}from"../../core/accessorSupport/decorators/property.js";import{Integer as h,ensureClass as f,ensureNumber as y}from"../../core/accessorSupport/ensureType.js";import{reader as g}from"../../core/accessorSupport/decorators/reader.js";import{subclass as R}from"../../core/accessorSupport/decorators/subclass.js";import{writer as b}from"../../core/accessorSupport/decorators/writer.js";import{opacity as v,url as S}from"../support/commonProperties.js";import x from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as I}from"../support/ExportImageServiceParameters.js";import w from"../support/Field.js";import _ from"../support/FieldsIndex.js";import{createBitmap as F}from"../support/imageBitmapUtils.js";import{isSupportedRendererType as D}from"../support/imageryRendererUtils.js";import P from"../support/MosaicRule.js";import j from"../support/MultidimensionalSubset.js";import T from"../support/PixelBlock.js";import{interpolationKebab as O,noDataInterpretationKebab as C,pixelTypeKebabDict as N}from"../support/rasterEnums.js";import M from"../support/RasterFunction.js";import A from"../support/RasterInfo.js";import J from"../support/RasterJobHandler.js";import{intersectMultimensionalSubset as q,getSubsetVariablesFromMdInfo as E,getDefaultMultidimensionalDefinition as V}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as H,getFormat as Q}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as L}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as U,getDefaultBandCombination as z,createDefaultRenderer as B,normalizeRendererJSON as k}from"../../renderers/support/rasterRendererHelper.js";import G from"../../renderers/support/RasterSymbolizer.js";import{computeAngles as W,computePixelSpaceLocations as $,computeHistograms as X,computeStatisticsHistograms as K,measureHeight as Y,measureAreaAndPerimeter as Z,measureDistanceAndAngle as ee,measurePointOrCentroid as te,getImageSpatialReferenceQueryParameter as re,getSamples as ie,identify as se}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as ne}from"../../rest/query/executeQueryJSON.js";import"../../config.js";import"../../kernel.js";import"../../core/unitUtils.js";import"../../geometry/support/spatialReferenceUtils.js";import"../graphics/featureConversionUtils.js";import oe from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import ae from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtils.js";import"../../core/pbf.js";import le from"../../rest/support/FeatureSet.js";import ue from"../../rest/support/Query.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as pe}from"../../rest/query/executeForCount.js";import{executeForIds as ce}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{generateRasterInfo as me,fetchServiceRasterInfo as de}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as he}from"../../rest/imageService/getCatalogItemRasterInfo.js";import fe from"../../rest/support/ImageAngleParameters.js";import ye from"../../rest/support/ImageAreaParameters.js";import ge from"../../rest/support/ImageDistanceParameters.js";import Re from"../../rest/support/ImageHeightParameters.js";import be from"../../rest/support/ImageHistogramParameters.js";import ve from"../../rest/support/ImageIdentifyParameters.js";import Se from"../../rest/support/ImagePixelLocationParameters.js";import xe from"../../rest/support/ImagePointParameters.js";import Ie from"../../rest/support/ImageSampleParameters.js";import{createFlowMesh as we}from"../../views/2d/engine/flow/dataUtils.js";import _e from"../../geometry/SpatialReference.js";const Fe=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),De=d(y,{min:0,max:255});function Pe(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),r=t?.map((e=>e.replace('"rasterFunction":"',"").replace('"',"")));return r?r.join("/"):null}const je=d=>{let y=class extends d{constructor(){super(...arguments),this._functionRasterInfos={},this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this._cachedRendererJson=null,this._serviceSupportsMosaicRule=null,this._rasterAttributeTableFieldPrefix="Raster.",this.adjustAspectRatio=null,this.bandIds=void 0,this.capabilities=null,this.compressionQuality=void 0,this.compressionTolerance=.01,this.copyright=null,this.defaultMosaicRule=null,this.definitionExpression=null,this.exportImageServiceParameters=null,this.rasterInfo=null,this.fields=null,this.fullExtent=null,this.hasMultidimensions=!1,this.imageMaxHeight=4100,this.imageMaxWidth=4100,this.interpolation=void 0,this.minScale=0,this.maxScale=0,this.multidimensionalInfo=null,this.multidimensionalSubset=null,this.noData=null,this.noDataInterpretation=void 0,this.objectIdField=null,this.geometryType="polygon",this.typeIdField=null,this.types=[],this.pixelFilter=null,this.raster=void 0,this.sourceType=null,this.viewId=void 0,this.symbolizer=null,this.rasterFunctionInfos=null,this.serviceDataType=null,this.spatialReference=null,this.pixelType=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.url=null,this.version=void 0}initialize(){this._set("exportImageServiceParameters",new I({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,r){null!=e&&"lerc"!==this.format&&(t[r]=e)}writeCompressionTolerance(e,t,r){"lerc"===this.format&&null!=e&&(t[r]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?P.fromJSON(t):null}get fieldsIndex(){return this.fields?new _(this.fields):null}set format(e){e&&Fe.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t&&t.mosaicMethod&&(t=P.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const r=e||t.mosaicRule;return r?P.fromJSON(r):this._isMosaicRuleSupported(t)?P.fromJSON(t):null}writeMosaicRule(e,t,r){let i=this.mosaicRule;const s=this.definitionExpression;i?s&&s!==i.where&&(i=i.clone(),i.where=s):s&&(i=new P({where:s})),this._isValidCustomizedMosaicRule(i)&&(t[r]=i.toJSON())}writeNoData(e,t,r){null!=e&&"number"==typeof e&&(t[r]=De(e))}readObjectIdField(e,t){if(!e){const r=t.fields.filter((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=r&&r[0]&&r[0].name}return e}get parsedUrl(){return c(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer,n=s(i,r);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!i.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),D(n)||u.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,r){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this._rasterAttributeTableFieldPrefix||"Raster.",t=new w({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new w({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new w({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?l(this.fields):[];s.push(r),this.capabilities?.operations.supportsQuery&&this.fields&&this.fields.length>0&&s.push(t),this.version>=10.4&&null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.some((e=>"none"===e.name.toLowerCase()))&&s.push(i),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new w({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),this._isVectorDataSet()&&(s.push(new w({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new w({name:"Raster.Direction",alias:"Direction",domain:null,editable:!1,type:"double"})));const{attributeTable:n}=this.rasterInfo??{};if(null!=n){const t=n.fields.filter((e=>"esriFieldTypeOID"!==e.type&&"value"!==e.name.toLowerCase())).map((t=>{const r=l(t);return r.name=e+t.name,r}));s=s.concat(t)}return s}get renderingRule(){return o(u.getLogger(this),"renderingRule",{replacement:"rasterFunction",version:"4.27",warnOnce:!0}),this._get("rasterFunction")}set renderingRule(e){o(u.getLogger(this),"renderingRule",{replacement:"rasterFunction",version:"4.27",warnOnce:!0}),this._set("rasterFunction",e)}set rasterFunction(e){let t=e;t&&t.rasterFunction&&(t=M.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const r=t.rasterFunctionInfos;return t.renderingRule||r&&r.length&&"None"!==r[0].name?this._isRFTJson(t.renderingRule)?M.fromJSON({rasterFunctionDefinition:t.renderingRule}):M.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const r=e||t.extent.spatialReference;return r?_e.fromJSON(r):null}readPixelType(e){return N.fromJSON(e)||e}writePixelType(e,t,r){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[r]=N.toJSON(e))}readVersion(e,t){let r=t.currentVersion;return r||(r=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),r}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let r=e;const{renderer:i,symbolizer:s,pixelFilter:n,bandIds:o}=this;if(!this._isPicture()&&i&&s&&!n){const n=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(i.toJSON()),a=this._rasterJobHandler.instance;if(a){n&&(s.bind(),await a.updateSymbolizer(s,t),this._cachedRendererJson=i.toJSON());const l=await a.symbolize({bandIds:o,...e},t);r={extent:e.extent,pixelBlock:l}}else r={extent:e.extent,pixelBlock:s.symbolize({bandIds:o,...e})}}return r}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new a("imagery-layer:compute-angles","this operation is not supported on the input image service");return e=f(fe,e).clone(),W(this.url,e,this._getRequestOptions(t))}async computePixelSpaceLocations(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputePixelLocation)throw new a("imagery-layer:compute-pixel-space-locations","this operation is not supported on the input image service");return e=f(Se,e).clone(),$(this.url,e,this._getRequestOptions(t))}async computeHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeHistograms)throw new a("imagery-layer:compute-histograms","this operation is not supported on the input image service");return e=f(be,e).clone(),this._applyMosaicAndRenderingRules(e),X(this.url,e,this._getRequestOptions(t))}async computeStatisticsHistograms(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeStatisticsHistograms)throw new a("imagery-layer:compute-statistics-histograms","this operation is not supported on the input image service");return e=f(be,e).clone(),this._applyMosaicAndRenderingRules(e),K(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const r=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?r.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?r.mensuration.supportsHeightFromBaseAndTopShadow:r.mensuration.supportsHeightFromTopAndTopShadow))throw new a("imagery-layer:measure-height","this operation is not supported on the input image service");return e=f(Re,e).clone(),this._applyMosaicAndRenderingRules(e),Y(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsAreaAndPerimeter&&(!e.is3D||r.mensuration.supports3D)))throw new a("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=f(ye,e).clone(),this._applyMosaicAndRenderingRules(e),Z(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsDistanceAndAngle&&(!e.is3D||r.mensuration.supports3D)))throw new a("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=f(ge,e).clone(),this._applyMosaicAndRenderingRules(e),ee(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const r=await this._fetchCapabilities(t?.signal);if(!(r.mensuration.supportsPointOrCentroid&&(!e.is3D||r.mensuration.supports3D)))throw new a("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=f(xe,e).clone(),this._applyMosaicAndRenderingRules(e),te(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const r=this.getField(e);return r?r.domain:null}async fetchImage(e,t,r,i={}){if(null==e||null==t||null==r)throw new a("imagery-layer:fetch-image","Insufficient parameters for requesting an image. A valid extent, width and height values are required.");if(this.renderer||this.symbolizer){const e=await this._generateRasterInfo(this.rasterFunction,{signal:i.signal});e&&(this.rasterInfo=e)}const s=this.getExportImageServiceParameters(e,t,r,i.timeExtent);if(null==s){if(i.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=r,i.returnImageBitmap){return{imageBitmap:await F(e,`${je(this.parsedUrl)}/exportImage`,i.signal)}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,o=(s?.length||n.bandCount)??0,a=t*r,l=n.pixelType,u=[];for(let e=0;e<o;e++)u.push(T.createEmptyBand(l,a));return{pixelData:{pixelBlock:new T({width:t,height:r,pixels:u,mask:new Uint8Array(a),pixelType:l}),extent:e}}}const n=!!i.requestAsImageElement&&!this.pixelFilter,o=n&&!!i.returnImageBitmap,l={imageServiceParameters:s,imageProps:{extent:e,width:t,height:r,format:this.format},requestAsImageElement:n,returnImageBitmap:o,signal:i.signal};return this._requestArrayBuffer(l)}fetchKeyProperties(e){return n(je(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 a("#fetchRasterAttributeTable()","Failed to get rasterAttributeTable")):n(je(this.parsedUrl)+"/rasterAttributeTable",{query:this._getQueryParams({renderingRule:this.version>=10.3?e?.rasterFunction:null})}).then((e=>le.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const r={...t,query:this._getQueryParams()};return he(je(this.parsedUrl),e,r)}async getCatalogItemICSInfo(e,t){const{data:r}=await n(je(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),i=r&&r.ics;if(!i)return;let s=null;try{s=(await n(je(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s||!s.spatialReference)return{ics:i,icsToPixelTransform:null,icsExtent:null,northDirection:null};const o=this.version>=10.7?n(je(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},a=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},u=n(je(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,c=(s.xmin+s.xmax)/2,m=(s.ymax-s.ymin)/(p+1),d=s.ymin+m,h=[];for(let n=0;n<p;n++)h.push({x:c,y:d+m*n});const f={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:a.wkid||JSON.stringify(a),outSR:"0:"+e},y=n(je(this.parsedUrl)+"/project",{query:this._getQueryParams(f),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([o,u,y]);let R=g[0].ipxf;if(null==R){const e=i.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const b=oe.fromJSON(g[1]&&g[1].geometries&&g[1].geometries[0]);b&&(b.spatialReference=new _e({wkid:0,imageCoordinateSystem:i}));const v=g[2].geometries?g[2].geometries.filter((e=>null!=e&&null!=e.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],S=v.length;if(S<3)return{ics:i,icsToPixelTransform:R,icsExtent:b,northDirection:null};let x=0,I=0,w=0,_=0;for(let n=0;n<S;n++)x+=v[n].x,I+=v[n].y,w+=v[n].x*v[n].x,_+=v[n].x*v[n].y;const F=(S*_-x*I)/(S*w-x*x);let D=0;const P=v[p-1].x>v[0].x,j=v[p-1].y>v[0].y;return F===1/0?D=j?90:270:0===F?D=P?0:180:F>0?D=P?180*Math.atan(F)/Math.PI:180*Math.atan(F)/Math.PI+180:F<0&&(D=j?180+180*Math.atan(F)/Math.PI:360+180*Math.atan(F)/Math.PI),{ics:i,icsToPixelTransform:R,icsExtent:b,northDirection:D}}async generateRasterInfo(e,t){if(e=f(M,e),this.serviceRasterInfo&&(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e)))return this.serviceRasterInfo;const r=Pe(e);if(!r)throw new a("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[r])return this._functionRasterInfos[r];const i={...t,query:this._getQueryParams()},s=me(je(this.parsedUrl),e,i);this._functionRasterInfos[r]=s;try{return await s}catch(n){throw this._functionRasterInfos[r]=null,n}}getExportImageServiceParameters(e,t,r,i){e=e.clone().shiftCentralMeridian();const s=re(e.spatialReference,je(this.parsedUrl));this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:o,noData:a}=n;let{renderingRule:l}=n;const u=this.rasterFunction?.rasterFunctionDefinition,p=!this.renderer||"raster-stretch"===this.renderer.type;if(o?.length&&this._hasRasterFunction(this.rasterFunction)&&!u&&p){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:o}};if("Stretch"===l.rasterFunction)e.rasterFunctionArguments.Raster=l.rasterFunctionArguments.Raster,l.rasterFunctionArguments.Raster=e;else if("Colormap"===l.rasterFunction){const t=l.rasterFunctionArguments.Raster;"Stretch"===t?.rasterFunction?(e.rasterFunctionArguments.Raster=t.rasterFunctionArguments.Raster,t.rasterFunctionArguments.Raster=e):(e.rasterFunctionArguments.Raster=t,l.rasterFunctionArguments.Raster=e)}else e.rasterFunctionArguments.Raster=l,l=e;n.bandIds=void 0}else n.bandIds=o?.join(",");a instanceof Array&&a.length>0&&(n.noData=a.join(","));const c=this._processMultidimensionalIntersection(null,i,this.exportImageServiceParameters.mosaicRule);if(c.isOutSide)return null;n.mosaicRule=null!=c.mosaicRule?JSON.stringify(c.mosaicRule):null,i=c.timeExtent,n.renderingRule=this._getRenderingRuleString(M.fromJSON(l));const m={};if(null!=i){const{start:e,end:t}=i.toJSON();e&&t&&e===t?m.time=""+e:null==e&&null==t||(m.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+r,...n,...m}}async getSamples(e,t){const r=await this._fetchCapabilities(t?.signal);if(!r?.operations.supportsGetSamples)throw new a("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=f(Ie,e).clone();const{raster:i}=this;return i&&null==e.raster&&(e.raster=i),ie(this.url,e,this._getRequestOptions(t))}async identify(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsIdentify)throw new a("imagery-layer:identify","identify operation is not supported on the input image service");e=f(ve,e).clone();const r=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(r.isOutSide)throw new a("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=r.timeExtent,e.mosaicRule=r.mosaicRule;const{raster:i,rasterFunction:s}=this;return s&&null==e.rasterFunction&&(e.rasterFunction=s),i&&null==e.raster&&(e.raster=i),se(this.url,e,this._getRequestOptions(t))}createQuery(){const e=new ue;return e.outFields=["*"],e.returnGeometry=!0,e.where=this.definitionExpression||"1=1",e}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ne(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),ce(this.url,e,t)}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),pe(this.url,e,t)}async queryVisibleRasters(e,t){if(!e)throw new a("imagery-layer: query-visible-rasters","missing query parameter");await this.load();const{pixelSize:r,returnDomainValues:i,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p="raster.servicepixelvalue",c=this._rasterFunctionNamesIndex;if(null!=e.outFields&&(o=e.outFields.some((e=>!e.toLowerCase().includes(p))),this.version>=10.4)){const t=e.outFields.filter((e=>e.toLowerCase().includes(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 M({functionName:e[0]}))),u=t.map((e=>e[1]));const{rasterFunction:r}=this;0===l.length?r?.functionName?(l.push(r),u.push(r.functionName)):l=null:r?.functionName&&!l.some((e=>e.functionName===r.functionName))&&(l.push(r),u.push(r.functionName))}const m=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:d}=this;let h=e.timeExtent||this.timeExtent;if(d){const{isOutside:t,intersection:r}=q(d,{geometry:e.geometry,timeExtent:e.timeExtent,multidimensionalDefinition:this.exportImageServiceParameters.mosaicRule?.multidimensionalDefinition});if(t)throw new a("imagery-layer:query-visible-rasters","the request cannot be fulfilled when falling outside of the multidimensional subset");r&&null!=r.timeExtent&&(h=r.timeExtent)}const f=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,h),y=this._getQueryParams({geometry:e.geometry,timeExtent:h,mosaicRule:f,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:r,returnCatalogItems:o,returnGeometry:m,raster:this.raster,maxItemCount:s?1:null});delete y.f;const g=new ve(y);try{await this._generateRasterInfo(this.rasterFunction);const r=await se(this.url,g,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,a=null!=r.value&&r.value.toLowerCase().includes("nodata");if(!(o&&!m&&r?.catalogItems?.features.length&&(n||!a)))return this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",p=r.catalogItems?.features??[],c=p.map((e=>e.attributes?.[l])),d=new ue({objectIds:c,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),h=await this.queryRasters(d);return h?.features?.length&&h.features.forEach((t=>{p.forEach((r=>{r.attributes[l]===t.attributes[l]&&(r.geometry=new ae(t.geometry),null!=e.outSpatialReference&&(r.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(r,{returnDomainValues:i,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s})}catch{throw new a("imagery-layer:query-visible-rasters","encountered error when querying visible rasters")}}async fetchVariableStatisticsHistograms(e,t){const r=n(je(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),i=n(je(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([r,i]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(e,t):we(e.meshType,e.simulationSettings,e.flowData,null!=t.signal?t.signal:(new AbortController).signal)}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return E(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,r=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):de(je(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),e))),i=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([r,i,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),u.getLogger(this).warn("ArcGISImageService","Switching to the default renderer. Renderer applied is not valid for this Imagery Layer")),this._set("renderer",this._configRenderer(this.renderer)),this.addHandles([p((()=>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 r=this.timeInfo,{multidimensionalInfo:i}=this.serviceRasterInfo;if(null==e||null==i||null==t||null==r?.startField)return e;const{startField:s}=r,n=i.variables.some((e=>e.dimensions.some((e=>e.name===s))))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter((e=>e.dimensionName!==n)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const o=e.multidimensionalDefinition.filter((e=>e.dimensionName===n)),a=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==a||null==l||a===l,p=u?[a||l]:[[a,l]],c=this.version>=10.8;if(o.length)o.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 x({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 a("imagery-layer:query-rasters","query operation is not supported on the input image service");return e=null!=e?f(ue,e):this.createQuery(),t=this._getRequestOptions(t),this.raster&&(t.query={...t.query,raster:this.raster}),{query:e,requestOptions:t}}async _initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const e=new J;this._rasterJobHandler.connectionPromise=e.initialize().then((()=>{this._rasterJobHandler.instance=e}),(()=>{})),await this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null}_isSupportedRenderer(e){const{rasterInfo:t,rasterFunction:r}=this;return"unique-value"===e.type&&this._hasRasterFunction(r)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&U(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:r,ssl:i}=await n(je(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=r,this.sourceJSON=t,i&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new a("imagery-layer:fetch-service-info","use ImageryTileLayer to open tiles-only image services");this.read(t,{origin:"service",url:this.parsedUrl})}_isMosaicDataset(e){return e.serviceSourceType?"esriImageServiceSourceTypeMosaicDataset"===e.serviceSourceType:e.fields?.length>0}_isMosaicRuleSupported(e){if(!e)return!1;const t=this._isMosaicDataset(e),r=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||r}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:r}=e,i="resample"===t?.toLowerCase(),s=r?.ResampleType||r?.resampleType;return i&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:r}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){if(!this.bandIds&&r.bandCount>=3){const e=z(r);!e||3===r.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=B(r,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=k(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=r):this.symbolizer=new G({rendererJSON:t,rasterInfo:r}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){e&&null!=e.renderingRule&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:r}=this;return{raster:t,viewId:r,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,r){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):H(e,t,r)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;const r=await n(je(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:r,returnImageBitmap:i,signal:s}=e;if(r&&this._canRequestImageElement(t.format)){const r=`${je(this.parsedUrl)}/exportImage`,{data:o}=await n(r,{responseType:i?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:s});if(o instanceof Blob){return{imageBitmap:await F(o,r,s),params:t}}return{imageOrCanvasElement:o,params:t}}const o=this._initJobHandler(),l=n(je(this.parsedUrl)+"/exportImage",{responseType:"array-buffer",query:this._getQueryParams({f:"image",...e.imageServiceParameters}),signal:s}),u=(await Promise.all([l,o]))[0].data,p=t.format||"jpgpng";let c=p;if("bsq"!==c&&"bip"!==c&&(c=Q(u)),!c)throw new a("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const m={signal:s},d="gif"===p||"bmp"===p||p.includes("png")&&("png"===c||"jpg"===c)?H(u,{useCanvas:!0,...t},m):this._decodePixelBlock(u,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:p},m);return{pixelData:{pixelBlock:await d,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=V(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,r){r=r||{};const i=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:o,templateFields:a}=r,l=e.processedValues;let u=e.catalogItems&&e.catalogItems.features,p=e.properties&&e.properties.Values&&e.properties.Values.map((e=>e.replaceAll(/ /gi,", ")))||[];const c=this.objectIdField||"ObjectId",m="string"==typeof i&&i.toLowerCase().includes("nodata"),d=[];if(i&&!u&&!m){const e={};e[c]=0;p=[i],u=[new t(this.fullExtent,null,e)]}if(!u)return[];let h,f,y;this._updateResponseFieldNames(u,a),m&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(h=u[t],null!=i){if(f=p[t],y=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:i,"nodata"===f.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",r="Raster.ServicePixelValue";h.attributes[e]=f,h.attributes[r]=y,this._updateFeatureWithMagDirValues(h,f);const o=this.fields&&this.fields.length>0;let a=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?o?f:i:y;this.rasterFunction||(a=o?f:i),this._updateFeatureWithRasterAttributeTableValues(h,a)}if(h.sourceLayer=h.layer=this,o&&this._updateFeatureWithDomainValues(h),s&&l&&s.length===l.length)for(let e=0;e<s.length;e++){const t="Raster.ServicePixelValue."+s[e];h.attributes[t]=l[e]}d.push(u[t])}return d}_processMultidimensionalIntersection(e,t,r){const{multidimensionalSubset:i}=this;if(!i)return{isOutSide:!1,timeExtent:t,mosaicRule:r=this._combineMosaicRuleWithTimeExtent(r,t)};if(i){const{isOutside:r,intersection:s}=q(i,{geometry:e,timeExtent:t});if(r)return{isOutSide:!0,timeExtent:null,mosaicRule:null};s&&null!=s.timeExtent&&(t=s.timeExtent)}if(null!=(r=this._combineMosaicRuleWithTimeExtent(r,t))&&r.multidimensionalDefinition){const{isOutside:e}=q(i,{multidimensionalDefinition:r.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:r}}_updateFeatureWithRasterAttributeTableValues(e,t){const r=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==r)return;const{features:i,fields:s}=r,n=s.map((e=>e.name)).filter((e=>"value"===e.toLowerCase())),o=n&&n[0];if(!o)return;const a=i.filter((e=>e.attributes[o]===(null!=t?parseInt(t,10):null)));a&&a[0]&&s.forEach((t=>{const r=this._rasterAttributeTableFieldPrefix+t.name;e.attributes[r]=a[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const r=t.split(/,\s*/).map((e=>parseFloat(e))),i=r.map((e=>[e])),s=r.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new T({height:1,width:1,pixelType:"f32",pixels:i,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new oe(0,0,0,0,this.spatialReference)});const o="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:L([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=o[0],e.attributes["Raster.Direction"]=o[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const r=e.attributes[t.name];if(null!=r){const i=t.domain.codedValues.find((e=>e.code===r));i&&(e.attributes[t.name]=i.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const r=this.fieldsIndex;null!=r&&e.forEach((e=>{if(e&&e.attributes)for(const i of t){const t=r.get(i)?.name;t&&t!==i&&(e.attributes[i]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(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&&null!=e.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const r=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(r)?t.get(r):e}_isRFTJson(e){return e&&e.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:r,rasterFunction:i}=this;i&&e instanceof be&&null==e.rasterFunction&&(e.rasterFunction=i),r&&null==e.mosaicRule&&(e.mosaicRule=r),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:r,advancedQueryCapabilities:i,maxRecordCount:s}=e,n=t.includes("image"),o="esriImageServiceDataTypeElevation"===e.serviceDataType,a=!!(e.spatialReference||e.extent&&e.extent.spatialReference),l=t.includes("edit"),u=t.includes("mensuration")&&a,p=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map((e=>e.trim())),c=u&&p.includes("basic");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsMeasure:u,supportsDownload:t.includes("download"),supportsQuery:t.includes("catalog")&&e.fields&&e.fields.length>0,supportsGetSamples:r>=10.2&&n,supportsProject:r>=10.3&&n,supportsComputeStatisticsHistograms:r>=10.4&&n,supportsQueryBoundary:r>=10.6&&n,supportsCalculateVolume:r>=10.7&&o,supportsComputePixelLocation:r>=10.7&&t.includes("catalog"),supportsComputeAngles:r>=10.91,supportsAdd:l,supportsDelete:l,supportsEditing:l,supportsUpdate:l,supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsChangeTracking:!1,supportsQueryAttachments:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsExceedsLimitStatistics:!1,supportsQueryAnalytics:!1,supportsQueryTopFeatures:!1,supportsAsyncConvert3D:!1},query:{maxRecordCount:s,maxRecordCountFactor:void 0,supportsStatistics:!!i?.supportsStatistics,supportsOrderBy:!!i?.supportsOrderBy,supportsDistinct:!!i?.supportsDistinct,supportsPagination:!!i?.supportsPagination,supportsStandardizedQueriesOnly:!!i?.useStandardizedQueries,supportsPercentileStatistics:!!i?.supportsPercentileStatistics,supportsCentroid:!!i?.supportsReturningGeometryCentroid,supportsDistance:!!i?.supportsQueryWithDistance,supportsExtent:!!i?.supportsReturningQueryExtent,supportsGeometryProperties:!!i?.supportsReturningGeometryProperties,supportsHavingClause:!!i?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!i?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0},mensuration:{supportsDistanceAndAngle:c,supportsAreaAndPerimeter:c,supportsPointOrCentroid:c,supportsHeightFromBaseAndTop:u&&p.includes("base-top height"),supportsHeightFromBaseAndTopShadow:u&&p.includes("base-top shadow height"),supportsHeightFromTopAndTopShadow:u&&p.includes("top-top shadow height"),supports3D:u&&p.includes("3d")}}}};function je(e){return e?.path??""}return e([m()],y.prototype,"_functionRasterInfos",void 0),e([m()],y.prototype,"_rasterJobHandler",void 0),e([m()],y.prototype,"_cachedRendererJson",void 0),e([m({readOnly:!0})],y.prototype,"_serviceSupportsMosaicRule",void 0),e([g("_serviceSupportsMosaicRule",["currentVersion","fields"])],y.prototype,"readServiceSupportsMosaicRule",null),e([m()],y.prototype,"_rasterAttributeTableFieldPrefix",void 0),e([m({readOnly:!0})],y.prototype,"_rasterFunctionNamesIndex",null),e([m()],y.prototype,"adjustAspectRatio",void 0),e([m({type:[h],json:{write:!0}})],y.prototype,"bandIds",void 0),e([g("bandIds")],y.prototype,"readBandIds",null),e([m({readOnly:!0,json:{read:!1}})],y.prototype,"capabilities",void 0),e([g("service","capabilities",["capabilities","currentVersion","serviceDataType"])],y.prototype,"readCapabilities",null),e([m({type:Number})],y.prototype,"compressionQuality",void 0),e([b("compressionQuality")],y.prototype,"writeCompressionQuality",null),e([m({type:Number})],y.prototype,"compressionTolerance",void 0),e([b("compressionTolerance")],y.prototype,"writeCompressionTolerance",null),e([m({json:{read:{source:"copyrightText"}}})],y.prototype,"copyright",void 0),e([m({readOnly:!0,dependsOn:["_serviceSupportsMosaicRule"]})],y.prototype,"defaultMosaicRule",void 0),e([g("defaultMosaicRule",["defaultMosaicMethod"])],y.prototype,"readDefaultMosaicRule",null),e([m({type:String,json:{name:"layerDefinition.definitionExpression",write:{enabled:!0,allowNull:!0}}})],y.prototype,"definitionExpression",void 0),e([m({readOnly:!0,constructOnly:!0})],y.prototype,"exportImageServiceParameters",void 0),e([m()],y.prototype,"rasterInfo",void 0),e([m({readOnly:!0,type:[w]})],y.prototype,"fields",void 0),e([m({readOnly:!0})],y.prototype,"fieldsIndex",null),e([m({type:["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"],json:{write:!0}})],y.prototype,"format",null),e([g("service","format",["serviceDataType"])],y.prototype,"readFormat",null),e([m({type:oe})],y.prototype,"fullExtent",void 0),e([m({readOnly:!0})],y.prototype,"hasMultidimensions",void 0),e([m({json:{read:{source:"maxImageHeight"}}})],y.prototype,"imageMaxHeight",void 0),e([m({json:{read:{source:"maxImageWidth"}}})],y.prototype,"imageMaxWidth",void 0),e([m({type:String,json:{type:O.jsonValues,read:O.read,write:O.write}})],y.prototype,"interpolation",void 0),e([m()],y.prototype,"minScale",void 0),e([g("service","minScale")],y.prototype,"readMinScale",null),e([m()],y.prototype,"maxScale",void 0),e([g("service","maxScale")],y.prototype,"readMaxScale",null),e([m({type:P})],y.prototype,"mosaicRule",null),e([g("mosaicRule",["mosaicRule","defaultMosaicMethod"])],y.prototype,"readMosaicRule",null),e([b("mosaicRule")],y.prototype,"writeMosaicRule",null),e([m()],y.prototype,"multidimensionalInfo",void 0),e([m({type:j,json:{write:!0}})],y.prototype,"multidimensionalSubset",void 0),e([m({json:{type:h}})],y.prototype,"noData",void 0),e([b("noData")],y.prototype,"writeNoData",null),e([m({type:String,json:{type:C.jsonValues,read:C.read,write:C.write}})],y.prototype,"noDataInterpretation",void 0),e([m({type:String,readOnly:!0,json:{read:{source:["fields"]}}})],y.prototype,"objectIdField",void 0),e([g("objectIdField")],y.prototype,"readObjectIdField",null),e([m({})],y.prototype,"geometryType",void 0),e([m({})],y.prototype,"typeIdField",void 0),e([m({})],y.prototype,"types",void 0),e([m({readOnly:!0})],y.prototype,"parsedUrl",null),e([m({type:Function})],y.prototype,"pixelFilter",void 0),e([m()],y.prototype,"raster",void 0),e([m({readOnly:!0})],y.prototype,"sourceType",void 0),e([g("sourceType",["serviceSourceType","fields"])],y.prototype,"readSourceType",null),e([m()],y.prototype,"viewId",void 0),e([m({types:r,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:i,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],y.prototype,"renderer",null),e([g("renderer")],y.prototype,"readRenderer",null),e([b("renderer")],y.prototype,"writeRenderer",null),e([m()],y.prototype,"symbolizer",void 0),e([m(v)],y.prototype,"opacity",void 0),e([m({readOnly:!0})],y.prototype,"rasterFields",null),e([m({constructOnly:!0})],y.prototype,"rasterFunctionInfos",void 0),e([m({type:M})],y.prototype,"renderingRule",null),e([m({type:M,json:{name:"renderingRule"}})],y.prototype,"rasterFunction",null),e([g("rasterFunction",["renderingRule","rasterFunctionInfos"])],y.prototype,"readRasterFunction",null),e([m()],y.prototype,"serviceDataType",void 0),e([m({readOnly:!0,type:_e})],y.prototype,"spatialReference",void 0),e([g("spatialReference",["spatialReference","extent"])],y.prototype,"readSpatialReference",null),e([m({json:{type:N.jsonValues}})],y.prototype,"pixelType",void 0),e([g("pixelType")],y.prototype,"readPixelType",null),e([b("pixelType")],y.prototype,"writePixelType",null),e([m({constructOnly:!0,type:A})],y.prototype,"serviceRasterInfo",void 0),e([m()],y.prototype,"sourceJSON",void 0),e([m(S)],y.prototype,"url",void 0),e([m({readOnly:!0})],y.prototype,"version",void 0),e([g("version",["currentVersion","fields","timeInfo"])],y.prototype,"readVersion",null),y=e([R("esri.layers.mixins.ArcGISImageService")],y),y};export{je as ArcGISImageService};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{rasterRendererTypes as e,websceneRasterRendererTypes as r,read as i}from"../../rasterRenderers.js";import n from"../../request.js";import s from"../../core/Error.js";import o from"../../core/Logger.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{ensureClass as l}from"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as u}from"../../core/accessorSupport/decorators/reader.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getInfo as d}from"../../geometry/support/spatialReferenceUtils.js";import{sanitizeUrl as m}from"../support/arcgisLayerUrl.js";import{url as h}from"../support/commonProperties.js";import p from"../support/DimensionalDefinition.js";import f from"../support/MultidimensionalSubset.js";import y from"../support/RasterFunction.js";import b from"../support/RasterJobHandler.js";import g from"../support/TileInfo.js";import F from"../support/rasterDatasets/FunctionRaster.js";import{getDefaultMultidimensionalDefinition as J,hasExcludedVariableOrDimension as R,getDefaultVariablInfo as _,isMultiSliceOrRangeDefinition as I,getSubsetVariablesFromMdInfo as S}from"../support/rasterDatasets/multidimensionalUtils.js";import{snapToRaster as x,clip as w}from"../support/rasterFunctions/clipUtils.js";import{create as v}from"../support/rasterFunctions/rasterFunctionHelper.js";import{load as j,projectExtent as D,projectPolygon as H}from"../support/rasterFunctions/rasterProjectionHelper.js";import{computeStatisticsHistograms as T}from"../support/rasterFunctions/stretchUtils.js";import{convertVectorFieldData as N}from"../support/rasterFunctions/vectorFieldUtils.js";import{normalizeRendererJSON as O,getVariableRasterInfo as z,getDefaultInterpolation as P,getDefaultBandCombination as C,createDefaultRenderer as E}from"../../renderers/support/rasterRendererHelper.js";import A from"../../renderers/support/RasterSymbolizer.js";import M from"../../rest/support/ImageHistogramParameters.js";import{createFlowMesh as U}from"../../views/2d/engine/flow/dataUtils.js";import k from"../../geometry/SpatialReference.js";import q from"../../geometry/Point.js";const B=o.getLogger("esri.layers.mixins.ImageryTileMixin"),V=o=>{let V=class extends o{constructor(...t){super(...t),this._isConstructedFromFunctionRaster=!1,this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.interpolation="nearest",this.multidimensionalSubset=null,this.raster=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster="Function"===t[0]?.raster?.datasetFormat}get fullExtent(){return this.rasterInfo?.extent}set multidimensionalDefinition(t){this._set("multidimensionalDefinition",t),this.updateRenderer()}set rasterFunction(t){this._set("rasterFunction",t),this.updateRasterFunction()}set url(t){this._set("url",m(t,B))}set renderer(t){null==t&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("renderer",t),this.updateRenderer())}readRenderer(t,e,r){const n=e?.layerDefinition?.drawingInfo?.renderer;return i(n,r)||void 0}async convertVectorFieldData(t,e){if(null==t||!this.rasterInfo)return null;const r=this._rasterJobHandler.instance,i=this.rasterInfo.dataType;return r?r.convertVectorFieldData({pixelBlock:t,dataType:i},e):N(t,i)}async computeStatisticsHistograms(t,e){t=l(M,t).clone();const{rasterInfo:r}=this,{geometry:i}=t;if(null==i)throw new s("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let n=i;const{spatialReference:o}=r;i.spatialReference.equals(o)||(await j(),n="extent"===i.type?D(i,o):H(i,o));const a=t.pixelSize??new q({x:r.pixelSize.x,y:r.pixelSize.y,spatialReference:o}),{extent:u,width:c,height:d}=x(r,n,a),m=await this.fetchPixels(u,c,d,{...e,interpolation:"nearest"});if(null==m.pixelBlock)throw new s("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const h=await w(m.pixelBlock,u,n),p=this._rasterJobHandler.instance;return p?p.computeStatisticsHistograms({pixelBlock:h},e):T(h)}async createFlowMesh(t,e){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(t,e):U(t.meshType,t.simulationSettings,t.flowData,null!=e.signal?e.signal:(new AbortController).signal)}normalizeRasterFetchOptions(t){const{multidimensionalInfo:e}=this.rasterInfo??{};if(null==e)return t;let r=t.multidimensionalDefinition||this.multidimensionalDefinition;null!=r&&r.length||(r=J(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const i=t.timeExtent||this.timeExtent;if(null!=r&&null!=i&&(null!=i.start||null!=i.end)){r=r.map((t=>t.clone()));const n=e.variables.find((({name:t})=>t===r[0].variableName))?.dimensions?.find((({name:t})=>"StdTime"===t)),s=r.find((({dimensionName:t})=>"StdTime"===t));if(!n||!s)return{...t,multidimensionalDefinition:null};const{start:o,end:a}=i,l=null==o?null:o.getTime(),u=null==a?null:a.getTime(),c=l??u,d=u??l;if(null!=n.values){const t=n.values.filter((t=>{if(Array.isArray(t)){if(c===d)return t[0]<=c&&t[1]>=c;const e=t[0]<=c&&t[1]>c||t[0]<d&&t[1]>=d,r=t[0]>=c&&t[1]<=d||t[0]<c&&t[1]>d;return e||r}return c===d?t===c:t>=c&&t<=d}));if(t.length){const e=t.sort(((t,e)=>{const r=Array.isArray(t)?t[0]:t,i=Array.isArray(t)?t[1]:t,n=Array.isArray(e)?e[0]:e,s=Array.isArray(e)?e[1]:e;if(c===d)return r-n;return Math.abs(i-d)-Math.abs(s-d)}))[0];s.values=[e]}else r=null}else if(n.hasRegularIntervals&&n.extent){const[t,e]=n.extent;c>e||d<t?r=null:s.values=c===d?[c]:[Math.max(t,c),Math.min(e,d)]}}return null!=r&&R(r,this.multidimensionalSubset)?{...t,multidimensionalDefinition:null}:{...t,multidimensionalDefinition:r}}async updateRasterFunction(){if(!this.loaded||"imagery-tile"!==this.type||!this.rasterFunction&&!this._cachedRasterFunctionJson||JSON.stringify(this.rasterFunction)===JSON.stringify(this._cachedRasterFunctionJson))return;if(this._isConstructedFromFunctionRaster&&"Function"===this.raster.datasetFormat){const t=this.raster.rasterFunction.toJSON();return!this.rasterFunction&&t&&this._set("rasterFunction",y.fromJSON(t)),void(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON())}let t,e=this.raster,r=!1;"Function"===e.datasetFormat?(t=e.primaryRasters.rasters,e=t[0],r=!0):t=[e];const{rasterFunction:i}=this;if(i){const r={raster:e};t.length>1&&t.forEach((t=>r[t.url]=t));const n=v(i.functionDefinition?.toJSON()??i.toJSON(),r),s=new F({rasterFunction:n});s.rasterJobHandler=this._rasterJobHandler.instance,await s.open(),this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this.raster=s}else this.raster=e,this._cachedRasterFunctionJson=null,await e.when();if(this._cachedRendererJson=null,!r&&!i)return;const{bandIds:n}=this,{bandCount:s}=this.raster.rasterInfo,o=n?.length?n.some((t=>t>=s)):s>=3;n&&(o||this.renderer&&"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}async updateRenderer(){const{loaded:t,symbolizer:e}=this;if(!t||!e||!this.renderer)return;const{rasterInfo:r}=this.raster,i=_(r,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=i?.name,s=O({...this.renderer.toJSON(),variableName:n});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(s))return;const o=this._rasterJobHandler.instance;o&&(e.rasterInfo=z(r,n),e.rendererJSON=s,e.bind(),await o.updateSymbolizer(e),this._cachedRendererJson=s)}async applyRenderer(t,e){const r=t&&t.pixelBlock;if(!(null!=r&&r.pixels&&r.pixels.length>0))return null;let i;await this.updateRenderer();const n=this._rasterJobHandler.instance,s=this.bandIds??[];return i=n?await n.symbolize({...t,simpleStretchParams:e,bandIds:s}):this.symbolizer.symbolize({...t,simpleStretchParams:e,bandIds:s}),i}getTileUrl(t,e,r){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${t}/${e}/${r}`:""}getCompatibleTileInfo(t,e,r=!1){if(!this.loaded||null==e)return null;if(r&&t.equals(this.spatialReference))return this.tileInfo;const i=d(t);return g.create({size:256,spatialReference:t,origin:i?{x:i.origin[0],y:i.origin[1]}:{x:e.xmin,y:e.ymax}})}getCompatibleFullExtent(t){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(t)||(this._compatibleFullExtent=this.raster.computeExtent(t)),this._compatibleFullExtent):null}async fetchTile(t,e,r,i={}){if($(this),i.requestAsImageElement){const s=this.getTileUrl(t,e,r);return n(s,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:i.signal}).then((t=>t.data))}const{rasterInfo:s}=this;if(null!=s.multidimensionalInfo&&null==(i=this.normalizeRasterFetchOptions(i)).multidimensionalDefinition){const n=i.tileInfo||s.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(t,e,r,n),pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer?.type&&(i={...i,buffer:{cols:1,rows:1}}),this.raster.fetchTile(t,e,r,i)}async fetchPixels(t,e,r,i={}){return null!=this.rasterInfo.multidimensionalInfo&&null==(i=this.normalizeRasterFetchOptions(i)).multidimensionalDefinition?{extent:t,pixelBlock:null}:(await this._initJobHandler(),await this.updateRasterFunction(),e=Math.round(e),r=Math.round(r),this.raster.fetchPixels(t,e,r,i))}async identify(t,e={}){const{raster:r,rasterInfo:i}=this;if(null!=i.multidimensionalInfo){if(!(i.hasMultidimensionalTranspose&&!!(I(e.multidimensionalDefinition)||e.transposedVariableName||e.timeExtent))&&null==(e=this.normalizeRasterFetchOptions(e)).multidimensionalDefinition)return{location:t,value:null}}const n=this.multidimensionalSubset?.areaOfInterest;if(n&&!n.contains(t))throw new s("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");return r.identify(t,e)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){const t=this.rasterInfo?.multidimensionalInfo;if(null==t||"standard-time"!==this.rasterInfo?.dataType)return!1;const e=this.multidimensionalDefinition,r=e?.[0]?.variableName;return t.variables.some((t=>t.name===r&&(!e?.[0].dimensionName||t.dimensions.some((t=>"StdTime"===t.name)))))}getStandardTimeValue(t){return new Date(24*(t-25569)*3600*1e3).toString()}getMultidimensionalSubsetVariables(t){const e=t??this.rasterInfo?.multidimensionalInfo;return S(this.multidimensionalSubset,e)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=J(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this.rasterFunction&&"Function"===this.raster.datasetFormat&&(this._cachedRasterFunctionJson=this.rasterFunction.toJSON()),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const t=new b;return this._rasterJobHandler.connectionPromise=t.initialize().then((async()=>{$(this),this._rasterJobHandler.instance=t,this.raster.rasterJobHandler=t,"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler(),this.rasterFunction&&await this.updateRasterFunction().catch((()=>{})),this.renderer&&this.updateRenderer()})).catch((()=>{})),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null,this.raster&&(this.raster.rasterJobHandler=null)}_configDefaultInterpolation(){if(null==this.interpolation){$(this);const{raster:t}=this,e=P(t.rasterInfo,t.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",e)}}_configDefaultRenderer(t="no"){$(this);const{rasterInfo:e}=this.raster;!this.bandIds&&e.bandCount>1&&(this.bandIds=C(e));const r=_(e,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),i=r?.name;if(!this.renderer||"override"===t){const t=E(e,{bandIds:this.bandIds,variableName:i}),r=e.statistics,n=r&&r.length>0?r[0]:null,s=n?.max??0,o=n?.min??0;"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===t.type&&(s>1e24||o<-1e24)&&(t.dynamicRangeAdjustment=!0,t.statistics=null,"none"===t.stretchType&&(t.stretchType="min-max")),this.renderer=t}const n=O({...this.renderer.toJSON(),variableName:i}),s=z(e,i);this.symbolizer?(this.symbolizer.rendererJSON=n,this.symbolizer.rasterInfo=s):this.symbolizer=new A({rendererJSON:n,rasterInfo:s});const o=this.symbolizer.bind();if(o.success){if("auto"===t){const{colormap:t}=this.raster.rasterInfo,e=this.renderer;if(null!=t&&"raster-colormap"===e.type){const t=E(this.raster.rasterInfo);JSON.stringify(t)!==JSON.stringify(e)&&this._configDefaultRenderer("override")}else if("raster-stretch"===e.type){const t=this.bandIds?.length,r=e.statistics?.length;!e.dynamicRangeAdjustment&&r&&t&&r!==t&&this._configDefaultRenderer("override")}}}else B.warn("imagery-tile-mixin",o.error||"The given renderer is not supported by the layer."),"auto"===t&&this._configDefaultRenderer("override")}};function $(t){if(!t.raster||!t.rasterInfo)throw new s("imagery-tile","no raster")}return t([a()],V.prototype,"_cachedRendererJson",void 0),t([a()],V.prototype,"_cachedRasterFunctionJson",void 0),t([a()],V.prototype,"_compatibleFullExtent",void 0),t([a()],V.prototype,"_isConstructedFromFunctionRaster",void 0),t([a()],V.prototype,"_rasterJobHandler",void 0),t([a()],V.prototype,"bandIds",void 0),t([a({json:{origins:{service:{read:{source:"copyrightText"}}}}})],V.prototype,"copyright",void 0),t([a({json:{read:!1}})],V.prototype,"fullExtent",null),t([a()],V.prototype,"interpolation",void 0),t([a()],V.prototype,"ioConfig",void 0),t([a({type:[p],json:{write:!0}})],V.prototype,"multidimensionalDefinition",null),t([a({type:f,json:{write:!0}})],V.prototype,"multidimensionalSubset",void 0),t([a()],V.prototype,"raster",void 0),t([a({type:y,json:{name:"renderingRule",write:!0}})],V.prototype,"rasterFunction",null),t([a()],V.prototype,"rasterInfo",void 0),t([a()],V.prototype,"sourceJSON",void 0),t([a({readOnly:!0,type:k,json:{read:!1}})],V.prototype,"spatialReference",void 0),t([a({type:g})],V.prototype,"tileInfo",void 0),t([a(h)],V.prototype,"url",null),t([a({types:e,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(){const t="raster-stretch"===this.renderer?.type&&"none"===this.renderer.stretchType&&!this.renderer.useGamma;return{enabled:!this.loaded||"Raster"===this.raster.tileType||!t}}},origins:{"web-scene":{types:r,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:t=>({enabled:t&&"vector-field"!==t.type&&"flow"!==t.type})}}}}})],V.prototype,"renderer",null),t([u("renderer")],V.prototype,"readRenderer",null),t([a()],V.prototype,"symbolizer",void 0),V=t([c("esri.layers.ImageryTileMixin")],V),V};export{V as ImageryTileMixin};
5
+ import{_ as t}from"../../chunks/tslib.es6.js";import"../../geometry.js";import{rasterRendererTypes as e,websceneRasterRendererTypes as r,read as i}from"../../rasterRenderers.js";import n from"../../request.js";import s from"../../core/Error.js";import o from"../../core/Logger.js";import{property as a}from"../../core/accessorSupport/decorators/property.js";import{ensureClass as l}from"../../core/accessorSupport/ensureType.js";import"../../core/arrayUtils.js";import"../../core/has.js";import{reader as u}from"../../core/accessorSupport/decorators/reader.js";import{subclass as c}from"../../core/accessorSupport/decorators/subclass.js";import{getInfo as d}from"../../geometry/support/spatialReferenceUtils.js";import{sanitizeUrl as m}from"../support/arcgisLayerUrl.js";import{url as h}from"../support/commonProperties.js";import p from"../support/DimensionalDefinition.js";import f from"../support/MultidimensionalSubset.js";import y from"../support/RasterFunction.js";import b from"../support/RasterJobHandler.js";import g from"../support/TileInfo.js";import F from"../support/rasterDatasets/FunctionRaster.js";import{getDefaultMultidimensionalDefinition as J,hasExcludedVariableOrDimension as R,getDefaultVariablInfo as _,isMultiSliceOrRangeDefinition as I,getSubsetVariablesFromMdInfo as S}from"../support/rasterDatasets/multidimensionalUtils.js";import{snapToRaster as x,clip as w}from"../support/rasterFunctions/clipUtils.js";import{create as v}from"../support/rasterFunctions/rasterFunctionHelper.js";import{load as j,projectExtent as D,projectPolygon as H}from"../support/rasterFunctions/rasterProjectionHelper.js";import{computeStatisticsHistograms as T}from"../support/rasterFunctions/stretchUtils.js";import{convertVectorFieldData as N}from"../support/rasterFunctions/vectorFieldUtils.js";import{normalizeRendererJSON as O,getVariableRasterInfo as z,getDefaultInterpolation as P,getDefaultBandCombination as C,createDefaultRenderer as E}from"../../renderers/support/rasterRendererHelper.js";import A from"../../renderers/support/RasterSymbolizer.js";import M from"../../rest/support/ImageHistogramParameters.js";import{createFlowMesh as U}from"../../views/2d/engine/flow/dataUtils.js";import k from"../../geometry/SpatialReference.js";import q from"../../geometry/Point.js";const B=o.getLogger("esri.layers.mixins.ImageryTileMixin"),V=o=>{let V=class extends o{constructor(...t){super(...t),this._isConstructedFromFunctionRaster=!1,this._rasterJobHandler={instance:null,refCount:0,connectionPromise:null},this.bandIds=null,this.copyright=null,this.interpolation="nearest",this.multidimensionalSubset=null,this.raster=null,this.rasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster="Function"===t[0]?.raster?.datasetFormat}get fullExtent(){return this.rasterInfo?.extent}set multidimensionalDefinition(t){this._set("multidimensionalDefinition",t),this.updateRenderer()}set rasterFunction(t){"none"===t?.functionName?.toLowerCase()&&(t=void 0),this._set("rasterFunction",t),this.updateRasterFunction()}set url(t){this._set("url",m(t,B))}set renderer(t){null==t&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("renderer",t),this.updateRenderer())}readRenderer(t,e,r){const n=e?.layerDefinition?.drawingInfo?.renderer;return i(n,r)||void 0}async convertVectorFieldData(t,e){if(null==t||!this.rasterInfo)return null;const r=this._rasterJobHandler.instance,i=this.rasterInfo.dataType;return r?r.convertVectorFieldData({pixelBlock:t,dataType:i},e):N(t,i)}async computeStatisticsHistograms(t,e){t=l(M,t).clone();const{rasterInfo:r}=this,{geometry:i}=t;if(null==i)throw new s("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let n=i;const{spatialReference:o}=r;i.spatialReference.equals(o)||(await j(),n="extent"===i.type?D(i,o):H(i,o));const a=t.pixelSize??new q({x:r.pixelSize.x,y:r.pixelSize.y,spatialReference:o}),{extent:u,width:c,height:d}=x(r,n,a),m=await this.fetchPixels(u,c,d,{...e,interpolation:"nearest"});if(null==m.pixelBlock)throw new s("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const h=await w(m.pixelBlock,u,n),p=this._rasterJobHandler.instance;return p?p.computeStatisticsHistograms({pixelBlock:h},e):T(h)}async createFlowMesh(t,e){const r=this._rasterJobHandler.instance;return r?r.createFlowMesh(t,e):U(t.meshType,t.simulationSettings,t.flowData,null!=e.signal?e.signal:(new AbortController).signal)}normalizeRasterFetchOptions(t){const{multidimensionalInfo:e}=this.rasterInfo??{};if(null==e)return t;let r=t.multidimensionalDefinition||this.multidimensionalDefinition;null!=r&&r.length||(r=J(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset}));const i=t.timeExtent||this.timeExtent;if(null!=r&&null!=i&&(null!=i.start||null!=i.end)){r=r.map((t=>t.clone()));const n=e.variables.find((({name:t})=>t===r[0].variableName))?.dimensions?.find((({name:t})=>"StdTime"===t)),s=r.find((({dimensionName:t})=>"StdTime"===t));if(!n||!s)return{...t,multidimensionalDefinition:null};const{start:o,end:a}=i,l=null==o?null:o.getTime(),u=null==a?null:a.getTime(),c=l??u,d=u??l;if(null!=n.values){const t=n.values.filter((t=>{if(Array.isArray(t)){if(c===d)return t[0]<=c&&t[1]>=c;const e=t[0]<=c&&t[1]>c||t[0]<d&&t[1]>=d,r=t[0]>=c&&t[1]<=d||t[0]<c&&t[1]>d;return e||r}return c===d?t===c:t>=c&&t<=d}));if(t.length){const e=t.sort(((t,e)=>{const r=Array.isArray(t)?t[0]:t,i=Array.isArray(t)?t[1]:t,n=Array.isArray(e)?e[0]:e,s=Array.isArray(e)?e[1]:e;if(c===d)return r-n;return Math.abs(i-d)-Math.abs(s-d)}))[0];s.values=[e]}else r=null}else if(n.hasRegularIntervals&&n.extent){const[t,e]=n.extent;c>e||d<t?r=null:s.values=c===d?[c]:[Math.max(t,c),Math.min(e,d)]}}return null!=r&&R(r,this.multidimensionalSubset)?{...t,multidimensionalDefinition:null}:{...t,multidimensionalDefinition:r}}async updateRasterFunction(){if(!this.loaded||"imagery-tile"!==this.type||!this.rasterFunction&&!this._cachedRasterFunctionJson||JSON.stringify(this.rasterFunction)===JSON.stringify(this._cachedRasterFunctionJson))return;if(this._isConstructedFromFunctionRaster&&"Function"===this.raster.datasetFormat){const t=this.raster.rasterFunction.toJSON();return!this.rasterFunction&&t&&this._set("rasterFunction",y.fromJSON(t)),void(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON())}let t,e=this.raster,r=!1;"Function"===e.datasetFormat?(t=e.primaryRasters.rasters,e=t[0],r=!0):t=[e];const{rasterFunction:i}=this;if(i){const r={raster:e};t.length>1&&t.forEach((t=>r[t.url]=t));const n=v(i.functionDefinition?.toJSON()??i.toJSON(),r),s=new F({rasterFunction:n});s.rasterJobHandler=this._rasterJobHandler.instance,await s.open(),this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this.raster=s}else this.raster=e,this._cachedRasterFunctionJson=null,await e.when();if(this._cachedRendererJson=null,!r&&!i)return;const{bandIds:n}=this,{bandCount:s}=this.raster.rasterInfo,o=n?.length?n.some((t=>t>=s)):s>=3;n&&(o||this.renderer&&"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}async updateRenderer(){const{loaded:t,symbolizer:e}=this;if(!t||!e||!this.renderer)return;const{rasterInfo:r}=this.raster,i=_(r,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=i?.name,s=O({...this.renderer.toJSON(),variableName:n});if(JSON.stringify(this._cachedRendererJson)===JSON.stringify(s))return;const o=this._rasterJobHandler.instance;o&&(e.rasterInfo=z(r,n),e.rendererJSON=s,e.bind(),await o.updateSymbolizer(e),this._cachedRendererJson=s)}async applyRenderer(t,e){const r=t&&t.pixelBlock;if(!(null!=r&&r.pixels&&r.pixels.length>0))return null;let i;await this.updateRenderer();const n=this._rasterJobHandler.instance,s=this.bandIds??[];return i=n?await n.symbolize({...t,simpleStretchParams:e,bandIds:s}):this.symbolizer.symbolize({...t,simpleStretchParams:e,bandIds:s}),i}getTileUrl(t,e,r){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${t}/${e}/${r}`:""}getCompatibleTileInfo(t,e,r=!1){if(!this.loaded||null==e)return null;if(r&&t.equals(this.spatialReference))return this.tileInfo;const i=d(t);return g.create({size:256,spatialReference:t,origin:i?{x:i.origin[0],y:i.origin[1]}:{x:e.xmin,y:e.ymax}})}getCompatibleFullExtent(t){return this.loaded?(this._compatibleFullExtent&&this._compatibleFullExtent.spatialReference.equals(t)||(this._compatibleFullExtent=this.raster.computeExtent(t)),this._compatibleFullExtent):null}async fetchTile(t,e,r,i={}){if(L(this),i.requestAsImageElement){const s=this.getTileUrl(t,e,r);return n(s,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:i.signal}).then((t=>t.data))}const{rasterInfo:s}=this;if(null!=s.multidimensionalInfo&&null==(i=this.normalizeRasterFetchOptions(i)).multidimensionalDefinition){const n=i.tileInfo||s.storageInfo.tileInfo;return{extent:this.raster.getTileExtentFromTileInfo(t,e,r,n),pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer?.type&&(i={...i,buffer:{cols:1,rows:1}}),this.raster.fetchTile(t,e,r,i)}async fetchPixels(t,e,r,i={}){return null!=this.rasterInfo.multidimensionalInfo&&null==(i=this.normalizeRasterFetchOptions(i)).multidimensionalDefinition?{extent:t,pixelBlock:null}:(await this._initJobHandler(),await this.updateRasterFunction(),e=Math.round(e),r=Math.round(r),this.raster.fetchPixels(t,e,r,i))}async identify(t,e={}){const{raster:r,rasterInfo:i}=this;if(null!=i.multidimensionalInfo){if(!(i.hasMultidimensionalTranspose&&!!(I(e.multidimensionalDefinition)||e.transposedVariableName||e.timeExtent))&&null==(e=this.normalizeRasterFetchOptions(e)).multidimensionalDefinition)return{location:t,value:null}}const n=this.multidimensionalSubset?.areaOfInterest;if(n&&!n.contains(t))throw new s("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");return r.identify(t,e)}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}hasStandardTime(){const t=this.rasterInfo?.multidimensionalInfo;if(null==t||"standard-time"!==this.rasterInfo?.dataType)return!1;const e=this.multidimensionalDefinition,r=e?.[0]?.variableName;return t.variables.some((t=>t.name===r&&(!e?.[0].dimensionName||t.dimensions.some((t=>"StdTime"===t.name)))))}getStandardTimeValue(t){return new Date(24*(t-25569)*3600*1e3).toString()}getMultidimensionalSubsetVariables(t){const e=t??this.rasterInfo?.multidimensionalInfo;return S(this.multidimensionalSubset,e)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=J(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this.rasterFunction&&"Function"===this.raster.datasetFormat&&(this._cachedRasterFunctionJson=this.rasterFunction.toJSON()),this._configDefaultRenderer()}_initJobHandler(){if(null!=this._rasterJobHandler.connectionPromise)return this._rasterJobHandler.connectionPromise;const t=new b;return this._rasterJobHandler.connectionPromise=t.initialize().then((async()=>{L(this),this._rasterJobHandler.instance=t,this.raster.rasterJobHandler=t,"Function"===this.raster.datasetFormat&&this.raster.syncJobHandler(),this.rasterFunction&&await this.updateRasterFunction().catch((()=>{})),this.renderer&&this.updateRenderer()})).catch((()=>{})),this._rasterJobHandler.connectionPromise}_shutdownJobHandler(){this._rasterJobHandler.instance&&this._rasterJobHandler.instance.destroy(),this._rasterJobHandler.instance=null,this._rasterJobHandler.connectionPromise=null,this._rasterJobHandler.refCount=0,this._cachedRendererJson=null,this.raster&&(this.raster.rasterJobHandler=null)}_configDefaultInterpolation(){if(null==this.interpolation){L(this);const{raster:t}=this,e=P(t.rasterInfo,t.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",e)}}_configDefaultRenderer(t="no"){L(this);const{rasterInfo:e}=this.raster;!this.bandIds&&e.bandCount>1&&(this.bandIds=C(e));const r=_(e,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),i=r?.name;if(!this.renderer||"override"===t){const t=E(e,{bandIds:this.bandIds,variableName:i}),r=e.statistics,n=r&&r.length>0?r[0]:null,s=n?.max??0,o=n?.min??0;"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===t.type&&(s>1e24||o<-1e24)&&(t.dynamicRangeAdjustment=!0,t.statistics=null,"none"===t.stretchType&&(t.stretchType="min-max")),this.renderer=t}const n=O({...this.renderer.toJSON(),variableName:i}),s=z(e,i);this.symbolizer?(this.symbolizer.rendererJSON=n,this.symbolizer.rasterInfo=s):this.symbolizer=new A({rendererJSON:n,rasterInfo:s});const o=this.symbolizer.bind();if(o.success){if("auto"===t){const{colormap:t}=this.raster.rasterInfo,e=this.renderer;if(null!=t&&"raster-colormap"===e.type){const t=E(this.raster.rasterInfo);JSON.stringify(t)!==JSON.stringify(e)&&this._configDefaultRenderer("override")}else if("raster-stretch"===e.type){const t=this.bandIds?.length,r=e.statistics?.length;!e.dynamicRangeAdjustment&&r&&t&&r!==t&&this._configDefaultRenderer("override")}}}else B.warn("imagery-tile-mixin",o.error||"The given renderer is not supported by the layer."),"auto"===t&&this._configDefaultRenderer("override")}};function L(t){if(!t.raster||!t.rasterInfo)throw new s("imagery-tile","no raster")}return t([a()],V.prototype,"_cachedRendererJson",void 0),t([a()],V.prototype,"_cachedRasterFunctionJson",void 0),t([a()],V.prototype,"_compatibleFullExtent",void 0),t([a()],V.prototype,"_isConstructedFromFunctionRaster",void 0),t([a()],V.prototype,"_rasterJobHandler",void 0),t([a()],V.prototype,"bandIds",void 0),t([a({json:{origins:{service:{read:{source:"copyrightText"}}}}})],V.prototype,"copyright",void 0),t([a({json:{read:!1}})],V.prototype,"fullExtent",null),t([a()],V.prototype,"interpolation",void 0),t([a()],V.prototype,"ioConfig",void 0),t([a({type:[p],json:{write:!0}})],V.prototype,"multidimensionalDefinition",null),t([a({type:f,json:{write:!0}})],V.prototype,"multidimensionalSubset",void 0),t([a()],V.prototype,"raster",void 0),t([a({type:y,json:{name:"renderingRule",write:!0}})],V.prototype,"rasterFunction",null),t([a()],V.prototype,"rasterInfo",void 0),t([a()],V.prototype,"sourceJSON",void 0),t([a({readOnly:!0,type:k,json:{read:!1}})],V.prototype,"spatialReference",void 0),t([a({type:g})],V.prototype,"tileInfo",void 0),t([a(h)],V.prototype,"url",null),t([a({types:e,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(){const t="raster-stretch"===this.renderer?.type&&"none"===this.renderer.stretchType&&!this.renderer.useGamma;return{enabled:!this.loaded||"Raster"===this.raster.tileType||!t}}},origins:{"web-scene":{types:r,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:t=>({enabled:t&&"vector-field"!==t.type&&"flow"!==t.type})}}}}})],V.prototype,"renderer",null),t([u("renderer")],V.prototype,"readRenderer",null),t([a()],V.prototype,"symbolizer",void 0),V=t([c("esri.layers.ImageryTileMixin")],V),V};export{V as ImageryTileMixin};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{ClonableMixin as t}from"../../../core/Clonable.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import{cast as a}from"../../../core/accessorSupport/decorators/cast.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{reader as i}from"../../../core/accessorSupport/decorators/reader.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import s from"./cameraOrientationFactory.js";import{CameraOrientationType as p}from"../enums/CameraOrientationType.js";import l from"../../../geometry/Point.js";let u=class extends(t(r)){constructor(e){super(e),this.name=null,this.nearDistance=0,this.sourcekeys=null,this.elevationSource=null,this.cameraOrientation=null,this.elevation=null}read(e,t){const r={},{attributes:o}=e;for(const a in o)r[a.toLowerCase()]=o[a];super.read({...e,attributes:r},t)}readGeometry(e){return e?new l(e):e}readName(e,t){const{attributes:r}=t;return r.name}readImageURL(e,t){const{attributes:r}=t,{version:o}=t.layer;let a=r.image;return o&&o&&o>11&&r.imageField&&(a=r[r.imageField]),a}readCameraHeading(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.cameraheading:r.camheading}readHFOV(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.horizontalfieldofview:r.hfov}readVFOV(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.verticalfieldofview:r.vfov}readOIType(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.orientedimagerytype:r.oitype}readSortOrder(e,t){const{attributes:r}=t;return r.sortorder}readImageRotation(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.imagerotation:r.imgrot}readCameraPitch(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.camerapitch:r.campitch}readCameraRoll(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.cameraroll:r.camroll}readAverageHeight(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.cameraheight:r.avghtag}readFarDistance(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.fardistance:r.fardist}readNearDistance(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.neardistance:r.neardist}readCamOffset(e,t){const{attributes:r}=t,{version:o}=t.layer,a=o&&o>11?r.cameraoffset:r.camoffset;return a?a.split(",").map(Number):null}readAccuracy(e,t){const{attributes:r}=t,{version:o}=t.layer,a=o&&o>11?r.orientationaccuracy:r.accuracy;return a?a.split(",").map(Number):null}readSourceKeys(e,t){const{attributes:r}=t;return r?Object.keys(r):null}readImagePyramids(e,t){const{attributes:r}=t,{version:o}=t.layer,a=o&&o>11?r.imagepyramids:r.imgpyramids;return a?a.split(",").map(Number):null}readImagePyramidsWithURL(e,t){const{attributes:r}=t,{version:o}=t.layer,a=o&&o>11?r.imagepyramidurls:r.imgpyramidsurl;return a?a.split(","):null}readElevationSource(e,t){const{attributes:r}=t,{version:o}=t.layer;if(o&&o&&o>11){if(r.elevationSource){const e=r.elevationSource;let{url:o}=e;if(o){if(t.layer.affixes){const{demPathSuffix:e,demPathPrefix:r}=t.layer.affixes;r?.trim()&&(o=r?.trim()+"/"+o),e?.trim()&&(o=o+"/"+e?.trim())}return{...e,url:o}}return e}return null}let a=r.dem?.trim();if(a){if(t.layer.affixes){const{demPathSuffix:e,demPathPrefix:r}=t.layer.affixes;r?.trim()&&(a=r?.trim()+"/"+a),e?.trim()&&(a=a+"/"+e?.trim())}return{url:a}}return null}readDepthImage(e,t){const{attributes:r,layer:o}=t,{affixes:a,version:i}=o;let n=i&&i>11?r.depthimage:r.depthimg;if(n){if(a){const{depthImagePathPrefix:e,depthImagePathSuffix:t}=a;e?.trim()&&(n=e?.trim()+"/"+n),t?.trim()&&(n=n+"/"+t?.trim())}return n}return null}readCameraOrientation(e,t){const{attributes:r}=t,{version:o}=t.layer;return o&&o>11?r.cameraorientation:r.camori}get isSpherical(){const{orientedImageryType:e}=this;return"B"===e}get isInspection(){const{orientedImageryType:e}=this;return"I"===e}get isOblique(){const{orientedImageryType:e}=this;return"O"===e}get isPanoramic(){const{orientedImageryType:e,horizontalFieldOfView:t}=this;return"T"===e&&t>=150&&t<360}get isVideo(){const{orientedImageryType:e}=this;return"V"===e}get location(){const{cameraOrientation:e,geometry:t,averageHeightAboveGround:r,elevation:o}=this;if(e){const{type:t,x:r,y:o,z:a,horizontalWKID:i}=e;return new l({x:r,y:o,z:a,spatialReference:{wkid:t===p.LTP?4326:i}})}return t.z=(o??0)+r,t}};e([o()],u.prototype,"geometry",void 0),e([i("geometry",["geometry"])],u.prototype,"readGeometry",null),e([o({json:{write:!0}})],u.prototype,"name",void 0),e([i("name",["attributes"])],u.prototype,"readName",null),e([o({json:{write:!0}})],u.prototype,"image",void 0),e([i("image",["attributes"])],u.prototype,"readImageURL",null),e([o({type:Date,json:{write:!0,name:"attributes.acquisitiondate"}})],u.prototype,"acquisitionDate",void 0),e([o({json:{write:!0}})],u.prototype,"cameraHeading",void 0),e([i("cameraHeading",["attributes"])],u.prototype,"readCameraHeading",null),e([o({json:{write:!0}})],u.prototype,"horizontalFieldOfView",void 0),e([i("horizontalFieldOfView",["attributes"])],u.prototype,"readHFOV",null),e([o({json:{write:!0}})],u.prototype,"verticalFieldOfView",void 0),e([i("verticalFieldOfView",["attributes"])],u.prototype,"readVFOV",null),e([o({json:{write:!0}}),a((e=>e?e.toUpperCase():null))],u.prototype,"orientedImageryType",void 0),e([i("orientedImageryType",["attributes"])],u.prototype,"readOIType",null),e([o({json:{write:!0}})],u.prototype,"sortOrder",void 0),e([i("sortOrder",["attributes"])],u.prototype,"readSortOrder",null),e([o({json:{write:!0}})],u.prototype,"imageRotation",void 0),e([i("imageRotation",["attributes"])],u.prototype,"readImageRotation",null),e([o({json:{write:!0}})],u.prototype,"exposureId",void 0),e([o({json:{write:!0}})],u.prototype,"cameraPitch",void 0),e([i("cameraPitch",["attributes"])],u.prototype,"readCameraPitch",null),e([o({json:{write:!0}})],u.prototype,"cameraRoll",void 0),e([i("cameraRoll",["attributes"])],u.prototype,"readCameraRoll",null),e([o({json:{write:!0}})],u.prototype,"averageHeightAboveGround",void 0),e([i("averageHeightAboveGround",["attributes"])],u.prototype,"readAverageHeight",null),e([o({json:{write:!0}})],u.prototype,"farDistance",void 0),e([i("farDistance",["attributes"])],u.prototype,"readFarDistance",null),e([o({json:{write:!0}})],u.prototype,"nearDistance",void 0),e([i("nearDistance",["attributes"])],u.prototype,"readNearDistance",null),e([o({json:{write:!0}})],u.prototype,"cameraOffset",void 0),e([i("cameraOffset",["attributes"])],u.prototype,"readCamOffset",null),e([o({json:{write:!0}})],u.prototype,"orientationAccuracy",void 0),e([i("orientationAccuracy",["attributes"])],u.prototype,"readAccuracy",null),e([o({json:{write:!0,name:"attributes.objectid"}})],u.prototype,"objectId",void 0),e([o({json:{write:!0}})],u.prototype,"sourcekeys",void 0),e([i("sourcekeys",["attributes"])],u.prototype,"readSourceKeys",null),e([o({json:{write:!0,name:"attributes.exposurestationid"}})],u.prototype,"exposureStationId",void 0),e([o({json:{write:!0}})],u.prototype,"imagePyramids",void 0),e([i("imagePyramids",["attributes"])],u.prototype,"readImagePyramids",null),e([o({json:{write:!0}})],u.prototype,"imagePyramidUrls",void 0),e([i("imagePyramidUrls",["attributes"])],u.prototype,"readImagePyramidsWithURL",null),e([o({json:{write:!0}})],u.prototype,"elevationSource",void 0),e([i("elevationSource",["attributes"])],u.prototype,"readElevationSource",null),e([o({json:{write:!0}})],u.prototype,"depthImage",void 0),e([i("depthImage",["attributes"])],u.prototype,"readDepthImage",null),e([o({json:{write:!0}}),a((e=>e?s.getCameraOrientation(e):null))],u.prototype,"cameraOrientation",void 0),e([i("cameraOrientation",["attributes"])],u.prototype,"readCameraOrientation",null),e([o()],u.prototype,"isSpherical",null),e([o()],u.prototype,"isInspection",null),e([o()],u.prototype,"isOblique",null),e([o()],u.prototype,"isPanoramic",null),e([o()],u.prototype,"isVideo",null),e([o({json:{write:!0}})],u.prototype,"elevation",void 0),e([o({json:{write:!0}})],u.prototype,"location",null),u=e([n("esri.layers.orientedImagery.core.ExposurePoint")],u);const m=u;export{m as default};
5
+ import{_ as t}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import{ClonableMixin as e}from"../../../core/Clonable.js";import r from"../../../core/Error.js";import{JSONSupport as a}from"../../../core/JSONSupport.js";import{property as o}from"../../../core/accessorSupport/decorators/property.js";import{cast as i}from"../../../core/accessorSupport/decorators/cast.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{reader as n}from"../../../core/accessorSupport/decorators/reader.js";import{subclass as s}from"../../../core/accessorSupport/decorators/subclass.js";import p from"./cameraOrientationFactory.js";import{CameraOrientationType as u}from"../enums/CameraOrientationType.js";import c from"../../../geometry/Point.js";function m(t,e){switch(t){case"O":return e&&e<10?"nadir":"oblique";case"B":case"S":case"D":return"360";default:return"horizontal"}}function l(t){throw new r("exposure-point:missing-default-value",`a value for ${t} is missing in default properties`)}function d(t,e){throw new r("exposure-point:missing-attribute-value",`a value for ${t} is missing in attribute table`,{exposurePoint:e})}let y=class extends(e(a)){constructor(t){super(t),this.cameraOrientation=null,this.elevation=null,this.elevationSource=null,this.name=null}read(t,e){const r={},{attributes:a}=t;for(const o in a)r[o.toLowerCase()]=a[o];super.read({...t,attributes:r},e)}readCameraHeading(t,e){const{attributes:r,layer:a}=e;return r.cameraheading??r.camheading??a.cameraHeading}readCameraHeight(t,e){const{attributes:r,layer:a}=e;return r.cameraheight??r.avghtag??a.cameraHeight}readCamOffset(t,e){const{attributes:r}=e;return r.cameraoffset?.split(";").map(Number)??r.camoffset?.split(";").map(Number)??null}readCameraOrientation(t,e){const{attributes:r}=e;return r.cameraorientation??r.camori}readCameraPitch(t,e){const{attributes:r,layer:a}=e;return r.camerapitch??r.campitch??a.cameraPitch}readCameraRoll(t,e){const{attributes:r,layer:a}=e;return r.cameraroll??r.camroll??a.cameraRoll}readDepthImage(t,e){const{attributes:r,layer:a}=e;let o=r.depthimage??r.depthimg??null;if(!o)return null;const{depthImagePathPrefix:i,depthImagePathSuffix:n}=a,s=i?.trim();s&&(o=`${s}/${o}`);const p=n?.trim();return p&&(o=`${o}/${p}`),o}readElevationSource(t,e){const{attributes:r,layer:a}=e;if(r.elevationSource){const t=r.elevationSource;let{url:e}=t;if(e){const{demPathSuffix:r,demPathPrefix:o}=a;return o?.trim()&&(e=o?.trim()+"/"+e),r?.trim()&&(e=e+"/"+r?.trim()),{...t,url:e}}return t}if(r.dem){let t=r.dem.trim();if(t){const{demPathSuffix:r,demPathPrefix:a}=e.layer;return a?.trim()&&(t=a?.trim()+"/"+t),r?.trim()&&(t=t+"/"+r?.trim()),{url:t}}}return a.effectiveElevationSource}readFarDistance(t,e){const{attributes:r,layer:a}=e;return r.fardistance??r.fardist??a.farDistance}readHFOV(t,e){const{attributes:r,layer:a}=e;return r.horizontalfieldofview??r.hfov??a.horizontalFieldOfView}readImageURL(t,e){const{attributes:r,layer:a}=e,{image:o}=r;o||d("image",this);const{imagePathPrefix:i,imagePathSuffix:n}=a;let s=o;const p=i?.trim();p&&(s=`${p.trim()}/${s}`);const u=n?.trim();return u&&(s=`${s}/${u.trim()}`),s}readImageRotation(t,e){const{attributes:r,layer:a}=e;return r.imagerotation??r.imgrot??a.imageRotation}get isHorizontal(){return"horizontal"===this.orientedImageryType}get isInspection(){return"inspection"===this.orientedImageryType}get isNadir(){return"nadir"===this.orientedImageryType}get isOblique(){return"oblique"===this.orientedImageryType}get isSpherical(){return"360"===this.orientedImageryType}get location(){const{cameraOrientation:t,geometry:e,cameraHeight:r,elevation:a}=this;if(t){const{type:e,x:r,y:a,z:o,horizontalWKID:i}=t;return new c({x:r,y:a,z:o,spatialReference:{wkid:e===u.LTP?4326:i}})}if(!r)throw l("cameraHeight");return e.z=(a??0)+r,e}readName(t,e){const{attributes:r}=e;return r.name}readNearDistance(t,e){const{attributes:r,layer:a}=e;return r.neardistance??r.neardist??a.nearDistance}readOrientationAccuracy(t,e){return e.attributes.orientationaccuracy?.split(";").map(Number)??e.attributes.accuracy?.split(";").map(Number)??null}readOIType(t,e){const{attributes:r,layer:a}=e;if(r.orientedimagerytype)return r.orientedimagerytype.toLowerCase();if(r.oitype){const t=r.camerapitch??r.campitch??a.cameraPitch;return m(r.oitype.toUpperCase(),t)}return a.orientedImageryType}readSortOrder(t,e){return e.attributes.sortorder}readVFOV(t,e){const{attributes:r,layer:a}=e;return r.verticalfieldofview??r.vfov??a.verticalFieldOfView}};t([o({type:Date,json:{write:!0,name:"attributes.acquisitiondate"}})],y.prototype,"acquisitionDate",void 0),t([o({type:Number,json:{write:!0}})],y.prototype,"cameraHeading",void 0),t([n("cameraHeading",["attributes"])],y.prototype,"readCameraHeading",null),t([o({type:Number,json:{write:!0}})],y.prototype,"cameraHeight",void 0),t([n("cameraHeight",["attributes"])],y.prototype,"readCameraHeight",null),t([o({json:{write:!0}})],y.prototype,"cameraOffset",void 0),t([n("cameraOffset",["attributes"])],y.prototype,"readCamOffset",null),t([o({json:{write:!0}}),i((t=>t?p.getCameraOrientation(t):null))],y.prototype,"cameraOrientation",void 0),t([n("cameraOrientation",["attributes"])],y.prototype,"readCameraOrientation",null),t([o({type:Number,json:{write:!0}})],y.prototype,"cameraPitch",void 0),t([n("cameraPitch",["attributes"])],y.prototype,"readCameraPitch",null),t([o({type:Number,json:{write:!0}})],y.prototype,"cameraRoll",void 0),t([n("cameraRoll",["attributes"])],y.prototype,"readCameraRoll",null),t([o({json:{write:!0}})],y.prototype,"depthImage",void 0),t([n("depthImage",["attributes"])],y.prototype,"readDepthImage",null),t([o({type:Number,json:{write:!0}})],y.prototype,"elevation",void 0),t([o({json:{write:!0}})],y.prototype,"elevationSource",void 0),t([n("elevationSource",["attributes"])],y.prototype,"readElevationSource",null),t([o({json:{write:!0,name:"attributes.exposurestationid"}})],y.prototype,"exposureStationId",void 0),t([o({type:Number,json:{write:!0}})],y.prototype,"farDistance",void 0),t([n("farDistance",["attributes"])],y.prototype,"readFarDistance",null),t([o({type:c})],y.prototype,"geometry",void 0),t([o({type:Number,json:{write:!0}})],y.prototype,"horizontalFieldOfView",void 0),t([n("horizontalFieldOfView",["attributes"])],y.prototype,"readHFOV",null),t([o({json:{write:!0}})],y.prototype,"image",void 0),t([n("image",["attributes"])],y.prototype,"readImageURL",null),t([o({type:Number,json:{write:!0}})],y.prototype,"imageRotation",void 0),t([n("imageRotation",["attributes"])],y.prototype,"readImageRotation",null),t([o()],y.prototype,"isHorizontal",null),t([o()],y.prototype,"isInspection",null),t([o()],y.prototype,"isNadir",null),t([o()],y.prototype,"isOblique",null),t([o()],y.prototype,"isSpherical",null),t([o({json:{write:!0}})],y.prototype,"location",null),t([o({json:{write:!0}})],y.prototype,"name",void 0),t([n("name",["attributes"])],y.prototype,"readName",null),t([o({type:Number,json:{write:!0}})],y.prototype,"nearDistance",void 0),t([n("nearDistance",["attributes"])],y.prototype,"readNearDistance",null),t([o({json:{write:!0,name:"attributes.objectid"}})],y.prototype,"objectId",void 0),t([o({json:{write:!0}})],y.prototype,"orientationAccuracy",void 0),t([n("orientationAccuracy",["attributes"])],y.prototype,"readOrientationAccuracy",null),t([o({json:{write:!0}})],y.prototype,"orientedImageryType",void 0),t([n("orientedImageryType",["attributes"])],y.prototype,"readOIType",null),t([o({type:Number,json:{write:!0}})],y.prototype,"sortOrder",void 0),t([n("sortOrder",["attributes"])],y.prototype,"readSortOrder",null),t([o({type:Number,json:{write:!0}})],y.prototype,"verticalFieldOfView",void 0),t([n("verticalFieldOfView",["attributes"])],y.prototype,"readVFOV",null),y=t([s("esri.layers.orientedImagery.core.ExposurePoint")],y);const f=y;export{f as default};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import t from"../../../Graphic.js";import{earth as e}from"../../../geometry/support/Ellipsoid.js";import{distance as a}from"../../../geometry/support/pointUtils.js";import{updateElevation as i}from"../transformations/groundToImageUtils.js";async function r(e){const{camera:a,features:r,selectedPoint:n,polygons:s}=e;if(!r.length)return[];if(r[0].layer.elevationSource&&!n.z){const e=await i([n],{feature:r[0],currentCoveragePolygon:new t({geometry:s[0]})});if(e[0]){const t=e[0];n.elevation=t.z}}const h=o(a,n);return r.map(h)}function o(t,i){return i.z=i.z??0,i.elevation=i.elevation??0,r=>{const{hfovWeight:o,vfovWeight:s,distanceWeight:h}=n(r,t?"3D":"2D"),{attributes:c,layer:l}=r,{cameraProperties:g}=l,{averageHeightAboveGround:f,cameraHeading:v,cameraPitch:u,farDistance:M,horizontalFieldOfView:m,verticalFieldOfView:b}=g??{},d=c.geometry,y=180*Math.atan2(d.y-i.y,d.x-i.x)/Math.PI,p=a(i,d);let W=c.horizontalFieldOfView??m,P=c.verticalFieldOfView??b;const x=c.cameraHeading??v;let z=x;const D=c.cameraPitch??u;let I=D;const w=c.averageHeightAboveGround??f,H=c.farDistance??M;t&&(z=t.heading,I=t.tilt,W=180,P=180);let O=1;d.spatialReference.isWebMercator&&(O=1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*d.y/e.radius))));const j=Math.sqrt((Math.sqrt((i.x-d.x)**2+(i.y-d.y)**2)/O)**2+((i.z??0)-(i.elevation??0)-w)**2),q=90-180*Math.atan2(i.y-d.y,i.x-d.x)/Math.PI;let F=(Math.abs(q-z)>180?Math.abs(360-Math.abs(q-z)):Math.abs(q-z))/W;F=4*F+1;const G=180*Math.acos((r.attributes.averageHeightAboveGround-(i.z??0)+(i.elevation??0))/j)/Math.PI;let V=Math.abs(G-I)/P;V=4*V+1;let A=j/Math.sqrt(H**2+w**2);A=4*A+1;const S=x>180?x-360:x;return{suitability:o*F+s*V+h*A,trueSuitability:o*(4*(Math.abs(q-S)>180?Math.abs(360-Math.abs(q-S)):Math.abs(q-S)/W)+1)+s*(Math.abs(G-D)/P*4+1)+h*A,feature:r,angle:y,distance:p,vangle:Math.abs(180*Math.atan(p/w)/Math.PI)}}}function n(t,e){const{attributes:a,layer:i}=t,{isOblique:r,isSpherical:o,isPanoramic:n,orientedImageryType:s}=a,h=a.cameraPitch??i.cameraProperties.cameraPitch;return o||n?{hfovWeight:"2D"===e?0:1,vfovWeight:"2D"===e?0:.6,distanceWeight:"2D"===e?1:.5}:"N"===s||h<10?{hfovWeight:.25,vfovWeight:1,distanceWeight:1}:r?{hfovWeight:1,vfovWeight:.25,distanceWeight:1}:{hfovWeight:1,vfovWeight:1,distanceWeight:1}}export{r as calculateSuitabilities};
5
+ import{earth as t}from"../../../geometry/support/Ellipsoid.js";import{distance as a}from"../../../geometry/support/pointUtils.js";import e from"./ExposurePoint.js";function i(t){const{camera:a,features:e,selectedPoint:i}=t;if(!e.length)return[];const s=h(a,i);return e.map(s)}function h(e,i){return i.z??=0,i.elevation??=0,h=>{const{hfovWeight:o,vfovWeight:r,distanceWeight:n}=s(h.attributes,e?"3D":"2D"),c=h.attributes,{cameraHeight:M,cameraHeading:l,cameraPitch:g,farDistance:f,horizontalFieldOfView:u,verticalFieldOfView:v}=c,b=c.geometry,W=180*Math.atan2(b.y-i.y,b.x-i.x)/Math.PI,m=a(i,b);let p=u,d=v,y=l,x=g;e&&(y=e.heading,x=e.tilt,p=180,d=180);let P=1;b.spatialReference.isWebMercator&&(P=1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*b.y/t.radius))));const D=Math.sqrt((Math.sqrt((i.x-b.x)**2+(i.y-b.y)**2)/P)**2+((i.z??0)-(i.elevation??0)-M)**2),q=90-180*Math.atan2(i.y-b.y,i.x-b.x)/Math.PI;let I=(Math.abs(q-y)>180?Math.abs(360-Math.abs(q-y)):Math.abs(q-y))/p;I=4*I+1;const z=180*Math.acos((c.cameraHeight-(i.z??0)+(i.elevation??0))/D)/Math.PI;let O=Math.abs(z-x)/d;O=4*O+1;let j=D/Math.sqrt(f**2+M**2);j=4*j+1;const w=l>180?l-360:l;return{suitability:o*I+r*O+n*j,trueSuitability:o*(4*(Math.abs(q-w)>180?Math.abs(360-Math.abs(q-w)):Math.abs(q-w)/p)+1)+r*(Math.abs(z-g)/d*4+1)+n*j,feature:h,angle:W,distance:m,vangle:Math.abs(180*Math.atan(m/M)/Math.PI)}}}function s(t,a){const i="isOblique"in t?t:new e(t),{isOblique:h,isSpherical:s,isNadir:o}=i;return s?{hfovWeight:"2D"===a?0:1,vfovWeight:"2D"===a?0:.6,distanceWeight:"2D"===a?1:.5}:o?{hfovWeight:.25,vfovWeight:1,distanceWeight:1}:h?{hfovWeight:1,vfovWeight:.25,distanceWeight:1}:{hfovWeight:1,vfovWeight:1,distanceWeight:1}}export{i as calculateSuitabilities};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import"../../../geometry.js";import{z as e}from"../../../chunks/vec3f64.js";import{w as t,a}from"../../../chunks/vec3.js";import r from"../../../geometry/Circle.js";import n from"../../../geometry/Mesh.js";import{earth as i}from"../../../geometry/support/Ellipsoid.js";import{MeshVertexAttributes as s}from"../../../geometry/support/MeshVertexAttributes.js";import{isWebMercator as o}from"../../../geometry/support/spatialReferenceUtils.js";import{isSphericalImagery as c}from"./imageryUtils.js";import{calculateRotationMatrix as f,transformMat3 as l,scaleAndAddWithFactor as h,scaleWithFactor as g}from"../transformations/utils.js";import m from"../../../geometry/Polygon.js";import y from"../../../geometry/SpatialReference.js";const u=Math.PI/180;function p(s){const{attributes:y,layer:p}=s,{horizontalFieldOfView:d,geometry:x,verticalFieldOfView:R}=y;let D,b=1,w=null;if(y.farDistance=y.farDistance??p.cameraProperties?.farDistance,y.nearDistance=y.nearDistance??p.cameraProperties?.nearDistance??0,x&&o(x?.spatialReference)&&(b=1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*x.y/i.radius)))),c(y)){if(D=new r({center:x,radius:y.farDistance*b}),y.nearDistance){const e=new r({center:x,radius:y.nearDistance*b});D.addRing(e.rings[0])}const e=D.center;e&&(e.z=y.averageHeightAboveGround,w=n.createSphere(e,{size:2*y.farDistance}),w.centerAt(e))}else{let r=y.cameraPitch,n=y.cameraRoll,i=150;const o=[];d>150&&(r=90,n=0,i=5);const c=Math.ceil(d/i);if(c%2==0)for(let e=0;e<c/2;e++)o.push(y.cameraHeading-d/c*(e+.5),y.cameraHeading+d/c*(e+.5));else{o.push(y.cameraHeading);for(let e=1;e<c/2;e++)o.push(y.cameraHeading-d/c*e,y.cameraHeading+d/c*e)}o.sort();let p=y.farDistance?y.farDistance*b:y.averageHeightAboveGround*b/Math.cos(r*u);y.cameraPitch+R/2>=90&&(p=(y.farDistance||20)*b),D=new m({spatialReference:x?.spatialReference});for(const m of o){const i=f("HPR",[m,r,n]);w=M(s,i);const o=l([0,0,-1],i),{x:H,y:A}=x,P=h([H,A,y.averageHeightAboveGround],o,p,b),j=2*Math.tan(R*u/2)*p,z=2*Math.tan(d/c*u/2)*p,G=l([0,1,0],i),F=l([1,0,0],i),O=g(G,j/2,b),V=g(F,z/2,b),q=t(e(),O,V),C=a(e(),O,V),I=[a(e(),P,q),a(e(),P,C),t(e(),P,q),t(e(),P,C)].map((e=>v(e,y.averageHeightAboveGround,x,b)));I.push(I[0]),D.addRing(I)}}return{polygon:D,frustum:w}}function d(e,t){return e.contains(t)}function x(e,t){return Math.sign(e)!==Math.sign(t)}function M(r,i,o){const c=r.attributes,f=c.geometry,m=f.spatialReference??r.spatialReference;f.spatialReference=m instanceof y?m:y.fromJSON(m);const p=D(f),d=c.nearDistance<0?0:c.nearDistance*p;let x=c.averageHeightAboveGround*p/Math.cos(c.cameraPitch*u),M=!0;c.cameraPitch+c.verticalFieldOfView/2>=90&&(x=(c.farDistance??20)*p,M=!1);const v=2*Math.tan(c.verticalFieldOfView*u/2)*d,R=2*Math.tan(c.horizontalFieldOfView*u/2)*d,b=2*Math.tan(c.verticalFieldOfView*u/2)*x,w=2*Math.tan(c.horizontalFieldOfView*u/2)*x;let H,A;o?(H=o,A=g(t(e(),H,[f.x,f.y,c.averageHeightAboveGround]),1/x,1/p)):(A=[0,0,-1],A=l(A,i),H=h([f.x,f.y,c.averageHeightAboveGround],A,x,p),M&&(H[2]=0));const P=h([f.x,f.y,c.averageHeightAboveGround],A,d,p);let j=[0,1,0];j=l(j,i);let z=[1,0,0];z=l(z,i);let G=[],F=[];d?(F=[{faces:[4,0,3,4,7,3]},{faces:[5,1,2,5,6,2]},{faces:[4,0,1,4,5,1]},{faces:[6,2,3,6,7,3]}],G=G.concat(a(e(),P,t(e(),g(j,v/2,p),g(z,R/2,p)))),G=G.concat(a(e(),P,a(e(),g(j,v/2,p),g(z,R/2,p)))),G=G.concat(t(e(),P,t(e(),g(j,v/2,p),g(z,R/2,p)))),G=G.concat(t(e(),P,a(e(),g(j,v/2,p),g(z,R/2,p))))):(G=[f.x,f.y,c.averageHeightAboveGround],F=[{faces:[0,1,2,0,2,3,0,3,4,0,4,1]}]),G=G.concat(a(e(),H,t(e(),g(j,b/2,p),g(z,w/2,p)))),G=G.concat(a(e(),H,a(e(),g(j,b/2,p),g(z,w/2,p)))),G=G.concat(t(e(),H,t(e(),g(j,b/2,p),g(z,w/2,p)))),G=G.concat(t(e(),H,a(e(),g(j,b/2,p),g(z,w/2,p))));const O=new s({position:Float64Array.from(G)});return new n({vertexAttributes:O,components:F,spatialReference:f.spatialReference})}function v(a,r,n,i){{const s=Math.sqrt((a[2]-r)**2+(Math.sqrt((a[0]-n.x)**2+(a[1]-n.y)**2)/i)**2)*i,o=g(t(e(),[a[0],a[1],a[2]],[n.x,n.y,r]),1/s,1/i),c=r/(r-a[2]),f={x:(1-c)*n.x+c*a[0],y:(1-c)*n.y+c*a[1],z:(1-c)*r+c*a[2]},l=Math.sqrt((f.z-r)**2+(Math.sqrt((f.x-n.x)**2+(f.y-n.y)**2)/i)**2)*i,h=g(t(e(),[f.x,f.y,f.z],[n.x,n.y,r]),1/l,1/i);return x(o[0],h[0])&&x(o[1],h[1])&&x(o[2],h[2])||a[2]>=0?[a[0],a[1],0]:[f.x,f.y,f.z]}}function R(e){const{attributes:t}=e,{spatialReference:a,x:r,y:n}=t.geometry,{cameraHeading:i,cameraPitch:s,farDistance:o,nearDistance:c}=t,f=D(t.geometry),l=new m({spatialReference:a}),h=Math.abs(1.44*o*f);let g=Math.abs(1.44*c*f);(s<20||null==i)&&(g=h);const y=[];return y[0]={x:r+h*Math.sin((i-45)*u),y:n+h*Math.cos((i-45)*u)},y[1]={x:r+h*Math.sin((i+45)*u),y:n+h*Math.cos((i+45)*u)},y[2]={x:r+g*Math.sin((i+135)*u),y:n+g*Math.cos((i+135)*u)},y[3]={x:r+g*Math.sin((i+225)*u),y:n+g*Math.cos((i+225)*u)},l.addRing([[y[0].x,y[0].y,0],[y[1].x,y[1].y,0],[y[2].x,y[2].y,0],[y[3].x,y[3].y,0],[y[0].x,y[0].y,0]]),l}function D(e){return e&&o(e?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e.y/i.radius))):1}function b(a,n){const i=1+n/100;if("esri.geometry.Circle"===a.declaredClass){const{radius:e,center:t}=a,n=new r({radius:e*i,center:t});return a.rings.length>1&&n.addRing(a.rings[1]),n}if("esri.geometry.Polygon"===a.declaredClass){const r=new m({spatialReference:a.spatialReference}),n=a.centroid;if(n){const s=[];for(let r=0;r<a.rings[0].length;r++){const o=Math.sqrt((n.x-a.rings[0][r][0])**2+(n.y-a.rings[0][r][1])**2),c=g(t(e(),[a.rings[0][r][0],a.rings[0][r][1],0],[n.x,n.y,0]),1/o,1),f=h([n.x,n.y,0],c,o*i,1);s.push({x:f[0],y:f[1]})}r.addRing([[s[0].x,s[0].y,0],[s[1].x,s[1].y,0],[s[2].x,s[2].y,0],[s[3].x,s[3].y,0],[s[0].x,s[0].y,0]])}return r}return a}export{d as checkIfPolygonContainsSelectedPoint,R as computePolygonForInspection,p as createCoveragePolygon,b as resizePolygon};
5
+ import"../../../geometry.js";import{z as e}from"../../../chunks/vec3f64.js";import{w as t,a}from"../../../chunks/vec3.js";import r from"../../../geometry/Circle.js";import n from"../../../geometry/Mesh.js";import{earth as i}from"../../../geometry/support/Ellipsoid.js";import{MeshVertexAttributes as s}from"../../../geometry/support/MeshVertexAttributes.js";import{isWebMercator as c}from"../../../geometry/support/spatialReferenceUtils.js";import{calculateRotationMatrix as o,transformMat3 as f,scaleAndAddWithFactor as l,scaleWithFactor as h}from"../transformations/utils.js";import m from"../../../geometry/Polygon.js";import y from"../../../geometry/SpatialReference.js";const g=Math.PI/180;function p(s){const{attributes:y}=s,{horizontalFieldOfView:p,geometry:u,verticalFieldOfView:x}=y;let R,w=1,H=null;if(u&&c(u?.spatialReference)&&(w=1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*u.y/i.radius)))),y.isSpherical){if(R=new r({center:u,radius:y.farDistance*w}),y.nearDistance){const e=new r({center:u,radius:y.nearDistance*w});R.addRing(e.rings[0])}const e=R.center;e&&(e.z=y.cameraHeight,H=n.createSphere(e,{size:2*y.farDistance}),H.centerAt(e))}else{let r=y.cameraPitch,n=y.cameraRoll,i=150;const c=[];p>150&&(r=90,n=0,i=5);const D=Math.ceil(p/i);if(D%2==0)for(let e=0;e<D/2;e++)c.push(y.cameraHeading-p/D*(e+.5),y.cameraHeading+p/D*(e+.5));else{c.push(y.cameraHeading);for(let e=1;e<D/2;e++)c.push(y.cameraHeading-p/D*e,y.cameraHeading+p/D*e)}c.sort();let j=y.farDistance?y.farDistance*w:y.cameraHeight*w/Math.cos(r*g);y.cameraPitch+x/2>=90&&(j=(y.farDistance||20)*w),R=new m({spatialReference:u?.spatialReference});for(const m of c){const i=o("HPR",[m,r,n]);H=M(s,i);const c=f([0,0,-1],i),{x:P,y:z}=u,F=l([P,z,y.cameraHeight],c,j,w),O=2*Math.tan(x*g/2)*j,V=2*Math.tan(p/D*g/2)*j,v=f([0,1,0],i),b=f([1,0,0],i),q=h(v,O/2,w),A=h(b,V/2,w),C=t(e(),q,A),S=a(e(),q,A),I=[a(e(),F,C),a(e(),F,S),t(e(),F,C),t(e(),F,S)].map((e=>d(e,y.cameraHeight,u,w)));I.push(I[0]),R.addRing(I)}}return{polygon:R,frustum:H}}function u(e,t){return e.contains(t)}function x(e,t){return Math.sign(e)!==Math.sign(t)}function M(r,i,c){const o=r.attributes,m=o.geometry,p=m.spatialReference??r.spatialReference;m.spatialReference=p instanceof y?p:y.fromJSON(p);const u=w(m),x=o.nearDistance<0?0:o.nearDistance*u;let M=o.cameraHeight*u/Math.cos(o.cameraPitch*g),d=!0;o.cameraPitch+o.verticalFieldOfView/2>=90&&(M=(o.farDistance??20)*u,d=!1);const R=2*Math.tan(o.verticalFieldOfView*g/2)*x,H=2*Math.tan(o.horizontalFieldOfView*g/2)*x,D=2*Math.tan(o.verticalFieldOfView*g/2)*M,j=2*Math.tan(o.horizontalFieldOfView*g/2)*M;let P,z;c?(P=c,z=h(t(e(),P,[m.x,m.y,o.cameraHeight]),1/M,1/u)):(z=[0,0,-1],z=f(z,i),P=l([m.x,m.y,o.cameraHeight],z,M,u),d&&(P[2]=0));const F=l([m.x,m.y,o.cameraHeight],z,x,u);let O=[0,1,0];O=f(O,i);let V=[1,0,0];V=f(V,i);let v=[],b=[];x?(b=[{faces:[4,0,3,4,7,3]},{faces:[5,1,2,5,6,2]},{faces:[4,0,1,4,5,1]},{faces:[6,2,3,6,7,3]}],v=v.concat(a(e(),F,t(e(),h(O,R/2,u),h(V,H/2,u)))),v=v.concat(a(e(),F,a(e(),h(O,R/2,u),h(V,H/2,u)))),v=v.concat(t(e(),F,t(e(),h(O,R/2,u),h(V,H/2,u)))),v=v.concat(t(e(),F,a(e(),h(O,R/2,u),h(V,H/2,u))))):(v=[m.x,m.y,o.cameraHeight],b=[{faces:[0,1,2,0,2,3,0,3,4,0,4,1]}]),v=v.concat(a(e(),P,t(e(),h(O,D/2,u),h(V,j/2,u)))),v=v.concat(a(e(),P,a(e(),h(O,D/2,u),h(V,j/2,u)))),v=v.concat(t(e(),P,t(e(),h(O,D/2,u),h(V,j/2,u)))),v=v.concat(t(e(),P,a(e(),h(O,D/2,u),h(V,j/2,u))));const q=new s({position:Float64Array.from(v)});return new n({vertexAttributes:q,components:b,spatialReference:m.spatialReference})}function d(a,r,n,i){{const s=Math.sqrt((a[2]-r)**2+(Math.sqrt((a[0]-n.x)**2+(a[1]-n.y)**2)/i)**2)*i,c=h(t(e(),[a[0],a[1],a[2]],[n.x,n.y,r]),1/s,1/i),o=r/(r-a[2]),f={x:(1-o)*n.x+o*a[0],y:(1-o)*n.y+o*a[1],z:(1-o)*r+o*a[2]},l=Math.sqrt((f.z-r)**2+(Math.sqrt((f.x-n.x)**2+(f.y-n.y)**2)/i)**2)*i,m=h(t(e(),[f.x,f.y,f.z],[n.x,n.y,r]),1/l,1/i);return x(c[0],m[0])&&x(c[1],m[1])&&x(c[2],m[2])||a[2]>=0?[a[0],a[1],0]:[f.x,f.y,f.z]}}function R(e){const{spatialReference:t,x:a,y:r}=e.geometry,{cameraHeading:n,cameraPitch:i,farDistance:s,nearDistance:c}=e,o=w(e.geometry),f=new m({spatialReference:t}),l=Math.abs(1.44*s*o);let h=Math.abs(1.44*c*o);(i<20||null==n)&&(h=l);const y=[];return y[0]={x:a+l*Math.sin((n-45)*g),y:r+l*Math.cos((n-45)*g)},y[1]={x:a+l*Math.sin((n+45)*g),y:r+l*Math.cos((n+45)*g)},y[2]={x:a+h*Math.sin((n+135)*g),y:r+h*Math.cos((n+135)*g)},y[3]={x:a+h*Math.sin((n+225)*g),y:r+h*Math.cos((n+225)*g)},f.addRing([[y[0].x,y[0].y,0],[y[1].x,y[1].y,0],[y[2].x,y[2].y,0],[y[3].x,y[3].y,0],[y[0].x,y[0].y,0]]),f}function w(e){return e&&c(e?.spatialReference)?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*e.y/i.radius))):1}function H(a,n){const i=1+n/100;if("esri.geometry.Circle"===a.declaredClass){const{radius:e,center:t}=a,n=new r({radius:e*i,center:t});return a.rings.length>1&&n.addRing(a.rings[1]),n}if("esri.geometry.Polygon"===a.declaredClass){const r=new m({spatialReference:a.spatialReference}),n=a.centroid;if(n){const s=[];for(let r=0;r<a.rings[0].length;r++){const c=Math.sqrt((n.x-a.rings[0][r][0])**2+(n.y-a.rings[0][r][1])**2),o=h(t(e(),[a.rings[0][r][0],a.rings[0][r][1],0],[n.x,n.y,0]),1/c,1),f=l([n.x,n.y,0],o,c*i,1);s.push({x:f[0],y:f[1]})}r.addRing([[s[0].x,s[0].y,0],[s[1].x,s[1].y,0],[s[2].x,s[2].y,0],[s[3].x,s[3].y,0],[s[0].x,s[0].y,0]])}return r}return a}export{u as checkIfPolygonContainsSelectedPoint,R as computePolygonForInspection,p as createCoveragePolygon,H as resizePolygon};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import e from"../../../core/Error.js";import{j as t}from"../../../chunks/mat3.js";import a from"../../../geometry/Point.js";import{project as r}from"../../../geometry/projection.js";import{geographicToWebMercator as i}from"../../../geometry/support/webMercatorUtils.js";import n from"../../ElevationLayer.js";import{calculateRotationMatrix as o,geographicToLTP as s}from"./utils.js";const c=Math.PI/180;async function l(e,t,r=!1){if(!e)return[];e=e.map((e=>"esri.geometry.Point"===e.declaredClass?e:a.fromJSON(e)));const{feature:i}=t,{attributes:n}=i;if(isNaN(parseFloat(n.elevation))){const e=await m([i.geometry],t);i.attributes.elevation=e[0].z}return m(e,t,r).then((e=>u(e,t)))}async function m(e,t,a=!1){if(a)return f(e,1);const{feature:i,options:o,currentCoveragePolygon:s}=t,{layer:c}=i,{effectiveElevationSource:l}=c;if(!l?.url&&!l?.constantElevation)return e;const{url:m,constantElevation:u}=l;if(u)return f(e,u);if(!i.elevationSample){const e=new n(m),t=s.geometry?.extent;t.xmin/=2,t.xmax*=2,t.ymin/=2,t.ymax*=2,i.elevationSample=await e.createElevationSampler(t,o),e.destroy()}return Promise.all(e.map((async e=>{e.z=1;const t=i.elevationSample?.queryElevation(r(e,i.elevationSample.spatialReference));return t?.z&&(e.z=t.z),e})))}function f(e,t){return e.map((e=>(e.z=t,e)))}function u(e,t){const{attributes:a}=t.feature;return a.isSpherical||360===a.horizontalFieldOfView?{}:a.cameraOrientation?.isAdvanced?y(e,t):Promise.resolve(p(e,t))}function p(e,r){const{feature:n,imageProperties:l}=r,{width:m,height:f}=l,{attributes:u}=n,p=o("HPR",[u.cameraHeading,u.cameraPitch,u.cameraRoll]),y=Math.sin(u.imageRotation??0*c),h=Math.cos(u.imageRotation??0*c),d=m??1,g=f??1,v=[Math.abs(h*d+y*g),Math.abs(h*g-y*d)],w={horizontal:1/(2*Math.tan(u.horizontalFieldOfView*c/2)),vertical:1/(2*Math.tan(u.verticalFieldOfView*c/2))},M=[-w.horizontal,0,.5,0,w.vertical,.5,0,0,1];let P=new a(u.geometry);P.spatialReference.isWGS84&&4!==u.cameraOrientation?.type&&(P=i(P));const R=P.spatialReference.isWebMercator?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*P.y/6378137))):1,x=t(new Array(9),p,M);return e.map((e=>{let t=new a(e);if(t.spatialReference.isWGS84)if(4===u.cameraOrientation?.type){const e=u.cameraOrientation;t=new a(s(t,[e.latitude,e.longitude,e.ellipsoidRadius,e.squaredEccentricity]))}else t=new a(i(t));const r=(t.z??0)-(P.z??0),n=(t.x-P.x)/R,o=(t.y-P.y)/R,c=(x[0]*n+x[1]*o+x[2]*r)/(x[6]*n+x[7]*o+x[8]*r),l=(x[3]*n+x[4]*o+x[5]*r)/(x[6]*n+x[7]*o+x[8]*r),m={x:c*v[0],y:l*v[1]};return{x:h*(m.x-v[0]/2)+y*(m.y-v[1]/2)+d/2,y:-y*(m.x-v[0]/2)+h*(m.y-v[1]/2)+g/2}}))}function y(t,n){const{feature:c}=n,{attributes:l}=c,m=l.cameraOrientation;if(!m)throw new e("groundToImageUtils:missing-camera-orientation-parameters","CameraOrientation Parameters are required to perform advanced transformations");let f=new a(l.location);f.spatialReference.isWGS84&&4!==l.cameraOrientation?.type&&(f=i(f));const u=f.spatialReference.isWebMercator?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*f.y/6378137))):1;let p;if("esri.layers.orientedImagery.core.CameraOrientationOPK"===m.declaredClass){const{omega:e,phi:t,kappa:a}=m;p=o("OPK",[e,t,a])}else{const{cameraHeading:e,cameraPitch:t,cameraRoll:a}=l;p=o("HPR",[e,t,a])}const{principalOffsetPoint:y,focalLength:h,radialDistortionCoefficients:d,affineTransformations:g,tangentialDistortionCoefficients:v}=m;return Promise.all(t.map((e=>{let t;return e.spatialReference.equals(f.spatialReference)?(t=new a(e),n(t)):(t=r(e,f.spatialReference),t?n(t):null);function n(e){if(e.spatialReference.isWGS84)if(4===l.cameraOrientation?.type){const t=l.cameraOrientation;e=new a(s(e,[t.latitude,t.longitude,t.ellipsoidRadius,t.squaredEccentricity]))}else e=new a(i(e));const t=(e.z??0)-(f.z??0),r=(e.x-f.x)/u,n=(e.y-f.y)/u,o=(p[0]*r+p[1]*n+p[2]*t)/(p[6]*r+p[7]*n+p[8]*t),c=(p[3]*r+p[4]*n+p[5]*t)/(p[6]*r+p[7]*n+p[8]*t),m=o**2+c**2;let w=0,M=0,P=0,R=0,x=0,O=0,b=0;d&&(w=d[0]??0,M=d[1]??0,P=d[2]??0),v&&(R=v[0],x=v[1]),y&&(O=y[0]??0,b=y[1]??0);const z=1+(w||0)*m+(M||0)*m*m+(P||0)*m*m*m;let S=o*z+(R||0)*(m+2*o**2)+2*(x||0)*o*c,j=c*z+(x||0)*(m+2*c**2)+2*(R||0)*o*c;S=-(h??0)*S+O,j=-(h??0)*j+b;return{x:Number(g[0])+Number(g[1])*S+Number(g[2])*j,y:Number(g[3])+Number(g[4])*S+Number(g[5])*j}}})))}export{l as transformPoints,m as updateElevation};
5
+ import e from"../../../core/Error.js";import{j as t}from"../../../chunks/mat3.js";import a from"../../../geometry/Point.js";import{project as r}from"../../../geometry/projection.js";import{geographicToWebMercator as i}from"../../../geometry/support/webMercatorUtils.js";import n from"../../ElevationLayer.js";import{calculateRotationMatrix as o,geographicToLTP as s}from"./utils.js";function c(e){return"esri.Graphic"===e?.declaredClass}const l=Math.PI/180;async function m(e,t,r=!1){if(!e)return[];e=e.map((e=>"esri.geometry.Point"===e.declaredClass?e:a.fromJSON(e)));const{feature:i}=t,{attributes:n}=i;if(isNaN(parseFloat(n.elevation))){const e=await u([i.geometry],t);i.attributes.elevation=e[0].z}return u(e,t,r).then((e=>p(e,t)))}async function u(e,t,a=!1){if(a)return f(e,1);const{feature:i,options:o,currentCoveragePolygon:s}=t,l=i.attributes.elevationSource;if(!l?.url&&!l?.constantElevation)return e;const{url:m,constantElevation:u}=l;if(u)return f(e,u);if(!i.elevationSample){const e=c(s)?s.geometry?.extent:s.extent;if(e){const t=e.clone(),a=new n(m);t.xmin/=2,t.xmax*=2,t.ymin/=2,t.ymax*=2,i.elevationSample=await a.createElevationSampler(t,o),a.destroy()}}return Promise.all(e.map((async e=>{e.z=1;const t=i.elevationSample?.queryElevation(r(e,i.elevationSample.spatialReference));return t?.z&&(e.z=t.z),e})))}function f(e,t){return e.map((e=>(e.z=t,e)))}function p(e,t){const{attributes:a}=t.feature;return a.isSpherical||360===a.horizontalFieldOfView?{}:a.cameraOrientation?.isAdvanced?d(e,t):Promise.resolve(y(e,t))}function y(e,r){const{feature:n,imageProperties:c}=r,{width:m,height:u}=c,{attributes:f}=n,p=o("HPR",[f.cameraHeading,f.cameraPitch,f.cameraRoll]),y=Math.sin(f.imageRotation??0*l),d=Math.cos(f.imageRotation??0*l),h=m??1,g=u??1,v=[Math.abs(d*h+y*g),Math.abs(d*g-y*h)],w={horizontal:1/(2*Math.tan(f.horizontalFieldOfView*l/2)),vertical:1/(2*Math.tan(f.verticalFieldOfView*l/2))},x=[-w.horizontal,0,.5,0,w.vertical,.5,0,0,1];let M=new a(f.geometry);M.spatialReference.isWGS84&&4!==f.cameraOrientation?.type&&(M=i(M));const P=M.spatialReference.isWebMercator?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*M.y/6378137))):1,R=t(new Array(9),p,x);return e.map((e=>{let t=new a(e);if(t.spatialReference.isWGS84)if(4===f.cameraOrientation?.type){const e=f.cameraOrientation;t=new a(s(t,[e.latitude,e.longitude,e.ellipsoidRadius,e.squaredEccentricity]))}else t=new a(i(t));const r=(t.z??0)-(M.z??0),n=(t.x-M.x)/P,o=(t.y-M.y)/P,c=(R[0]*n+R[1]*o+R[2]*r)/(R[6]*n+R[7]*o+R[8]*r),l=(R[3]*n+R[4]*o+R[5]*r)/(R[6]*n+R[7]*o+R[8]*r),m={x:c*v[0],y:l*v[1]};return{x:d*(m.x-v[0]/2)+y*(m.y-v[1]/2)+h/2,y:-y*(m.x-v[0]/2)+d*(m.y-v[1]/2)+g/2}}))}function d(t,n){const{feature:c}=n,{attributes:l}=c,m=l.cameraOrientation;if(!m)throw new e("groundToImageUtils:missing-camera-orientation-parameters","CameraOrientation Parameters are required to perform advanced transformations");let u=new a(l.location);u.spatialReference.isWGS84&&4!==l.cameraOrientation?.type&&(u=i(u));const f=u.spatialReference.isWebMercator?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*u.y/6378137))):1;let p;if("esri.layers.orientedImagery.core.CameraOrientationOPK"===m.declaredClass){const{omega:e,phi:t,kappa:a}=m;p=o("OPK",[e,t,a])}else{const{cameraHeading:e,cameraPitch:t,cameraRoll:a}=l;p=o("HPR",[e,t,a])}const{principalOffsetPoint:y,focalLength:d,radialDistortionCoefficients:h,affineTransformations:g,tangentialDistortionCoefficients:v}=m;return Promise.all(t.map((e=>{let t;return e.spatialReference.equals(u.spatialReference)?(t=new a(e),n(t)):(t=r(e,u.spatialReference),t?n(t):null);function n(e){if(e.spatialReference.isWGS84)if(4===l.cameraOrientation?.type){const t=l.cameraOrientation;e=new a(s(e,[t.latitude,t.longitude,t.ellipsoidRadius,t.squaredEccentricity]))}else e=new a(i(e));const t=(e.z??0)-(u.z??0),r=(e.x-u.x)/f,n=(e.y-u.y)/f,o=(p[0]*r+p[1]*n+p[2]*t)/(p[6]*r+p[7]*n+p[8]*t),c=(p[3]*r+p[4]*n+p[5]*t)/(p[6]*r+p[7]*n+p[8]*t),m=o**2+c**2;let w=0,x=0,M=0,P=0,R=0,b=0,O=0;h&&(w=h[0]??0,x=h[1]??0,M=h[2]??0),v&&(P=v[0],R=v[1]),y&&(b=y[0]??0,O=y[1]??0);const z=1+(w||0)*m+(x||0)*m*m+(M||0)*m*m*m;let S=o*z+(P||0)*(m+2*o**2)+2*(R||0)*o*c,j=c*z+(R||0)*(m+2*c**2)+2*(P||0)*o*c;S=-(d??0)*S+b,j=-(d??0)*j+O;return{x:Number(g[0])+Number(g[1])*S+Number(g[2])*j,y:Number(g[3])+Number(g[4])*S+Number(g[5])*j}}})))}export{m as transformPoints,u as updateElevation};
@@ -2,4 +2,4 @@
2
2
  All material copyright ESRI, All Rights Reserved, unless otherwise specified.
3
3
  See https://js.arcgis.com/4.27/esri/copyright.txt for details.
4
4
  */
5
- import"../../../geometry.js";import{z as e}from"../../../chunks/vec3f64.js";import{w as t,a}from"../../../chunks/vec3.js";import n from"../../../geometry/Point.js";import{project as r}from"../../../geometry/projection.js";import{geographicToWebMercator as i,webMercatorToGeographic as s}from"../../../geometry/support/webMercatorUtils.js";import o from"../core/ExposurePoint.js";import{transformPoints as x,updateElevation as y}from"./groundToImageUtils.js";import{ltpToGeographic as c,computeHFOVAndVFOV as l,projectiveTransform2 as f,scaleWithFactor as z,scaleAndAddWithFactor as p,calculateRotationMatrix as m,transformMat3 as u,projectiveTransform as w,getPlaneLineIntersectionPoint as R}from"./utils.js";import g from"../../../geometry/SpatialReference.js";import h from"../../../geometry/Polygon.js";const b=Math.PI/180;function v(e,t){if(!e)return Promise.resolve([]);const a=t.feature;let n=a.attributes;return n instanceof o||(n=o.fromJSON(a),n&&(a.attributes=n)),M(e,t)}function M(e,t){const{attributes:a}=t.feature;return a.isSpherical||360===a.horizontalFieldOfView?[]:P(e,t)}async function P(e,t){const{feature:a,imageProperties:o}=t,{attributes:z}=a;let p=new n(z.location);if(4===z.cameraOrientation?.type){const e=z.cameraOrientation;p=new n(c(p,[e.latitude,e.longitude,e.ellipsoidRadius,e.squaredEccentricity]))}let m=!1;p.spatialReference.isWGS84&&(m=!0,p=i(p));const u=p.spatialReference.isWebMercator?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*p.y/6378137))):1,w=S(t,p,u),R=4===z.cameraOrientation?.type?w.map((e=>s(new n(e)))):w,g=await x(R,t,!0),b=await Promise.all(g);b.forEach((e=>{e.z=1,e.x=e.x*o.pixelSize.x+o.extent.xmin,e.y=o.extent.ymax-e.y*o.pixelSize.y}));const v=l(z.horizontalFieldOfView,z.verticalFieldOfView,z.cameraRoll).vfov;return Promise.all(e.map((async e=>{e.z=1;let i,c=f(e,b,R);if(i=4===z.cameraOrientation?.type?await(await x([s(new n({...c,spatialReference:p.spatialReference}))],t,!0))[0]:await(await x([new n({...c,spatialReference:p.spatialReference})],t,!0))[0],!i)return null;i.x=i.x*o.pixelSize.x+o.extent.xmin,i.y=o.extent.ymax-i.y*o.pixelSize.y;let l,w=Math.abs(e.x-i.x)+Math.abs(e.y-i.y);if(w>1){const a=await G(e,i,b,R,p,c,t);c=a.point,w=a.error}if(a.layer.elevationSource){let a=await O(t);if(a&&a.extent){let i=H(a,p,c);if(!i)return null;const f={x:i.x,y:i.y,z:i.z,hasZ:!0,spatialReference:p.spatialReference},w=new n(f);if(i){const f=r(w,t.currentCoveragePolygon.geometry?.spatialReference),R=y([f],t,!1);let g;g=R instanceof Promise?await R:R,w.z=i.z=g[0].z;const b=await x([4===z.cameraOrientation?.type?s(w):w],t);if(!b[0])return null;b[0].x=b[0].x*o.pixelSize.x+o.extent.xmin,b[0].y=o.extent.ymax-b[0].y*o.pixelSize.y;let M=Math.abs(e.x-b[0].x)+Math.abs(e.y-b[0].y);if(l=i.z,M>1){let f=0;const w=async R=>{if(M>1){const g=R.width/10,b=R.height/10;if(!R||g<1||b<1)return c=d(c,p,u,l,z,v,m),c;const P=[{x:i.x-g,y:i.y-b,spatialReference:p.spatialReference},{x:i.x+g,y:i.y-b,spatialReference:p.spatialReference},{x:i.x+g,y:i.y+b,spatialReference:p.spatialReference},{x:i.x-g,y:i.y+b,spatialReference:p.spatialReference}].map((e=>new n(e))),S=await y(P,t,!1);if(a=new h({rings:[[[S[0].x,S[0].y,S[0].z],[S[1].x,S[1].y,S[1].z],[S[2].x,S[2].y,S[2].z],[S[3].x,S[3].y,S[3].z],[S[0].x,S[0].y,S[0].z]]],spatialReference:p.spatialReference}),i=H(a,p,c),i){const y=r(new n({x:i.x,y:i.y,z:i.z,spatialReference:p.spatialReference}),t.currentCoveragePolygon.geometry?.spatialReference),R=await x([4===z.cameraOrientation?.type?s(y):y],t);if(R[0])return R[0].x=R[0].x*o.pixelSize.x+o.extent.xmin,R[0].y=o.extent.ymax-R[0].y*o.pixelSize.y,M=Math.abs(e.x-R[0].x)+Math.abs(e.y-R[0].y),l=i.z,M<=1||8===f?d(c,p,u,l,z,v,m):(f+=1,w(a.extent))}return d(c,p,u,p.z-z.averageHeightAboveGround,z,v,m)}return d(c,p,u,p.z-z.averageHeightAboveGround,z,v,m)};return w(a.extent)}return d(c,p,u,p.z-z.averageHeightAboveGround,z,v,m)}return d(c,p,u,p.z-z.averageHeightAboveGround,z,v,m)}}return d(c,p,u,p.z-z.averageHeightAboveGround,z,v,m)})))}function d(a,r,i,o,x,y,c){const l=Math.sqrt((a.z-r.z)**2+(Math.sqrt((a.x-r.x)**2+(a.y-r.y)**2)/i)**2)*i,f=z(t(e(),[a.x,a.y,a.z],[r.x,r.y,r.z]),1/l,1/i);if(a.z<o||x.cameraPitch+y/2<90){const e=Math.abs((r.z-o)/-f[2])*i,t=p([r.x,r.y,r.z],f,e,i);a={x:t[0],y:t[1],z:t[2]}}else a.z=o;return a.spatialReference=r.spatialReference,a=new n(a),c&&(a=s(a)),a}function S(r,i,s){const{feature:o}=r,{attributes:x}=o,y=2*Math.tan(x.verticalFieldOfView*b/2)*x.farDistance*s,c=2*Math.tan(x.horizontalFieldOfView*b/2)*x.farDistance*s,l=m("HPR",[x.cameraHeading,x.cameraPitch,x.cameraRoll]),f=u([0,0,-1],l),w=p([i.x,i.y,i.z],f,x.farDistance*s,s),R=u([0,1,0],l),g=u([1,0,0],l),h=z(R,y/2,s),v=z(g,c/2,s),M=t(e(),h,v),P=a(e(),h,v);return[a(e(),w,M),a(e(),w,P),t(e(),w,M),t(e(),w,P)].map((e=>{const[t,a,r]=e;return new n({x:t,y:a,z:r,spatialReference:i.spatialReference})}))}function O(e){const{feature:t}=e,a=j(e);if(!a)return Promise.resolve(null);const n=t.attributes.location.spatialReference.isWGS84?new g({wkid:102100}):t.attributes.location.spatialReference;return y(a,e,!1).then((e=>{const t=e.map((e=>r(e,n)));return new h({hasZ:!0,rings:[t.map((e=>[e.x,e.y,e.z]))],spatialReference:n})}))}function j(e){if(!e.currentCoveragePolygon.geometry)return null;const{xmin:t,xmax:a,ymin:r,ymax:i,spatialReference:s}=e.currentCoveragePolygon.geometry.extent.toJSON();return[new n({x:t,y:i,spatialReference:s}),new n({x:a,y:i,spatialReference:s}),new n({x:a,y:r,spatialReference:s}),new n({x:t,y:r,spatialReference:s})]}async function G(e,t,a,r,i,o,y){const{feature:{attributes:c},imageProperties:l}=y;let f=Math.abs(e.x-t.x)+Math.abs(e.y-t.y);if(f>1)for(let z=0;z<9;z++)if(f>1){let t,p={x:e.x-f,y:e.y-f,z:1},m={x:e.x+f,y:e.y-f,z:1},u={x:e.x+f,y:e.y+f,z:1},R={x:e.x-f,y:e.y+f,z:1};p=w(p,a[0],a[1],a[2],a[3],{x:r[0].x,y:r[0].y,z:r[0].z},{x:r[1].x,y:r[1].y,z:r[1].z},{x:r[2].x,y:r[2].y,z:r[2].z},{x:r[3].x,y:r[3].y,z:r[3].z}),m=w(m,a[0],a[1],a[2],a[3],{x:r[0].x,y:r[0].y,z:r[0].z},{x:r[1].x,y:r[1].y,z:r[1].z},{x:r[2].x,y:r[2].y,z:r[2].z},{x:r[3].x,y:r[3].y,z:r[3].z}),u=w(u,a[0],a[1],a[2],a[3],{x:r[0].x,y:r[0].y,z:r[0].z},{x:r[1].x,y:r[1].y,z:r[1].z},{x:r[2].x,y:r[2].y,z:r[2].z},{x:r[3].x,y:r[3].y,z:r[3].z}),R=w(R,a[0],a[1],a[2],a[3],{x:r[0].x,y:r[0].y,z:r[0].z},{x:r[1].x,y:r[1].y,z:r[1].z},{x:r[2].x,y:r[2].y,z:r[2].z},{x:r[3].x,y:r[3].y,z:r[3].z}),p.spatialReference=i.spatialReference,m.spatialReference=i.spatialReference,u.spatialReference=i.spatialReference,R.spatialReference=i.spatialReference,t=4===c.cameraOrientation?.type?await x([s(new n(p)),s(new n(m)),s(new n(u)),s(new n(R))],y,!0):await x([new n(p),new n(m),new n(u),new n(R)],y,!0);const g=await Promise.all(t);g.forEach((e=>{e.z=0,e.x=e.x*l.pixelSize.x+l.extent.xmin,e.y=l.extent.ymax-e.y*l.pixelSize.y}));const h=w(e,g[0],g[1],g[2],g[3],p,m,u,R);let b;if(b=4===c.cameraOrientation?.type?await(await x([s(new n({x:h.x,y:h.y,z:h.z,spatialReference:i.spatialReference}))],y,!0))[0]:await(await x([new n({x:h.x,y:h.y,z:h.z,spatialReference:i.spatialReference})],y,!0))[0],f=Math.abs(e.x-b.x)+Math.abs(e.y-b.y),f<=1||8===z){o=h;break}}return{error:f,point:o}}function H(e,t,a){const n={x:e.rings[0][0][0],y:e.rings[0][0][1],z:e.rings[0][0][2]},r={x:e.rings[0][1][0],y:e.rings[0][1][1],z:e.rings[0][1][2]},i={x:e.rings[0][1][0],y:e.rings[0][1][1],z:e.rings[0][1][2]},s={x:e.rings[0][2][0],y:e.rings[0][2][1],z:e.rings[0][2][2]},o=(s.z-i.z)*(r.y-n.y)-(s.y-i.y)*(r.z-n.z),x=-((s.z-i.z)*(r.x-n.x)-(r.z-n.z)*(s.x-i.x)),y=(s.y-i.y)*(r.x-n.x)-(r.y-n.y)*(s.x-i.x),c=-(o*n.x+x*n.y+y*n.z);return R(t.toJSON(),a,o,x,y,c)}export{v as transformPoints};
5
+ import"../../../geometry.js";import{z as e}from"../../../chunks/vec3f64.js";import{w as t,a}from"../../../chunks/vec3.js";import r from"../../../geometry/Point.js";import{project as n}from"../../../geometry/projection.js";import{geographicToWebMercator as i,webMercatorToGeographic as s}from"../../../geometry/support/webMercatorUtils.js";import x from"../core/ExposurePoint.js";import{transformPoints as c,updateElevation as y}from"./groundToImageUtils.js";import{ltpToGeographic as o,computeHFOVAndVFOV as l,projectiveTransform2 as f,scaleWithFactor as z,scaleAndAddWithFactor as p,calculateRotationMatrix as m,transformMat3 as u,projectiveTransform as w,getPlaneLineIntersectionPoint as R}from"./utils.js";import h from"../../../geometry/SpatialReference.js";import g from"../../../geometry/Polygon.js";const P=Math.PI/180;function b(e,t){if(!e)return Promise.resolve([]);const a=t.feature;let r=a.attributes;return r instanceof x||(r=x.fromJSON(a),r&&(a.attributes=r)),M(e,t)}function M(e,t){const{attributes:a}=t.feature;return a.isSpherical||360===a.horizontalFieldOfView?[]:S(e,t)}async function S(e,t){const{feature:a,imageProperties:x}=t,{attributes:z}=a;let p=new r(z.location);if(4===z.cameraOrientation?.type){const e=z.cameraOrientation;p=new r(o(p,[e.latitude,e.longitude,e.ellipsoidRadius,e.squaredEccentricity]))}let m=!1;p.spatialReference.isWGS84&&(m=!0,p=i(p));const u=p.spatialReference.isWebMercator?1/Math.cos(Math.PI/2-2*Math.atan(Math.exp(-1*p.y/6378137))):1,w=d(t,p,u),R=4===z.cameraOrientation?.type?w.map((e=>s(new r(e)))):w,h=await c(R,t,!0),P=await Promise.all(h);P.forEach((e=>{e.z=1,e.x=e.x*x.pixelSize.x+x.extent.xmin,e.y=x.extent.ymax-e.y*x.pixelSize.y}));const b=l(z.horizontalFieldOfView,z.verticalFieldOfView,z.cameraRoll??0).vfov;return Promise.all(e.map((async e=>{e.z=1;let i,o=f(e,P,R);if(i=4===z.cameraOrientation?.type?await(await c([s(new r({...o,spatialReference:p.spatialReference}))],t,!0))[0]:await(await c([new r({...o,spatialReference:p.spatialReference})],t,!0))[0],!i)return null;i.x=i.x*x.pixelSize.x+x.extent.xmin,i.y=x.extent.ymax-i.y*x.pixelSize.y;let l,w=Math.abs(e.x-i.x)+Math.abs(e.y-i.y);if(w>1){const a=await H(e,i,P,R,p,o,t);o=a.point,w=a.error}if(a.layer.elevationSource){let a=await v(t);if(a&&a.extent){let i=F(a,p,o);if(!i)return null;const f={x:i.x,y:i.y,z:i.z,hasZ:!0,spatialReference:p.spatialReference},w=new r(f);if(i){const f=n(w,t.currentCoveragePolygon.geometry?.spatialReference),R=y([f],t,!1);let h;h=R instanceof Promise?await R:R,w.z=i.z=h[0].z;const P=await c([4===z.cameraOrientation?.type?s(w):w],t);if(!P[0])return null;P[0].x=P[0].x*x.pixelSize.x+x.extent.xmin,P[0].y=x.extent.ymax-P[0].y*x.pixelSize.y;let M=Math.abs(e.x-P[0].x)+Math.abs(e.y-P[0].y);if(l=i.z,M>1){let f=0;const w=async R=>{if(M>1){const h=R.width/10,P=R.height/10;if(!R||h<1||P<1)return o=O(o,p,u,l,z.cameraPitch,b,m),o;const S=[{x:i.x-h,y:i.y-P,spatialReference:p.spatialReference},{x:i.x+h,y:i.y-P,spatialReference:p.spatialReference},{x:i.x+h,y:i.y+P,spatialReference:p.spatialReference},{x:i.x-h,y:i.y+P,spatialReference:p.spatialReference}].map((e=>new r(e))),d=await y(S,t,!1);if(a=new g({rings:[[[d[0].x,d[0].y,d[0].z],[d[1].x,d[1].y,d[1].z],[d[2].x,d[2].y,d[2].z],[d[3].x,d[3].y,d[3].z],[d[0].x,d[0].y,d[0].z]]],spatialReference:p.spatialReference}),i=F(a,p,o),i){const y=n(new r({x:i.x,y:i.y,z:i.z,spatialReference:p.spatialReference}),t.currentCoveragePolygon.geometry?.spatialReference),R=await c([4===z.cameraOrientation?.type?s(y):y],t);if(R[0])return R[0].x=R[0].x*x.pixelSize.x+x.extent.xmin,R[0].y=x.extent.ymax-R[0].y*x.pixelSize.y,M=Math.abs(e.x-R[0].x)+Math.abs(e.y-R[0].y),l=i.z,M<=1||8===f?O(o,p,u,l,z.cameraPitch,b,m):(f+=1,w(a.extent))}return O(o,p,u,p.z-z.cameraHeight,z.cameraPitch,b,m)}return O(o,p,u,p.z-z.cameraHeight,z.cameraPitch,b,m)};return w(a.extent)}return O(o,p,u,p.z-z.cameraHeight,z.cameraPitch,b,m)}return O(o,p,u,p.z-z.cameraHeight,z.cameraPitch,b,m)}}return O(o,p,u,p.z-z.cameraHeight,z.cameraPitch,b,m)})))}function O(a,n,i,x,c,y,o){const l=Math.sqrt((a.z-n.z)**2+(Math.sqrt((a.x-n.x)**2+(a.y-n.y)**2)/i)**2)*i,f=z(t(e(),[a.x,a.y,a.z],[n.x,n.y,n.z]),1/l,1/i);if(a.z<x||c+y/2<90){const e=Math.abs((n.z-x)/-f[2])*i,t=p([n.x,n.y,n.z],f,e,i);a={x:t[0],y:t[1],z:t[2]}}else a.z=x;return a.spatialReference=n.spatialReference,a=new r(a),o&&(a=s(a)),a}function d(n,i,s){const{feature:x}=n,{attributes:c}=x,y=2*Math.tan(c.verticalFieldOfView*P/2)*c.farDistance*s,o=2*Math.tan(c.horizontalFieldOfView*P/2)*c.farDistance*s,l=m("HPR",[c.cameraHeading,c.cameraPitch,c.cameraRoll??0]),f=u([0,0,-1],l),w=p([i.x,i.y,i.z],f,c.farDistance*s,s),R=u([0,1,0],l),h=u([1,0,0],l),g=z(R,y/2,s),b=z(h,o/2,s),M=t(e(),g,b),S=a(e(),g,b);return[a(e(),w,M),a(e(),w,S),t(e(),w,M),t(e(),w,S)].map((e=>{const[t,a,n]=e;return new r({x:t,y:a,z:n,spatialReference:i.spatialReference})}))}function v(e){const{feature:t}=e,a=j(e);if(!a)return Promise.resolve(null);const r=t.attributes.location.spatialReference.isWGS84?new h({wkid:102100}):t.attributes.location.spatialReference;return y(a,e,!1).then((e=>{const t=e.map((e=>n(e,r)));return new g({hasZ:!0,rings:[t.map((e=>[e.x,e.y,e.z]))],spatialReference:r})}))}function j(e){if(!e.currentCoveragePolygon.geometry)return null;const{xmin:t,xmax:a,ymin:n,ymax:i,spatialReference:s}=e.currentCoveragePolygon.geometry.extent.toJSON();return[new r({x:t,y:i,spatialReference:s}),new r({x:a,y:i,spatialReference:s}),new r({x:a,y:n,spatialReference:s}),new r({x:t,y:n,spatialReference:s})]}async function H(e,t,a,n,i,x,y){const{feature:{attributes:o},imageProperties:l}=y;let f=Math.abs(e.x-t.x)+Math.abs(e.y-t.y);if(f>1)for(let z=0;z<9;z++)if(f>1){let t,p={x:e.x-f,y:e.y-f,z:1},m={x:e.x+f,y:e.y-f,z:1},u={x:e.x+f,y:e.y+f,z:1},R={x:e.x-f,y:e.y+f,z:1};p=w(p,a[0],a[1],a[2],a[3],{x:n[0].x,y:n[0].y,z:n[0].z},{x:n[1].x,y:n[1].y,z:n[1].z},{x:n[2].x,y:n[2].y,z:n[2].z},{x:n[3].x,y:n[3].y,z:n[3].z}),m=w(m,a[0],a[1],a[2],a[3],{x:n[0].x,y:n[0].y,z:n[0].z},{x:n[1].x,y:n[1].y,z:n[1].z},{x:n[2].x,y:n[2].y,z:n[2].z},{x:n[3].x,y:n[3].y,z:n[3].z}),u=w(u,a[0],a[1],a[2],a[3],{x:n[0].x,y:n[0].y,z:n[0].z},{x:n[1].x,y:n[1].y,z:n[1].z},{x:n[2].x,y:n[2].y,z:n[2].z},{x:n[3].x,y:n[3].y,z:n[3].z}),R=w(R,a[0],a[1],a[2],a[3],{x:n[0].x,y:n[0].y,z:n[0].z},{x:n[1].x,y:n[1].y,z:n[1].z},{x:n[2].x,y:n[2].y,z:n[2].z},{x:n[3].x,y:n[3].y,z:n[3].z}),p.spatialReference=i.spatialReference,m.spatialReference=i.spatialReference,u.spatialReference=i.spatialReference,R.spatialReference=i.spatialReference,t=4===o.cameraOrientation?.type?await c([s(new r(p)),s(new r(m)),s(new r(u)),s(new r(R))],y,!0):await c([new r(p),new r(m),new r(u),new r(R)],y,!0);const h=await Promise.all(t);h.forEach((e=>{e.z=0,e.x=e.x*l.pixelSize.x+l.extent.xmin,e.y=l.extent.ymax-e.y*l.pixelSize.y}));const g=w(e,h[0],h[1],h[2],h[3],p,m,u,R);let P;if(P=4===o.cameraOrientation?.type?await(await c([s(new r({x:g.x,y:g.y,z:g.z,spatialReference:i.spatialReference}))],y,!0))[0]:await(await c([new r({x:g.x,y:g.y,z:g.z,spatialReference:i.spatialReference})],y,!0))[0],f=Math.abs(e.x-P.x)+Math.abs(e.y-P.y),f<=1||8===z){x=g;break}}return{error:f,point:x}}function F(e,t,a){const r={x:e.rings[0][0][0],y:e.rings[0][0][1],z:e.rings[0][0][2]},n={x:e.rings[0][1][0],y:e.rings[0][1][1],z:e.rings[0][1][2]},i={x:e.rings[0][1][0],y:e.rings[0][1][1],z:e.rings[0][1][2]},s={x:e.rings[0][2][0],y:e.rings[0][2][1],z:e.rings[0][2][2]},x=(s.z-i.z)*(n.y-r.y)-(s.y-i.y)*(n.z-r.z),c=-((s.z-i.z)*(n.x-r.x)-(n.z-r.z)*(s.x-i.x)),y=(s.y-i.y)*(n.x-r.x)-(n.y-r.y)*(s.x-i.x),o=-(x*r.x+c*r.y+y*r.z);return R(t.toJSON(),a,x,c,y,o)}export{b as transformPoints};