@arcgis/core 4.31.0-next.20240708 → 4.31.0-next.20240710
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{0975e54c50383375cc09.js → 14cf7411e8318a1bccb9.js} +1 -1
- package/assets/esri/core/workers/chunks/{71852b8437ec66b9ef06.js → 2123ab24163a532ebc8d.js} +1 -1
- package/assets/esri/core/workers/chunks/{c91b3800cf3891bf2d59.js → 252ff37bf5e12dae0b18.js} +1 -1
- package/assets/esri/core/workers/chunks/2799007b5f3f4a2e364c.js +51 -0
- package/assets/esri/core/workers/chunks/{ff5e6d823d512f87a527.js → 2dddb8a989b9c96572fe.js} +1 -1
- package/assets/esri/core/workers/chunks/34b5bab6239c7277f854.js +1 -0
- package/assets/esri/core/workers/chunks/543f9db420c99d429637.js +1 -0
- package/assets/esri/core/workers/chunks/{5089a12084a8a8fb93d8.js → 61e5179fb49866241128.js} +1 -1
- package/assets/esri/core/workers/chunks/632e3ba2b8a881df29a0.js +1 -0
- package/assets/esri/core/workers/chunks/63eb1cc923bb8dcb3cb3.js +1 -0
- package/assets/esri/core/workers/chunks/{380e2654bc7e07163df0.js → 725a0eae5248a933db05.js} +1 -1
- package/assets/esri/core/workers/chunks/{1cc4a89c96a36d6b3d52.js → 7767559d56d16b644655.js} +1 -1
- package/assets/esri/core/workers/chunks/7baf288a07401f9e972d.js +1 -0
- package/assets/esri/core/workers/chunks/{43e83f4d827f59ff556a.js → 8087288f00dfdcc479b9.js} +1 -1
- package/assets/esri/core/workers/chunks/{a5fbe1c95e49093e5af4.js → 8cce4b218568638e6e64.js} +1 -1
- package/assets/esri/core/workers/chunks/{c7e2a97cb7bcd153bcef.js → 8e326def543268f8a08e.js} +1 -1
- package/assets/esri/core/workers/chunks/92cb45b18e151db007dc.js +1 -0
- package/assets/esri/core/workers/chunks/b2e8cc76381077b78d4c.js +1 -0
- package/assets/esri/core/workers/chunks/b6a8132708afcd988fa9.js +1 -0
- package/assets/esri/core/workers/chunks/{b4d850e82a8ae902d684.js → c44cc686774ff53c0a94.js} +1 -1
- package/assets/esri/core/workers/chunks/c52701477405c1fb2072.js +1 -0
- package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js → cfc2a1858a8bbb284979.js} +2 -2
- package/assets/esri/core/workers/chunks/{9ed11b9202013ca001ee.js.LICENSE.txt → cfc2a1858a8bbb284979.js.LICENSE.txt} +1 -1
- package/assets/esri/core/workers/chunks/d9863289c69d2550cd49.js +1 -0
- package/assets/esri/core/workers/chunks/e1f4df3a5b0b31521b3c.js +1 -0
- package/assets/esri/core/workers/chunks/ee72a006e25e94a4cd4a.js +1039 -0
- package/assets/esri/core/workers/chunks/{61505947371cebab9cbe.js → fdebfe55cd097714ec11.js} +1 -1
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +13 -18
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/chunks/AtmosphereCompositing.glsl.js +6 -9
- package/chunks/BlendLayers.glsl.js +1 -7
- package/chunks/BlendWeights.glsl.js +81 -86
- package/chunks/Blur.glsl.js +1 -3
- package/chunks/ChapmanAtmosphere.glsl.js +3 -8
- package/chunks/CheckerBoard.glsl.js +3 -9
- package/chunks/Clouds.glsl.js +21 -10
- package/chunks/CloudsComposition.glsl.js +3 -7
- package/chunks/ColorMaterial.glsl.js +3 -9
- package/chunks/ComponentShader.glsl.js +41 -75
- package/chunks/Compositing.glsl.js +5 -7
- package/chunks/DefaultMaterial.glsl.js +68 -73
- package/chunks/EdgeDetect.glsl.js +29 -39
- package/chunks/EdgeShader.glsl.js +37 -60
- package/chunks/Fog.glsl.js +4 -9
- package/chunks/HUDCompositing.glsl.js +1 -3
- package/chunks/HUDMaterial.glsl.js +11 -20
- package/chunks/Heatmap.glsl.js +3 -11
- package/chunks/HeatmapDensity.glsl.js +12 -15
- package/chunks/HighlightApply.glsl.js +130 -174
- package/chunks/HighlightDownsample.glsl.js +29 -32
- package/chunks/ImageMaterial.glsl.js +11 -21
- package/chunks/LaserlinePath.glsl.js +6 -10
- package/chunks/Laserlines.glsl.js +8 -20
- package/chunks/LineCallout.glsl.js +91 -108
- package/chunks/LineMarker.glsl.js +62 -53
- package/chunks/Magnifier.glsl.js +4 -9
- package/chunks/MeasurementArrow.glsl.js +9 -15
- package/chunks/NativeLine.glsl.js +8 -12
- package/chunks/NoiseTextureAtlas.glsl.js +89 -86
- package/chunks/OITCompositing.glsl.js +8 -12
- package/chunks/OverlayCompositing.glsl.js +2 -4
- package/chunks/Path.glsl.js +31 -55
- package/chunks/Pattern.glsl.js +16 -20
- package/chunks/PointRenderer.glsl.js +39 -48
- package/chunks/Precipitation.glsl.js +22 -39
- package/chunks/RasterColorizer.glsl.js +25 -33
- package/chunks/RealisticTree.glsl.js +53 -65
- package/chunks/RibbonLine.glsl.js +31 -36
- package/chunks/SSAO.glsl.js +7 -10
- package/chunks/SSAOBlur.glsl.js +10 -14
- package/chunks/ShadedColorMaterial.glsl.js +12 -15
- package/chunks/ShadowCastAccumulate.glsl.js +6 -8
- package/chunks/ShadowCastVisualize.glsl.js +12 -18
- package/chunks/ShadowHighlight.glsl.js +49 -51
- package/chunks/SimpleAtmosphere.glsl.js +4 -13
- package/chunks/SlicePlaneMaterial.glsl.js +3 -7
- package/chunks/Stars.glsl.js +3 -7
- package/chunks/Terrain.glsl.js +20 -61
- package/chunks/TextureOnly.glsl.js +2 -4
- package/chunks/Viewshed.glsl.js +20 -38
- package/chunks/WaterSurface.glsl.js +34 -60
- package/core/accessorSupport/tracking.js +1 -1
- package/core/workers/registry.js +1 -1
- package/geometry/Circle.js +1 -1
- package/geometry/Polygon.js +1 -1
- package/geometry/Polyline.js +1 -1
- package/geometry/support/geodesicUtils.js +1 -1
- package/interfaces.d.ts +34 -4
- package/layers/WCSLayer.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/orientedImagery/transformations/imageToGroundUtils.js +1 -1
- package/layers/support/SubtypeSublayer.js +1 -1
- package/layers/support/rasterDatasets/WCSRaster.js +1 -1
- package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
- package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
- package/package.json +3 -3
- package/support/revision.js +1 -1
- package/views/2d/engine/flow/styles/Imagery.js +1 -1
- package/views/2d/engine/flow/styles/Particles.js +1 -1
- package/views/2d/engine/flow/styles/Streamlines.js +1 -1
- package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/vectorTiles/RenderBucket.js +1 -1
- package/views/2d/engine/vectorTiles/shaders/VTLMaterial.js +1 -1
- package/views/2d/engine/webgl/BitBlitRenderer.js +1 -1
- package/views/2d/engine/webgl/DefaultVertexAttributeLayouts.js +1 -1
- package/views/2d/engine/webgl/Mesh2D.js +1 -1
- package/views/2d/engine/webgl/Overlay.js +1 -1
- package/views/2d/engine/webgl/OverlayMultipoint.js +1 -1
- package/views/2d/engine/webgl/Utils.js +1 -1
- package/views/2d/engine/webgl/VertexStream.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushStencil.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushTileDebugInfo.js +1 -1
- package/views/2d/engine/webgl/brushes/WGLBrushVTLBackground.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
- package/views/2d/engine/webgl/effects/highlight/HighlightRenderer.js +1 -1
- package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
- package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/ShaderBuilder2D.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/FeatureInstanceStore.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/dotDensity/DotDensityTechnique.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/heatmap/HeatmapTechnique.js +1 -1
- package/views/2d/layers/graphics/GraphicBoundsRenderer.js +1 -1
- package/views/2d/layers/support/DebugOverlay.js +1 -1
- package/views/2d/magnifier/MagnifierView2D.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/environment/LocalAtmosphere.js +1 -1
- package/views/3d/environment/MarsAtmosphere.js +1 -1
- package/views/3d/environment/Precipitation.js +1 -1
- package/views/3d/environment/Stars.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/edgeOffsetUtils.js +1 -1
- package/views/3d/interactive/editingTools/reshape/reshapeTooltipUtils.js +1 -1
- package/views/3d/interactive/editingTools/transform/extentTransform/extentUtils.js +1 -1
- package/views/3d/layers/FeatureLayerViewBase3D.js +1 -1
- package/views/3d/layers/FeatureLikeLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/StreamLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DFeatureProcessor.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphicsPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +5 -0
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +5 -0
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +5 -0
- package/views/3d/layers/graphics/pipeline/PBFPointFeaturesView.js +5 -0
- package/views/3d/layers/graphics/pipeline/TestSymbol.js +5 -0
- package/views/3d/layers/graphics/pipeline/Tile.js +5 -0
- package/views/3d/layers/graphics/pipeline/Tile3DFetcher.js +5 -0
- package/views/3d/layers/graphics/pipeline/Tile3DProcessor.js +5 -0
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/HeatmapFeatureProcessor.js +1 -1
- package/views/3d/layers/support/projectExtentUtils.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchGeometryFactory.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/webgl/ManagedFBObject.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentObjectCollection.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPass.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ScreenSpacePass.glsl.js +3 -5
- package/views/3d/webgl-engine/core/shaderLibrary/Slice.glsl.js +3 -3
- package/views/3d/webgl-engine/core/shaderLibrary/default/DefaultMaterialAuxiliaryPasses.glsl.js +29 -59
- package/views/3d/webgl-engine/core/shaderLibrary/hud/HUDOcclusionPass.glsl.js +6 -12
- package/views/3d/webgl-engine/core/shaderLibrary/shading/LineStipple.glsl.js +11 -11
- package/views/3d/webgl-engine/core/shaderLibrary/shading/MarkerSizing.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/MultipassTerrainTest.glsl.js +4 -7
- package/views/3d/webgl-engine/core/shaderLibrary/shading/ScreenSpaceReflections.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/TextureTransformUV.glsl.js +6 -6
- package/views/3d/webgl-engine/core/shaderLibrary/shading/Water.glsl.js +4 -4
- package/views/3d/webgl-engine/core/shaderLibrary/terrain/TileComposite.glsl.js +2 -4
- package/views/3d/webgl-engine/core/shaderLibrary/util/LocalFromScreenSpace.glsl.js +2 -2
- package/views/3d/webgl-engine/core/shaderModules/ShaderBuilder.js +1 -1
- package/views/3d/webgl-engine/effects/RenderNodes.js +1 -1
- package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +1 -1
- package/views/3d/webgl-engine/effects/blit/Blit.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePathData.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserlinePathTechnique.js +1 -1
- package/views/3d/webgl-engine/effects/magnifier/MagnifierRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/DrapedHeatmapRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/EdgeView.js +1 -1
- package/views/3d/webgl-engine/lib/glUtil3D.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
- package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoCache.js +1 -1
- package/views/3d/webgl-engine/shaders/Heatmap.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/HighlightApply.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/OITCompositing.glsl.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/draw/support/Box.js +1 -1
- package/views/interactive/tooltip/Tooltip.js +1 -1
- package/views/interactive/tooltip/fields/fields.js +1 -1
- package/views/webgl/RenderingContext.js +1 -1
- package/views/webgl/Util.js +1 -1
- package/views/webgl/VertexArrayObject.js +1 -1
- package/views/webgl/enums.js +1 -1
- package/views/webgl/heatmapTextureUtils.js +1 -1
- package/views/webgl/testDoublePrecisionArithmetic.js +1 -1
- package/views/webgl/testFloatBufferBlend.js +1 -1
- package/views/webgl/testSVGPremultipliedAlpha.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileController.js +1 -1
- package/widgets/Feature/FeatureRelationship/FeatureRelationshipViewModel.js +1 -1
- package/widgets/Feature/support/relatedFeatureUtils.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/OrientedImageryViewer/constants.js +1 -1
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/UtilityNetworkTrace/UtilityNetworkTraceViewModel.js +1 -1
- package/widgets/UtilityNetworkTrace.js +1 -1
- package/widgets/support/TimezonePicker.js +1 -1
- package/assets/esri/core/workers/chunks/0cb2eb96ffb1dbed00eb.js +0 -1
- package/assets/esri/core/workers/chunks/0d6ed27fc9948f4ea061.js +0 -1
- package/assets/esri/core/workers/chunks/225b947ba4b2fcfd5630.js +0 -1
- package/assets/esri/core/workers/chunks/7c7c3068da3bf7467685.js +0 -1
- package/assets/esri/core/workers/chunks/812e18c65aa6e398c338.js +0 -1
- package/assets/esri/core/workers/chunks/85e5cdd723f68dec8c25.js +0 -1
- package/assets/esri/core/workers/chunks/a7e2ca5ede46395f0787.js +0 -1
- package/assets/esri/core/workers/chunks/aed0db145187d9eb52f2.js +0 -51
- package/assets/esri/core/workers/chunks/cf9a32a03b3d3b66effb.js +0 -1
- package/assets/esri/core/workers/chunks/d85c51abde781660b1f5.js +0 -1
- package/assets/esri/core/workers/chunks/e840e54455eb500b501d.js +0 -1098
- package/assets/esri/core/workers/chunks/fec53ce15ae52f8cb802.js +0 -1
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/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 i,websceneRasterRendererTypes as r,read as s}from"../../rasterRenderers.js";import n from"../../request.js";import a from"../../core/Error.js";import{clone as o}from"../../core/lang.js";import l from"../../core/Logger.js";import{watch as u}from"../../core/reactiveUtils.js";import{urlToObject as p}from"../../core/urlUtils.js";import{property as m,ensureRange as c}from"../../core/accessorSupport/decorators/property.js";import{Integer as d,ensureClass as h,ensureNumber as y}from"../../core/accessorSupport/ensureType.js";import{reader as f}from"../../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{writer as R}from"../../core/accessorSupport/decorators/writer.js";import{srToRESTValue as b}from"../../geometry/support/spatialReferenceUtils.js";import{opacity as w,url as I}from"../support/commonProperties.js";import v from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as S}from"../support/ExportImageServiceParameters.js";import x 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 T from"../support/MosaicRule.js";import O from"../support/MultidimensionalSubset.js";import P from"../support/PixelBlock.js";import{interpolationKebab as j,noDataInterpretationKebab as C,pixelTypeKebabDict as M}from"../support/rasterEnums.js";import N from"../support/RasterFunction.js";import q from"../support/RasterInfo.js";import A from"../support/RasterJobHandler.js";import{intersectMultimensionalSubset as E,getSubsetVariablesFromMdInfo as J,getDefaultMultidimensionalDefinition as V}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as Q,getFormat as H}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as U}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as B,getDefaultBandCombination as L,createDefaultRenderer as z,normalizeRendererJSON as G}from"../../renderers/support/rasterRendererHelper.js";import k 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,measureLengthFromImage as ie,measureAreaFromImage as re,getImageSpatialReferenceQueryParameter as se,getSamples as ne,identify as ae,imageToMap as oe,imageToMapMultiray as le,mapToImage as ue,findImages as pe,getImageUrl as me,queryBoundary as ce,queryGPSInfo as de}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as he}from"../../rest/query/executeQueryJSON.js";import"../../config.js";import"../../kernel.js";import"../../core/unitUtils.js";import"../../geometry/ellipsoidUtils.js";import"../../geometry/support/aaBoundingBox.js";import"../../core/mathUtils.js";import ye from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import fe from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtilsCommon.js";import ge from"../../geometry/SpatialReference.js";import"../../geometry/support/Ellipsoid.js";import"../../core/pbf.js";import Re from"../../rest/support/FeatureSet.js";import be from"../../rest/support/Query.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as we}from"../../rest/query/executeForCount.js";import{executeForIds as Ie}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{generateRasterInfo as ve,fetchServiceRasterInfo as Se,patchServiceInfo as xe}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as _e}from"../../rest/imageService/getCatalogItemRasterInfo.js";import Fe from"../../rest/support/ImageIdentifyParameters.js";import{createFlowMesh as De}from"../../views/2d/engine/flow/dataUtils.js";const Te=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),Oe=c(y,{min:0,max:255});function Pe(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),i=t?.map((e=>e.slice(18,-1)));return i?i.join("/"):null}const je=c=>{let y=class extends c{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 S({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.length<1||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replaceAll(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,i){null!=e&&"lerc"!==this.format&&(t[i]=e)}writeCompressionTolerance(e,t,i){"lerc"===this.format&&null!=e&&(t[i]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?T.fromJSON(t):null}get fieldsIndex(){return this.fields?new _(this.fields):null}set format(e){e&&Te.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t?.mosaicMethod&&(t=T.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const i=e||t.mosaicRule;return i?T.fromJSON(i):this._isMosaicRuleSupported(t)?T.fromJSON(t):null}writeMosaicRule(e,t,i){let r=this.mosaicRule;const s=this.definitionExpression;r?s&&s!==r.where&&(r=r.clone(),r.where=s):s&&(r=new T({where:s})),this._isValidCustomizedMosaicRule(r)&&(t[i]=r.toJSON())}writeNoData(e,t,i){null!=e&&"number"==typeof e&&(t[i]=Oe(e))}readObjectIdField(e,t){if(!e){const i=t.fields.find((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=i?.name}return e}get parsedUrl(){return p(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer,n=s(r,i);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!r.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),D(n)||l.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,i){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this._rasterAttributeTableFieldPrefix,t=new x({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new x({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new x({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?o(this.fields):[];s.push(i),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(r),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new x({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),this._isVectorDataSet()&&(s.push(new x({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new x({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 i=o(t);return i.name=e+t.name,i}));s=s.concat(t)}return s}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=N.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const i=t.rasterFunctionInfos;return t.renderingRule||i?.length&&"None"!==i[0].name?this._isRFTJson(t.renderingRule)?N.fromJSON({rasterFunctionDefinition:t.renderingRule}):N.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const i=e||t.extent.spatialReference;return i?ge.fromJSON(i):null}readPixelType(e){return M.fromJSON(e)||e}writePixelType(e,t,i){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[i]=M.toJSON(e))}readVersion(e,t){let i=t.currentVersion;return i||(i=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),i}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let i=e;const{renderer:r,symbolizer:s,pixelFilter:n,bandIds:a}=this;if(!this._isPicture()&&r&&s&&!n){const n=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(r.toJSON()),o=this._rasterJobHandler.instance;if(o){n&&(s.bind(),await o.updateSymbolizer(s,t),this._cachedRendererJson=r.toJSON());const l=await o.symbolize({bandIds:a,...e},t);i={extent:e.extent,pixelBlock:l}}else i={extent:e.extent,pixelBlock:s.symbolize({bandIds:a,...e})}}return i}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new a("imagery-layer:compute-angles","this operation is not supported on the input image service");return 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 $(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=o(e),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=o(e),this._applyMosaicAndRenderingRules(e),K(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const i=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?i.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?i.mensuration.supportsHeightFromBaseAndTopShadow:i.mensuration.supportsHeightFromTopAndTopShadow))throw new a("imagery-layer:measure-height","this operation is not supported on the input image service");return e=o(e),this._applyMosaicAndRenderingRules(e),Y(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsAreaAndPerimeter&&(!e.is3D||i.mensuration.supports3D)))throw new a("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=o(e),this._applyMosaicAndRenderingRules(e),Z(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsDistanceAndAngle&&(!e.is3D||i.mensuration.supports3D)))throw new a("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=o(e),this._applyMosaicAndRenderingRules(e),ee(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsPointOrCentroid&&(!e.is3D||i.mensuration.supports3D)))throw new a("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=o(e),this._applyMosaicAndRenderingRules(e),te(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new a("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new a("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return ie(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new a("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new a("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return re(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const i=this.getField(e);return i?i.domain:null}async fetchImage(e,t,i,r={}){if(null==e||null==t||null==i)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:r.signal});e&&(this.rasterInfo=e)}const s=this.getExportImageServiceParameters(e,t,i,r.timeExtent);if(null==s){if(r.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=i,r.returnImageBitmap){return{imageBitmap:await F(e,`${je(this.parsedUrl)}/exportImage`,r.signal)}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,a=(s?.length||n.bandCount)??0,o=t*i,l=n.pixelType,u=[];for(let e=0;e<a;e++)u.push(P.createEmptyBand(l,o));return{pixelData:{pixelBlock:new P({width:t,height:i,pixels:u,mask:new Uint8Array(o),pixelType:l}),extent:e}}}const n=!!r.requestAsImageElement&&!this.pixelFilter,o=n&&!!r.returnImageBitmap,l={imageServiceParameters:s,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:n,returnImageBitmap:o,signal:r.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=>Re.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return _e(je(this.parsedUrl),e,i)}async getCatalogItemICSInfo(e,t){const{data:i}=await n(je(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),r=i?.ics;if(!r)return;let s=null;try{s=(await n(je(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s?.spatialReference)return{ics:r,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?n(je(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},o=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:b(o),outSR:"0:"+e},u=n(je(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,m=(s.xmin+s.xmax)/2,c=(s.ymax-s.ymin)/(p+1),d=s.ymin+c,h=[];for(let n=0;n<p;n++)h.push({x:m,y:d+c*n});const y={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:b(o),outSR:"0:"+e},f=n(je(this.parsedUrl)+"/project",{query:this._getQueryParams(y),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([a,u,f]);let R=g[0].ipxf;if(null==R){const e=r.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const w=ye.fromJSON(g[1]?.geometries?.[0]);w&&(w.spatialReference=new ge({wkid:0,imageCoordinateSystem:r}));const I=g[2].geometries?g[2].geometries.filter((e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],v=I.length;if(v<3)return{ics:r,icsToPixelTransform:R,icsExtent:w,northDirection:null};let S=0,x=0,_=0,F=0;for(let n=0;n<v;n++)S+=I[n].x,x+=I[n].y,_+=I[n].x*I[n].x,F+=I[n].x*I[n].y;const D=(v*F-S*x)/(v*_-S*S);let T=0;const O=I[p-1].x>I[0].x,P=I[p-1].y>I[0].y;return D===1/0?T=P?90:270:0===D?T=O?0:180:D>0?T=O?180*Math.atan(D)/Math.PI:180*Math.atan(D)/Math.PI+180:D<0&&(T=P?180+180*Math.atan(D)/Math.PI:360+180*Math.atan(D)/Math.PI),{ics:r,icsToPixelTransform:R,icsExtent:w,northDirection:T}}async generateRasterInfo(e,t){if(e=h(N,e),this.serviceRasterInfo&&(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e)))return this.serviceRasterInfo;const i=Pe(e);if(!i)throw new a("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[i])return this._functionRasterInfos[i];const r={...t,query:this._getQueryParams()},s=ve(je(this.parsedUrl),e,r);this._functionRasterInfos[i]=s;try{return await s}catch(n){throw this._functionRasterInfos[i]=null,n}}getExportImageServiceParameters(e,t,i,r){e=e.clone().shiftCentralMeridian();const s=se(e.spatialReference,je(this.parsedUrl));this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:a,noData:o}=n;let{renderingRule:l}=n;const u=this.rasterFunction?.rasterFunctionDefinition,p=!this.renderer||"raster-stretch"===this.renderer.type;if(a?.length&&this._hasRasterFunction(this.rasterFunction)&&!u&&p){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:a}};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=a?.join(",");Array.isArray(o)&&o.length>0&&(n.noData=o.join(","));const m=this._processMultidimensionalIntersection(null,r,this.exportImageServiceParameters.mosaicRule);if(m.isOutSide)return null;n.mosaicRule=null!=m.mosaicRule?JSON.stringify(m.mosaicRule):null,r=m.timeExtent,n.renderingRule=this._getRenderingRuleString(N.fromJSON(l));const c={};if(null!=r){const{start:e,end:t}=r.toJSON();e&&t&&e===t?c.time=""+e:null==e&&null==t||(c.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+i,...n,...c}}async getSamples(e,t){const i=await this._fetchCapabilities(t?.signal);if(!i?.operations.supportsGetSamples)throw new a("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=o(e);const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),ne(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=o(e),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=fe.fromExtent(e.geometry));const i=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(i.isOutSide)throw new a("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=i.timeExtent,e.mosaicRule=i.mosaicRule;const{raster:r,rasterFunction:s}=this;return s&&null==e.rasterFunction&&(e.rasterFunction=s),r&&null==e.raster&&(e.raster=r),ae(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new a("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return oe(je(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new a("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return le(je(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new a("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return ue(je(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new a("imagery-layer:find-images","findImages operation is not supported on the input image service");return pe(je(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new a("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return me(je(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new be({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new a("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=e??{outSpatialReference:this.spatialReference},ce(je(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),he(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ie(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new a("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=e??{where:"1=1"},de(je(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),we(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:i,returnDomainValues:r,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p="raster.servicepixelvalue",m=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,m),t]}));l=t.map((e=>new N({functionName:e[0]}))),u=t.map((e=>e[1]));const{rasterFunction:i}=this;0===l.length?i?.functionName?(l.push(i),u.push(i.functionName)):l=null:i?.functionName&&!l.some((e=>e.functionName===i.functionName))&&(l.push(i),u.push(i.functionName))}const c=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:d}=this;let h=e.timeExtent||this.timeExtent;if(d){const{isOutside:t,intersection:i}=E(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");null!=i?.timeExtent&&(h=i.timeExtent)}const y=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,h);let f=e.geometry;this.version<10.91&&"extent"===f?.type&&(f=fe.fromExtent(f));const g=this._getQueryParams({geometry:f,timeExtent:h,mosaicRule:y,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:i,returnCatalogItems:o,returnGeometry:c,raster:this.raster,maxItemCount:s?1:null});delete g.f;const R=new Fe(g);try{await this._generateRasterInfo(this.rasterFunction);const i=await ae(this.url,R,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,a=null!=i.value&&i.value.toLowerCase().includes("nodata");if(!(o&&!c&&i?.catalogItems?.features.length&&(n||!a)))return this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",p=i.catalogItems?.features??[],m=p.map((e=>e.attributes?.[l])),d=new be({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),h=await this.queryRasters(d);return h?.features?.length&&h.features.forEach((t=>{p.forEach((i=>{i.attributes[l]===t.attributes[l]&&(i.geometry=new fe(t.geometry),null!=e.outSpatialReference&&(i.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(i,{returnDomainValues:r,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 i=n(je(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),r=n(je(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([i,r]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const i=this._rasterJobHandler.instance;return i?i.createFlowMesh(e,t):De(e.meshType,e.simulationSettings,e.flowData,null!=t.signal?t.signal:(new AbortController).signal)}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return J(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,i=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):Se(je(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),xe(e,t),e))),r=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([i,r,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),l.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([u((()=>this.rasterFunction),(e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this._generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))}))]);const{serviceRasterInfo:t}=this;null!=t.multidimensionalInfo&&this._updateMultidimensionalDefinition(t)}))}_combineMosaicRuleWithTimeExtent(e,t){const i=this.timeInfo,{multidimensionalInfo:r}=this.serviceRasterInfo;if(null==e||null==r||null==t||null==i?.startField)return e;const{startField:s}=i,n=r.variables.some((e=>e.dimensions.some((e=>e.name===s))))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter((e=>e.dimensionName!==n)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const a=e.multidimensionalDefinition.filter((e=>e.dimensionName===n)),o=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==o||null==l||o===l,p=u?[o||l]:[[o,l]],m=this.version>=10.8;if(a.length)a.forEach((e=>{e.dimensionName===n&&(m?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=p))}));else if(!m){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 v({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?h(be,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 A;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:i}=this;return"unique-value"===e.type&&this._hasRasterFunction(i)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&B(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:i,ssl:r}=await n(je(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=i,this.sourceJSON=t,r&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new 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),i=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||i}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:i}=e,r="resample"===t?.toLowerCase(),s=i?.ResampleType||i?.resampleType;return r&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:i}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){if(!this.bandIds&&i.bandCount>=3){const e=L(i);!e||3===i.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=z(i,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=G(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=i):this.symbolizer=new k({rendererJSON:t,rasterInfo:i}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){null!=e?.renderingRule&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:i}=this;return{raster:t,viewId:i,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,i){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):Q(e,t,i)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;const i=await n(je(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e});return i.data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:i,returnImageBitmap:r,signal:s}=e;if(i&&this._canRequestImageElement(t.format)){const i=`${je(this.parsedUrl)}/exportImage`,{data:a}=await n(i,{responseType:r?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:s});if(a instanceof Blob){return{imageBitmap:await F(a,i,s),params:t}}return{imageOrCanvasElement:a,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 m=p;if("bsq"!==m&&"bip"!==m&&(m=H(u)),!m)throw new a("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const c={signal:s},d="gif"===p||"bmp"===p||p.includes("png")&&("png"===m||"jpg"===m)?Q(u,{useCanvas:!0,...t},c):this._decodePixelBlock(u,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:p},c);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 T;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.rasterFunction&&"none"!==this.rasterFunction.functionName?.toLowerCase()&&t.forEach((e=>e.variableName="")),t=t.filter((({variableName:e,dimensionName:t})=>e&&"*"!==e||t)),!e?.length&&t.length&&(this.mosaicRule.multidimensionalDefinition=t)}}_processVisibleRastersResponse(e,i){i=i||{};const r=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=i,l=e.processedValues;let u=e.catalogItems?.features,p=e.properties?.Values?.map((e=>e.replaceAll(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",c="string"==typeof r&&r.toLowerCase().includes("nodata"),d=[];if(r&&!u&&!c){const e={};e[m]=0;p=[r],u=[new t({geometry:this.fullExtent,attributes:e})]}if(!u)return[];let h,y,f;this._updateResponseFieldNames(u,o),c&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(h=u[t],null!=r){if(y=p[t],f=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:r,"nodata"===y.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",i="Raster.ServicePixelValue";h.attributes[e]=y,h.attributes[i]=f,this._updateFeatureWithMagDirValues(h,y);const a=this.fields&&this.fields.length>0;let o=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?a?y:r:f;this.rasterFunction||(o=a?y:r),this._updateFeatureWithRasterAttributeTableValues(h,o)}if(h.sourceLayer=h.layer=this,a&&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,i){const{multidimensionalSubset:r}=this;if(!r)return{isOutSide:!1,timeExtent:t,mosaicRule:i=this._combineMosaicRuleWithTimeExtent(i,t)};if(r){const{isOutside:i,intersection:s}=E(r,{geometry:e,timeExtent:t});if(i)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=s?.timeExtent&&(t=s.timeExtent)}if(i=this._combineMosaicRuleWithTimeExtent(i,t),i?.multidimensionalDefinition){const{isOutside:e}=E(r,{multidimensionalDefinition:i.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:i}}_updateFeatureWithRasterAttributeTableValues(e,t){const i=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==i)return;const{features:r,fields:s}=i,n=s.map((e=>e.name)).find((e=>"value"===e.toLowerCase()));if(!n)return;const a=r.filter((e=>e.attributes[n]===(null!=t?parseInt(t,10):null)));a&&a[0]&&s.forEach((t=>{const i=this._rasterAttributeTableFieldPrefix+t.name;e.attributes[i]=a[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const i=t.split(/,\s*/).map((e=>parseFloat(e))),r=i.map((e=>[e])),s=i.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new P({height:1,width:1,pixelType:"f32",pixels:r,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new ye(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:U([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=a[0],e.attributes["Raster.Direction"]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const i=e.attributes[t.name];if(null!=i){const r=t.domain.codedValues.find((e=>e.code===i));r&&(e.attributes[t.name]=r.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const i=this.fieldsIndex;null!=i&&e.forEach((e=>{if(e?.attributes)for(const r of t){const t=i.get(r)?.name;t&&t!==r&&(e.attributes[r]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(e){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRasterFunction(e){return null!=e?.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const i=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(i)?t.get(i):e}_isRFTJson(e){return e?.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:i,rasterFunction:r}=this;r&&"rasterFunction"in e&&null==e.rasterFunction&&(e.rasterFunction=r),i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:i,advancedQueryCapabilities:r,maxRecordCount:s}=e,n=t.includes("image"),a="esriImageServiceDataTypeElevation"===e.serviceDataType,o=!(!e.spatialReference&&!e.extent?.spatialReference),l=t.includes("edit"),u=t.includes("mensuration")&&o,p=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map((e=>e.trim())),m=u&&p.includes("basic"),c=this._isMosaicDataset(e)&&t.includes("catalog"),d=t.includes("download");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsImageToMap:i>=11.2&&c,supportsImageToMapMultiray:i>=11.2&&c,supportsMapToImage:i>=11.2&&c,supportsFindImages:i>=11.2&&c,supportsGetImageUrl:i>=11.3&&d,supportsMeasure:u,supportsMeasureFromImage:i>=11.2,supportsDownload:d,supportsQuery:c&&e.fields&&e.fields.length>0,supportsGetSamples:i>=10.2&&n,supportsProject:i>=10.3&&n,supportsComputeStatisticsHistograms:i>=10.4&&n,supportsQueryBoundary:i>=10.6&&n,supportsCalculateVolume:i>=10.7&&a,supportsComputePixelLocation:i>=10.7&&c,supportsComputeAngles:i>=10.91,supportsQueryGPSInfo:i>=11.2&&c,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:!!r?.supportsStatistics,supportsOrderBy:!!r?.supportsOrderBy,supportsDistinct:!!r?.supportsDistinct,supportsPagination:!!r?.supportsPagination,supportsStandardizedQueriesOnly:!!r?.useStandardizedQueries,supportsPercentileStatistics:!!r?.supportsPercentileStatistics,supportsCentroid:!!r?.supportsReturningGeometryCentroid,supportsDistance:!!r?.supportsQueryWithDistance,supportsExtent:!!r?.supportsReturningQueryExtent,supportsGeometryProperties:!!r?.supportsReturningGeometryProperties,supportsHavingClause:!!r?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!r?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0},mensuration:{supportsDistanceAndAngle:m,supportsAreaAndPerimeter:m,supportsPointOrCentroid:m,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({clonable:!1})],y.prototype,"_functionRasterInfos",void 0),e([m({clonable:!1})],y.prototype,"_rasterJobHandler",void 0),e([m({clonable:!1})],y.prototype,"_cachedRendererJson",void 0),e([m({readOnly:!0})],y.prototype,"_serviceSupportsMosaicRule",void 0),e([f("_serviceSupportsMosaicRule",["currentVersion","fields"])],y.prototype,"readServiceSupportsMosaicRule",null),e([m({readOnly:!0})],y.prototype,"_rasterAttributeTableFieldPrefix",void 0),e([m({readOnly:!0})],y.prototype,"_rasterFunctionNamesIndex",null),e([m()],y.prototype,"adjustAspectRatio",void 0),e([m({type:[d],json:{write:!0}})],y.prototype,"bandIds",void 0),e([f("bandIds")],y.prototype,"readBandIds",null),e([m({readOnly:!0,json:{read:!1}})],y.prototype,"capabilities",void 0),e([f("service","capabilities",["capabilities","currentVersion","serviceDataType"])],y.prototype,"readCapabilities",null),e([m({type:Number})],y.prototype,"compressionQuality",void 0),e([R("compressionQuality")],y.prototype,"writeCompressionQuality",null),e([m({type:Number})],y.prototype,"compressionTolerance",void 0),e([R("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([f("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:[x]})],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","bip","bsq"],json:{write:!0}})],y.prototype,"format",null),e([f("service","format",["serviceDataType"])],y.prototype,"readFormat",null),e([m({type:ye})],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:j.jsonValues,read:j.read,write:j.write}})],y.prototype,"interpolation",void 0),e([m()],y.prototype,"minScale",void 0),e([f("service","minScale")],y.prototype,"readMinScale",null),e([m()],y.prototype,"maxScale",void 0),e([f("service","maxScale")],y.prototype,"readMaxScale",null),e([m({type:T})],y.prototype,"mosaicRule",null),e([f("mosaicRule",["mosaicRule","defaultMosaicMethod"])],y.prototype,"readMosaicRule",null),e([R("mosaicRule")],y.prototype,"writeMosaicRule",null),e([m()],y.prototype,"multidimensionalInfo",void 0),e([m({type:O,json:{write:!0}})],y.prototype,"multidimensionalSubset",void 0),e([m({json:{type:d}})],y.prototype,"noData",void 0),e([R("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([f("objectIdField")],y.prototype,"readObjectIdField",null),e([m({readOnly:!0})],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([f("sourceType",["serviceSourceType","fields"])],y.prototype,"readSourceType",null),e([m()],y.prototype,"viewId",void 0),e([m({types:i,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:r,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],y.prototype,"renderer",null),e([f("renderer")],y.prototype,"readRenderer",null),e([R("renderer")],y.prototype,"writeRenderer",null),e([m({clonable:!1})],y.prototype,"symbolizer",void 0),e([m(w)],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:N,json:{name:"renderingRule"}})],y.prototype,"rasterFunction",null),e([f("rasterFunction",["renderingRule","rasterFunctionInfos"])],y.prototype,"readRasterFunction",null),e([m({readOnly:!0})],y.prototype,"serviceDataType",void 0),e([m({readOnly:!0,type:ge})],y.prototype,"spatialReference",void 0),e([f("spatialReference",["spatialReference","extent"])],y.prototype,"readSpatialReference",null),e([m({json:{type:M.jsonValues}})],y.prototype,"pixelType",void 0),e([f("pixelType")],y.prototype,"readPixelType",null),e([R("pixelType")],y.prototype,"writePixelType",null),e([m({constructOnly:!0,type:q})],y.prototype,"serviceRasterInfo",void 0),e([m()],y.prototype,"sourceJSON",void 0),e([m(I)],y.prototype,"url",void 0),e([m({readOnly:!0})],y.prototype,"version",void 0),e([f("version",["currentVersion","fields","timeInfo"])],y.prototype,"readVersion",null),y=e([g("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 i,websceneRasterRendererTypes as r,read as s}from"../../rasterRenderers.js";import n from"../../request.js";import a from"../../core/Error.js";import{clone as o}from"../../core/lang.js";import l from"../../core/Logger.js";import{watch as u}from"../../core/reactiveUtils.js";import{urlToObject as p}from"../../core/urlUtils.js";import{property as m,ensureRange as c}from"../../core/accessorSupport/decorators/property.js";import{Integer as d,ensureClass as h,ensureNumber as y}from"../../core/accessorSupport/ensureType.js";import{reader as f}from"../../core/accessorSupport/decorators/reader.js";import{subclass as g}from"../../core/accessorSupport/decorators/subclass.js";import{writer as R}from"../../core/accessorSupport/decorators/writer.js";import{srToRESTValue as b}from"../../geometry/support/spatialReferenceUtils.js";import{opacity as w,url as I}from"../support/commonProperties.js";import v from"../support/DimensionalDefinition.js";import{ExportImageServiceParameters as S}from"../support/ExportImageServiceParameters.js";import x 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 T from"../support/MosaicRule.js";import O from"../support/MultidimensionalSubset.js";import P from"../support/PixelBlock.js";import{interpolationKebab as j,noDataInterpretationKebab as C,pixelTypeKebabDict as M}from"../support/rasterEnums.js";import N from"../support/RasterFunction.js";import q from"../support/RasterInfo.js";import A from"../support/RasterJobHandler.js";import{intersectMultimensionalSubset as E,getSubsetVariablesFromMdInfo as J,getDefaultMultidimensionalDefinition as V}from"../support/rasterDatasets/multidimensionalUtils.js";import{decode as Q,getFormat as H}from"../support/rasterFormats/RasterCodec.js";import{uvComponentToVector as U}from"../support/rasterFunctions/vectorFieldUtils.js";import{getSupportedRendererTypes as B,getDefaultBandCombination as L,createDefaultRenderer as z,normalizeRendererJSON as G}from"../../renderers/support/rasterRendererHelper.js";import k 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,measureLengthFromImage as ie,measureAreaFromImage as re,getImageSpatialReferenceQueryParameter as se,getSamples as ne,identify as ae,imageToMap as oe,imageToMapMultiray as le,mapToImage as ue,findImages as pe,getImageUrl as me,queryBoundary as ce,queryGPSInfo as de}from"../../rest/imageService.js";import"../../core/has.js";import"../support/source/DataLayerSource.js";import{executeQueryJSON as he}from"../../rest/query/executeQueryJSON.js";import"../../config.js";import"../../kernel.js";import"../../core/unitUtils.js";import"../../geometry/ellipsoidUtils.js";import"../../geometry/support/aaBoundingBox.js";import"../../core/mathUtils.js";import ye from"../../geometry/Extent.js";import"../../geometry/Geometry.js";import"../../geometry/Multipoint.js";import"../../geometry/Point.js";import fe from"../../geometry/Polygon.js";import"../../geometry/Polyline.js";import"../../geometry/support/normalizeUtilsCommon.js";import ge from"../../geometry/SpatialReference.js";import"../../geometry/support/Ellipsoid.js";import"../../core/pbf.js";import Re from"../../rest/support/FeatureSet.js";import be from"../../rest/support/Query.js";import"../../rest/query/support/AttachmentInfo.js";import"../../rest/support/AttachmentQuery.js";import{executeForCount as we}from"../../rest/query/executeForCount.js";import{executeForIds as Ie}from"../../rest/query/executeForIds.js";import"../../rest/support/RelationshipQuery.js";import"../../rest/support/TopFeaturesQuery.js";import{generateRasterInfo as ve,fetchServiceRasterInfo as Se,patchServiceInfo as xe}from"../../rest/imageService/fetchRasterInfo.js";import{getCatalogItemRasterInfo as _e}from"../../rest/imageService/getCatalogItemRasterInfo.js";import Fe from"../../rest/support/ImageIdentifyParameters.js";import{createFlowMesh as De}from"../../views/2d/engine/flow/dataUtils.js";const Te=new Set(["png","png8","png24","png32","jpg","bmp","gif","jpgpng","lerc","tiff"]),Oe=c(y,{min:0,max:255});function Pe(e){if(!e)return null;const t=JSON.stringify(e).match(/"rasterFunction":"(.*?")/gi),i=t?.map((e=>e.slice(18,-1)));return i?i.join("/"):null}const je=c=>{let y=class extends c{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 S({layer:this}))}readServiceSupportsMosaicRule(e,t){return this._isMosaicRuleSupported(t)}get _rasterFunctionNamesIndex(){const e=new Map;return!this.rasterFunctionInfos||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.length<1||null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.forEach((t=>{e.set(t.name.toLowerCase().replaceAll(/ /gi,"_"),t.name)})),e}readBandIds(e,t){if(Array.isArray(e)&&e.length>0&&e.every((e=>"number"==typeof e)))return e}readCapabilities(e,t){return this._readCapabilities(t)}writeCompressionQuality(e,t,i){null!=e&&"lerc"!==this.format&&(t[i]=e)}writeCompressionTolerance(e,t,i){"lerc"===this.format&&null!=e&&(t[i]=e)}readDefaultMosaicRule(e,t){return this._serviceSupportsMosaicRule?T.fromJSON(t):null}get fieldsIndex(){return this.fields?new _(this.fields):null}set format(e){e&&Te.has(e.toLowerCase())&&this._set("format",e.toLowerCase())}readFormat(e,t){return"esriImageServiceDataTypeVector-UV"===t.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===t.serviceDataType||null!=this.pixelFilter?"lerc":"jpgpng"}readMinScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}readMaxScale(e,t){return null!=t.minLOD&&null!=t.maxLOD?e:0}set mosaicRule(e){let t=e;t?.mosaicMethod&&(t=T.fromJSON({...t.toJSON(),mosaicMethod:t.mosaicMethod,mosaicOperation:t.mosaicOperation})),this._set("mosaicRule",t)}readMosaicRule(e,t){const i=e||t.mosaicRule;return i?T.fromJSON(i):this._isMosaicRuleSupported(t)?T.fromJSON(t):null}writeMosaicRule(e,t,i){let r=this.mosaicRule;const s=this.definitionExpression;r?s&&s!==r.where&&(r=r.clone(),r.where=s):s&&(r=new T({where:s})),this._isValidCustomizedMosaicRule(r)&&(t[i]=r.toJSON())}writeNoData(e,t,i){null!=e&&"number"==typeof e&&(t[i]=Oe(e))}readObjectIdField(e,t){if(!e){const i=t.fields.find((e=>"esriFieldTypeOID"===e.type||"oid"===e.type));e=i?.name}return e}get parsedUrl(){return p(this.url)}readSourceType(e,t){return this._isMosaicDataset(t)?"mosaic-dataset":"raster-dataset"}set renderer(e){this.loaded&&(e=this._configRenderer(e)),this._set("renderer",e)}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer,n=s(r,i);return null==n?null:("vector-field"===n.type&&t.symbolTileSize&&!r.symbolTileSize&&(n.symbolTileSize=t.symbolTileSize),D(n)||l.getLogger(this).warn("ArcGISImageService","Imagery layer doesn't support given renderer type."),n)}writeRenderer(e,t,i){t.layerDefinition=t.layerDefinition||{},t.layerDefinition.drawingInfo=t.layerDefinition.drawingInfo||{},t.layerDefinition.drawingInfo.renderer=e.toJSON(),"vector-field"===e.type&&(t.symbolTileSize=e.symbolTileSize)}get rasterFields(){const e=this._rasterAttributeTableFieldPrefix,t=new x({name:"Raster.ItemPixelValue",alias:"Item Pixel Value",domain:null,editable:!1,length:50,type:"string"}),i=new x({name:"Raster.ServicePixelValue",alias:"Service Pixel Value",domain:null,editable:!1,length:50,type:"string"}),r=new x({name:"Raster.ServicePixelValue.Raw",alias:"Raw Service Pixel Value",domain:null,editable:!1,length:50,type:"string"});let s=this.fields?o(this.fields):[];s.push(i),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(r),null!=this.rasterFunctionInfos&&this.rasterFunctionInfos.filter((e=>"none"!==e.name.toLowerCase())).forEach((e=>{s.push(new x({name:"Raster.ServicePixelValue."+e.name,alias:e.name,domain:null,editable:!1,length:50,type:"string"}))})),this._isVectorDataSet()&&(s.push(new x({name:"Raster.Magnitude",alias:"Magnitude",domain:null,editable:!1,type:"double"})),s.push(new x({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 i=o(t);return i.name=e+t.name,i}));s=s.concat(t)}return s}set rasterFunction(e){let t=e;t?.rasterFunction&&(t=N.fromJSON({...t.toJSON(),rasterFunction:t.rasterFunction,rasterFunctionArguments:t.rasterFunctionArguments})),this._set("rasterFunction",t)}readRasterFunction(e,t){const i=t.rasterFunctionInfos;return t.renderingRule||i?.length&&"None"!==i[0].name?this._isRFTJson(t.renderingRule)?N.fromJSON({rasterFunctionDefinition:t.renderingRule}):N.fromJSON(t.renderingRule||{rasterFunctionInfos:t.rasterFunctionInfos}):null}readSpatialReference(e,t){const i=e||t.extent.spatialReference;return i?ge.fromJSON(i):null}readPixelType(e){return M.fromJSON(e)||e}writePixelType(e,t,i){null!=this.serviceRasterInfo&&this.pixelType===this.serviceRasterInfo.pixelType||(t[i]=M.toJSON(e))}readVersion(e,t){let i=t.currentVersion;return i||(i=t.hasOwnProperty("fields")||t.hasOwnProperty("timeInfo")?10:9.3),i}applyFilter(e){let t=e;return this.pixelFilter&&(t=this._clonePixelData(e),this.pixelFilter(t)),t}async applyRenderer(e,t){let i=e;const{renderer:r,symbolizer:s,pixelFilter:n,bandIds:a}=this;if(!this._isPicture()&&r&&s&&!n){const n=JSON.stringify(this._cachedRendererJson)!==JSON.stringify(r.toJSON()),o=this._rasterJobHandler.instance;if(o){n&&(s.bind(),await o.updateSymbolizer(s,t),this._cachedRendererJson=r.toJSON());const l=await o.symbolize({bandIds:a,...e},t);i={extent:e.extent,pixelBlock:l}}else i={extent:e.extent,pixelBlock:s.symbolize({bandIds:a,...e})}}return i}destroy(){this._shutdownJobHandler()}increaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandler.refCount--,this._rasterJobHandler.refCount<=0&&this._shutdownJobHandler()}async computeAngles(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsComputeAngles)throw new a("imagery-layer:compute-angles","this operation is not supported on the input image service");return 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 $(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=o(e),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=o(e),this._applyMosaicAndRenderingRules(e),K(this.url,e,this._getRequestOptions(t))}async measureHeight(e,t){const i=await this._fetchCapabilities(t?.signal);if(!("base-and-top"===e.operationType?i.mensuration.supportsHeightFromBaseAndTop:"base-and-top-shadow"===e.operationType?i.mensuration.supportsHeightFromBaseAndTopShadow:i.mensuration.supportsHeightFromTopAndTopShadow))throw new a("imagery-layer:measure-height","this operation is not supported on the input image service");return e=o(e),this._applyMosaicAndRenderingRules(e),Y(this.url,e,this._getRequestOptions(t))}async measureAreaAndPerimeter(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsAreaAndPerimeter&&(!e.is3D||i.mensuration.supports3D)))throw new a("imagery-layer:measure-area-and-perimeter","this operation is not supported on the input image service");return e=o(e),this._applyMosaicAndRenderingRules(e),Z(this.url,e,this._getRequestOptions(t))}async measureDistanceAndAngle(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsDistanceAndAngle&&(!e.is3D||i.mensuration.supports3D)))throw new a("imagery-layer:measure-distance-and-angle","this operation is not supported on the input image service");return e=o(e),this._applyMosaicAndRenderingRules(e),ee(this.url,e,this._getRequestOptions(t))}async measurePointOrCentroid(e,t){const i=await this._fetchCapabilities(t?.signal);if(!(i.mensuration.supportsPointOrCentroid&&(!e.is3D||i.mensuration.supports3D)))throw new a("imagery-layer:measure-point-or-centroid","this operation is not supported on the input image service");return e=o(e),this._applyMosaicAndRenderingRules(e),te(this.url,e,this._getRequestOptions(t))}async measureLengthFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new a("imagery-layer:measure-length-from-image","this operation is not supported on the input image service");if("polyline"!==e.geometry.type)throw new a("imagery-layer:measure-length-from-image","this input geometry must be a polyline");return ie(this.url,e,this._getRequestOptions(t))}async measureAreaFromImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMeasureFromImage)throw new a("imagery-layer:measure-area-from-image","this operation is not supported on the input image service");if("polygon"!==e.geometry.type)throw new a("imagery-layer:measure-area-from-image","this input geometry must be a polygon");return re(this.url,e,this._getRequestOptions(t))}getField(e){const{fieldsIndex:t}=this;return null!=t?t.get(e):void 0}getFieldDomain(e,t){const i=this.getField(e);return i?i.domain:null}async fetchImage(e,t,i,r={}){if(null==e||null==t||null==i)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:r.signal});e&&(this.rasterInfo=e)}const s=this.getExportImageServiceParameters(e,t,i,r.timeExtent);if(null==s){if(r.requestAsImageElement&&this._canRequestImageElement(this.format)){const e=document.createElement("canvas");if(e.width=t,e.height=i,r.returnImageBitmap){return{imageBitmap:await F(e,`${je(this.parsedUrl)}/exportImage`,r.signal)}}return{imageOrCanvasElement:e}}const{bandIds:s,rasterInfo:n}=this,a=(s?.length||n.bandCount)??0,o=t*i,l=n.pixelType,u=[];for(let e=0;e<a;e++)u.push(P.createEmptyBand(l,o));return{pixelData:{pixelBlock:new P({width:t,height:i,pixels:u,mask:new Uint8Array(o),pixelType:l}),extent:e}}}const n=!!r.requestAsImageElement&&!this.pixelFilter,o=n&&!!r.returnImageBitmap,l={imageServiceParameters:s,imageProps:{extent:e,width:t,height:i,format:this.format},requestAsImageElement:n,returnImageBitmap:o,signal:r.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=>Re.fromJSON(e.data)))}getCatalogItemRasterInfo(e,t){const i={...t,query:this._getQueryParams()};return _e(je(this.parsedUrl),e,i)}async getCatalogItemICSInfo(e,t){const{data:i}=await n(je(this.parsedUrl)+"/"+e+"/info/ics",{query:this._getQueryParams(),...t}),r=i?.ics;if(!r)return;let s=null;try{s=(await n(je(this.parsedUrl)+"/"+e+"/info",{query:this._getQueryParams(),...t})).data.extent}catch{}if(!s?.spatialReference)return{ics:r,icsToPixelTransform:null,icsExtent:null,northDirection:null};const a=this.version>=10.7?n(je(this.parsedUrl)+"/"+e+"/info/icstopixel",{query:this._getQueryParams(),...t}).then((e=>e.data)).catch((()=>({}))):{},o=s.spatialReference,l={geometries:JSON.stringify({geometryType:"esriGeometryEnvelope",geometries:[s]}),inSR:b(o),outSR:"0:"+e},u=n(je(this.parsedUrl)+"/project",{query:this._getQueryParams(l),...t}).then((e=>e.data)).catch((()=>({}))),p=5,m=(s.xmin+s.xmax)/2,c=(s.ymax-s.ymin)/(p+1),d=s.ymin+c,h=[];for(let n=0;n<p;n++)h.push({x:m,y:d+c*n});const y={geometries:JSON.stringify({geometryType:"esriGeometryPoint",geometries:h}),inSR:b(o),outSR:"0:"+e},f=n(je(this.parsedUrl)+"/project",{query:this._getQueryParams(y),...t}).then((e=>e.data)).catch((()=>({}))),g=await Promise.all([a,u,f]);let R=g[0].ipxf;if(null==R){const e=r.geodataXform?.xf_0;"topup"===e?.name?.toLowerCase()&&6===e?.coefficients?.length&&(R={affine:{name:"ics [sensor: Frame] to pixel (column, row) transformation",coefficients:e.coefficients,cellsizeRatio:0,type:"GeometricXform"}})}const w=ye.fromJSON(g[1]?.geometries?.[0]);w&&(w.spatialReference=new ge({wkid:0,imageCoordinateSystem:r}));const I=g[2].geometries?g[2].geometries.filter((e=>null!=e?.x&&null!=e.y&&"NaN"!==e.x&&"NaN"!==e.y)):[],v=I.length;if(v<3)return{ics:r,icsToPixelTransform:R,icsExtent:w,northDirection:null};let S=0,x=0,_=0,F=0;for(let n=0;n<v;n++)S+=I[n].x,x+=I[n].y,_+=I[n].x*I[n].x,F+=I[n].x*I[n].y;const D=(v*F-S*x)/(v*_-S*S);let T=0;const O=I[p-1].x>I[0].x,P=I[p-1].y>I[0].y;return D===1/0?T=P?90:270:0===D?T=O?0:180:D>0?T=O?180*Math.atan(D)/Math.PI:180*Math.atan(D)/Math.PI+180:D<0&&(T=P?180+180*Math.atan(D)/Math.PI:360+180*Math.atan(D)/Math.PI),{ics:r,icsToPixelTransform:R,icsExtent:w,northDirection:T}}async generateRasterInfo(e,t){if(e=h(N,e),this.serviceRasterInfo&&(!e||"none"===e.functionName?.toLowerCase()||this._isVectorFieldResampleFunction(e)))return this.serviceRasterInfo;const i=Pe(e);if(!i)throw new a("imagery-layer:generate-raster-info","the rendering rule is not supported");if(this._functionRasterInfos[i])return this._functionRasterInfos[i];const r={...t,query:this._getQueryParams()},s=ve(je(this.parsedUrl),e,r);this._functionRasterInfos[i]=s;try{return await s}catch(n){throw this._functionRasterInfos[i]=null,n}}getExportImageServiceParameters(e,t,i,r){e=e.clone().shiftCentralMeridian();const s=se(e.spatialReference,je(this.parsedUrl));this.pixelType!==this.serviceRasterInfo.pixelType&&(this.exportImageServiceParameters.pixelType=this.pixelType);const n=this.exportImageServiceParameters.toJSON(),{bandIds:a,noData:o}=n;let{renderingRule:l}=n;const u=this.rasterFunction?.rasterFunctionDefinition,p=!this.renderer||"raster-stretch"===this.renderer.type;if(a?.length&&this._hasRasterFunction(this.rasterFunction)&&!u&&p){const e={rasterFunction:"ExtractBand",rasterFunctionArguments:{BandIds:a}};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=a?.join(",");Array.isArray(o)&&o.length>0&&(n.noData=o.join(","));const m=this._processMultidimensionalIntersection(null,r,this.exportImageServiceParameters.mosaicRule);if(m.isOutSide)return null;n.mosaicRule=null!=m.mosaicRule?JSON.stringify(m.mosaicRule):null,r=m.timeExtent,n.renderingRule=this._getRenderingRuleString(N.fromJSON(l));const c={};if(null!=r){const{start:e,end:t}=r.toJSON();e&&t&&e===t?c.time=""+e:null==e&&null==t||(c.time=`${e??"null"},${t??"null"}`)}return{bbox:e.xmin+","+e.ymin+","+e.xmax+","+e.ymax,bboxSR:s,imageSR:s,size:t+","+i,...n,...c}}async getSamples(e,t){const i=await this._fetchCapabilities(t?.signal);if(!i?.operations.supportsGetSamples)throw new a("imagery-layer:get-samples","getSamples operation is not supported on the input image service");e=o(e);const{raster:r}=this;return r&&null==e.raster&&(e.raster=r),ne(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=o(e),this.version<10.91&&"extent"===e.geometry?.type&&(e.geometry=fe.fromExtent(e.geometry));const i=this._processMultidimensionalIntersection(e.geometry,e.timeExtent,e.mosaicRule||this.mosaicRule);if(i.isOutSide)throw new a("imagery-layer:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");e.timeExtent=i.timeExtent,e.mosaicRule=i.mosaicRule;const{raster:r,rasterFunction:s}=this;return s&&null==e.rasterFunction&&(e.rasterFunction=s),r&&null==e.raster&&(e.raster=r),ae(this.url,e,this._getRequestOptions(t))}async imageToMap(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMap)throw new a("imagery-layer:image-to-map","imageToMap operation is not supported on the input image service");return oe(je(this.parsedUrl),e,this._getRequestOptions(t))}async imageToMapMultiray(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsImageToMapMultiray)throw new a("imagery-layer:image-to-map-multiray","imageToMapMultiray operation is not supported on the input image service");return le(je(this.parsedUrl),e,this._getRequestOptions(t))}async mapToImage(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsMapToImage)throw new a("imagery-layer:map-to-image","mapToImage operation is not supported on the input image service");return ue(je(this.parsedUrl),e,this._getRequestOptions(t))}async findImages(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsFindImages)throw new a("imagery-layer:find-images","findImages operation is not supported on the input image service");return pe(je(this.parsedUrl),e,this._getRequestOptions(t))}async getImageUrl(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsGetImageUrl)throw new a("imagery-layer:get-image-url","getImageUrl operation is not supported on the input image service");return me(je(this.parsedUrl),e,this._getRequestOptions(t))}createQuery(){return new be({outFields:["*"],returnGeometry:!0,where:this.definitionExpression||"1=1"})}async queryBoundary(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryBoundary)throw new a("imagery-layer:query-boundary","queryBoundary operation is not supported on the input image service");return e=e??{outSpatialReference:this.spatialReference},ce(je(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasters(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),he(this.url,e,t)}async queryObjectIds(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),Ie(this.url,e,t)}async queryGPSInfo(e,t){if(!(await this._fetchCapabilities(t?.signal)).operations.supportsQueryGPSInfo)throw new a("imagery-layer:query-gps-info","queryGPSInfo operation is not supported on the input image service");return e=e??{where:"1=1"},de(je(this.parsedUrl),e,this._getRequestOptions(t))}async queryRasterCount(e,t){return({query:e,requestOptions:t}=await this._prepareForQuery(e,t)),we(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:i,returnDomainValues:r,returnTopmostRaster:s,showNoDataRecords:n}=t||{pixelSize:null,returnDomainValues:!1,returnTopmostRaster:!1,showNoDataRecords:!1};let o=!1,l=null,u=null;const p="raster.servicepixelvalue",m=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,m),t]}));l=t.map((e=>new N({functionName:e[0]}))),u=t.map((e=>e[1]));const{rasterFunction:i}=this;0===l.length?i?.functionName?(l.push(i),u.push(i.functionName)):l=null:i?.functionName&&!l.some((e=>e.functionName===i.functionName))&&(l.push(i),u.push(i.functionName))}const c=null==e.outSpatialReference||e.outSpatialReference.equals(this.spatialReference),{multidimensionalSubset:d}=this;let h=e.timeExtent||this.timeExtent;if(d){const{isOutside:t,intersection:i}=E(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");null!=i?.timeExtent&&(h=i.timeExtent)}const y=this._combineMosaicRuleWithTimeExtent(this.exportImageServiceParameters.mosaicRule,h);let f=e.geometry;this.version<10.91&&"extent"===f?.type&&(f=fe.fromExtent(f));const g=this._getQueryParams({geometry:f,timeExtent:h,mosaicRule:y,rasterFunction:this.version<10.4?this.rasterFunction:null,rasterFunctions:l,pixelSize:i,returnCatalogItems:o,returnGeometry:c,raster:this.raster,maxItemCount:s?1:null});delete g.f;const R=new Fe(g);try{await this._generateRasterInfo(this.rasterFunction);const i=await ae(this.url,R,{signal:t?.signal,query:{...this.customParameters}}),s=e.outFields,a=null!=i.value&&i.value.toLowerCase().includes("nodata");if(!(o&&!c&&i?.catalogItems?.features.length&&(n||!a)))return this._processVisibleRastersResponse(i,{returnDomainValues:r,templateRRFunctionNames:u,showNoDataRecords:n,templateFields:s});const l=this.objectIdField||"ObjectId",p=i.catalogItems?.features??[],m=p.map((e=>e.attributes?.[l])),d=new be({objectIds:m,returnGeometry:!0,outSpatialReference:e.outSpatialReference,outFields:[l]}),h=await this.queryRasters(d);return h?.features?.length&&h.features.forEach((t=>{p.forEach((i=>{i.attributes[l]===t.attributes[l]&&t.geometry&&(i.geometry=t.geometry.clone(),null!=e.outSpatialReference&&(i.geometry.spatialReference=e.outSpatialReference))}))})),this._processVisibleRastersResponse(i,{returnDomainValues:r,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 i=n(je(this.parsedUrl)+"/statistics",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.statistics)),r=n(je(this.parsedUrl)+"/histograms",{query:this._getQueryParams({variable:e}),signal:t}).then((e=>e.data?.histograms)),s=await Promise.all([i,r]);return s[0]&&s[0].forEach((e=>{e.avg=e.mean,e.stddev=e.standardDeviation})),{statistics:s[0]||null,histograms:s[1]||null}}async createFlowMesh(e,t){const i=this._rasterJobHandler.instance;return i?i.createFlowMesh(e,t):De(e.meshType,e.simulationSettings,e.flowData,null!=t.signal?t.signal:(new AbortController).signal)}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo.multidimensionalInfo;return J(this.multidimensionalSubset,t)}async _fetchService(e){await this._fetchServiceInfo(e),this.rasterInfo||(this.rasterInfo=this.serviceRasterInfo);const t=this.sourceJSON,i=null!=this.serviceRasterInfo?Promise.resolve(this.serviceRasterInfo):Se(je(this.parsedUrl),t,{signal:e,query:this._getQueryParams()}).then((e=>(this._set("serviceRasterInfo",e),this._set("multidimensionalInfo",e.multidimensionalInfo),xe(e,t),e))),r=this._hasRasterFunction(this.rasterFunction)?this._generateRasterInfo(this.rasterFunction,{signal:e}):null,s=this._getRasterFunctionInfos();return Promise.all([i,r,s]).then((e=>{e[1]?this._set("rasterInfo",e[1]):this._set("rasterInfo",e[0]),e[2]&&this._set("rasterFunctionInfos",e[2]),this.renderer&&!this._isSupportedRenderer(this.renderer)&&(this._set("renderer",null),l.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([u((()=>this.rasterFunction),(e=>{(this.renderer||this.symbolizer||this.popupEnabled&&this.popupTemplate)&&this._generateRasterInfo(e).then((e=>{e&&(this.rasterInfo=e)}))}))]);const{serviceRasterInfo:t}=this;null!=t.multidimensionalInfo&&this._updateMultidimensionalDefinition(t)}))}_combineMosaicRuleWithTimeExtent(e,t){const i=this.timeInfo,{multidimensionalInfo:r}=this.serviceRasterInfo;if(null==e||null==r||null==t||null==i?.startField)return e;const{startField:s}=i,n=r.variables.some((e=>e.dimensions.some((e=>e.name===s))))?s:"StdTime";if(e=e.clone(),"mosaic-dataset"===this.sourceType)return e.multidimensionalDefinition=e.multidimensionalDefinition?.filter((e=>e.dimensionName!==n)),this._cleanupMultidimensionalDefinition(e);e.multidimensionalDefinition=e.multidimensionalDefinition||[];const a=e.multidimensionalDefinition.filter((e=>e.dimensionName===n)),o=null!=t.start?t.start.getTime():null,l=null!=t.end?t.end.getTime():null,u=null==o||null==l||o===l,p=u?[o||l]:[[o,l]],m=this.version>=10.8;if(a.length)a.forEach((e=>{e.dimensionName===n&&(m?(e.dimensionName=null,e.isSlice=!1,e.values=[]):(e.isSlice=u,e.values=p))}));else if(!m){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 v({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?h(be,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 A;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:i}=this;return"unique-value"===e.type&&this._hasRasterFunction(i)&&1===t?.bandCount&&["u8","s8"].includes(t.pixelType)||null!=t&&null!=e&&B(t).includes(e.type)}async _fetchCapabilities(e){return this.capabilities||await this._fetchServiceInfo(e),this.capabilities}async _fetchServiceInfo(e){let t=this.sourceJSON;if(!t){const{data:i,ssl:r}=await n(je(this.parsedUrl),{query:this._getQueryParams(),signal:e});t=i,this.sourceJSON=t,r&&(this.url=this.url.replace(/^http:/i,"https:"))}if(t.capabilities?.toLowerCase().split(",").map((e=>e.trim())).indexOf("tilesonly")>-1)throw new 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),i=e.currentVersion>=10.71&&e.hasMultidimensions&&!(e.fields?.length>1);return t||i}_isVectorFieldResampleFunction(e){if(null==e)return!1;const{functionName:t,functionArguments:i}=e,r="resample"===t?.toLowerCase(),s=i?.ResampleType||i?.resampleType;return r&&(7===s||10===s)}_isPicture(){return!this.format||this.format.includes("jpg")||this.format.includes("png")}_configRenderer(e){const t=this._isPicture(),{rasterInfo:i}=this;if(!t&&!this.pixelFilter||this._isVectorDataSet()){if(!this.bandIds&&i.bandCount>=3){const e=L(i);!e||3===i.bandCount&&0===e[0]&&1===e[1]&&2===e[2]||(this.bandIds=e)}e||(e=z(i,{bandIds:this.bandIds,variableName:this.rasterFunction?null:this.mosaicRule?.multidimensionalDefinition?.[0].variableName}));const t=G(e.toJSON());this.symbolizer?(this.symbolizer.rendererJSON=t,this.symbolizer.rasterInfo=i):this.symbolizer=new k({rendererJSON:t,rasterInfo:i}),this.symbolizer.bind().success||(this.symbolizer=null)}return e}_clonePixelData(e){return null==e?e:{extent:e.extent&&e.extent.clone(),pixelBlock:null!=e.pixelBlock?e.pixelBlock.clone():null}}_getQueryParams(e){null!=e?.renderingRule&&"string"!=typeof e.renderingRule&&(e.renderingRule=this._getRenderingRuleString(e.renderingRule));const{raster:t,viewId:i}=this;return{raster:t,viewId:i,f:"json",...e,...this.customParameters}}_getRequestOptions(e){return{...e,query:{...e?.query,...this.customParameters}}}_decodePixelBlock(e,t,i){return this._rasterJobHandler.instance?this._rasterJobHandler.instance.decode({data:e,options:t}):Q(e,t,i)}async _getRasterFunctionInfos(e){const t=this.sourceJSON.rasterFunctionInfos;if(this.loaded)return t;if(t&&this.version>=10.3){if(1===t.length&&"none"===t[0].name.toLowerCase())return t;const i=await n(je(this.parsedUrl)+"/rasterFunctionInfos",{query:this._getQueryParams(),signal:e});return i.data?.rasterFunctionInfos}return null}_canRequestImageElement(e){return!this.pixelFilter&&(!e||e.includes("png"))}async _requestArrayBuffer(e){const{imageProps:t,requestAsImageElement:i,returnImageBitmap:r,signal:s}=e;if(i&&this._canRequestImageElement(t.format)){const i=`${je(this.parsedUrl)}/exportImage`,{data:a}=await n(i,{responseType:r?"blob":"image",query:this._getQueryParams({f:"image",...this.refreshParameters,...e.imageServiceParameters}),signal:s});if(a instanceof Blob){return{imageBitmap:await F(a,i,s),params:t}}return{imageOrCanvasElement:a,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 m=p;if("bsq"!==m&&"bip"!==m&&(m=H(u)),!m)throw new a("imagery-layer:fetch-image","unsupported format signature "+String.fromCharCode.apply(null,new Uint8Array(u)));const c={signal:s},d="gif"===p||"bmp"===p||p.includes("png")&&("png"===m||"jpg"===m)?Q(u,{useCanvas:!0,...t},c):this._decodePixelBlock(u,{width:t.width,height:t.height,planes:null,pixelType:null,noDataValue:null,format:p},c);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 T;const e=this.mosaicRule.multidimensionalDefinition;!this.sourceJSON.defaultVariableName&&this.rasterFunction&&"none"!==this.rasterFunction.functionName?.toLowerCase()&&t.forEach((e=>e.variableName="")),t=t.filter((({variableName:e,dimensionName:t})=>e&&"*"!==e||t)),!e?.length&&t.length&&(this.mosaicRule.multidimensionalDefinition=t)}}_processVisibleRastersResponse(e,i){i=i||{};const r=e.value,{templateRRFunctionNames:s,showNoDataRecords:n,returnDomainValues:a,templateFields:o}=i,l=e.processedValues;let u=e.catalogItems?.features,p=e.properties?.Values?.map((e=>e.replaceAll(/ /gi,", ")))||[];const m=this.objectIdField||"ObjectId",c="string"==typeof r&&r.toLowerCase().includes("nodata"),d=[];if(r&&!u&&!c){const e={};e[m]=0;p=[r],u=[new t({geometry:this.fullExtent,attributes:e})]}if(!u)return[];let h,y,f;this._updateResponseFieldNames(u,o),c&&!n&&(u=[]);for(let t=0;t<u.length;t++){if(h=u[t],null!=r){if(y=p[t],f=this.rasterFunction&&l&&l.length>0&&s&&s.length>0&&s.includes(this.rasterFunction.functionName)?l[s.indexOf(this.rasterFunction.functionName)]:r,"nodata"===y.toLowerCase()&&!n)continue;const e="Raster.ItemPixelValue",i="Raster.ServicePixelValue";h.attributes[e]=y,h.attributes[i]=f,this._updateFeatureWithMagDirValues(h,y);const a=this.fields&&this.fields.length>0;let o=this.rasterFunction&&null!=this.serviceRasterInfo.attributeTable?a?y:r:f;this.rasterFunction||(o=a?y:r),this._updateFeatureWithRasterAttributeTableValues(h,o)}if(h.sourceLayer=h.layer=this,a&&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,i){const{multidimensionalSubset:r}=this;if(!r)return{isOutSide:!1,timeExtent:t,mosaicRule:i=this._combineMosaicRuleWithTimeExtent(i,t)};if(r){const{isOutside:i,intersection:s}=E(r,{geometry:e,timeExtent:t});if(i)return{isOutSide:!0,timeExtent:null,mosaicRule:null};null!=s?.timeExtent&&(t=s.timeExtent)}if(i=this._combineMosaicRuleWithTimeExtent(i,t),i?.multidimensionalDefinition){const{isOutside:e}=E(r,{multidimensionalDefinition:i.multidimensionalDefinition});if(e)return{isOutSide:!0,timeExtent:null,mosaicRule:null}}return{isOutSide:!1,timeExtent:t,mosaicRule:i}}_updateFeatureWithRasterAttributeTableValues(e,t){const i=this.rasterInfo.attributeTable||this.serviceRasterInfo.attributeTable;if(null==i)return;const{features:r,fields:s}=i,n=s.map((e=>e.name)).find((e=>"value"===e.toLowerCase()));if(!n)return;const a=r.filter((e=>e.attributes[n]===(null!=t?parseInt(t,10):null)));a&&a[0]&&s.forEach((t=>{const i=this._rasterAttributeTableFieldPrefix+t.name;e.attributes[i]=a[0].attributes[t.name]}))}_updateFeatureWithMagDirValues(e,t){if(!this._isVectorDataSet())return;const i=t.split(/,\s*/).map((e=>parseFloat(e))),r=i.map((e=>[e])),s=i.map((e=>({minValue:e,maxValue:e,noDataValue:null}))),n=new P({height:1,width:1,pixelType:"f32",pixels:r,statistics:s});null!=this.pixelFilter&&this.pixelFilter({pixelBlock:n,extent:new ye(0,0,0,0,this.spatialReference)});const a="esriImageServiceDataTypeVector-MagDir"===this.serviceDataType?[n.pixels[0][0],n.pixels[1][0]]:U([n.pixels[0][0],n.pixels[1][0]]);e.attributes["Raster.Magnitude"]=a[0],e.attributes["Raster.Direction"]=a[1]}_updateFeatureWithDomainValues(e){const t=this.fields&&this.fields.filter((e=>e.domain&&"coded-value"===e.domain.type));null!=t&&t.forEach((t=>{const i=e.attributes[t.name];if(null!=i){const r=t.domain.codedValues.find((e=>e.code===i));r&&(e.attributes[t.name]=r.name)}}))}_updateResponseFieldNames(e,t){if(!t||t.length<1)return;const i=this.fieldsIndex;null!=i&&e.forEach((e=>{if(e?.attributes)for(const r of t){const t=i.get(r)?.name;t&&t!==r&&(e.attributes[r]=e.attributes[t],delete e.attributes[t])}}))}_getRenderingRuleString(e){if(e){let t=e.toJSON();return t=t.rasterFunctionDefinition??t,(t.thumbnail||t.thumbnailEx)&&(t.thumbnail=t.thumbnailEx=null),JSON.stringify(t)}return null}_hasRasterFunction(e){return null!=e?.functionName&&"none"!==e.functionName.toLowerCase()}_updateRenderingRulesFunctionName(e,t){if(!e||e.length<1)return;if("Raw"===e)return e.replace("Raw","None");const i=e.toLowerCase().replaceAll(/ /gi,"_");return t.has(i)?t.get(i):e}_isRFTJson(e){return e?.name&&e.arguments&&e.function&&e.hasOwnProperty("functionType")}_isVectorDataSet(){return"esriImageServiceDataTypeVector-UV"===this.serviceDataType||"esriImageServiceDataTypeVector-MagDir"===this.serviceDataType}_applyMosaicAndRenderingRules(e){const{raster:t,mosaicRule:i,rasterFunction:r}=this;r&&"rasterFunction"in e&&null==e.rasterFunction&&(e.rasterFunction=r),i&&null==e.mosaicRule&&(e.mosaicRule=i),t&&null==e.raster&&(e.raster=t)}_readCapabilities(e){const t=e.capabilities?e.capabilities.toLowerCase().split(",").map((e=>e.trim())):["image","catalog"],{currentVersion:i,advancedQueryCapabilities:r,maxRecordCount:s}=e,n=t.includes("image"),a="esriImageServiceDataTypeElevation"===e.serviceDataType,o=!(!e.spatialReference&&!e.extent?.spatialReference),l=t.includes("edit"),u=t.includes("mensuration")&&o,p=null==e.mensurationCapabilities?[]:e.mensurationCapabilities.toLowerCase().split(",").map((e=>e.trim())),m=u&&p.includes("basic"),c=this._isMosaicDataset(e)&&t.includes("catalog"),d=t.includes("download");return{data:{supportsAttachment:!1},operations:{supportsComputeHistograms:n,supportsExportImage:n,supportsIdentify:n,supportsImageToMap:i>=11.2&&c,supportsImageToMapMultiray:i>=11.2&&c,supportsMapToImage:i>=11.2&&c,supportsFindImages:i>=11.2&&c,supportsGetImageUrl:i>=11.3&&d,supportsMeasure:u,supportsMeasureFromImage:i>=11.2,supportsDownload:d,supportsQuery:c&&e.fields&&e.fields.length>0,supportsGetSamples:i>=10.2&&n,supportsProject:i>=10.3&&n,supportsComputeStatisticsHistograms:i>=10.4&&n,supportsQueryBoundary:i>=10.6&&n,supportsCalculateVolume:i>=10.7&&a,supportsComputePixelLocation:i>=10.7&&c,supportsComputeAngles:i>=10.91,supportsQueryGPSInfo:i>=11.2&&c,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:!!r?.supportsStatistics,supportsOrderBy:!!r?.supportsOrderBy,supportsDistinct:!!r?.supportsDistinct,supportsPagination:!!r?.supportsPagination,supportsStandardizedQueriesOnly:!!r?.useStandardizedQueries,supportsPercentileStatistics:!!r?.supportsPercentileStatistics,supportsCentroid:!!r?.supportsReturningGeometryCentroid,supportsDistance:!!r?.supportsQueryWithDistance,supportsExtent:!!r?.supportsReturningQueryExtent,supportsGeometryProperties:!!r?.supportsReturningGeometryProperties,supportsHavingClause:!!r?.supportsHavingClause,supportsQuantization:!1,supportsQuantizationEditMode:!1,supportsQueryGeometry:!1,supportsResultType:!1,supportsMaxRecordCountFactor:!1,supportsSqlExpression:!1,supportsTopFeaturesQuery:!1,supportsQueryByAnonymous:!1,supportsQueryByOthers:!1,supportsHistoricMoment:!1,supportsFormatPBF:!1,supportsDisjointSpatialRelationship:!1,supportsCacheHint:!1,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1},supportsDefaultSpatialReference:!!r?.supportsDefaultSR,supportsFullTextSearch:!1,supportsCompactGeometry:!1,standardMaxRecordCount:void 0,tileMaxRecordCount:void 0},mensuration:{supportsDistanceAndAngle:m,supportsAreaAndPerimeter:m,supportsPointOrCentroid:m,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({clonable:!1})],y.prototype,"_functionRasterInfos",void 0),e([m({clonable:!1})],y.prototype,"_rasterJobHandler",void 0),e([m({clonable:!1})],y.prototype,"_cachedRendererJson",void 0),e([m({readOnly:!0})],y.prototype,"_serviceSupportsMosaicRule",void 0),e([f("_serviceSupportsMosaicRule",["currentVersion","fields"])],y.prototype,"readServiceSupportsMosaicRule",null),e([m({readOnly:!0})],y.prototype,"_rasterAttributeTableFieldPrefix",void 0),e([m({readOnly:!0})],y.prototype,"_rasterFunctionNamesIndex",null),e([m()],y.prototype,"adjustAspectRatio",void 0),e([m({type:[d],json:{write:!0}})],y.prototype,"bandIds",void 0),e([f("bandIds")],y.prototype,"readBandIds",null),e([m({readOnly:!0,json:{read:!1}})],y.prototype,"capabilities",void 0),e([f("service","capabilities",["capabilities","currentVersion","serviceDataType"])],y.prototype,"readCapabilities",null),e([m({type:Number})],y.prototype,"compressionQuality",void 0),e([R("compressionQuality")],y.prototype,"writeCompressionQuality",null),e([m({type:Number})],y.prototype,"compressionTolerance",void 0),e([R("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([f("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:[x]})],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","bip","bsq"],json:{write:!0}})],y.prototype,"format",null),e([f("service","format",["serviceDataType"])],y.prototype,"readFormat",null),e([m({type:ye})],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:j.jsonValues,read:j.read,write:j.write}})],y.prototype,"interpolation",void 0),e([m()],y.prototype,"minScale",void 0),e([f("service","minScale")],y.prototype,"readMinScale",null),e([m()],y.prototype,"maxScale",void 0),e([f("service","maxScale")],y.prototype,"readMaxScale",null),e([m({type:T})],y.prototype,"mosaicRule",null),e([f("mosaicRule",["mosaicRule","defaultMosaicMethod"])],y.prototype,"readMosaicRule",null),e([R("mosaicRule")],y.prototype,"writeMosaicRule",null),e([m()],y.prototype,"multidimensionalInfo",void 0),e([m({type:O,json:{write:!0}})],y.prototype,"multidimensionalSubset",void 0),e([m({json:{type:d}})],y.prototype,"noData",void 0),e([R("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([f("objectIdField")],y.prototype,"readObjectIdField",null),e([m({readOnly:!0})],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([f("sourceType",["serviceSourceType","fields"])],y.prototype,"readSourceType",null),e([m()],y.prototype,"viewId",void 0),e([m({types:i,json:{name:"layerDefinition.drawingInfo.renderer",origins:{"web-scene":{types:r,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type&&"flow"!==e.type})}}}}})],y.prototype,"renderer",null),e([f("renderer")],y.prototype,"readRenderer",null),e([R("renderer")],y.prototype,"writeRenderer",null),e([m({clonable:!1})],y.prototype,"symbolizer",void 0),e([m(w)],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:N,json:{name:"renderingRule"}})],y.prototype,"rasterFunction",null),e([f("rasterFunction",["renderingRule","rasterFunctionInfos"])],y.prototype,"readRasterFunction",null),e([m({readOnly:!0})],y.prototype,"serviceDataType",void 0),e([m({readOnly:!0,type:ge})],y.prototype,"spatialReference",void 0),e([f("spatialReference",["spatialReference","extent"])],y.prototype,"readSpatialReference",null),e([m({json:{type:M.jsonValues}})],y.prototype,"pixelType",void 0),e([f("pixelType")],y.prototype,"readPixelType",null),e([R("pixelType")],y.prototype,"writePixelType",null),e([m({constructOnly:!0,type:q})],y.prototype,"serviceRasterInfo",void 0),e([m()],y.prototype,"sourceJSON",void 0),e([m(I)],y.prototype,"url",void 0),e([m({readOnly:!0})],y.prototype,"version",void 0),e([f("version",["currentVersion","fields","timeInfo"])],y.prototype,"readVersion",null),y=e([g("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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../geometry.js";import"../../../core/has.js";import"../../../core/Logger.js";import{deg2rad as e}from"../../../core/mathUtils.js";import{zeros as t,create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{m as a,z as n,g as i}from"../../../chunks/vec32.js";import o from"../../../geometry/Point.js";import{projectWithZConversion as s,initializeProjection as c,project as f}from"../../../geometry/projection.js";import{fromPoints as p,fromValues as m}from"../../../geometry/support/ray.js";import{l,i as y}from"../../../chunks/sphere.js";import{geographicToWebMercator as u,webMercatorToGeographic as g}from"../../../geometry/support/webMercatorUtils.js";import{createCoveragePolygon as w,limitZToGround as x}from"../core/coverageUtils.js";import z from"../core/ExposurePoint.js";import{transformPoints as h,updateElevation as d}from"./groundToImageUtils.js";import{getWebMercatorScalingFactor as R,convertPixelToHeadingPitch as j,convertHeadingPitchToSphereVertex as b,scaleAndAddWithFactor as P,hasCameraOrientationLTP as v,computeHFOVAndVFOV as M,ltpToGeographic as O,projectiveTransform2 as S,scaleWithFactor as F,calculateRotationMatrix as L,transformMat3 as H,projectiveTransform as V,getPlaneLineIntersectionPoint as A}from"./utils.js";import{defaultImageSphereCenter as T}from"../../../widgets/PanoramicViewer/constants.js";import{isNumber as U}from"../../../widgets/support/dataUtils.js";import C from"../../../geometry/Polygon.js";import D from"../../../geometry/SpatialReference.js";function E(e,t){if(!e)return Promise.resolve([]);const r=t.feature;let a=r.attributes;return a instanceof z||(a=z.fromJSON(r),a&&(r.attributes=a)),G(e,t)}function G(e,t){const{attributes:r}=t.feature;if(r.isSpherical||360===r.horizontalFieldOfView){const{location:a,cameraOrientation:n,farDistance:i,cameraHeading:o,cameraHeight:s}=r;return W(e,a,i,[t.imageProperties.width,t.imageProperties.height],o,s,n)}return q(e,t)}async function W(e,t,a,n,i,s,c){let f=new o(t);f.spatialReference.isGeographic&&f.spatialReference.isWGS84&&4!==c?.type&&(f=u(f));const g=R(f),w=new Array,[x,z,h]=f.toArray(),d=l([x,z,h??0],a*g),v=T.toArray();for(const l of e){let e,t;if(U(l.heading)&&U(l.pitch))e=l.heading,t=l.pitch;else{const r=j({x:l.x,y:l.y},n[0],n[1]);e=r.heading,t=r.pitch}e=(e+i)%360;const a=p([v[0],v[1],v[2]],b(e,t)),c=m([x,z,h??0],a.direction),u=r();y(d,c,u);const R=(f.z??0)-s;if(u[2]<R){const e=Math.abs((f.z-R)/-a.direction[2])*g;P([f.x,f.y,f.z],a.direction,e,g,u)}else u[2]=R;w.push(new o(u,f.spatialReference))}return w}async function q(e,t){const{feature:r,footprintExtent:a,options:n}=t,{attributes:{cameraHeight:i,cameraOrientation:c,cameraPitch:f,cameraRoll:p,elevationSource:m,horizontalFieldOfView:l,location:y,verticalFieldOfView:x},elevationSample:z}=r,d=v(c),{vfov:j}=M(l,x,p??0);let b=new o(y),P=!1;d&&(b=new o(O(b,[c.latitude,c.longitude,c.ellipsoidRadius,c.squaredEccentricity]))),b.spatialReference.isWGS84&&(P=!0,b=u(b));const F=R(b),L=I(t,b,F),H=d?L.map((e=>g(new o(e)))):L,V=await h(H,t,!0).then((e=>e.map((e=>({x:e.x,y:e.y,z:1}))))),A=new Array;for(const u of e){const e={...u,z:1},c={...S(e,V,H),spatialReference:b.spatialReference},[p]=await h([d?g(new o(c)):new o(c)],t,!0);await B(e,p,V,H,b,c,d,t);const l=r.attributes.clone();l.geometry=b.clone();const{polygon:y}=w(l),x=y.rings[0].map((e=>new o(e,y.spatialReference))),R=await s(m||z?await J({cameraLocation:b,groundFootPrint:x,projectedPoint:c,webMercatorScalingFactor:F,vfov:j,shouldConvertToLatLong:P,isCameraOrientationLTP:d,imgPoint:e},t):new o(k(c,b,F,b.z-i,f,j,P)),a.spatialReference,n);A.push(R)}return A}async function J(e,t){const{cameraLocation:r,groundFootPrint:a,projectedPoint:n,webMercatorScalingFactor:i,vfov:s,shouldConvertToLatLong:f,isCameraOrientationLTP:p,imgPoint:m}=e,{cameraHeight:l,cameraPitch:y}=t.feature.attributes;await c(r.spatialReference,t.footprintExtent.spatialReference,null,t.options);let u=await Z(a,t),w=0,x=(r.z??0)-l,z=0;for(;z<10;){const e=K(u,r,n);if(!e||!N([r.x,r.y,r.z],[e.x,e.y,e.z],[n.x,n.y,n.z]))return new o(k(n,r,i,x,y,s,f));const a=new o({x:e.x,y:e.y,z:e.z,spatialReference:r.spatialReference}),c=await h([p?g(a):a],t);if(w=Math.abs(m.x-c[0].x)+Math.abs(m.y-c[0].y),x=e.z,w<=1)return new o(k(n,r,i,x,y,s,f));z+=1;const{extent:l}=u,R=(l?.width??0)/10,j=(l?.height??0)/10;if(R<1||j<1)return new o(k(n,r,i,x,y,s,f));const{x:b,y:P}=e,v=await d(Q(R,j).map((([e,t])=>new o({x:b+e,y:P+t,spatialReference:r.spatialReference}))),t,!1);v.push(v[0]),u=new C({rings:[v.map((e=>e.toArray()))],spatialReference:r.spatialReference})}return new o(k(n,r,i,x,y,s,f))}const N=(e,r,i)=>a(n(t(),r,e),n(t(),i,e))>0;function k(e,r,a,i,s,c,f){const p=Math.sqrt((e.z-r.z)**2+(Math.sqrt((e.x-r.x)**2+(e.y-r.y)**2)/a)**2)*a,m=F(n(t(),[e.x,e.y,e.z],[r.x,r.y,r.z]),1/p,1/a);if(e.z<i||s+c/2<90){const t=Math.abs((r.z-i)/-m[2])*a,n=P([r.x,r.y,r.z],m,t,a);e.x=n[0],e.y=n[1],e.z=n[2]}else e.z=i;return f?g(new o(e)).toJSON():e}function I(r,a,s){const{feature:c}=r,{attributes:f}=c,p=2*Math.tan(e(f.verticalFieldOfView)/2)*f.farDistance*s,m=2*Math.tan(e(f.horizontalFieldOfView)/2)*f.farDistance*s,l=L("HPR",[f.cameraHeading,f.cameraPitch,f.cameraRoll??0]),y=H([0,0,-1],l),u=P([a.x,a.y,a.z],y,f.farDistance*s,s),g=H([0,1,0],l),w=H([1,0,0],l),x=F(g,p/2,s),z=F(w,m/2,s),h=n(t(),x,z),d=i(t(),x,z);return[i(t(),u,h),i(t(),u,d),n(t(),u,h),n(t(),u,d)].map((e=>{const[t,r,n]=e;return new o({x:t,y:r,z:n,spatialReference:a.spatialReference})}))}async function Z(e,t){const r=e[0].spatialReference.isWGS84?D.WebMercator:e[0].spatialReference,{cameraHeight:a,location:n,elevation:i}=t.feature.attributes,s="number"==typeof n.z&&"number"==typeof i?n.z-i:a,c=x(e.map((({x:e,y:t,z:r})=>[e,t,r])),s,n,R(n)),p=(await d(c.map((e=>new o(e,n.spatialReference))),t,!1)).map((e=>f(e,r)));return new C({hasZ:!0,rings:[p.map((e=>[e
|
|
5
|
+
import"../../../geometry.js";import"../../../core/has.js";import"../../../core/Logger.js";import{deg2rad as e}from"../../../core/mathUtils.js";import{zeros as t,create as r}from"../../../core/libs/gl-matrix-2/factories/vec3f64.js";import{m as a,z as n,g as i}from"../../../chunks/vec32.js";import o from"../../../geometry/Point.js";import{projectWithZConversion as s,initializeProjection as c,project as f}from"../../../geometry/projection.js";import{fromPoints as p,fromValues as m}from"../../../geometry/support/ray.js";import{l,i as y}from"../../../chunks/sphere.js";import{geographicToWebMercator as u,webMercatorToGeographic as g}from"../../../geometry/support/webMercatorUtils.js";import{createCoveragePolygon as w,limitZToGround as x}from"../core/coverageUtils.js";import z from"../core/ExposurePoint.js";import{transformPoints as h,updateElevation as d}from"./groundToImageUtils.js";import{getWebMercatorScalingFactor as R,convertPixelToHeadingPitch as j,convertHeadingPitchToSphereVertex as b,scaleAndAddWithFactor as P,hasCameraOrientationLTP as v,computeHFOVAndVFOV as M,ltpToGeographic as O,projectiveTransform2 as S,scaleWithFactor as F,calculateRotationMatrix as L,transformMat3 as H,projectiveTransform as V,getPlaneLineIntersectionPoint as A}from"./utils.js";import{defaultImageSphereCenter as T}from"../../../widgets/PanoramicViewer/constants.js";import{isNumber as U}from"../../../widgets/support/dataUtils.js";import C from"../../../geometry/Polygon.js";import D from"../../../geometry/SpatialReference.js";function E(e,t){if(!e)return Promise.resolve([]);const r=t.feature;let a=r.attributes;return a instanceof z||(a=z.fromJSON(r),a&&(r.attributes=a)),G(e,t)}function G(e,t){const{attributes:r}=t.feature;if(r.isSpherical||360===r.horizontalFieldOfView){const{location:a,cameraOrientation:n,farDistance:i,cameraHeading:o,cameraHeight:s}=r;return W(e,a,i,[t.imageProperties.width,t.imageProperties.height],o,s,n)}return q(e,t)}async function W(e,t,a,n,i,s,c){let f=new o(t);f.spatialReference.isGeographic&&f.spatialReference.isWGS84&&4!==c?.type&&(f=u(f));const g=R(f),w=new Array,[x,z,h]=f.toArray(),d=l([x,z,h??0],a*g),v=T.toArray();for(const l of e){let e,t;if(U(l.heading)&&U(l.pitch))e=l.heading,t=l.pitch;else{const r=j({x:l.x,y:l.y},n[0],n[1]);e=r.heading,t=r.pitch}e=(e+i)%360;const a=p([v[0],v[1],v[2]],b(e,t)),c=m([x,z,h??0],a.direction),u=r();y(d,c,u);const R=(f.z??0)-s;if(u[2]<R){const e=Math.abs((f.z-R)/-a.direction[2])*g;P([f.x,f.y,f.z],a.direction,e,g,u)}else u[2]=R;w.push(new o(u,f.spatialReference))}return w}async function q(e,t){const{feature:r,footprintExtent:a,options:n}=t,{attributes:{cameraHeight:i,cameraOrientation:c,cameraPitch:f,cameraRoll:p,elevationSource:m,horizontalFieldOfView:l,location:y,verticalFieldOfView:x},elevationSample:z}=r,d=v(c),{vfov:j}=M(l,x,p??0);let b=new o(y),P=!1;d&&(b=new o(O(b,[c.latitude,c.longitude,c.ellipsoidRadius,c.squaredEccentricity]))),b.spatialReference.isWGS84&&(P=!0,b=u(b));const F=R(b),L=I(t,b,F),H=d?L.map((e=>g(new o(e)))):L,V=await h(H,t,!0).then((e=>e.map((e=>({x:e.x,y:e.y,z:1}))))),A=new Array;for(const u of e){const e={...u,z:1},c={...S(e,V,H),spatialReference:b.spatialReference},[p]=await h([d?g(new o(c)):new o(c)],t,!0);await B(e,p,V,H,b,c,d,t);const l=r.attributes.clone();l.geometry=b.clone();const{polygon:y}=w(l),x=y.rings[0].map((e=>new o(e,y.spatialReference))),R=await s(m||z?await J({cameraLocation:b,groundFootPrint:x,projectedPoint:c,webMercatorScalingFactor:F,vfov:j,shouldConvertToLatLong:P,isCameraOrientationLTP:d,imgPoint:e},t):new o(k(c,b,F,b.z-i,f,j,P)),a.spatialReference,n);A.push(R)}return A}async function J(e,t){const{cameraLocation:r,groundFootPrint:a,projectedPoint:n,webMercatorScalingFactor:i,vfov:s,shouldConvertToLatLong:f,isCameraOrientationLTP:p,imgPoint:m}=e,{cameraHeight:l,cameraPitch:y}=t.feature.attributes;await c(r.spatialReference,t.footprintExtent.spatialReference,null,t.options);let u=await Z(a,t),w=0,x=(r.z??0)-l,z=0;for(;z<10;){const e=K(u,r,n);if(!e||!N([r.x,r.y,r.z],[e.x,e.y,e.z],[n.x,n.y,n.z]))return new o(k(n,r,i,x,y,s,f));const a=new o({x:e.x,y:e.y,z:e.z,spatialReference:r.spatialReference}),c=await h([p?g(a):a],t);if(w=Math.abs(m.x-c[0].x)+Math.abs(m.y-c[0].y),x=e.z,w<=1)return new o(k(n,r,i,x,y,s,f));z+=1;const{extent:l}=u,R=(l?.width??0)/10,j=(l?.height??0)/10;if(R<1||j<1)return new o(k(n,r,i,x,y,s,f));const{x:b,y:P}=e,v=await d(Q(R,j).map((([e,t])=>new o({x:b+e,y:P+t,spatialReference:r.spatialReference}))),t,!1);v.push(v[0]),u=new C({rings:[v.map((e=>e.toArray()))],spatialReference:r.spatialReference})}return new o(k(n,r,i,x,y,s,f))}const N=(e,r,i)=>a(n(t(),r,e),n(t(),i,e))>0;function k(e,r,a,i,s,c,f){const p=Math.sqrt((e.z-r.z)**2+(Math.sqrt((e.x-r.x)**2+(e.y-r.y)**2)/a)**2)*a,m=F(n(t(),[e.x,e.y,e.z],[r.x,r.y,r.z]),1/p,1/a);if(e.z<i||s+c/2<90){const t=Math.abs((r.z-i)/-m[2])*a,n=P([r.x,r.y,r.z],m,t,a);e.x=n[0],e.y=n[1],e.z=n[2]}else e.z=i;return f?g(new o(e)).toJSON():e}function I(r,a,s){const{feature:c}=r,{attributes:f}=c,p=2*Math.tan(e(f.verticalFieldOfView)/2)*f.farDistance*s,m=2*Math.tan(e(f.horizontalFieldOfView)/2)*f.farDistance*s,l=L("HPR",[f.cameraHeading,f.cameraPitch,f.cameraRoll??0]),y=H([0,0,-1],l),u=P([a.x,a.y,a.z],y,f.farDistance*s,s),g=H([0,1,0],l),w=H([1,0,0],l),x=F(g,p/2,s),z=F(w,m/2,s),h=n(t(),x,z),d=i(t(),x,z);return[i(t(),u,h),i(t(),u,d),n(t(),u,h),n(t(),u,d)].map((e=>{const[t,r,n]=e;return new o({x:t,y:r,z:n,spatialReference:a.spatialReference})}))}async function Z(e,t){const r=e[0].spatialReference.isWGS84?D.WebMercator:e[0].spatialReference,{cameraHeight:a,location:n,elevation:i}=t.feature.attributes,s="number"==typeof n.z&&"number"==typeof i?n.z-i:a,c=x(e.map((({x:e,y:t,z:r})=>[e,t,r])),s,n,R(n)),p=(await d(c.map((e=>new o(e,n.spatialReference))),t,!1)).map((e=>f(e,r)));return new C({hasZ:!0,rings:[p.map((({x:e,y:t,z:r})=>[e,t,r??0]))],spatialReference:r})}async function B(e,t,r,a,n,i,s,c){let f=0;const p=8;for(let m=0;m<=p;m+=1){if(f=Math.abs(e.x-t.x)+Math.abs(e.y-t.y),f<=1)return;const[p,m,l,y]=Q(f,f).map((([t,i])=>({...V({x:e.x+t,y:e.y+i,z:1},r[0],r[1],r[2],r[3],{x:a[0].x,y:a[0].y,z:a[0].z},{x:a[1].x,y:a[1].y,z:a[1].z},{x:a[2].x,y:a[2].y,z:a[2].z},{x:a[3].x,y:a[3].y,z:a[3].z}),spatialReference:n.spatialReference}))),[u,w,x,z]=await h(s?[g(new o(p)),g(new o(m)),g(new o(l)),g(new o(y))]:[new o(p),new o(m),new o(l),new o(y)],c,!0).then((e=>e.map((e=>({...e,z:0}))))),{x:d,y:R,z:j}=V(e,u,w,x,z,p,m,l,y);i.x=d,i.y=R,i.z=j,[t]=await h([s?g(new o(i)):new o(i)],c,!0)}}function K(e,t,r){const a={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]},o={x:e.rings[0][2][0],y:e.rings[0][2][1],z:e.rings[0][2][2]},s=(o.z-i.z)*(n.y-a.y)-(o.y-i.y)*(n.z-a.z),c=-((o.z-i.z)*(n.x-a.x)-(n.z-a.z)*(o.x-i.x)),f=(o.y-i.y)*(n.x-a.x)-(n.y-a.y)*(o.x-i.x),p=-(s*a.x+c*a.y+f*a.z);return A(t.toJSON(),r,s,c,f,p)}const Q=(e,t)=>[[-e,-t],[e,-t],[e,t],[-e,t]];export{E as transformPoints};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../PopupTemplate.js";import r from"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import i from"../../renderers/Renderer.js";import o from"../../renderers/SimpleRenderer.js";import n from"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import s from"../../core/Logger.js";import{ClonableMixin as l}from"../../core/Clonable.js";import"../../core/has.js";import a from"../../core/Error.js";import{IdentifiableMixin as p}from"../../core/Identifiable.js";import{clone as d}from"../../core/lang.js";import u from"../../core/Loadable.js";import{MultiOriginJSONMixin as y}from"../../core/MultiOriginJSONSupport.js";import{setDeepValue as c}from"../../core/object.js";import{sqlAnd as m}from"../../core/sql.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import{reader as h}from"../../core/accessorSupport/decorators/reader.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{writer as g}from"../../core/accessorSupport/decorators/writer.js";import{createTypeReader as v}from"../../core/accessorSupport/extensions/serializableProperty/reader.js";import j from"../../form/FormTemplate.js";import{labelsVisible as w,legendEnabled as O,minScale as F,maxScale as I,popupEnabled as S}from"./commonProperties.js";import{createQuery as T}from"./featureLayerUtils.js";import E from"./FeatureTemplate.js";import{defineFieldProperties as C}from"./fieldProperties.js";import{fixRendererFields as A}from"./fieldUtils.js";import x from"./LabelClass.js";import{reader as R}from"./labelingInfo.js";import P from"../../rest/support/Query.js";import{createPopupTemplate as D}from"../../support/popupUtils.js";import{defaultPolygonSymbol2D as L,defaultPolylineSymbol2D as q,defaultPointSymbol2D as V}from"../../symbols/support/defaults.js";const G={key:"type",base:i,errorContext:"renderer",typeMap:{simple:o,"unique-value":n,"class-breaks":r}},N=C(),U=v({types:G});let $=0;function k(e){const t=e.json.write;return"object"==typeof t?t.ignoreOrigin=!0:e.json.write={ignoreOrigin:!0},e}function M(e){return new o({symbol:_(e)})}function _(e){switch(e){case"point":case"multipoint":return V.clone();case"polyline":return q.clone();case"polygon":case"multipatch":return L.clone();default:return null}}function B(e,t){return!!t&&("unique-value"===e?.type&&null!=e.field&&e.field.toLowerCase()===t.toLowerCase()&&!e.field2&&!e.field3&&!e.valueExpression)}function H(e,t){return null==e?null:t.subtypes?.find((t=>t.code===e))}function Q(e,t){let r=null;switch(t.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":r="point";break;case"esriGeometryPolyline":r="line";break;case"esriGeometryPolygon":case"esriGeometryMultiPatch":r="polygon";break;default:t.type,r=null}const i={},o=H(e,t);if(null!=o){const{defaultValues:e}=o;for(const t in e)i[t]=e[t]}return i[t.subtypeField]=e,new E({name:"New Feature",drawingTool:r,prototype:{attributes:i}})}let z=class extends(y(l(p(u)))){constructor(e){super(e),this.charts=null,this.editingEnabled=!0,this.fieldOverrides=null,this.fieldsIndex=null,this.formTemplate=null,this.id=`${Date.now().toString(16)}-subtype-sublayer-${$++}`,this.type="subtype-sublayer",this.labelsVisible=!0,this.labelingInfo=null,this.layerType="ArcGISFeatureLayer",this.legendEnabled=!0,this.listMode="show",this.minScale=0,this.maxScale=0,this.opacity=1,this.parent=null,this.popupEnabled=!0,this.popupTemplate=null,this.subtypeCode=null,this.templates=null,this.title=null,this.visible=!0}load(e){return A(this.renderer,this.fieldsIndex),Promise.resolve(this)}get capabilities(){return this.parent?.capabilities}get effectiveCapabilities(){return this.parent?.effectiveCapabilities}get effectiveEditingEnabled(){const{parent:e}=this;return e?e.effectiveEditingEnabled&&this.editingEnabled:this.editingEnabled}get elevationInfo(){return this.parent?.elevationInfo}writeFieldOverrides(e,t,r){const{fields:i,parent:o}=this;let n;if(i){n=[];let e=0;i.forEach((({name:t,alias:r,editable:i,visible:s})=>{if(!s)return;const l=o?.fields?.find((e=>e.name===t));if(!l)return;const a={name:t};let p=!1;r!==l.alias&&(a.alias=r,p=!0),i!==l.editable&&(a.editable=i,p=!0),n.push(a),p&&e++})),0===e&&n.length===i.length&&(n=null)}else n=d(e);n?.length&&c(r,n,t)}get fields(){const{parent:e,fieldOverrides:t,subtypeCode:r}=this,i=e?.fields;if(!e||!i?.length)return null;const{subtypes:o,subtypeField:n}=e,s=o?.find((e=>e.code===r)),l=s?.defaultValues,a=s?.domains,p=[];for(const d of i){const e=d.clone(),{name:i}=e,o=t?.find((e=>e.name===i));if(e.visible=!t||!!o,o){const{alias:t,editable:r}=o;t&&(e.alias=t),!1===r&&(e.editable=!1)}const s=l?.[i]??null;e.defaultValue=i===n?r:s;const u=a?.[i]??null;e.domain=i===n?null:u?"inherited"===u.type?e.domain:u.clone():null,p.push(e)}return p}get floorInfo(){return this.parent?.floorInfo}get geometryType(){return this.parent?.geometryType}get effectiveScaleRange(){const{minScale:e,maxScale:t}=this;return{minScale:e,maxScale:t}}get objectIdField(){return this.parent||s.getLogger(this).error(K("objectIdField")),this.parent?.objectIdField}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){A(e,this.fieldsIndex),this._override("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const{parent:e}=this;return e&&!e.isTable&&"mesh"!==e.geometryType?M(e.geometryType):null}readRendererFromService(e,t,r){if("Table"===t.type)return null;const i=t.drawingInfo?.renderer,n=U(i,t,r);let s;const{subtypeCode:l}=this;if(null!=l&&B(n,t.subtypeField)){const e=n.uniqueValueInfos?.find((({value:e})=>(e="number"==typeof e?String(e):e)===String(l)));e&&(s=new o({symbol:e.symbol}))}else"simple"!==n?.type||n.visualVariables?.length||(s=n);return s}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer;if(!i)return;const o=i.visualVariables?.some((e=>"rotationInfo"!==e.type));return o?void 0:U(i,t,r)||void 0}get spatialReference(){return this.parent?.spatialReference}get subtypeField(){return this.parent?.subtypeField}readTemplatesFromService(e,t){return[Q(this.subtypeCode,t)]}readTitleFromService(e,t){const r=H(this.subtypeCode,t);return null!=r?r.name:null}get url(){return this.parent?.url}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}async addAttachment(e,t){const{parent:r}=this;if(!r)throw K("addAttachment");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new a("subtype-sublayer:addAttachment","The feature provided does not belong to this SubtypeSublayer");return r.addAttachment(e,t)}async updateAttachment(e,t,r){const{parent:i}=this;if(!i)throw K("updateAttachment");if(e.getAttribute(i.subtypeField)!==this.subtypeCode)throw new a("subtype-sublayer:updateAttachment","The feature provided does not belong to this SubtypeSublayer");return i.updateAttachment(e,t,r)}async deleteAttachments(e,t){const{parent:r}=this;if(!r)throw K("deleteAttachments");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new a("subtype-sublayer:deleteAttachments","The feature provided does not belong to this SubtypeSublayer");return r.deleteAttachments(e,t)}async applyEdits(e,t){if(!this.parent)throw K("applyEdits");return this.parent.applyEdits(e,t)}createPopupTemplate(e){let t=this;const{parent:r,fields:i,title:o}=this;if(r){const{displayField:e,editFieldsInfo:n,objectIdField:s}=r;t={displayField:e,editFieldsInfo:n,fields:i,objectIdField:s,title:o}}return D(t,e)}createQuery(){if(!this.parent)throw K("createQuery");const e=T(this.parent),t=`${this.parent.subtypeField}=${this.subtypeCode}`;return e.where=m(t,this.parent.definitionExpression),e}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e){return this._getLayerDomain(e)}async queryAttachments(e,t){const r=await this.load();if(!r.parent)throw K("queryAttachments");const i=e.clone();return i.where=J(i.where,r.parent.subtypeField,r.subtypeCode),r.parent.queryAttachments(e,t)}async queryFeatures(e,t){const r=await this.load();if(!r.parent)throw K("queryFeatures");const i=P.from(e)??r.createQuery();return null!=e&&(i.where=J(i.where,r.parent.subtypeField,r.subtypeCode)),r.parent.queryFeatures(i,t)}_getLayerDomain(e){const t=this.fieldsIndex.get(e);return t?t.domain:null}};e([f({readOnly:!0,json:{read:!1}})],z.prototype,"capabilities",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"effectiveCapabilities",null),e([f({json:{write:{ignoreOrigin:!0}}})],z.prototype,"charts",void 0),e([f({type:Boolean,nonNullable:!0,json:{name:"enableEditing",write:{ignoreOrigin:!0}}})],z.prototype,"editingEnabled",void 0),e([f({type:Boolean,readOnly:!0})],z.prototype,"effectiveEditingEnabled",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"elevationInfo",null),e([f({json:{name:"layerDefinition.fieldOverrides",origins:{service:{read:!1}},write:{ignoreOrigin:!0,allowNull:!0}}})],z.prototype,"fieldOverrides",void 0),e([g("fieldOverrides")],z.prototype,"writeFieldOverrides",null),e([f({...N.fields,readOnly:!0,json:{read:!1}})],z.prototype,"fields",null),e([f(N.fieldsIndex)],z.prototype,"fieldsIndex",void 0),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"floorInfo",null),e([f({type:j,json:{name:"formInfo",write:{ignoreOrigin:!0}}})],z.prototype,"formTemplate",void 0),e([f({type:String,clonable:!1,readOnly:!0,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],z.prototype,"id",void 0),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"geometryType",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"type",void 0),e([f(k(d(w)))],z.prototype,"labelsVisible",void 0),e([f({type:[x],json:{name:"layerDefinition.drawingInfo.labelingInfo",origins:{service:{read:!1}},read:{reader:R},write:{ignoreOrigin:!0}}})],z.prototype,"labelingInfo",void 0),e([f({type:["ArcGISFeatureLayer"],readOnly:!0,json:{read:!1,write:{ignoreOrigin:!0}}})],z.prototype,"layerType",void 0),e([f(k(d(O)))],z.prototype,"legendEnabled",void 0),e([f({type:["show","hide"]})],z.prototype,"listMode",void 0),e([f((()=>{const e=d(F);return e.json.origins.service.read=!1,k(e)})())],z.prototype,"minScale",void 0),e([f((()=>{const e=d(I);return e.json.origins.service.read=!1,k(e)})())],z.prototype,"maxScale",void 0),e([f({readOnly:!0})],z.prototype,"effectiveScaleRange",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"objectIdField",null),e([f({type:Number,range:{min:0,max:1},nonNullable:!0,json:{write:{ignoreOrigin:!0}}})],z.prototype,"opacity",void 0),e([f({clonable:!1})],z.prototype,"parent",void 0),e([f(k(d(S)))],z.prototype,"popupEnabled",void 0),e([f({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],z.prototype,"popupTemplate",void 0),e([f({readOnly:!0})],z.prototype,"defaultPopupTemplate",null),e([f({types:G,json:{write:{target:"layerDefinition.drawingInfo.renderer",ignoreOrigin:!0}}})],z.prototype,"renderer",null),e([h("service","renderer",["drawingInfo.renderer","subtypeField","type"])],z.prototype,"readRendererFromService",null),e([h("renderer",["layerDefinition.drawingInfo.renderer"])],z.prototype,"readRenderer",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"spatialReference",null),e([f({type:Number,json:{origins:{service:{read:!1}},write:{ignoreOrigin:!0}}})],z.prototype,"subtypeCode",void 0),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"subtypeField",null),e([f({type:[E],json:{name:"layerDefinition.templates",write:{ignoreOrigin:!0}}})],z.prototype,"templates",void 0),e([h("service","templates",["geometryType","subtypeField","subtypes","type"])],z.prototype,"readTemplatesFromService",null),e([f({type:String,json:{write:{ignoreOrigin:!0}}})],z.prototype,"title",void 0),e([h("service","title",["subtypes"])],z.prototype,"readTitleFromService",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"url",null),e([f({readOnly:!0})],z.prototype,"userHasUpdateItemPrivileges",null),e([f({type:Boolean,nonNullable:!0,json:{name:"visibility",write:{ignoreOrigin:!0}}})],z.prototype,"visible",void 0),z=e([b("esri.layers.support.SubtypeSublayer")],z);const J=(e,t,r)=>{const i=new RegExp(`${t}\\s*=\\s*\\d+`),o=`${t}=${r}`,n=e??"";return i.test(n)?n.replace(i,o):m(o,n)},K=e=>new a(`This sublayer must have a parent SubtypeGroupLayer in order to use ${e}`),W=z;export{W as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../PopupTemplate.js";import r from"../../renderers/ClassBreaksRenderer.js";import"../../renderers/DictionaryRenderer.js";import"../../renderers/DotDensityRenderer.js";import"../../renderers/HeatmapRenderer.js";import"../../renderers/PieChartRenderer.js";import i from"../../renderers/Renderer.js";import o from"../../renderers/SimpleRenderer.js";import n from"../../renderers/UniqueValueRenderer.js";import"../../renderers/support/jsonUtils.js";import s from"../../core/Logger.js";import{ClonableMixin as l}from"../../core/Clonable.js";import"../../core/has.js";import a from"../../core/Error.js";import{IdentifiableMixin as p}from"../../core/Identifiable.js";import{clone as d}from"../../core/lang.js";import u from"../../core/Loadable.js";import{MultiOriginJSONMixin as y}from"../../core/MultiOriginJSONSupport.js";import{setDeepValue as c}from"../../core/object.js";import{sqlAnd as m}from"../../core/sql.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import{reader as h}from"../../core/accessorSupport/decorators/reader.js";import{subclass as b}from"../../core/accessorSupport/decorators/subclass.js";import{writer as g}from"../../core/accessorSupport/decorators/writer.js";import{createTypeReader as j}from"../../core/accessorSupport/extensions/serializableProperty/reader.js";import v from"../../form/FormTemplate.js";import{labelsVisible as w,legendEnabled as O,minScale as F,maxScale as I,popupEnabled as S}from"./commonProperties.js";import{createQuery as T}from"./featureLayerUtils.js";import C from"./FeatureTemplate.js";import{defineFieldProperties as E}from"./fieldProperties.js";import{fixRendererFields as A}from"./fieldUtils.js";import x from"./LabelClass.js";import{reader as R}from"./labelingInfo.js";import q from"../../rest/support/Query.js";import{createPopupTemplate as P}from"../../support/popupUtils.js";import{defaultPolygonSymbol2D as D,defaultPolylineSymbol2D as L,defaultPointSymbol2D as V}from"../../symbols/support/defaults.js";const G={key:"type",base:i,errorContext:"renderer",typeMap:{simple:o,"unique-value":n,"class-breaks":r}},N=E(),U=j({types:G});let $=0;function k(e){const t=e.json.write;return"object"==typeof t?t.ignoreOrigin=!0:e.json.write={ignoreOrigin:!0},e}function M(e){return new o({symbol:_(e)})}function _(e){switch(e){case"point":case"multipoint":return V.clone();case"polyline":return L.clone();case"polygon":case"multipatch":return D.clone();default:return null}}function B(e,t){return!!t&&("unique-value"===e?.type&&null!=e.field&&e.field.toLowerCase()===t.toLowerCase()&&!e.field2&&!e.field3&&!e.valueExpression)}function H(e,t){return null==e?null:t.subtypes?.find((t=>t.code===e))}function Q(e,t){let r=null;switch(t.geometryType){case"esriGeometryPoint":case"esriGeometryMultipoint":r="point";break;case"esriGeometryPolyline":r="line";break;case"esriGeometryPolygon":case"esriGeometryMultiPatch":r="polygon";break;default:t.type,r=null}const i={},o=H(e,t);if(null!=o){const{defaultValues:e}=o;for(const t in e)i[t]=e[t]}return i[t.subtypeField]=e,new C({name:"New Feature",drawingTool:r,prototype:{attributes:i}})}let z=class extends(y(l(p(u)))){constructor(e){super(e),this.charts=null,this.editingEnabled=!0,this.fieldOverrides=null,this.fieldsIndex=null,this.formTemplate=null,this.id=`${Date.now().toString(16)}-subtype-sublayer-${$++}`,this.type="subtype-sublayer",this.labelsVisible=!0,this.labelingInfo=null,this.layerType="ArcGISFeatureLayer",this.legendEnabled=!0,this.listMode="show",this.minScale=0,this.maxScale=0,this.opacity=1,this.parent=null,this.popupEnabled=!0,this.popupTemplate=null,this.subtypeCode=null,this.templates=null,this.title=null,this.visible=!0}load(e){return A(this.renderer,this.fieldsIndex),Promise.resolve(this)}get capabilities(){return this.parent?.capabilities}get effectiveCapabilities(){return this.parent?.effectiveCapabilities}get effectiveEditingEnabled(){const{parent:e}=this;return e?e.effectiveEditingEnabled&&this.editingEnabled:this.editingEnabled}get elevationInfo(){return this.parent?.elevationInfo}writeFieldOverrides(e,t,r){const{fields:i,parent:o}=this;let n;if(i){n=[];let e=0;i.forEach((({name:t,alias:r,editable:i,visible:s})=>{if(!s)return;const l=o?.fields?.find((e=>e.name===t));if(!l)return;const a={name:t};let p=!1;r!==l.alias&&(a.alias=r,p=!0),i!==l.editable&&(a.editable=i,p=!0),n.push(a),p&&e++})),0===e&&n.length===i.length&&(n=null)}else n=d(e);n?.length&&c(r,n,t)}get fields(){const{parent:e,fieldOverrides:t,subtypeCode:r}=this,i=e?.fields;if(!e||!i?.length)return null;const{subtypes:o,subtypeField:n}=e,s=o?.find((e=>e.code===r)),l=s?.defaultValues,a=s?.domains,p=[];for(const d of i){const e=d.clone(),{name:i}=e,o=t?.find((e=>e.name===i));if(e.visible=!t||!!o,o){const{alias:t,editable:r}=o;t&&(e.alias=t),!1===r&&(e.editable=!1)}const s=l?.[i]??null;e.defaultValue=i===n?r:s;const u=a?.[i]??null;e.domain=i===n?null:u?"inherited"===u.type?e.domain:u.clone():null,p.push(e)}return p}get floorInfo(){return this.parent?.floorInfo}get geometryType(){return this.parent?.geometryType}get effectiveScaleRange(){const{minScale:e,maxScale:t}=this;return{minScale:e,maxScale:t}}get objectIdField(){return this.parent||s.getLogger(this).error(W("objectIdField")),this.parent?.objectIdField}get defaultPopupTemplate(){return this.createPopupTemplate()}set renderer(e){A(e,this.fieldsIndex),this._override("renderer",e)}get renderer(){if(this._isOverridden("renderer"))return this._get("renderer");const{parent:e}=this;return e&&!e.isTable&&"mesh"!==e.geometryType?M(e.geometryType):null}readRendererFromService(e,t,r){if("Table"===t.type)return null;const i=t.drawingInfo?.renderer,n=U(i,t,r);let s;const{subtypeCode:l}=this;if(null!=l&&B(n,t.subtypeField)){const e=n.uniqueValueInfos?.find((({value:e})=>(e="number"==typeof e?String(e):e)===String(l)));e&&(s=new o({symbol:e.symbol}))}else"simple"!==n?.type||n.visualVariables?.length||(s=n);return s}readRenderer(e,t,r){const i=t?.layerDefinition?.drawingInfo?.renderer;if(!i)return;const o=i.visualVariables?.some((e=>"rotationInfo"!==e.type));return o?void 0:U(i,t,r)||void 0}get spatialReference(){return this.parent?.spatialReference}get subtypeField(){return this.parent?.subtypeField}readTemplatesFromService(e,t){return[Q(this.subtypeCode,t)]}readTitleFromService(e,t){const r=H(this.subtypeCode,t);return null!=r?r.name:null}get url(){return this.parent?.url}get userHasUpdateItemPrivileges(){return!!this.parent?.userHasUpdateItemPrivileges}async addAttachment(e,t){const{parent:r}=this;if(!r)throw W("addAttachment");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new a("subtype-sublayer:addAttachment","The feature provided does not belong to this SubtypeSublayer");return r.addAttachment(e,t)}async updateAttachment(e,t,r){const{parent:i}=this;if(!i)throw W("updateAttachment");if(e.getAttribute(i.subtypeField)!==this.subtypeCode)throw new a("subtype-sublayer:updateAttachment","The feature provided does not belong to this SubtypeSublayer");return i.updateAttachment(e,t,r)}async deleteAttachments(e,t){const{parent:r}=this;if(!r)throw W("deleteAttachments");if(e.getAttribute(r.subtypeField)!==this.subtypeCode)throw new a("subtype-sublayer:deleteAttachments","The feature provided does not belong to this SubtypeSublayer");return r.deleteAttachments(e,t)}async applyEdits(e,t){if(!this.parent)throw W("applyEdits");return this.parent.applyEdits(e,t)}createPopupTemplate(e){let t=this;const{parent:r,fields:i,title:o}=this;if(r){const{displayField:e,editFieldsInfo:n,objectIdField:s}=r;t={displayField:e,editFieldsInfo:n,fields:i,objectIdField:s,title:o}}return P(t,e)}createQuery(){if(!this.parent)throw W("createQuery");const e=T(this.parent),t=`${this.parent.subtypeField}=${this.subtypeCode}`;return e.where=m(t,this.parent.definitionExpression),e}getField(e){return this.fieldsIndex.get(e)}getFieldDomain(e){return this._getLayerDomain(e)}async queryAttachments(e,t){const r=await this.load();if(!r.parent)throw W("queryAttachments");const i=e.clone();return i.where=K(i.where,r.parent.subtypeField,r.subtypeCode),r.parent.queryAttachments(e,t)}async queryFeatureCount(e,t){const r=await this.load();if(!r.parent)throw W("queryFeatureCount");return r.parent.queryFeatureCount(J(r.parent,r,e),t)}async queryFeatures(e,t){const r=await this.load();if(!r.parent)throw W("queryFeatures");return r.parent.queryFeatures(J(r.parent,r,e),t)}async queryObjectIds(e,t){const r=await this.load();if(!r.parent)throw W("queryObjectIds");return r.parent.queryObjectIds(J(r.parent,r,e),t)}_getLayerDomain(e){const t=this.fieldsIndex.get(e);return t?t.domain:null}};e([f({readOnly:!0,json:{read:!1}})],z.prototype,"capabilities",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"effectiveCapabilities",null),e([f({json:{write:{ignoreOrigin:!0}}})],z.prototype,"charts",void 0),e([f({type:Boolean,nonNullable:!0,json:{name:"enableEditing",write:{ignoreOrigin:!0}}})],z.prototype,"editingEnabled",void 0),e([f({type:Boolean,readOnly:!0})],z.prototype,"effectiveEditingEnabled",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"elevationInfo",null),e([f({json:{name:"layerDefinition.fieldOverrides",origins:{service:{read:!1}},write:{ignoreOrigin:!0,allowNull:!0}}})],z.prototype,"fieldOverrides",void 0),e([g("fieldOverrides")],z.prototype,"writeFieldOverrides",null),e([f({...N.fields,readOnly:!0,json:{read:!1}})],z.prototype,"fields",null),e([f(N.fieldsIndex)],z.prototype,"fieldsIndex",void 0),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"floorInfo",null),e([f({type:v,json:{name:"formInfo",write:{ignoreOrigin:!0}}})],z.prototype,"formTemplate",void 0),e([f({type:String,clonable:!1,readOnly:!0,json:{origins:{service:{read:!1},"portal-item":{read:!1}},write:{ignoreOrigin:!0}}})],z.prototype,"id",void 0),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"geometryType",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"type",void 0),e([f(k(d(w)))],z.prototype,"labelsVisible",void 0),e([f({type:[x],json:{name:"layerDefinition.drawingInfo.labelingInfo",origins:{service:{read:!1}},read:{reader:R},write:{ignoreOrigin:!0}}})],z.prototype,"labelingInfo",void 0),e([f({type:["ArcGISFeatureLayer"],readOnly:!0,json:{read:!1,write:{ignoreOrigin:!0}}})],z.prototype,"layerType",void 0),e([f(k(d(O)))],z.prototype,"legendEnabled",void 0),e([f({type:["show","hide"]})],z.prototype,"listMode",void 0),e([f((()=>{const e=d(F);return e.json.origins.service.read=!1,k(e)})())],z.prototype,"minScale",void 0),e([f((()=>{const e=d(I);return e.json.origins.service.read=!1,k(e)})())],z.prototype,"maxScale",void 0),e([f({readOnly:!0})],z.prototype,"effectiveScaleRange",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"objectIdField",null),e([f({type:Number,range:{min:0,max:1},nonNullable:!0,json:{write:{ignoreOrigin:!0}}})],z.prototype,"opacity",void 0),e([f({clonable:!1})],z.prototype,"parent",void 0),e([f(k(d(S)))],z.prototype,"popupEnabled",void 0),e([f({type:t,json:{name:"popupInfo",write:{ignoreOrigin:!0}}})],z.prototype,"popupTemplate",void 0),e([f({readOnly:!0})],z.prototype,"defaultPopupTemplate",null),e([f({types:G,json:{write:{target:"layerDefinition.drawingInfo.renderer",ignoreOrigin:!0}}})],z.prototype,"renderer",null),e([h("service","renderer",["drawingInfo.renderer","subtypeField","type"])],z.prototype,"readRendererFromService",null),e([h("renderer",["layerDefinition.drawingInfo.renderer"])],z.prototype,"readRenderer",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"spatialReference",null),e([f({type:Number,json:{origins:{service:{read:!1}},write:{ignoreOrigin:!0}}})],z.prototype,"subtypeCode",void 0),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"subtypeField",null),e([f({type:[C],json:{name:"layerDefinition.templates",write:{ignoreOrigin:!0}}})],z.prototype,"templates",void 0),e([h("service","templates",["geometryType","subtypeField","subtypes","type"])],z.prototype,"readTemplatesFromService",null),e([f({type:String,json:{write:{ignoreOrigin:!0}}})],z.prototype,"title",void 0),e([h("service","title",["subtypes"])],z.prototype,"readTitleFromService",null),e([f({readOnly:!0,json:{read:!1}})],z.prototype,"url",null),e([f({readOnly:!0})],z.prototype,"userHasUpdateItemPrivileges",null),e([f({type:Boolean,nonNullable:!0,json:{name:"visibility",write:{ignoreOrigin:!0}}})],z.prototype,"visible",void 0),z=e([b("esri.layers.support.SubtypeSublayer")],z);const J=(e,t,r)=>{if(!r)return t.createQuery();const i=q.from(r);return i.where=K(i.where,e.subtypeField,t.subtypeCode),i},K=(e,t,r)=>{const i=new RegExp(`${t}\\s*=\\s*\\d+`),o=`${t}=${r}`,n=e??"";return i.test(n)?n.replace(i,o):m(o,n)},W=e=>new a(`This sublayer must have a parent SubtypeGroupLayer in order to use ${e}`),X=z;export{X 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.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{property as s}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import a from"../DimensionalDefinition.js";import l from"./BaseRaster.js";import{parse as c}from"./multipartParser.js";import{parseCapabilities as d}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as p,parseCoverages as u}from"./wcsCoverageParser.js";import{getFormat as h}from"../rasterFormats/RasterCodec.js";import{clip as f}from"../rasterFunctions/pixelUtils.js";import g from"../../../geometry/Extent.js";const m=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",C="server returns an exception";let b=class extends l{constructor(){super(...arguments),this.datasetFormat="WCSServer"}async open(e){await this.init();const i=e?.signal,n=await this._getCapabilities(i);if(this.capabilities=n,!this.version){let e=n.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=n.capabilitiesVersion:(e=n.supportedVersions.find((e=>"2.0.1"===e))||n.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||n.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}const s=n.coverages.filter((({coverageSubType:e})=>null==e||""===e||/^rectified(grid|dataset)/i.test(e)));if(!s.length)throw new t("wcsraster-open","cannot find rectified grid coverages");null==this.coverageId&&(this.coverageId=s[0].id);const r=s.find((e=>e.id===this.coverageId));if(null==r)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const o=await this._describeCoverage(i);this.coverageInfo=o[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=r.lonLatEnvelope,this.coverageInfo.supportedInterpolations=p(n.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:r,spatialReference:o}=this.rasterInfo,a=2**e,l=r.x*a,c=r.y*a,{blockWidth:d,blockHeight:p}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:c},i,n,u,o,[d,p]),g=this.rasterInfo.extent,m=h.xmax>g.xmax,w=h.ymin<g.ymin,v=m||w;let y=h,x=d,C=p;if(v&&(y=h.clone().intersection(g),null!=y&&(m&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(C=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*C))),null==y||x<=1||C<=1)return null;const b=await this._getCoverage(y,x,C,a,s);if(!b)return null;const{coverageDescription:I}=this.coverageInfo;let{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo;const{multidimensionalDefinition:j}=s;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===I.version){const t=I.rangeType[0].find((t=>t.name===e));$=t?.nilValue}else if("1.1"===I.version){const t=I.range.find((t=>t.identifier===e));$=t?.nullValues}}const T=await this.decodePixelBlock(b,{width:x,height:C,planes:null,pixelType:null,noDataValue:Array.isArray($)?$[0]:$});if(null==T)return null;if(T&&(T.width!==x||T.height!==C))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${T.width}, height: {pixelBlock.height}`);return v?f(T,{x:0,y:0},{width:p,height:p}):T}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return d(t)}catch(s){if(!n(s))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw s}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},s=this.version?.slice(0,3);"1.0"===s?i.coverage=this.coverageId:"1.1"===s?i.identifiers=this.coverageId:"2.0"===s&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return u(t,this.version)}catch(r){if(!n(r))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw r}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:r}=this.rasterInfo,o=s.center,l=new g({xmin:o.x-n.x,xmax:o.x+n.x,ymin:o.y-n.y,ymax:o.y+n.y,spatialReference:s.spatialReference});let c=[];if(null!=r){const e=r.variables[0];c=[],e.dimensions.forEach((t=>{c.push(new a({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))}))}const{coverageDescription:d}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:u}=d,{ioConfig:h}=this,f="2.0"===u&&null==h.allowAnyMediaType||"1.1"===u&&null==h.use2GridOffsets;let m;try{m=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!f)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;h.use2GridOffsets=!0}}if(!m&&f&&("2.0"===u&&(h.allowAnyMediaType=!0),m=await this._getCoverage(l,2,2,1,p),m&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!m)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(m,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,r,o,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:d}=l,p="2.0"===d?this._getCoverage201Parameters(e,n,s,r,o,l):"1.1"===d?this._getCoverage110Parameters(e,n,s,o,l):this._getCoverage100Parameters(e,n,s,o),u="2.0"===d?await this.request(this._constructWCS201Url(p),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:p,signal:o.signal,responseType:"array-buffer"});if("1.0"===d)return u.data;if("2.0"===d&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===h(u.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),u.data}const f=c(u);if(f.isMultipart&&f.data){const e=f.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData));return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const g=new Uint8Array(u.data,0,Math.min(u.data.byteLength,2e3)),m=String.fromCharCode.apply(null,g).toLowerCase().includes("exception"),w=m&&String.fromCharCode.apply(null,g).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(m)throw new t("wcsraster:getcoverage",C,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,r=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=m[c],{multidimensionalDefinition:u}=n;let h;if(null!=u&&null!=this.rasterInfo.multidimensionalInfo){const e=u.find((e=>"StdTime"===e.dimensionName));let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),h=t.map((e=>I(e))).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${r}`,bbox:s,width:t,height:i,time:h,interpolation:p,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:r,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",u=this._getInterpolationIndex(l),h=w[u],f=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),g=s.domain.spatialDomain,m=g.origin.x<=g.envelope.xmin&&g.origin.y<=g.envelope.ymin,v=e.width/t,y=e.height/i*(m?1:-1),x=m?[e.xmin,e.ymin]:[e.xmin,e.ymax],C=g.useEPSGAxis&&o(c),b=C?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,$=this.ioConfig.use2GridOffsets,S=C?$?`${y},${v}`:`${y},0,0,${v}`:$?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,_=Math.abs(y)/2,R=e.ymin+_,D=e.ymax-_,E=C?`${R},${T},${D},${L},${d}`:`${T},${R},${L},${D},${d}`,P=s.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let A,G=P&&h&&a?f?`${P.identifier}[${P.axis[0].identifier}[${a.join(",")}]]`:`${P.identifier}:${h}[${P.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=r&&r.length)for(let o=0;o<r.length;o++){let e=r[o].values;const t=r[o].dimensionName?.toLowerCase(),i=r[o].variableName?.toLowerCase();if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)A=e.map((e=>I(e))).join(",");else{const n=s.range.find((e=>e.identifier.toLowerCase()===i));if(n){const i=n.axis.find((e=>e.identifier.toLowerCase()===t));i&&(G=f?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+h+"["+i.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:p,crs:`EPSG:${c}`,boundingbox:E,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:b,gridOffsets:S,gridBaseCRS:d,timeSequence:A,rangeSubset:G}}_getCoverage201Parameters(e,t,i,n,s,r){const{multidimensionalDefinition:o,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find((e=>e.toLowerCase().includes("nearest")));break;case 1:c=d.find((e=>e.toLowerCase().includes("linear")));break;case 2:c=d.find((e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic")))}const p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:h,domainSet:f,rangeType:g}=r,m=h.isEastFirst?0:1,w=1-m,{axisLabels:v}=h,y=v[m],x=v[w],C=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,b=C,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let D=2;D<v.length;D++){const e=f.origin[D];if(v[D].toLowerCase().includes("time")){let t=e.toString();h.uomLabels?.[D].toLowerCase().includes("ole")&&(S.push(v[D]),t=I(e,!0)),$.push(v[D]+",http://www.opengis.net("+t+")")}else $.push(v[D]+",http://www.opengis.net("+e+")")}let j=null;if(null!=o&&o.length){const e=[];g.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<o.length;i++){const n=v.find((e=>e===o[i].dimensionName)),s=e.find((e=>e===o[i].variableName));if(t.includes(s)||t.push(s),n){let e=o[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map((e=>I(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(n+",http://www.opengis.net")));-1===i&&$.push(n+",http://www.opengis.net("+t+")"),-1===i||$[i].includes("("+t+")")||$.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length>=2){j=(s.bandIds?s.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),L=!r.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,_=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:_,scaleFactor:R,subset:T,format:p,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:C,subsettingcrs:b}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(n)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};function I(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}e([s({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([s()],b.prototype,"tileType",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([s({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),b=e([r("esri.layers.support.rasterDatasets.WCSRaster")],b);const $=b;export{$ as default};
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import"../../../geometry.js";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{isAbortError as s}from"../../../core/promiseUtils.js";import{property as n}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as r}from"../../../core/accessorSupport/decorators/subclass.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import a from"../DimensionalDefinition.js";import l from"./BaseRaster.js";import{parse as c}from"./multipartParser.js";import{parseCapabilities as d}from"./wcsCapabilitiesParser.js";import{standardizeInterpolations as p,parseCoverages as u}from"./wcsCoverageParser.js";import{getFormat as h}from"../rasterFormats/RasterCodec.js";import{clip as f}from"../rasterFunctions/pixelUtils.js";import g from"../../../geometry/Extent.js";const m=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",C="server returns an exception";let b=class extends l{constructor(){super(...arguments),this.datasetFormat="WCSServer",this.tileType="Raster"}async open(e){await this.init();const i=e?.signal,s=await this._getCapabilities(i);if(this.capabilities=s,!this.version){let e=s.capabilitiesVersion?.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.capabilitiesVersion:(e=s.supportedVersions.find((e=>"2.0.1"===e))||s.supportedVersions.find((e=>"2.0"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.1"===e.slice(0,3)))||s.supportedVersions.find((e=>"1.0"===e.slice(0,3)))||"1.0.0",this.version=e)}const n=s.coverages.filter((({coverageSubType:e})=>null==e||""===e||/^rectified(grid|dataset)/i.test(e)));if(!n.length)throw new t("wcsraster-open","cannot find rectified grid coverages");null==this.coverageId&&(this.coverageId=n[0].id);const r=n.find((e=>e.id===this.coverageId));if(null==r)throw new t("wcsraster-open",`the coverageId ${this.coverageId} does not exist in capabilities`);const o=await this._describeCoverage(i);this.coverageInfo=o[0],"2.0"===this.version.slice(0,3)&&(this.coverageInfo.lonLatEnvelope=r.lonLatEnvelope,this.coverageInfo.supportedInterpolations=p(s.supportedInterpolations)),this.datasetName=this.coverageInfo.title;const{rasterInfo:a}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(a,512,512),this._set("rasterInfo",a),null==a.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${this.coverageId}`);const{pixelType:l,bandCount:c}=await this._getPixelTypeAndBandCount(i);a.pixelType=l,1===a.bandCount&&c>1&&(a.bandCount=c),this.updateTileInfo()}async fetchRawTile(e,i,s,n={}){if(this.isBlockOutside(e,i,s))return null;const{nativePixelSize:r,spatialReference:o}=this.rasterInfo,a=2**e,l=r.x*a,c=r.y*a,{blockWidth:d,blockHeight:p}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:c},i,s,u,o,[d,p]),g=this.rasterInfo.extent,m=h.xmax>g.xmax,w=h.ymin<g.ymin,v=m||w;let y=h,x=d,C=p;if(v&&(y=h.clone().intersection(g),null!=y&&(m&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(C=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*C))),null==y||x<=1||C<=1)return null;const b=await this._getCoverage(y,x,C,a,n);if(!b)return null;const{coverageDescription:I}=this.coverageInfo;let{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo;const{multidimensionalDefinition:j}=n;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===I.version){const t=I.rangeType[0].find((t=>t.name===e));$=t?.nilValue}else if("1.1"===I.version){const t=I.range.find((t=>t.identifier===e));$=t?.nullValues}}const T=await this.decodePixelBlock(b,{width:x,height:C,planes:null,pixelType:null,noDataValue:Array.isArray($)?$[0]:$});if(null==T)return null;if(T&&(T.width!==x||T.height!==C))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${T.width}, height: {pixelBlock.height}`);return v?f(T,{x:0,y:0},{width:p,height:p}):T}async _getCapabilities(e){const i={service:"WCS",request:"GetCapabilities"};this.version&&(i.version=this.version,i.acceptVersions=this.version);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return d(t)}catch(n){if(!s(n))throw new t("wcslayer:open","wcs capabilities is not valid or supported");throw n}}async _describeCoverage(e){const i={service:"WCS",request:"DescribeCoverage",version:this.version},n=this.version?.slice(0,3);"1.0"===n?i.coverage=this.coverageId:"1.1"===n?i.identifiers=this.coverageId:"2.0"===n&&(i.coverageId=this.coverageId);try{const{data:t}=await this.request(this.url,{query:i,responseType:"xml",signal:e});return u(t,this.version)}catch(r){if(!s(r))throw new t("wcslayer:open","wcs coverage description is not valid or supported");throw r}}async _getPixelTypeAndBandCount(e){const{pixelSize:s,extent:n,multidimensionalInfo:r}=this.rasterInfo,o=n.center,l=new g({xmin:o.x-s.x,xmax:o.x+s.x,ymin:o.y-s.y,ymax:o.y+s.y,spatialReference:n.spatialReference});let c=[];if(null!=r){const e=r.variables[0];c=[],e.dimensions.forEach((t=>{c.push(new a({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))}))}const{coverageDescription:d}=this.coverageInfo,p={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:u}=d,{ioConfig:h}=this,f="2.0"===u&&null==h.allowAnyMediaType||"1.1"===u&&null==h.use2GridOffsets;let m;try{m=await this._getCoverage(l,2,2,1,p,!0)}catch(y){if(!f)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;h.use2GridOffsets=!0}}if(!m&&f&&("2.0"===u&&(h.allowAnyMediaType=!0),m=await this._getCoverage(l,2,2,1,p),m&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!m)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(m,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,s,n,r,o,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:d}=l,p="2.0"===d?this._getCoverage201Parameters(e,s,n,r,o,l):"1.1"===d?this._getCoverage110Parameters(e,s,n,o,l):this._getCoverage100Parameters(e,s,n,o),u="2.0"===d?await this.request(this._constructWCS201Url(p),{signal:o.signal,responseType:"array-buffer"}):await this.request(this.url,{query:p,signal:o.signal,responseType:"array-buffer"});if("1.0"===d)return u.data;if("2.0"===d&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===h(u.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),u.data}const f=c(u);if(f.isMultipart&&f.data){const e=f.data.find((e=>e.contentType?.toLowerCase().includes("image")&&null!=e.contentData));return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const g=new Uint8Array(u.data,0,Math.min(u.data.byteLength,2e3)),m=String.fromCharCode.apply(null,g).toLowerCase().includes("exception"),w=m&&String.fromCharCode.apply(null,g).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(m)throw new t("wcsraster:getcoverage",C,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,s){const n=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,r=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"GEOTIFF",{bandIds:a,interpolation:l}=s,c=this._getInterpolationIndex(l),d=a?a.map((e=>this.coverageInfo.bandNames[e])):null,p=m[c],{multidimensionalDefinition:u}=s;let h;if(null!=u&&null!=this.rasterInfo.multidimensionalInfo){const e=u.find((e=>"StdTime"===e.dimensionName));let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),h=t.map((e=>I(e))).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${r}`,bbox:n,width:t,height:i,time:h,interpolation:p,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,s,n){const{multidimensionalDefinition:r,bandIds:a,interpolation:l}=s,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",u=this._getInterpolationIndex(l),h=w[u],f=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),g=n.domain.spatialDomain,m=g.origin.x<=g.envelope.xmin&&g.origin.y<=g.envelope.ymin,v=e.width/t,y=e.height/i*(m?1:-1),x=m?[e.xmin,e.ymin]:[e.xmin,e.ymax],C=g.useEPSGAxis&&o(c),b=C?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,$=this.ioConfig.use2GridOffsets,S=C?$?`${y},${v}`:`${y},0,0,${v}`:$?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,_=Math.abs(y)/2,R=e.ymin+_,D=e.ymax-_,E=C?`${R},${T},${D},${L},${d}`:`${T},${R},${L},${D},${d}`,P=n.range.find((e=>e.axis.some((e=>e.identifier.toLowerCase().includes("band")))));let A,G=P&&h&&a?f?`${P.identifier}[${P.axis[0].identifier}[${a.join(",")}]]`:`${P.identifier}:${h}[${P.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=r&&r.length)for(let o=0;o<r.length;o++){let e=r[o].values;const t=r[o].dimensionName?.toLowerCase(),i=r[o].variableName?.toLowerCase();if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)A=e.map((e=>I(e))).join(",");else{const s=n.range.find((e=>e.identifier.toLowerCase()===i));if(s){const i=s.axis.find((e=>e.identifier.toLowerCase()===t));i&&(G=f?s.identifier+"["+i.identifier+"["+e.join(",")+"]]":s.identifier+":"+h+"["+i.identifier+"["+e.join(",")+"]]")}}}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:p,crs:`EPSG:${c}`,boundingbox:E,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:b,gridOffsets:S,gridBaseCRS:d,timeSequence:A,rangeSubset:G}}_getCoverage201Parameters(e,t,i,s,n,r){const{multidimensionalDefinition:o,interpolation:a}=n,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find((e=>e.toLowerCase().includes("nearest")));break;case 1:c=d.find((e=>e.toLowerCase().includes("linear")));break;case 2:c=d.find((e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic")))}const p=(this.coverageInfo.supportedFormats||[]).find((e=>e.toLowerCase().includes("tiff")))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:h,domainSet:f,rangeType:g}=r,m=h.isEastFirst?0:1,w=1-m,{axisLabels:v}=h,y=v[m],x=v[w],C=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,b=C,$=[];$.push(`${y}(${e.xmin},${e.xmax})`),$.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let D=2;D<v.length;D++){const e=f.origin[D];if(v[D].toLowerCase().includes("time")){let t=e.toString();h.uomLabels?.[D].toLowerCase().includes("ole")&&(S.push(v[D]),t=I(e,!0)),$.push(v[D]+",http://www.opengis.net("+t+")")}else $.push(v[D]+",http://www.opengis.net("+e+")")}let j=null;if(null!=o&&o.length){const e=[];g.forEach((t=>t.forEach((t=>e.push(t.name)))));const t=[];for(let i=0;i<o.length;i++){const s=v.find((e=>e===o[i].dimensionName)),n=e.find((e=>e===o[i].variableName));if(t.includes(n)||t.push(n),s){let e=o[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=s.toLowerCase().includes("time")?e.map((e=>I(e))).join(","):e.join(",");const i=$.findIndex((e=>0===e.indexOf(s+",http://www.opengis.net")));-1===i&&$.push(s+",http://www.opengis.net("+t+")"),-1===i||$[i].includes("("+t+")")||$.splice(i,1,s+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length>=2){j=(n.bandIds?n.bandIds.map((e=>u[e])):u).join(",")}const T=$.join("&subset="),L=!r.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,_=L?null:`${y}(${t}),${x}(${i})`,R=L?1/s:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:_,scaleFactor:R,subset:T,format:p,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:C,subsettingcrs:b}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach((e=>{const s=t[e];null!=s&&("subset"===e?"string"==typeof s&&s.split("&subset=").forEach((e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)})):i.push(`${e}=${encodeURIComponent(s)}`))}));return`${encodeURI(this.url)}?${i.join("&")}`}};function I(e,t=!1){return(t?new Date(24*(e-25569)*60*60*1e3):new Date(e)).toISOString()}e([n({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([n({readOnly:!0})],b.prototype,"tileType",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),b=e([r("esri.layers.support.rasterDatasets.WCSRaster")],b);const $=b;export{$ as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.31/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e}from"../../../core/arrayUtils.js";import n from"../DimensionalDefinition.js";function t(e,n,
|
|
5
|
+
import{isSome as e}from"../../../core/arrayUtils.js";import n from"../DimensionalDefinition.js";function t(e,n,a){const i=n.shift();if(0===a.length){const e=[];a.push({sliceId:-1,multidimensionalDefinition:e})}const s=a.length;for(let t=0;t<s;t++){const n=a.shift().multidimensionalDefinition;i.values?.forEach((t=>{a.push({sliceId:-1,multidimensionalDefinition:[...n,{variableName:e,dimensionName:i.name,values:[t]}]})}))}n.length&&t(e,n,a)}function a(e,n){const a=[];let i=0;return(n?e.variables.filter((e=>e.name.toLowerCase()===n.toLowerCase())):[...e.variables].sort(((e,n)=>e.name>n.name?1:-1))).forEach((e=>{const n=[],s=[...e.dimensions].sort(((e,n)=>e.name>n.name?-1:1));t(e.name,s,n),n.forEach((e=>{a.push({...e,sliceId:i++})}))})),a}function i(e,n,t){let a=e;if(n&&(n=[...n].sort(((e,n)=>e.dimensionName<n.dimensionName?-1:1))).forEach((({dimensionName:e,values:n,isSlice:t})=>{n.length&&(a=a.filter((a=>{const i=a.multidimensionalDefinition.find((n=>n.dimensionName===e));if(null==i)return!1;const s=i.values[0];return"number"==typeof s?"number"==typeof n[0]?n.includes(s):n.some((e=>e[0]<=s&&e[1]>=s)):"number"==typeof n[0]?n.some((e=>s[0]<=e&&s[1]>=e)):t?n.some((e=>e[0]===s[0]&&e[0]===s[1])):n.some((e=>e[0]>=s[0]&&e[0]<=s[1]||e[1]>=s[0]&&e[1]<=s[1]||e[0]<s[0]&&e[1]>s[1]))})))})),a.length&&null!=t?.start&&null!=t.end){const e=t.start.getTime(),n=t.end.getTime(),i=a[0].multidimensionalDefinition.findIndex((e=>"StdTime"===e.dimensionName));i>-1&&(a=a.filter((t=>{const a=t.multidimensionalDefinition[i].values[0];return e<=a&&n>=a})))}return a.map((e=>e.sliceId))}function s(e,n){return Array.isArray(e)?n[0]===n[1]?e[0]===n[0]||e[1]===n[0]:e[0]>=n[0]&&e[0]<=n[1]&&e[1]>=n[0]&&e[1]<=n[1]:e>=n[0]&&e<=n[1]}function r(e,n){return e[0]<=n[0]&&e[1]>=n[0]||e[0]<=n[1]&&e[1]>=n[1]||e[0]>=n[0]&&e[1]<=n[1]}function l(e){return 1===e.length?[e[0],e[0]]:[e[0],e[e.length-1]]}function u(e,n,t){if(!n?.subsetDefinitions?.length)return e;let a;if(t){const{variables:i}=n;if(i.length&&!i.includes(t))return null;const s=n.subsetDefinitions.find((n=>n.dimensionName===e.name&&n.variableName===t));if(!s?.values?.length)return e;a=l(s.values)}else{const t=n.dimensions.find((({name:n})=>n===e.name));a=t?.extent}const i=a;if(!i?.length)return e;const r=e.values.filter((e=>s(e,i)));return{...e,extent:[...i],values:r}}function o(e,n,t){if(!n?.subsetDefinitions?.length)return!1;const{variables:a}=n;if(a.length&&e.some((({variableName:e})=>e&&!a.includes(e))))return!0;for(let i=0;i<e.length;i++){const a=e[i],u=n.subsetDefinitions.find((e=>(""===a.variableName||e.variableName===a.variableName)&&e.dimensionName===a.dimensionName));if(u?.values.length){const e=l(u.values);if(!a.isSlice&&2===a.values.length&&!Array.isArray(a.values[0])&&a.values[0]!==a.values[1]&&t){if(!r(a.values,e))return!0}else if(a.values.some((n=>!s(n,e))))return!0}}return!1}function m(e,n){if(null==e)return{isOutside:!1};const{geometry:t,timeExtent:a,multidimensionalDefinition:i}=n;let s=null;if(null!=a&&(s=c(e,a),null==s))return{isOutside:!0};const{areaOfInterest:r}=e;if(r&&t){const e="point"===t.type?t:"extent"===t.type?t.center:"polygon"===t.type?t.centroid:null;if(e&&!r.contains(e))return{isOutside:!0}}return null!=i&&i.length&&o(i,e,!0)?{isOutside:!0}:{isOutside:!1,intersection:{geometry:t,timeExtent:s,multidimensionalDefinition:i}}}function c(e,t){const a=e.dimensions.find((({name:e})=>"StdTime"===e));if(null==a||null==t.start&&null==t.end)return t;t=t.clone();const{start:i,end:s}=t.toJSON(),r=i===s?[i]:null!=i&&null!=s?[i,s]:[i??s];if(2===r.length&&a?.extent.length&&(r[0]=Math.max(r[0],a.extent[0]),r[1]=Math.min(r[1],a.extent[1]??a.extent[0]),r[1]<r[0]))return null;return o([new n({variableName:"",dimensionName:"StdTime",isSlice:1===r.length,values:r})],e,!0)?null:(t.start=new Date(r[0]),t.end=new Date(r[1]??r[0]),t)}function f(e,n={}){const{multidimensionalInfo:t,keyProperties:a}=e;if(null==t)return null;const{variableName:i,multidimensionalSubset:s,multidimensionalDefinition:r}=n,l=null!=r?r[0]?.variableName:null,u=i||l||a?.DefaultVariable;let{variables:o}=t;s?.variables?.length&&(o=o.filter((({name:e})=>s.variables.includes(e))));return u?o.find((({name:e})=>e===u))??o[0]:o[0]}function d(e,t={}){const a=f(e,t);if(!a)return null;const i=[],{dimensions:s,name:r}=a;if(0===s.length)return[new n({variableName:r,dimensionName:"",values:[],isSlice:!0})];for(let l=0;l<s.length;l++){const e=u(s[l],t.multidimensionalSubset,r);if(!e)return null;const{values:a,extent:o}=e;let m=a?.[0]??o?.[0];"stdz"===e.name.toLowerCase()&&!e.hasRanges&&o&&Math.abs(o[1])<=Math.abs(o[0])&&(m=a?.length?a[a.length-1]:o[1]),i.push(new n({variableName:r,dimensionName:e.name,values:[m],isSlice:!t.useRangeForRangedDimensionInfo||!!e.hasRanges}))}return i}function h(e){return!!e?.length&&e.some((e=>{if(null==e.values)return!0;const n=e.values.length;return 0===n||n>1||!e.isSlice&&Array.isArray(e.values[0])}))}function g(n,t){if(null==t||null==n)return null;let a=t.variables.map((e=>({...e})));return n?.variables?.length&&(a=a.filter((({name:e})=>n.variables.includes(e))),a.forEach((t=>{t.dimensions=t.dimensions.map((e=>u(e,n,t.name))).filter(e)}))),a}function v(e,n){const{values:t}=n;if(t?.length){const n=Array.isArray(t[0]),a=Array.isArray(e);return n!==a?-1:n&&a?t.findIndex((n=>n[0]===e[0]&&n[1]===e[1])):t.indexOf(e)}const{extent:a}=n;if(Array.isArray(e)||!a||e<a[0]||e>a[1])return-1;const i=n.interval||1;if("ISO8601"!==n.unit)return Math.round((e-a[0])/i);const s=a[0];let r=-1;switch(n.intervalUnit?.toLowerCase()||"days"){case"seconds":r=Math.round((e-s)/1e3/i);break;case"minutes":r=Math.round((e-s)/6e4/i);break;case"hours":r=Math.round((e-s)/36e5/i);break;case"days":r=Math.round((e-s)/864e5/i);break;case"months":{const n=new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear(),t=new Date(s).getUTCMonth(),a=new Date(e).getUTCMonth();r=0===n?a-t:a+11-t+12*(n-1)}break;case"years":r=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/i);break;case"decades":r=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/10/i)}return r}function b(e){let n=e.values?.length;if(n)return n;const{extent:t,unit:a}=e,i=e.interval||1,s=t?t[1]-t[0]:0;if("ISO8601"!==a)return Math.round(s/i);switch(e.intervalUnit?.toLowerCase()??"seconds"){case"seconds":n=Math.round(s/1e3/i);break;case"minutes":n=Math.round(s/6e4/i);break;case"hours":n=Math.round(s/36e5/i);break;case"days":n=Math.round(s/864e5/i);break;case"months":if(t){const e=new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear(),a=new Date(t[0]).getUTCMonth(),i=new Date(t[1]).getUTCMonth();n=0===e?i-a+1:i+11-a+12*(e-1)+1}else n=0;break;case"years":n=t?Math.round((new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear())/i):0;break;case"decades":n=t?Math.round((new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear())/10/i):0;break;default:n=0}return n}function D(e){if(2!==e.extent?.length||!e.interval)return[];const{extent:[n,t],interval:a}=e;if("ISO8601"===e.unit){const i=e.intervalUnit?.toLowerCase()??"days";return["decades","years","months","days","hours","minutes","seconds"].includes(i)?y(n,t,a,i):[]}const i=Math.round((t-n)/a);return Array.from({length:i},((e,s)=>s===i-1?t:n+s*a))}function y(e,n,t,a){const i=[];let s=e;const r=new Date(e);for(;s<=n;)switch(i.push(s),a){case"decades":r.setUTCFullYear(r.getUTCFullYear()+10*t),s=r.getTime();break;case"years":r.setUTCFullYear(r.getUTCFullYear()+t),s=r.getTime();break;case"months":r.setUTCMonth(r.getUTCMonth()+t),s=r.getTime();break;case"days":s+=864e5*t;break;case"hours":s+=36e5*t;break;case"minutes":s+=6e4*t;break;case"seconds":s+=1e3*t}return 1===i.length?i[1]=n:i[i.length-1]=n,i}function w(e,n){let t=0;const a=e[0].variableName,i=[...n.variables].sort(((e,n)=>e.name>n.name?1:-1));for(let s=0;s<i.length;s++){const n=i[s],r=[...n.dimensions].sort(((e,n)=>e.name>n.name?-1:1));if(n.name!==a){t+=r.map((e=>b(e))).reduce(((e,n)=>e*n));continue}const l=r.map((e=>b(e))),u=r.length;for(let a=0;a<u;a++){const n=e.find((e=>e.dimensionName===r[a].name));if(null==n)return null;const i=v(n.values[0],r[a]);if(-1===i)return null;l.shift(),t+=a===u-1?i:i*l.reduce(((e,n)=>e*n))}break}return t}export{a as createSlices,d as getDefaultMultidimensionalDefinition,f as getDefaultVariableInfo,D as getDimensionValues,i as getSliceIds,w as getSliceIndex,g as getSubsetVariablesFromMdInfo,y as getTimeDimensionValues,o as hasExcludedVariableOrDimension,m as intersectMultimensionalSubset,h as isMultiSliceOrRangeDefinition};
|