@arcgis/core 5.0.0-next.42 → 5.0.0-next.44
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/applications/Components/imageryUtils.js +1 -1
- package/arcade/featureset/sources/FeatureLayerOGC.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{f97a7cb367634353177d.js → 001a7a4cf6fe74432ed6.js} +1 -1
- package/assets/esri/core/workers/chunks/00ff4ca88c9d291d82c3.js +1 -0
- package/assets/esri/core/workers/chunks/04a0685ee53ef74883aa.js +1 -0
- package/assets/esri/core/workers/chunks/{c320a29df40e85fb4a8e.js → 15a0750c10b510564a42.js} +1 -1
- package/assets/esri/core/workers/chunks/{9d95f38da21f97214f83.js → 1e0e7cef7ef947894bbe.js} +10 -10
- package/assets/esri/core/workers/chunks/20ad34f9d45c64392022.js +1 -0
- package/assets/esri/core/workers/chunks/23396a6318edf9264c1f.js +1 -0
- package/assets/esri/core/workers/chunks/{816227de5bd42b437df4.js → 233f9eb617f3d72995b5.js} +1 -1
- package/assets/esri/core/workers/chunks/{fb9643b74cf35221ff98.js → 249504f7d356be80d214.js} +1 -1
- package/assets/esri/core/workers/chunks/{ad891ac388fa6c1c9b94.js → 2b34a010f76e5f289868.js} +1 -1
- package/assets/esri/core/workers/chunks/2ef4c0092c59a98a5532.js +1 -0
- package/assets/esri/core/workers/chunks/35272810c2ed04eb403d.js +1 -0
- package/assets/esri/core/workers/chunks/{4f4d51181ae7db9fbe6d.js → 4404b6f931f681cca342.js} +1 -1
- package/assets/esri/core/workers/chunks/555a0ea44ba77819d493.js +1 -0
- package/assets/esri/core/workers/chunks/6e8925412fb90f88d688.js +1 -0
- package/assets/esri/core/workers/chunks/{d1f4152b2b8d47cbf586.js → 72fbee59d5d909615408.js} +1 -1
- package/assets/esri/core/workers/chunks/75c66e38bdc1c786c599.js +1 -0
- package/assets/esri/core/workers/chunks/7d3c2a063598bdd015e2.js +1 -0
- package/assets/esri/core/workers/chunks/83da9ee6544ee9d3c124.js +1 -0
- package/assets/esri/core/workers/chunks/897ce6fc9cefb1e14a64.js +1 -0
- package/assets/esri/core/workers/chunks/{da517b4b07d4d27ce94c.js → 8e26831f71634288f834.js} +1 -1
- package/assets/esri/core/workers/chunks/{c367c7e553be3682f2db.js → 93c5f097bb7b380bb175.js} +1 -1
- package/assets/esri/core/workers/chunks/992e9bbdf9d3787ddb0e.js +1 -0
- package/assets/esri/core/workers/chunks/9c7682b300b877f60095.js +1 -0
- package/assets/esri/core/workers/chunks/a2442549c5daf3653eb4.js +1 -0
- package/assets/esri/core/workers/chunks/a7cd795042ebb8585906.js +1 -0
- package/assets/esri/core/workers/chunks/{f3b3b193959db809c8c6.js → ab520fd1ae917daf07d8.js} +1 -1
- package/assets/esri/core/workers/chunks/{2c9865e34f32fb5683e5.js → af8d6e6949930d0e6c7b.js} +1 -1
- package/assets/esri/core/workers/chunks/c9942ca57f542582ab4d.js +1 -0
- package/assets/esri/core/workers/chunks/ca1c65eb7f5900c60170.js +1 -0
- package/assets/esri/core/workers/chunks/cddce67919e13e2f365e.js +1 -0
- package/assets/esri/core/workers/chunks/da2ba40bc017bff0fe49.js +1 -0
- package/assets/esri/core/workers/chunks/e5a6a646f27715152714.js +1 -0
- package/assets/esri/core/workers/chunks/e6784251bbb8b71ead93.js +1 -0
- package/assets/esri/core/workers/chunks/e8a9971c8354569cb81d.js +1 -0
- package/assets/esri/core/workers/chunks/{96f798ee286b59396131.js → ea3cba01c60d9bc72719.js} +1 -1
- package/assets/esri/core/workers/chunks/ed550bf27f2bbf8d30fa.js +1 -0
- package/assets/esri/core/workers/chunks/ee186ddbb1eb5144a790.js +1 -0
- package/assets/esri/core/workers/chunks/{1357cc637524cd254974.js → ffcdc7ae03b0570e0db8.js} +1 -1
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/assets/esri/themes/base/widgets/_Attribution.scss +1 -1
- 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/config.js +1 -1
- package/core/PooledArray.js +1 -1
- package/geometry/FlatGeometry.js +1 -1
- package/geometry/support/MeshMaterialMetallicRoughness.js +1 -1
- package/geometry/support/meshUtils/exporters/gltf/gltf.js +1 -1
- package/geometry/support/meshUtils/loadGLTFMesh.js +1 -1
- package/interfaces.d.ts +109 -37
- package/kernel.js +1 -1
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/sources/support/clientSideDefaults.js +1 -1
- package/layers/mixins/ArcGISImageService.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/mixins/RasterJobHandlerMixin.js +1 -1
- package/layers/ogc/wcsUtils.js +1 -1
- package/layers/raster/datasets/BaseRaster.js +5 -0
- package/layers/raster/datasets/CovJSONRaster.js +5 -0
- package/layers/raster/datasets/FunctionRaster.js +5 -0
- package/layers/raster/datasets/ImageAuxRaster.js +5 -0
- package/layers/raster/datasets/ImageServerRaster.js +5 -0
- package/layers/raster/datasets/InMemoryRaster.js +5 -0
- package/layers/raster/datasets/MRFRaster.js +5 -0
- package/layers/raster/datasets/RawBlockCache.js +5 -0
- package/layers/raster/datasets/TIFFRaster.js +5 -0
- package/layers/raster/datasets/WCSRaster.js +5 -0
- package/layers/raster/datasets/covJSONParser.js +5 -0
- package/layers/raster/datasets/multidimensionalUtils.js +5 -0
- package/layers/raster/datasets/pamParser.js +5 -0
- package/layers/raster/datasets/pixelReader.js +5 -0
- package/layers/raster/datasets/wcsCoverageParser.js +5 -0
- package/layers/raster/formats/Lerc.js +5 -0
- package/layers/raster/formats/Qb3.js +5 -0
- package/layers/raster/formats/RasterCodec.js +5 -0
- package/layers/raster/formats/TiffDecoder.js +5 -0
- package/layers/raster/functions/ArithmeticFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ArithmeticFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/AspectFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/AspectFunctionArguments.js +1 -1
- package/layers/raster/functions/BandArithmeticFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/BandArithmeticFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/BaseFunctionArguments.js +1 -1
- package/layers/raster/functions/BaseRasterFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ClipFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ClipFunctionArguments.js +1 -1
- package/layers/raster/functions/ColormapFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ColormapFunctionArguments.js +1 -1
- package/layers/raster/functions/ColormapToRGBFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ColormapToRGBFunctionArguments.js +1 -1
- package/layers/raster/functions/CompositeBandFunction.js +5 -0
- package/layers/raster/functions/CompositeBandFunctionArguments.js +5 -0
- package/layers/raster/functions/ComputeChangeFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ComputeChangeFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ContrastBrightnessFunctionArguments.js +1 -1
- package/layers/raster/functions/ConvolutionFunction.js +5 -0
- package/layers/raster/functions/ConvolutionFunctionArguments.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/CurvatureFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/ExtractBandFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/GrayscaleFunctionArguments.js +1 -1
- package/layers/raster/functions/HillshadeFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/HillshadeFunctionArguments.js +1 -1
- package/layers/raster/functions/LocalFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/LocalFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/MaskFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/MaskFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/NDVIFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/NDVIFunctionArguments.js +1 -1
- package/layers/raster/functions/RemapFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/RemapFunctionArguments.js +1 -1
- package/layers/raster/functions/ShadedReliefFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/ShadedReliefFunctionArguments.js +1 -1
- package/layers/raster/functions/SlopeFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/SlopeFunctionArguments.js +1 -1
- package/layers/raster/functions/StatisticsFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/StatisticsFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/StatisticsHistogramFunctionArguments.js +1 -1
- package/layers/raster/functions/StretchFunction.js +5 -0
- package/layers/{support/rasterFunctions → raster/functions}/StretchFunctionArguments.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/TableFunction.js +1 -1
- package/layers/{support/rasterFunctions → raster/functions}/TableFunctionArguments.js +1 -1
- package/layers/raster/functions/bandIndexUtils.js +5 -0
- package/layers/raster/functions/changeDetectionUtils.js +5 -0
- package/layers/raster/functions/clipUtils.js +5 -0
- package/layers/raster/functions/conversionUtils.js +5 -0
- package/layers/raster/functions/convolutionUtils.js +5 -0
- package/layers/raster/functions/creators/createDataManagementFunctions.js +5 -0
- package/layers/raster/functions/creators/utils.js +5 -0
- package/layers/raster/functions/focalStatUtils.js +5 -0
- package/layers/raster/functions/localUtils.js +5 -0
- package/layers/raster/functions/pixelTransformUtils.js +5 -0
- package/layers/raster/functions/pixelUtils.js +5 -0
- package/layers/raster/functions/stretchUtils.js +5 -0
- package/layers/raster/functions/surfaceUtils.js +5 -0
- package/layers/raster/functions/vectorFieldUtils.js +5 -0
- package/layers/raster/transforms/BaseRasterTransform.js +5 -0
- package/layers/{support/rasterTransforms → raster/transforms}/GCSShiftTransform.js +1 -1
- package/layers/{support/rasterTransforms → raster/transforms}/IdentityTransform.js +1 -1
- package/layers/{support/rasterTransforms → raster/transforms}/PolynomialTransform.js +1 -1
- package/layers/save/imageryUtils.js +1 -1
- package/layers/support/PixelBlock.js +1 -1
- package/layers/support/RasterWorker.js +1 -1
- package/layers/support/imageryRendererUtils.js +1 -1
- package/layers/support/rasterFunctionUtils.js +1 -1
- package/package.json +1 -1
- package/renderers/VectorFieldRenderer.js +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/renderers/support/rasterRendererHelper.js +1 -1
- package/rest/locator/addressToLocations.js +1 -1
- package/rest/locator/addressesToLocations.js +1 -1
- package/rest/locator/suggestLocations.js +1 -1
- package/rest/networks/support/Association.js +1 -1
- package/smartMapping/raster/support/adapters/ImageryLayerAdapter.js +1 -1
- package/smartMapping/raster/support/adapters/ImageryTileLayerAdapter.js +1 -1
- package/support/revision.js +1 -1
- package/views/2d/engine/imagery/RasterVFDisplayObject.js +1 -1
- package/views/2d/engine/webgl/cpuMapped/MappedMesh.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/RasterRangeHighlightShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/MaskShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/RemapShader.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/techniques/shaders/raster/processor/math.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
- package/views/2d/engine/webgl/textureUtils.js +1 -1
- package/views/2d/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldTileView2D.js +1 -1
- package/views/2d/layers/imagery/VectorFieldView2D.js +1 -1
- package/views/3d/glTF/LoaderResult.js +1 -1
- package/views/3d/glTF/internal/Resource.js +1 -1
- package/views/3d/glTF/loader.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/SceneLayerGraphicsView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DExtrudeSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DObjectSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/objectResourceUtils.js +1 -1
- package/views/3d/layers/i3s/I3SGraphicsMap.js +1 -1
- package/views/3d/layers/i3s/I3SIndex.js +1 -1
- package/views/3d/support/buffer/glUtil.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatFadeTexture.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatOrderTexture.js +1 -1
- package/views/3d/support/gaussianSplatting/GaussianSplatTextureAtlas.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentData.glsl.js +1 -1
- package/views/3d/webgl-engine/collections/Component/Material/ComponentTechniqueConfiguration.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/ShaderOutput.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/TextureBackedBuffer.glsl.js +10 -10
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/bufferLayouts.js +1 -1
- package/views/3d/webgl-engine/lib/edgeRendering/edgeProcessing.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultLayouts.js +1 -1
- package/views/3d/webgl-engine/materials/DefaultMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/DrawParameters.js +1 -1
- package/views/3d/webgl-engine/materials/HUDMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ImageMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/LineMarkerMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/NativeLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/PathTechnique.js +1 -1
- package/views/3d/webgl-engine/materials/PatternMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/RibbonLineMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/ShadedColorMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/WaterMaterial.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/Instance.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedBuffer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerOriginData.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/VaoWriter.js +1 -1
- package/views/3d/webgl-engine/shaders/DefaultMaterialTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/sources/edgeRenderer/EdgeUtil.glsl.js +9 -9
- package/views/DOMContainer.js +1 -1
- package/views/GroundView.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/layers/ImageryLayerViewMixin.js +1 -1
- package/views/layers/ImageryTileLayerViewMixin.js +1 -1
- package/views/support/imageReprojection.js +1 -1
- package/views/webgl/ShaderBuilder.js +1 -1
- package/views/webgl/Util.js +1 -1
- package/views/webgl/VertexElementDescriptor.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/BuildingExplorer/BuildingExplorerViewModel.js +1 -1
- package/widgets/CoordinateConversion/CoordinateConversionViewModel.js +1 -1
- package/widgets/CoordinateConversion.js +1 -1
- package/widgets/DirectLineMeasurement3D.js +1 -1
- package/widgets/DistanceMeasurement2D.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/ElevationProfile.js +1 -1
- package/widgets/Feature.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/Grid/GridViewModel.js +1 -1
- package/widgets/FeatureTable/support/GroupColumnTemplate.js +1 -1
- package/widgets/FeatureTable/support/TableTemplate.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend.js +1 -1
- package/widgets/LineOfSight.js +1 -1
- package/widgets/Locate.js +1 -1
- package/widgets/OrientedImageryViewer/galleryUtils.js +1 -1
- package/widgets/OrientedImageryViewer/services/DepthImageService.js +1 -1
- package/widgets/PanoramicViewer/support/importUtils.js +1 -1
- package/widgets/Print.js +1 -1
- package/widgets/ScaleBar.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Search/SearchResultRenderer.js +1 -1
- package/widgets/Search/SearchViewModel.js +1 -1
- package/widgets/Search/types.js +1 -1
- package/widgets/Search.js +1 -1
- package/widgets/ShadowCast.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/Sketch.js +1 -1
- package/widgets/VersionManagement/VersionManagementViewModel.js +1 -1
- package/assets/esri/core/workers/chunks/0a5427127634738aa239.js +0 -1
- package/assets/esri/core/workers/chunks/110429583b28c28c36ee.js +0 -1
- package/assets/esri/core/workers/chunks/145c6a7cdcc9893efb27.js +0 -1
- package/assets/esri/core/workers/chunks/1bacdd17e199e22b5cd1.js +0 -1
- package/assets/esri/core/workers/chunks/1d566539ff6fb6ac798c.js +0 -1
- package/assets/esri/core/workers/chunks/1f6ead46b723630db897.js +0 -1
- package/assets/esri/core/workers/chunks/3a16347e17312556e02c.js +0 -1
- package/assets/esri/core/workers/chunks/478def691ae6763686f3.js +0 -1
- package/assets/esri/core/workers/chunks/4c4a55be41ba105c091c.js +0 -1
- package/assets/esri/core/workers/chunks/4cbf5a97b2b3c6553f6f.js +0 -1
- package/assets/esri/core/workers/chunks/5dc0d853c21ccb6054c7.js +0 -1
- package/assets/esri/core/workers/chunks/613cbac9cb925cd20b48.js +0 -1
- package/assets/esri/core/workers/chunks/646f58b69d2354f1ef27.js +0 -1
- package/assets/esri/core/workers/chunks/800c91302eaad7f00877.js +0 -1
- package/assets/esri/core/workers/chunks/93d11075f65a5b6625ea.js +0 -1
- package/assets/esri/core/workers/chunks/9f2a8445a5848502c7e7.js +0 -1
- package/assets/esri/core/workers/chunks/a1b08aab73747f4e7e25.js +0 -1
- package/assets/esri/core/workers/chunks/ba59568e748f0ba53b78.js +0 -1
- package/assets/esri/core/workers/chunks/c4de24582c29fda5a033.js +0 -1
- package/assets/esri/core/workers/chunks/d786b17cc9062b1450ac.js +0 -1
- package/assets/esri/core/workers/chunks/d9958654c6438f28237b.js +0 -1
- package/assets/esri/core/workers/chunks/e6fa6f9c278589c8a713.js +0 -1
- package/assets/esri/core/workers/chunks/e7f4d135ef9665de1468.js +0 -1
- package/assets/esri/core/workers/chunks/f21cb5b34d4d1e3af1a9.js +0 -1
- package/assets/esri/core/workers/chunks/f93f0586ce10cb5d98b3.js +0 -1
- package/layers/support/rasterDatasets/BaseRaster.js +0 -5
- package/layers/support/rasterDatasets/CovJSONRaster.js +0 -5
- package/layers/support/rasterDatasets/FunctionRaster.js +0 -5
- package/layers/support/rasterDatasets/ImageAuxRaster.js +0 -5
- package/layers/support/rasterDatasets/ImageServerRaster.js +0 -5
- package/layers/support/rasterDatasets/InMemoryRaster.js +0 -5
- package/layers/support/rasterDatasets/MRFRaster.js +0 -5
- package/layers/support/rasterDatasets/RawBlockCache.js +0 -5
- package/layers/support/rasterDatasets/TIFFRaster.js +0 -5
- package/layers/support/rasterDatasets/WCSRaster.js +0 -5
- package/layers/support/rasterDatasets/covJSONParser.js +0 -5
- package/layers/support/rasterDatasets/multidimensionalUtils.js +0 -5
- package/layers/support/rasterDatasets/pamParser.js +0 -5
- package/layers/support/rasterDatasets/pixelReader.js +0 -5
- package/layers/support/rasterDatasets/wcsCoverageParser.js +0 -5
- package/layers/support/rasterFormats/Lerc.js +0 -5
- package/layers/support/rasterFormats/Qb3.js +0 -5
- package/layers/support/rasterFormats/RasterCodec.js +0 -5
- package/layers/support/rasterFormats/TiffDecoder.js +0 -5
- package/layers/support/rasterFunctions/ArithmeticFunction.js +0 -5
- package/layers/support/rasterFunctions/BandArithmeticFunction.js +0 -5
- package/layers/support/rasterFunctions/BaseRasterFunction.js +0 -5
- package/layers/support/rasterFunctions/ColormapFunction.js +0 -5
- package/layers/support/rasterFunctions/ColormapToRGBFunction.js +0 -5
- package/layers/support/rasterFunctions/CompositeBandFunction.js +0 -5
- package/layers/support/rasterFunctions/CompositeBandFunctionArguments.js +0 -5
- package/layers/support/rasterFunctions/ComputeChangeFunction.js +0 -5
- package/layers/support/rasterFunctions/ConvolutionFunction.js +0 -5
- package/layers/support/rasterFunctions/ConvolutionFunctionArguments.js +0 -5
- package/layers/support/rasterFunctions/HillshadeFunction.js +0 -5
- package/layers/support/rasterFunctions/LocalFunction.js +0 -5
- package/layers/support/rasterFunctions/RemapFunction.js +0 -5
- package/layers/support/rasterFunctions/ShadedReliefFunction.js +0 -5
- package/layers/support/rasterFunctions/SlopeFunction.js +0 -5
- package/layers/support/rasterFunctions/StatisticsFunction.js +0 -5
- package/layers/support/rasterFunctions/StretchFunction.js +0 -5
- package/layers/support/rasterFunctions/bandIndexUtils.js +0 -5
- package/layers/support/rasterFunctions/changeDetectionUtils.js +0 -5
- package/layers/support/rasterFunctions/clipUtils.js +0 -5
- package/layers/support/rasterFunctions/conversionUtils.js +0 -5
- package/layers/support/rasterFunctions/convolutionUtils.js +0 -5
- package/layers/support/rasterFunctions/creators/createDataManagementFunctions.js +0 -5
- package/layers/support/rasterFunctions/creators/utils.js +0 -5
- package/layers/support/rasterFunctions/focalStatUtils.js +0 -5
- package/layers/support/rasterFunctions/localUtils.js +0 -5
- package/layers/support/rasterFunctions/pixelTransformUtils.js +0 -5
- package/layers/support/rasterFunctions/pixelUtils.js +0 -5
- package/layers/support/rasterFunctions/stretchUtils.js +0 -5
- package/layers/support/rasterFunctions/surfaceUtils.js +0 -5
- package/layers/support/rasterFunctions/vectorFieldUtils.js +0 -5
- package/layers/support/rasterTransforms/BaseRasterTransform.js +0 -5
- /package/assets/esri/layers/{support/rasterFormats → raster/formats}/lerc-wasm.wasm +0 -0
- /package/assets/esri/layers/{support/rasterFormats → raster/formats}/qb3-wasm.wasm +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/DBFParser.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/EphemeralBlockCache.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/RasterFactory.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/byteStreamUtils.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/datasetUtils.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/multipartParser.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/wcsCapabilitiesParser.js +0 -0
- /package/layers/{support/rasterDatasets → raster/datasets}/xmlUtilities.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/ImageCanvasDecoder.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/JpgPlus.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/Lzw.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/Raw.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/pixelRangeUtils.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/tiffTag.js +0 -0
- /package/layers/{support/rasterFormats → raster/formats}/utils.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/colormaps.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createAppearenceFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createBandIndexFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createChangeFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createConversionFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createLocalFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createMultiRasterAnalysisFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createStatisticsFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/creators/createSurfaceFunctions.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/customBandIndexUtils.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/mirror.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionHelper.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/rasterFunctionSchema.js +0 -0
- /package/layers/{support/rasterFunctions → raster/functions}/rasterProjectionHelper.js +0 -0
- /package/layers/{support/rasterTransforms → raster/transforms}/utils.js +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import t from"../../request.js";import i from"../../core/Error.js";import r from"../../core/Logger.js";import{property as s,subclass as n}from"../../core/accessorSupport/decorators.js";import{Integer as o,ensureClass as a}from"../../core/accessorSupport/ensureType.js";import l from"../../geometry/Point.js";import u from"../../geometry/SpatialReference.js";import{getInfo as m}from"../../geometry/support/spatialReferenceUtils.js";import{sanitizeUrl as c}from"../support/arcgisLayerUrl.js";import{url as p}from"../support/commonProperties.js";import d from"../support/DimensionalDefinition.js";import h from"../support/MultidimensionalSubset.js";import{interpolationKebab as f}from"../support/rasterEnums.js";import y from"../support/RasterFunction.js";import g from"../support/TileInfo.js";import{isFunctionRaster as b}from"../support/rasterDatasets/datasetUtils.js";import R from"../support/rasterDatasets/FunctionRaster.js";import{getEffectiveMultidimensionalDefinition as I,getDefaultVariableInfo as x,isMultiSliceOrRangeDefinition as w,convertOleDateTimeToEpoch as S,getSubsetVariablesFromMdInfo as v,getDefaultMultidimensionalDefinition as F}from"../support/rasterDatasets/multidimensionalUtils.js";import{snapToRaster as _,clip as j}from"../support/rasterFunctions/clipUtils.js";import{create as D}from"../support/rasterFunctions/rasterFunctionHelper.js";import{load as J,projectExtent as T,projectPolygon as N}from"../support/rasterFunctions/rasterProjectionHelper.js";import{computeStatisticsHistograms as O}from"../support/rasterFunctions/stretchUtils.js";import{getVariableRasterInfo as z,getDefaultInterpolation as H,matchPresetRenderer as P,getDefaultBandCombination as E,getFunctionColorRamp as C,createDefaultRenderer as B,normalizeRendererJSON as M}from"../../renderers/support/rasterRendererHelper.js";import U from"../../renderers/support/RasterSymbolizer.js";import{rasterRendererTypes as q,websceneRasterRendererTypes as k,read as L}from"../../renderers/support/rasterTypeUtils.js";import A from"../../rest/support/ImageHistogramParameters.js";import V from"../../rest/support/ImageSample.js";import $ from"../../rest/support/ImageSampleParameters.js";import G from"../../rest/support/ImageSampleResult.js";import{enumeration as W}from"../../core/accessorSupport/decorators/enumeration.js";import{reader as K}from"../../core/accessorSupport/decorators/reader.js";const Q=1e3,X=X=>{const Y=X;let Z=class extends Y{constructor(...e){super(...e),this._isConstructedFromFunctionRaster=!1,this.bandIds=null,this.copyright=null,this.interpolation=null,this.multidimensionalSubset=null,this.raster=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster=b(e[0]?.raster)}destroy(){this._shutdownJobHandler()}get fullExtent(){return this.serviceRasterInfo?.extent}set multidimensionalDefinition(e){this._set("multidimensionalDefinition",e),this.updateRenderer()}set rasterFunction(e){"none"===e?.functionName?.toLowerCase()&&(e=void 0),this._set("rasterFunction",e),this.updateRasterFunction()}set url(e){this._set("url",c(e,r.getLogger(this)))}get renderer(){if("imagery-tile"!==this.type)return this.internalRenderer;const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const i=t?.find(({name:t})=>t===e);return i?.renderer.clone()}return this.internalRenderer}set renderer(e){"imagery-tile"===this.type&&(this.activePresetRendererName=null),this.internalRenderer=e}set internalRenderer(e){null==e&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("internalRenderer",e),this.updateRenderer())}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer;return L(r,i)||void 0}async computeStatisticsHistograms(e,t){await this.load(t),e=a(A,e).clone();const{serviceRasterInfo:r}=this;if(null==r)throw new i("imagery-tile-mixin:compute-statistics-histograms","serviceRasterInfo must be specified");const{geometry:s}=e;if(null==s)throw new i("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let n=s;const{spatialReference:o}=r;if(!s.spatialReference.equals(o)){await J();const e="extent"===s.type?T(s,o):N(s,o);if(null==e)throw new i("imagery-tile-mixin:compute-statistics-histograms","geometry cannot be projected to the data source");n=e}const u=e.pixelSize??new l({x:r.pixelSize.x,y:r.pixelSize.y,spatialReference:o}),{extent:m,width:c,height:p}=_(r,n,u),d=await this.fetchPixels(m,c,p,{...t,interpolation:"nearest"});if(null==d.pixelBlock)throw new i("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const h=await j(d.pixelBlock,m,n),f=this._rasterJobHandler;return f?f.computeStatisticsHistograms({pixelBlock:h},t):O(h)}normalizeRasterFetchOptions(e){const{multidimensionalInfo:t}=this.serviceRasterInfo??{};if(null==t)return e;const i=I({rasterInfo:this.raster.rasterInfo,multidimensionalDefinition:e.multidimensionalDefinition||this.multidimensionalDefinition,timeExtent:e.timeExtent??this.timeExtent,multidimensionalSubset:this.multidimensionalSubset});return{...e,multidimensionalDefinition:i,timeExtent:void 0}}async updateRasterFunction(){return this.loaded&&"imagery-tile"===this.type&&(this.rasterFunction||this._cachedRasterFunctionJson)&&JSON.stringify(this.rasterFunction)!==JSON.stringify(this._cachedRasterFunctionJson)?(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this._rasterFunctionUpdatePromise=this._updateRasterFunction(),this._rasterFunctionUpdatePromise):this._rasterFunctionUpdatePromise}async updateRenderer(){const{loaded:e,symbolizer:t,renderer:i}=this;if(!e||!t||!i)return;const{rasterInfo:r}=this.raster,s=x(r,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=s?.name,o=z(r,n);return this._updateSymbolizer(t,i,n,o)}async applyRenderer(e,t,i){const r=e?.pixelBlock;if(!(null!=r&&r.pixels&&r.pixels.length>0))return null;await this.updateRenderer();const s=this.bandIds??[],{pixelBlock:n}=await this._symbolize({pixelData:e,simpleStretchParams:t,bandIds:s,symbolizer:this.symbolizer},i);return n}getRawDisplayBandIds(){let{bandIds:e,raster:t}=this;if(this.rasterFunction&&b(t)){const i=t.rasterFunction.rawInputBandIds;e=e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map(e=>i[Math.min(e,i.length-1)]):i}return e&&e.length>3&&e.every((e,t)=>e===t)?null:e}getTileUrl(e,t,i){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${e}/${t}/${i}`:""}getCompatibleTileInfo(e,t,i=!1){if(!this.loaded||null==t)return null;if(i&&e.equals(this.spatialReference))return this.tileInfo;const r=m(e);return g.create({size:256,spatialReference:e,origin:r?{x:r.origin[0],y:r.origin[1]}:{x:t.xmin,y:t.ymax}})}getCompatibleFullExtent(e){return this.loaded?(this._compatibleFullExtent?.spatialReference.equals(e)||(this._compatibleFullExtent=this.raster.computeExtent(e)),this._compatibleFullExtent):null}async fetchTile(e,i,r,s={}){if(ee(this),s.requestAsImageElement){const n=this.getTileUrl(e,i,r);return t(n,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:s.signal}).then(e=>e.data)}const{serviceRasterInfo:n}=this;if(null!=n.multidimensionalInfo&&null==(s=this.normalizeRasterFetchOptions(s)).multidimensionalDefinition){const t=s.tileInfo||n.storageInfo.tileInfo,o=this.raster.getTileExtentFromTileInfo(e,i,r,t);if(o)return{extent:o,pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer?.type&&(s={...s,buffer:{cols:1,rows:1}}),this.raster.fetchTile(e,i,r,s)}async fetchPixels(e,t,i,r={}){if(null!=this.serviceRasterInfo.multidimensionalInfo&&null==(r=this.normalizeRasterFetchOptions(r)).multidimensionalDefinition)return{extent:e,pixelBlock:null};await this._initJobHandler(),await this.updateRasterFunction(),t=Math.round(t),i=Math.round(i);const s=await this.raster.fetchPixels(e,t,i,r);return r.bandIds?.length&&!this.raster.rasterInfo.storageInfo.isBsqTile&&(s.pixelBlock=s.pixelBlock?.extractBands(r.bandIds)),s}async getSamples(e,t){if(await this.load(),(e=a($,e).clone()).interpolation&&"nearest"!==e.interpolation)throw new i("imagery-tile-mixin:get-samples","only nearest interpolation is currently supported");const r=e.mosaicRule?.multidimensionalDefinition,s={...t,multidimensionalDefinition:r},n=(await this._getSampleLocations(e)).map(e=>this.identify(e,s).then(t=>(t.location=e,t))),o=(await Promise.all(n)).flatMap((e,t)=>this._convertRasterIdentifyResultToSample(e,t));return new G({samples:o})}async identify(e,t={}){await this.load(),e=a(l,e).clone().normalize();const{raster:r,serviceRasterInfo:s}=this;if(null!=s?.multidimensionalInfo){if(!(s.hasMultidimensionalTranspose&&!(!w(t.multidimensionalDefinition)&&!t.transposedVariableName))&&null==(t=this.normalizeRasterFetchOptions(t)).multidimensionalDefinition)return{location:e,value:null}}const n=this.multidimensionalSubset?.areaOfInterest;if(n&&!n.contains(e))throw new i("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");let o;if(this.serviceRasterInfo?.storageInfo.isBsqTile){const e=b(r)?this.getRawDisplayBandIds():this.bandIds;o=e?.length?e:void 0}return r.identify(e,{...t,bandIds:o})}hasStandardTime(){const e=this.serviceRasterInfo?.multidimensionalInfo;if(null==e||"standard-time"!==this.serviceRasterInfo?.dataType)return!1;const t=this.multidimensionalDefinition,i=t?.[0]?.variableName;return e.variables.some(e=>e.name===i&&(!t?.[0].dimensionName||e.dimensions.some(e=>"StdTime"===e.name)))}getStandardTimeValue(e){return new Date(S(e)).toISOString()}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo?.multidimensionalInfo;return v(this.multidimensionalSubset,t)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=F(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this.rasterFunction&&b(this.raster)&&(this._cachedRasterFunctionJson=this.rasterFunction.toJSON()),this._configDefaultRenderer()}async _initJobHandler(){if(!this._rasterJobHandler)return super._initJobHandler().then(async()=>{if(!this._rasterJobHandler)return;ee(this);const{raster:e}=this;e.rasterJobHandler=this._rasterJobHandler,b(e)&&e.syncJobHandler(),this.rasterFunction&&await this.updateRasterFunction().catch(()=>{}),this.renderer&&this.updateRenderer()}).catch(()=>{})}_shutdownJobHandler(){super._shutdownJobHandler(),this.raster&&(this.raster.rasterJobHandler=null)}async _getSampleLocations(e){const{geometry:t}=e;if("point"===t.type)return[t];const{spatialReference:i,type:r}=t;if("multipoint"===r)return t.points.map(e=>new l({x:e[0],y:e[1],spatialReference:i}));if("polyline"===r){let r=t;if(e.sampleCount||e.sampleDistance){const i=await import("../../geometry/operators/densifyOperator.js"),s=(await import("../../geometry/operators/lengthOperator.js")).execute(t,{unit:"meters"}),n=Math.min(e.sampleCount||100,Q);let o=e.sampleDistance;if(!o){o=s/(n+(2===r.paths[0].length?1:0))}r=i.execute(t,o,{unit:"meters"})}return r.paths.flatMap(e=>e.map(e=>new l({x:e[0],y:e[1],spatialReference:i})))}const s=Math.min(e.sampleCount||100,Q),n="extent"===t.type,o=n?t:t.extent,a=Math.sqrt(o.width*o.height/s),u=o.height/a,m=o.width/a,{xmin:c,ymax:p}=o,d=[];for(let h=0;h<u;h++)for(let e=0;e<m;e++){const r=new l({x:c+(e+.5)*a,y:p-(h+.5)*a,spatialReference:i});(n||t.contains(r))&&d.push(r)}return d}_configDefaultInterpolation(){if(null==this.interpolation){ee(this);const{raster:e}=this,t=H(e.rasterInfo,e.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultRenderer(e="no"){ee(this);const{rasterInfo:t}=this.raster,i=x(t,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),s=i?.name,n=P({variableName:s,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&t.bandCount>1&&(this.bandIds=n?.bandIds??E(t)),!this.renderer||"override"===e){const e=C(this.raster),i=n?.renderer??B(t,{bandIds:this.bandIds,variableName:s,rasterFunctionColorRamp:e}),r=t.statistics,o=r&&r.length>0?r[0]:null,a=o?.max??0,l=o?.min??0;"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===i.type&&(a>1e24||l<-1e24)&&(i.dynamicRangeAdjustment=!0,i.customStatistics=null,"none"===i.stretchType&&(i.stretchType="min-max")),this.renderer=i}const o=M({...this.renderer.toJSON(),variableName:s}),a=z(t,s);this.symbolizer?(this.symbolizer.rendererJSON=o,this.symbolizer.rasterInfo=a):this.symbolizer=new U({rendererJSON:o,rasterInfo:a});const l=this.symbolizer.bind();if(l.success){if("auto"===e){const{colormap:e}=this.raster.rasterInfo,t=this.renderer;if(null!=e&&"raster-colormap"===t.type){const e=B(this.raster.rasterInfo);JSON.stringify(e)!==JSON.stringify(t)&&this._configDefaultRenderer("override")}else if("raster-stretch"===t.type){const e=this.bandIds?.length,i=t.customStatistics?.length;!t.dynamicRangeAdjustment&&i&&e&&i!==e&&this._configDefaultRenderer("override")}}}else r.getLogger(this).warn("imagery-tile-mixin",l.error||"The given renderer is not supported by the layer."),"auto"===e&&this._configDefaultRenderer("override")}async _updateRasterFunction(){if(this._isConstructedFromFunctionRaster&&b(this.raster)){const e=this.raster.rasterFunction.toJSON();return void(!this.rasterFunction&&e&&this._set("rasterFunction",y.fromJSON(e)))}let e,t=this.raster,i=!1;b(t)?(e=t.primaryRasters.rasters,t=e[0],i=!0):e=[t];const{rasterFunction:r}=this;if(r){const i={raster:t};e.length>1&&e.forEach(e=>i[e.url]=e);const s=D(r.functionDefinition?.toJSON()??r.toJSON(),i),n=new R({rasterFunction:s});n.rasterJobHandler=this._rasterJobHandler,await n.open(),this.raster=n}else this.raster=t,await t.open();if(this._cachedRendererJson=void 0,!i&&!r)return;const{bandIds:s}=this,{bandCount:n}=this.raster.rasterInfo,o=s?.length?s.some(e=>e>=n):n>=3;s&&(o||this.renderer&&"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}_convertRasterIdentifyResultToSample(e,t){const{rasterInfo:i}=this.raster,r=i.storageInfo.pyramidScalingFactor**(e.pyramidLevel??0),s=(i.pixelSize.x+i.pixelSize.y)/2*r;if(!e.dataSeries?.length)return[new V({location:e.location,pixelValue:e.value,locationId:t,resolution:s})];const n=[];return e.dataSeries.forEach(({value:i,multidimensionalDefinition:r},o)=>{const a={Variables:r[0].variableName,Dimensions:r.flatMap(({dimensionName:e})=>e).join(",")};for(const{dimensionName:e,values:t}of r){a[e]=Array.isArray(t[0])?t[0][0]:t[0];const i=t[t.length-1];a[`${e}_Max`]=Array.isArray(i)?i[i.length-1]:i}const l=new V({location:e.location,pixelValue:i,rasterId:o,locationId:t,resolution:s,attributes:a});n.push(l)}),n}};function ee(e){if(!e.raster||!e.serviceRasterInfo)throw new i("imagery-tile","no raster")}return e([s({clonable:!1})],Z.prototype,"_cachedRasterFunctionJson",void 0),e([s({clonable:!1})],Z.prototype,"_compatibleFullExtent",void 0),e([s({clonable:!1})],Z.prototype,"_isConstructedFromFunctionRaster",void 0),e([s({clonable:!1})],Z.prototype,"_rasterFunctionUpdatePromise",void 0),e([s({type:[o],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],Z.prototype,"bandIds",void 0),e([s({json:{origins:{service:{read:{source:"copyrightText"}}}}})],Z.prototype,"copyright",void 0),e([s({json:{read:!1}})],Z.prototype,"fullExtent",null),e([s({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),W(f)],Z.prototype,"interpolation",void 0),e([s()],Z.prototype,"ioConfig",void 0),e([s({type:[d],json:{write:!0}})],Z.prototype,"multidimensionalDefinition",null),e([s({type:h,json:{write:!0}})],Z.prototype,"multidimensionalSubset",void 0),e([s()],Z.prototype,"raster",void 0),e([s({type:y})],Z.prototype,"rasterFunction",null),e([s()],Z.prototype,"serviceRasterInfo",void 0),e([s()],Z.prototype,"sourceJSON",void 0),e([s({readOnly:!0,type:u,json:{read:!1}})],Z.prototype,"spatialReference",void 0),e([s({type:g})],Z.prototype,"tileInfo",void 0),e([s(p)],Z.prototype,"url",null),e([s({types:q})],Z.prototype,"renderer",null),e([s({types:q,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(){const e="raster-stretch"===this.renderer?.type&&"none"===this.renderer.stretchType&&!this.renderer.useGamma;return{enabled:!this.loaded||"Raster"===this.raster.tileType||!e}}},origins:{"web-scene":{types:k,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],Z.prototype,"internalRenderer",null),e([K("internalRenderer")],Z.prototype,"readRenderer",null),e([s({clonable:!1})],Z.prototype,"symbolizer",void 0),Z=e([n("esri.layers.mixins.ImageryTileMixin")],Z),Z};export{X as ImageryTileMixin};
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../request.js";import i from"../../core/Error.js";import r from"../../core/Logger.js";import{property as s,subclass as n}from"../../core/accessorSupport/decorators.js";import{Integer as o,ensureClass as a}from"../../core/accessorSupport/ensureType.js";import l from"../../geometry/Point.js";import m from"../../geometry/SpatialReference.js";import{getInfo as u}from"../../geometry/support/spatialReferenceUtils.js";import{isFunctionRaster as c}from"../raster/datasets/datasetUtils.js";import d from"../raster/datasets/FunctionRaster.js";import{getEffectiveMultidimensionalDefinition as p,getDefaultVariableInfo as h,isMultiSliceOrRangeDefinition as f,convertOleDateTimeToEpoch as y,getSubsetVariablesFromMdInfo as g,getDefaultMultidimensionalDefinition as b}from"../raster/datasets/multidimensionalUtils.js";import{snapToRaster as R,clip as I}from"../raster/functions/clipUtils.js";import{create as x}from"../raster/functions/rasterFunctionHelper.js";import{load as w,projectExtent as S,projectPolygon as v}from"../raster/functions/rasterProjectionHelper.js";import{computeStatisticsHistograms as F}from"../raster/functions/stretchUtils.js";import{sanitizeUrl as _}from"../support/arcgisLayerUrl.js";import{url as j}from"../support/commonProperties.js";import D from"../support/DimensionalDefinition.js";import J from"../support/MultidimensionalSubset.js";import{interpolationKebab as T}from"../support/rasterEnums.js";import N from"../support/RasterFunction.js";import O from"../support/TileInfo.js";import{getVariableRasterInfo as z,getDefaultInterpolation as H,matchPresetRenderer as P,getDefaultBandCombination as E,getFunctionColorRamp as C,createDefaultRenderer as B,normalizeRendererJSON as M}from"../../renderers/support/rasterRendererHelper.js";import U from"../../renderers/support/RasterSymbolizer.js";import{rasterRendererTypes as q,websceneRasterRendererTypes as k,read as L}from"../../renderers/support/rasterTypeUtils.js";import A from"../../rest/support/ImageHistogramParameters.js";import V from"../../rest/support/ImageSample.js";import $ from"../../rest/support/ImageSampleParameters.js";import G from"../../rest/support/ImageSampleResult.js";import{enumeration as W}from"../../core/accessorSupport/decorators/enumeration.js";import{reader as K}from"../../core/accessorSupport/decorators/reader.js";const Q=1e3,X=X=>{const Y=X;let Z=class extends Y{constructor(...e){super(...e),this._isConstructedFromFunctionRaster=!1,this.bandIds=null,this.copyright=null,this.interpolation=null,this.multidimensionalSubset=null,this.raster=null,this.serviceRasterInfo=null,this.sourceJSON=null,this.spatialReference=null,this.symbolizer=null,this._isConstructedFromFunctionRaster=c(e[0]?.raster)}destroy(){this._shutdownJobHandler()}get fullExtent(){return this.serviceRasterInfo?.extent}set multidimensionalDefinition(e){this._set("multidimensionalDefinition",e),this.updateRenderer()}set rasterFunction(e){"none"===e?.functionName?.toLowerCase()&&(e=void 0),this._set("rasterFunction",e),this.updateRasterFunction()}set url(e){this._set("url",_(e,r.getLogger(this)))}get renderer(){if("imagery-tile"!==this.type)return this.internalRenderer;const{activePresetRendererName:e,presetRenderers:t}=this;if(e){const i=t?.find(({name:t})=>t===e);return i?.renderer.clone()}return this.internalRenderer}set renderer(e){"imagery-tile"===this.type&&(this.activePresetRendererName=null),this.internalRenderer=e}set internalRenderer(e){null==e&&null==this.rasterFunction?this._configDefaultRenderer("override"):(this._set("internalRenderer",e),this.updateRenderer())}readRenderer(e,t,i){const r=t?.layerDefinition?.drawingInfo?.renderer;return L(r,i)||void 0}async computeStatisticsHistograms(e,t){await this.load(t),e=a(A,e).clone();const{serviceRasterInfo:r}=this;if(null==r)throw new i("imagery-tile-mixin:compute-statistics-histograms","serviceRasterInfo must be specified");const{geometry:s}=e;if(null==s)throw new i("imagery-tile-mixin:compute-statistics-histograms","geometry must be specified");let n=s;const{spatialReference:o}=r;if(!s.spatialReference.equals(o)){await w();const e="extent"===s.type?S(s,o):v(s,o);if(null==e)throw new i("imagery-tile-mixin:compute-statistics-histograms","geometry cannot be projected to the data source");n=e}const m=e.pixelSize??new l({x:r.pixelSize.x,y:r.pixelSize.y,spatialReference:o}),{extent:u,width:c,height:d}=R(r,n,m),p=await this.fetchPixels(u,c,d,{...t,interpolation:"nearest"});if(null==p.pixelBlock)throw new i("imagery-tile-mixin:compute-statistics-histograms","failed to fetch pixels");const h=await I(p.pixelBlock,u,n),f=this._rasterJobHandler;return f?f.computeStatisticsHistograms({pixelBlock:h},t):F(h)}normalizeRasterFetchOptions(e){const{multidimensionalInfo:t}=this.serviceRasterInfo??{};if(null==t)return e;const i=p({rasterInfo:this.raster.rasterInfo,multidimensionalDefinition:e.multidimensionalDefinition||this.multidimensionalDefinition,timeExtent:e.timeExtent??this.timeExtent,multidimensionalSubset:this.multidimensionalSubset});return{...e,multidimensionalDefinition:i,timeExtent:void 0}}async updateRasterFunction(){return this.loaded&&"imagery-tile"===this.type&&(this.rasterFunction||this._cachedRasterFunctionJson)&&JSON.stringify(this.rasterFunction)!==JSON.stringify(this._cachedRasterFunctionJson)?(this._cachedRasterFunctionJson=this.rasterFunction?.toJSON(),this._rasterFunctionUpdatePromise=this._updateRasterFunction(),this._rasterFunctionUpdatePromise):this._rasterFunctionUpdatePromise}async updateRenderer(){const{loaded:e,symbolizer:t,renderer:i}=this;if(!e||!t||!i)return;const{rasterInfo:r}=this.raster,s=h(r,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),n=s?.name,o=z(r,n);return this._updateSymbolizer(t,i,n,o)}async applyRenderer(e,t,i){const r=e?.pixelBlock;if(!(null!=r&&r.pixels&&r.pixels.length>0))return null;await this.updateRenderer();const s=this.bandIds??[],{pixelBlock:n}=await this._symbolize({pixelData:e,simpleStretchParams:t,bandIds:s,symbolizer:this.symbolizer},i);return n}getRawDisplayBandIds(){let{bandIds:e,raster:t}=this;if(this.rasterFunction&&c(t)){const i=t.rasterFunction.rawInputBandIds;e=e?.length&&i?.length&&1!==t.rasterInfo.bandCount?e.map(e=>i[Math.min(e,i.length-1)]):i}return e&&e.length>3&&e.every((e,t)=>e===t)?null:e}getTileUrl(e,t,i){return"RasterTileServer"===this.raster.datasetFormat?`${this.url}/tile/${e}/${t}/${i}`:""}getCompatibleTileInfo(e,t,i=!1){if(!this.loaded||null==t)return null;if(i&&e.equals(this.spatialReference))return this.tileInfo;const r=u(e);return O.create({size:256,spatialReference:e,origin:r?{x:r.origin[0],y:r.origin[1]}:{x:t.xmin,y:t.ymax}})}getCompatibleFullExtent(e){return this.loaded?(this._compatibleFullExtent?.spatialReference.equals(e)||(this._compatibleFullExtent=this.raster.computeExtent(e)),this._compatibleFullExtent):null}async fetchTile(e,i,r,s={}){if(ee(this),s.requestAsImageElement){const n=this.getTileUrl(e,i,r);return t(n,{responseType:"image",query:{...this.refreshParameters,...this.raster.ioConfig.customFetchParameters},signal:s.signal}).then(e=>e.data)}const{serviceRasterInfo:n}=this;if(null!=n.multidimensionalInfo&&null==(s=this.normalizeRasterFetchOptions(s)).multidimensionalDefinition){const t=s.tileInfo||n.storageInfo.tileInfo,o=this.raster.getTileExtentFromTileInfo(e,i,r,t);if(o)return{extent:o,pixelBlock:null}}return await this._initJobHandler(),await this.updateRasterFunction(),"raster-shaded-relief"===this.renderer?.type&&(s={...s,buffer:{cols:1,rows:1}}),this.raster.fetchTile(e,i,r,s)}async fetchPixels(e,t,i,r={}){if(null!=this.serviceRasterInfo.multidimensionalInfo&&null==(r=this.normalizeRasterFetchOptions(r)).multidimensionalDefinition)return{extent:e,pixelBlock:null};await this._initJobHandler(),await this.updateRasterFunction(),t=Math.round(t),i=Math.round(i);const s=await this.raster.fetchPixels(e,t,i,r);return r.bandIds?.length&&!this.raster.rasterInfo.storageInfo.isBsqTile&&(s.pixelBlock=s.pixelBlock?.extractBands(r.bandIds)),s}async getSamples(e,t){if(await this.load(),(e=a($,e).clone()).interpolation&&"nearest"!==e.interpolation)throw new i("imagery-tile-mixin:get-samples","only nearest interpolation is currently supported");const r=e.mosaicRule?.multidimensionalDefinition,s={...t,multidimensionalDefinition:r},n=(await this._getSampleLocations(e)).map(e=>this.identify(e,s).then(t=>(t.location=e,t))),o=(await Promise.all(n)).flatMap((e,t)=>this._convertRasterIdentifyResultToSample(e,t));return new G({samples:o})}async identify(e,t={}){await this.load(),e=a(l,e).clone().normalize();const{raster:r,serviceRasterInfo:s}=this;if(null!=s?.multidimensionalInfo){if(!(s.hasMultidimensionalTranspose&&!(!f(t.multidimensionalDefinition)&&!t.transposedVariableName))&&null==(t=this.normalizeRasterFetchOptions(t)).multidimensionalDefinition)return{location:e,value:null}}const n=this.multidimensionalSubset?.areaOfInterest;if(n&&!n.contains(e))throw new i("imagery-tile-mixin:identify","the request cannot be fulfilled when falling outside of the multidimensional subset");let o;if(this.serviceRasterInfo?.storageInfo.isBsqTile){const e=c(r)?this.getRawDisplayBandIds():this.bandIds;o=e?.length?e:void 0}return r.identify(e,{...t,bandIds:o})}hasStandardTime(){const e=this.serviceRasterInfo?.multidimensionalInfo;if(null==e||"standard-time"!==this.serviceRasterInfo?.dataType)return!1;const t=this.multidimensionalDefinition,i=t?.[0]?.variableName;return e.variables.some(e=>e.name===i&&(!t?.[0].dimensionName||e.dimensions.some(e=>"StdTime"===e.name)))}getStandardTimeValue(e){return new Date(y(e)).toISOString()}getMultidimensionalSubsetVariables(e){const t=e??this.serviceRasterInfo?.multidimensionalInfo;return g(this.multidimensionalSubset,t)}_configDefaultSettings(){this._configDefaultInterpolation(),this.multidimensionalDefinition||(this.multidimensionalDefinition=b(this.raster.rasterInfo,{multidimensionalSubset:this.multidimensionalSubset})),this.rasterFunction&&c(this.raster)&&(this._cachedRasterFunctionJson=this.rasterFunction.toJSON()),this._configDefaultRenderer()}async _initJobHandler(){if(!this._rasterJobHandler)return super._initJobHandler().then(async()=>{if(!this._rasterJobHandler)return;ee(this);const{raster:e}=this;e.rasterJobHandler=this._rasterJobHandler,c(e)&&e.syncJobHandler(),this.rasterFunction&&await this.updateRasterFunction().catch(()=>{}),this.renderer&&this.updateRenderer()}).catch(()=>{})}_shutdownJobHandler(){super._shutdownJobHandler(),this.raster&&(this.raster.rasterJobHandler=null)}async _getSampleLocations(e){const{geometry:t}=e;if("point"===t.type)return[t];const{spatialReference:i,type:r}=t;if("multipoint"===r)return t.points.map(e=>new l({x:e[0],y:e[1],spatialReference:i}));if("polyline"===r){let r=t;if(e.sampleCount||e.sampleDistance){const i=await import("../../geometry/operators/densifyOperator.js"),s=(await import("../../geometry/operators/lengthOperator.js")).execute(t,{unit:"meters"}),n=Math.min(e.sampleCount||100,Q);let o=e.sampleDistance;if(!o){o=s/(n+(2===r.paths[0].length?1:0))}r=i.execute(t,o,{unit:"meters"})}return r.paths.flatMap(e=>e.map(e=>new l({x:e[0],y:e[1],spatialReference:i})))}const s=Math.min(e.sampleCount||100,Q),n="extent"===t.type,o=n?t:t.extent,a=Math.sqrt(o.width*o.height/s),m=o.height/a,u=o.width/a,{xmin:c,ymax:d}=o,p=[];for(let h=0;h<m;h++)for(let e=0;e<u;e++){const r=new l({x:c+(e+.5)*a,y:d-(h+.5)*a,spatialReference:i});(n||t.contains(r))&&p.push(r)}return p}_configDefaultInterpolation(){if(null==this.interpolation){ee(this);const{raster:e}=this,t=H(e.rasterInfo,e.tileType,this.sourceJSON?.defaultResamplingMethod);this._set("interpolation",t)}}_configDefaultRenderer(e="no"){ee(this);const{rasterInfo:t}=this.raster,i=h(t,{multidimensionalDefinition:this.multidimensionalDefinition,multidimensionalSubset:this.multidimensionalSubset}),s=i?.name,n=P({variableName:s,rasterFunctionName:this.rasterFunction?.functionName,presetRenderers:this.presetRenderers});if(!this.bandIds&&t.bandCount>1&&(this.bandIds=n?.bandIds??E(t)),!this.renderer||"override"===e){const e=C(this.raster),i=n?.renderer??B(t,{bandIds:this.bandIds,variableName:s,rasterFunctionColorRamp:e}),r=t.statistics,o=r&&r.length>0?r[0]:null,a=o?.max??0,l=o?.min??0;"WCSServer"===this.raster.datasetFormat&&"raster-stretch"===i.type&&(a>1e24||l<-1e24)&&(i.dynamicRangeAdjustment=!0,i.customStatistics=null,"none"===i.stretchType&&(i.stretchType="min-max")),this.renderer=i}const o=M({...this.renderer.toJSON(),variableName:s}),a=z(t,s);this.symbolizer?(this.symbolizer.rendererJSON=o,this.symbolizer.rasterInfo=a):this.symbolizer=new U({rendererJSON:o,rasterInfo:a});const l=this.symbolizer.bind();if(l.success){if("auto"===e){const{colormap:e}=this.raster.rasterInfo,t=this.renderer;if(null!=e&&"raster-colormap"===t.type){const e=B(this.raster.rasterInfo);JSON.stringify(e)!==JSON.stringify(t)&&this._configDefaultRenderer("override")}else if("raster-stretch"===t.type){const e=this.bandIds?.length,i=t.customStatistics?.length;!t.dynamicRangeAdjustment&&i&&e&&i!==e&&this._configDefaultRenderer("override")}}}else r.getLogger(this).warn("imagery-tile-mixin",l.error||"The given renderer is not supported by the layer."),"auto"===e&&this._configDefaultRenderer("override")}async _updateRasterFunction(){if(this._isConstructedFromFunctionRaster&&c(this.raster)){const e=this.raster.rasterFunction.toJSON();return void(!this.rasterFunction&&e&&this._set("rasterFunction",N.fromJSON(e)))}let e,t=this.raster,i=!1;c(t)?(e=t.primaryRasters.rasters,t=e[0],i=!0):e=[t];const{rasterFunction:r}=this;if(r){const i={raster:t};e.length>1&&e.forEach(e=>i[e.url]=e);const s=x(r.functionDefinition?.toJSON()??r.toJSON(),i),n=new d({rasterFunction:s});n.rasterJobHandler=this._rasterJobHandler,await n.open(),this.raster=n}else this.raster=t,await t.open();if(this._cachedRendererJson=void 0,!i&&!r)return;const{bandIds:s}=this,{bandCount:n}=this.raster.rasterInfo,o=s?.length?s.some(e=>e>=n):n>=3;s&&(o||this.renderer&&"raster-stretch"!==this.renderer.type)&&this._set("bandIds",null),this._configDefaultRenderer("auto")}_convertRasterIdentifyResultToSample(e,t){const{rasterInfo:i}=this.raster,r=i.storageInfo.pyramidScalingFactor**(e.pyramidLevel??0),s=(i.pixelSize.x+i.pixelSize.y)/2*r;if(!e.dataSeries?.length)return[new V({location:e.location,pixelValue:e.value,locationId:t,resolution:s})];const n=[];return e.dataSeries.forEach(({value:i,multidimensionalDefinition:r},o)=>{const a={Variables:r[0].variableName,Dimensions:r.flatMap(({dimensionName:e})=>e).join(",")};for(const{dimensionName:e,values:t}of r){a[e]=Array.isArray(t[0])?t[0][0]:t[0];const i=t[t.length-1];a[`${e}_Max`]=Array.isArray(i)?i[i.length-1]:i}const l=new V({location:e.location,pixelValue:i,rasterId:o,locationId:t,resolution:s,attributes:a});n.push(l)}),n}};function ee(e){if(!e.raster||!e.serviceRasterInfo)throw new i("imagery-tile","no raster")}return e([s({clonable:!1})],Z.prototype,"_cachedRasterFunctionJson",void 0),e([s({clonable:!1})],Z.prototype,"_compatibleFullExtent",void 0),e([s({clonable:!1})],Z.prototype,"_isConstructedFromFunctionRaster",void 0),e([s({clonable:!1})],Z.prototype,"_rasterFunctionUpdatePromise",void 0),e([s({type:[o],json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"0,1,2"!==this.bandIds?.join(",")}}}}})],Z.prototype,"bandIds",void 0),e([s({json:{origins:{service:{read:{source:"copyrightText"}}}}})],Z.prototype,"copyright",void 0),e([s({json:{read:!1}})],Z.prototype,"fullExtent",null),e([s({json:{write:{overridePolicy(){return{enabled:!this.loaded||"Raster"===this.raster.tileType||"bilinear"!==this.interpolation}}}}}),W(T)],Z.prototype,"interpolation",void 0),e([s()],Z.prototype,"ioConfig",void 0),e([s({type:[D],json:{write:!0}})],Z.prototype,"multidimensionalDefinition",null),e([s({type:J,json:{write:!0}})],Z.prototype,"multidimensionalSubset",void 0),e([s()],Z.prototype,"raster",void 0),e([s({type:N})],Z.prototype,"rasterFunction",null),e([s()],Z.prototype,"serviceRasterInfo",void 0),e([s()],Z.prototype,"sourceJSON",void 0),e([s({readOnly:!0,type:m,json:{read:!1}})],Z.prototype,"spatialReference",void 0),e([s({type:O})],Z.prototype,"tileInfo",void 0),e([s(j)],Z.prototype,"url",null),e([s({types:q})],Z.prototype,"renderer",null),e([s({types:q,json:{name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy(){const e="raster-stretch"===this.renderer?.type&&"none"===this.renderer.stretchType&&!this.renderer.useGamma;return{enabled:!this.loaded||"Raster"===this.raster.tileType||!e}}},origins:{"web-scene":{types:k,name:"layerDefinition.drawingInfo.renderer",write:{overridePolicy:e=>({enabled:e&&"vector-field"!==e.type})}}}}})],Z.prototype,"internalRenderer",null),e([K("internalRenderer")],Z.prototype,"readRenderer",null),e([s({clonable:!1})],Z.prototype,"symbolizer",void 0),Z=e([n("esri.layers.mixins.ImageryTileMixin")],Z),Z};export{X as ImageryTileMixin};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{__decorate as e}from"tslib";import{property as r,subclass as n}from"../../core/accessorSupport/decorators.js";import t
|
|
5
|
+
import{__decorate as e}from"tslib";import{property as r,subclass as n}from"../../core/accessorSupport/decorators.js";import{convertVectorFieldData as t}from"../raster/functions/vectorFieldUtils.js";import o from"../support/RasterJobHandler.js";import{normalizeRendererJSON as s}from"../../renderers/support/rasterRendererHelper.js";import{createFlowMesh as a}from"../../views/2d/engine/flow/dataUtils.js";const i=i=>{const l=i;let c=class extends l{constructor(){super(...arguments),this._rasterJobHandlerConfig={instance:null,refCount:0,connectionPromise:null}}get _rasterJobHandler(){return this._rasterJobHandlerConfig.instance}increaseRasterJobHandlerUsage(){this._rasterJobHandlerConfig.refCount++}decreaseRasterJobHandlerUsage(){this._rasterJobHandlerConfig.refCount--,this._rasterJobHandlerConfig.refCount<=0&&this._shutdownJobHandler()}async convertVectorFieldData(e,r,n){if(null==e)return null;const o=this._rasterJobHandler;return o?o.convertVectorFieldData({pixelBlock:e,dataType:r},n):t(e,r)}async createFlowMesh(e,r){const n=this._rasterJobHandler;return n?n.createFlowMesh(e,r):a(e.meshType,e.simulationSettings,e.flowData,null!=r.signal?r.signal:(new AbortController).signal)}_initJobHandler(){const{_rasterJobHandlerConfig:e}=this;if(e.connectionPromise)return e.connectionPromise;const r=new o;return e.connectionPromise=r.initialize().then(()=>{e.instance=r,this.notifyChange("_rasterJobHandler")},()=>{}),e.connectionPromise}_shutdownJobHandler(){const{_rasterJobHandlerConfig:e}=this;e.instance?.destroy(),e.instance=null,e.connectionPromise=null,e.refCount=0,this.notifyChange("_rasterJobHandler"),this._cachedRendererJson=void 0}async _updateSymbolizer(e,r,n,t){const o=this._rasterJobHandlerConfig.instance;if(!o)return;const a=s({...r.toJSON(),variableName:n});JSON.stringify(this._cachedRendererJson)!==JSON.stringify(a)&&(t&&(e.rasterInfo=t),e.rendererJSON=a,e.bind(),await o.updateSymbolizer(e),this._cachedRendererJson=r.toJSON())}async _symbolize(e,r){const{pixelData:n,bandIds:t,simpleStretchParams:o}=e,s=this._rasterJobHandler;if(s){const e=await s.symbolize({...n,simpleStretchParams:o,bandIds:t},r);return{extent:n.extent,pixelBlock:e}}const a=e.symbolizer.symbolize({...n,simpleStretchParams:o,bandIds:t});return{extent:n.extent,pixelBlock:a}}};return e([r({clonable:!1})],c.prototype,"_rasterJobHandler",null),e([r({clonable:!1})],c.prototype,"_cachedRendererJson",void 0),e([r({clonable:!1})],c.prototype,"_rasterJobHandlerConfig",void 0),c=e([n("esri.layers.mixins.RasterJobHandlerMixin")],c),c};export{i as RasterJobHandlerMixin};
|
package/layers/ogc/wcsUtils.js
CHANGED
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import e from"../../request.js";import r from"../../core/Error.js";import{isAbortError as s}from"../../core/promiseUtils.js";import{isSupportedVersion as t,parseCapabilities as
|
|
5
|
+
import e from"../../request.js";import r from"../../core/Error.js";import{isAbortError as s}from"../../core/promiseUtils.js";import{isSupportedVersion as t,parseCapabilities as a}from"../raster/datasets/wcsCapabilitiesParser.js";import{parseCoverages as o}from"../raster/datasets/wcsCoverageParser.js";async function i(o,i){const{version:n,customParameters:c,signal:p}=i??{},l=n?.startsWith("1.0")?"version":"acceptVersions",m={service:"WCS",request:"GetCapabilities",[l]:n,...c};try{let{data:r}=await e(o,{query:m,responseType:"xml",signal:p});return i?.version||t(r)||(m[l]="2.0.1",({data:r}=await e(o,{query:m,responseType:"xml",signal:p}))),a(r)}catch(v){if(!s(v))throw new r("wcslayer:open","wcs capabilities is not valid or supported");throw v}}async function n(t,a){const{coverageIds:i,version:n,customParameters:c,signal:p}=a,l=n.slice(0,3),m="1.0"===l?"coverage":"1.1"===l?"identifiers":"coverageId",v={service:"WCS",request:"DescribeCoverage",version:n,[m]:i.join(","),...c};try{const{data:r}=await e(t,{query:v,responseType:"xml",signal:p});return o(r,n)}catch(w){if(!s(w))throw new r("wcslayer:open","wcs coverage description is not valid or supported");throw w}}export{n as describeCoverage,i as getCapabilities};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../request.js";import i from"../../../core/Error.js";import{JSONSupport as o}from"../../../core/JSONSupport.js";import n from"../../../core/Logger.js";import{onAbort as r}from"../../../core/promiseUtils.js";import{QueueProcessor as s}from"../../../core/QueueProcessor.js";import{property as l,subclass as a}from"../../../core/accessorSupport/decorators.js";import{ensureClass as c}from"../../../core/accessorSupport/ensureType.js";import f from"../../../geometry/Extent.js";import u from"../../../geometry/Point.js";import m from"../../../geometry/SpatialReference.js";import{isFunctionRaster as h,getPixelSpaceCoverage as p}from"./datasetUtils.js";import{isMultiSliceOrRangeDefinition as d,getSliceIndex as x,createSlices as y,getSliceIds as g}from"./multidimensionalUtils.js";import{getRasterId as I,getBlock as R,putBlock as w,deleteBlock as S,decreaseRefCount as b}from"./RawBlockCache.js";import{convertNoDataToMask as k}from"../formats/pixelRangeUtils.js";import{decode as T}from"../formats/RasterCodec.js";import{mosaic as v,approximateTransform as P,getLocalArithmeticNorthRotations as B,compositeBands as _}from"../functions/pixelUtils.js";import{getWorldWidth as M,load as W,projectPoint as C,snapPyramid as H,shiftExtent as z,getWorldWrapCount as L,projectExtent as E,getProjectionOffsetGrid as j,getRasterDatasetAlignmentInfo as D,projectResolution as O}from"../functions/rasterProjectionHelper.js";import{convertToLocalDirections as A,uvComponentToVector as q}from"../functions/vectorFieldUtils.js";import{sanitizeUrl as F}from"../../support/arcgisLayerUrl.js";import{url as G}from"../../support/commonProperties.js";import J from"../../support/DimensionalDefinition.js";import N from"../../support/LOD.js";import V from"../../support/RasterStorageInfo.js";import U from"../../support/TileInfo.js";const Q=8,$=256;let X=0,K=class extends o{constructor(){super(...arguments),this._tileFetchQueue=new s({concurrency:32,process:(e,t)=>this.fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:"closest"}}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:"closest",tileInfo:U.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=M(e.spatialReference);return null!=t&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){const{transform:e}=this.rasterInfo;return null==e||"gcs-shift"===e.type}set rasterJobHandler(e){this._set("rasterJobHandler",e),h(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||"rasterId-"+X++}set url(e){this._set("url",F(e,n.getLogger(this)))}async open(e){return this._openPromise??=W().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,o,n={}){const r=n.tileInfo||this.rasterInfo.storageInfo.tileInfo,s=this.getTileExtentFromTileInfo(e,t,o,r);if(!s)throw new i("imagery-tile:out-of-bounds","Level for fetch tile out of range");return n={noClip:!0,...n},this.fetchPixels(s,r.size[0],r.size[1],n)}async identify(e,t={}){e=c(u,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:o}=t,{rasterInfo:n}=this,{hasMultidimensionalTranspose:r,multidimensionalInfo:s}=n;let{transposedVariableName:l}=t;const a=null!=s&&r&&(null!=o||d(i));if(a&&!l){l=null!=i&&i.length>0?i[0].variableName??void 0:s.variables[0].name,t={...t,transposedVariableName:l}}t=this._getRequestOptionsWithSliceId(t);const{spatialReference:m,extent:p}=n,{datumTransformation:x}=t;let y=C(e,m,x);if(!p.intersects(y))return{location:y,value:null};if(null!=n.transform){const e=n.transform.inverseTransform(y);if(!n.nativeExtent.intersects(e))return{location:e,value:null};y=e}let g=0;const I=null!=l&&null!=s&&n.hasMultidimensionalTranspose;if(h(this)){const e=this.primaryRasters.rasters[0];if(I)return e.identify(y,t);const{pixelSize:o}=n,r=3,s=o.x*r/2,l=o.y*r/2,a=new f({xmin:y.x-s,xmax:y.x+s,ymin:y.y-l,ymax:y.y+l,spatialReference:m}),c={interpolation:"nearest",multidimensionalDefinition:i,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:u}=await e.fetchPixels(a,r,r,c),{pixelBlock:h}=await this.fetchPixels(a,r,r,c);if(null==u)return{location:y,value:null};const p=Math.floor(r*r*.5),d=!u.mask||u.mask[p]?u.pixels.map(e=>e[p]):null;let x;return null!=h&&(x=!h.mask||h.mask[p]?h.pixels.map(e=>e[p]):void 0),{location:y,value:d,processedValue:x,pyramidLevel:0}}if(!I)if(t.srcResolution){g=H(t.srcResolution,n,this.ioConfig.sampling).pyramidLevel}else if(g=await this.computeBestPyramidLevelForLocation(e,t),null==g)return{location:y,value:null};const R=this.identifyPixelLocation(y,g,null,I);if(null===R)return{location:y,value:null};const{row:w,col:S,rowOffset:b,colOffset:k,blockWidth:T}=R,v=await this._fetchRawTile(g,w,S,t);if(!v?.pixels?.length)return{location:y,value:null};const P=b*T+k;return this._processIdentifyResult(v,{srcLocation:y,position:P,pyramidLevel:g,useTransposedTile:!!I,requestSomeSlices:a,identifyOptions:t})}async fetchPixels(e,t,i,o={}){e=z(e),o=this._getRequestOptionsWithSliceId(o);const{_hasNoneOrGCSShiftTransform:n}=this;if(o.requestRawData&&n)return this._fetchPixels(e,t,i,o);const r=M(e.spatialReference),s=L(e);if(null==r||0===s||1===s&&this._isGlobalWrappableSource&&n)return this._fetchPixels(e,t,i,o);if(s>=3)return{extent:e,pixelBlock:null};const l=[],{xmin:a,xmax:c}=e,u=Math.round(r/(c-a)*t),m=u-Math.round((r/2-a)/(c-a)*t);let h=0;const p=[];for(let g=0;g<=s;g++){const n=new f({xmin:0===g?a:-r/2,xmax:g===s?c-r*g:r/2,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),d=0===g?u-m:g===s?t-h:u;h+=d,p.push(d);const x=o.disableWrapAround&&g>0?null:this._fetchPixels(n,d,i,o);l.push(x)}const d=(await Promise.all(l)).map(e=>e?.pixelBlock);let x=null;const y={width:t,height:i};if(this.rasterJobHandler){x=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:d,srcMosaicSize:y,destDimension:null,coefs:null,sampleSpacing:null,interpolation:"nearest",alignmentInfo:null,blockWidths:p},o)).pixelBlock}else x=v(d,y,{blockWidths:p});return{extent:e,srcExtent:E(e,this.rasterInfo.spatialReference,o.datumTransformation),pixelBlock:x}}async fetchRawPixels(e,t,i,o={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};const n=await this._fetchRawTiles(e,t,i,o),{nativeExtent:r,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,u=s.y*a,m=new f({xmin:r.xmin+c*t.x,xmax:r.xmin+c*(t.x+i.width-1),ymin:r.ymax-u*(t.y+i.height-1),ymax:r.ymax-u*t.y,spatialReference:r.spatialReference});if(!n)return{extent:m,srcExtent:m,pixelBlock:null};const{pixelBlocks:h,mosaicSize:p}=n;if(1===h.length&&null!=h[0]&&h[0].width===i.width&&h[0].height===i.height)return{extent:m,srcExtent:m,pixelBlock:n.pixelBlocks[0]};const d=e>0?l.pyramidBlockWidth:l.blockWidth,x=e>0?l.pyramidBlockHeight:l.blockHeight,y={x:t.x%d,y:t.y%x};let g;if(this.rasterJobHandler){g=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:h,srcMosaicSize:p,destDimension:i,clipOffset:y,clipSize:i,coefs:null,sampleSpacing:null,interpolation:o.interpolation,alignmentInfo:null,blockWidths:null},o)).pixelBlock}else g=v(h,p,{clipOffset:y,clipSize:i});return{extent:m,srcExtent:m,pixelBlock:g}}fetchRawTile(e,t,o,n){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return E(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?T(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,i,o=0){const{customFetchParameters:n}=this.ioConfig,{range:r,query:s,headers:l}=i;o=o??i.retryCount??this.ioConfig.retryCount;const a=r?{Range:`bytes=${r.from}-${r.to}`}:null;try{return await t(e,{...i,query:{...s,...n},headers:{...l,...a}})}catch(c){if(o>0)return o--,this.request(e,i,o);throw c}}getSliceIndex(e){const{multidimensionalInfo:t}=this.rasterInfo;return null==t||null==e||0===e.length?null:x(e,t)}getTileExtentFromTileInfo(e,t,i,o){const n=o.lodAt(e);return n?this.getTileExtent({x:n.resolution,y:n.resolution},t,i,o.origin,o.spatialReference,o.size):null}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:o}=this.rasterInfo,{pyramidResolutions:n}=e;if(!e.tileInfo){const r=[],s=e.maximumPyramidLevel||0;let l=(o.x+o.y)/2,a=1/.0254*96*l;for(let e=0;e<=s&&(r.unshift(new N({level:s-e,resolution:l,scale:a})),e!==s);e++)if(n){const t=(n[e].x+n[e].y)/2;a*=t/l,l=t}else l*=2,a*=2;const c=new u({x:i.xmin,y:i.ymax,spatialReference:t});e.tileInfo=new U({origin:c,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:r}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,o){const{width:n,height:r,nativeExtent:s,pixelSize:l,spatialReference:a}=e,c=new u({x:s.xmin,y:s.ymax,spatialReference:a});null==o&&(o=Math.max(0,Math.round(Math.log(Math.max(n,r))/Math.LN2-8)));const f=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],o);e.storageInfo=new V({blockWidth:t,blockHeight:i,pyramidBlockWidth:t,pyramidBlockHeight:i,origin:c,firstPyramidLevel:1,maximumPyramidLevel:o,blockBoundary:f})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,i,o,n,r=0,s=2){if(1===n.length&&r>0){n=[...n];let{x:e,y:t}=n[0];for(let i=0;i<r;i++)e*=s,t*=s,n.push({x:e,y:t})}const l=[],{x:a,y:c}=o;for(let f=0;f<n.length;f++){const{x:o,y:r}=n[f];l.push({minCol:Math.floor((e.xmin-a+.1*o)/t/o),maxCol:Math.floor((e.xmax-a-.1*o)/t/o),minRow:Math.floor((c-e.ymax+.1*r)/i/r),maxRow:Math.floor((c-e.ymin-.1*r)/i/r)})}return l}getPyramidPixelSize(e){const{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:i,pyramidScalingFactor:o}=this.rasterInfo.storageInfo;if(0===e)return t;if(null!=i&&i.length)return i[e-1];const n=o**e;return{x:t.x*n,y:t.y*n}}identifyPixelLocation(e,t,i,o){const{spatialReference:n,nativeExtent:r,storageInfo:s}=this.rasterInfo,{maximumPyramidLevel:l,origin:a,transposeInfo:c}=s,f=o&&null!=c?c.tileSize[0]:s.blockWidth,u=o&&null!=c?c.tileSize[1]:s.blockHeight,m=C(e,n,i);if(!r.intersects(m))return null;if(t<0||t>l)return null;const h=this.getPyramidPixelSize(t),{x:p,y:d}=h,x=(a.y-m.y)/d/u,y=(m.x-a.x)/p/f,g=Math.min(u-1,Math.floor((x-Math.floor(x))*u)),I=Math.min(f-1,Math.floor((y-Math.floor(y))*f));return{pyramidLevel:t,row:Math.floor(x),col:Math.floor(y),rowOffset:g,colOffset:I,blockWidth:f,srcLocation:m}}getTileExtent(e,t,i,o,n,r){const[s,l]=r,a=o.x+i*s*e.x,c=a+s*e.x,u=o.y-t*l*e.y,m=u-l*e.y;return new f({xmin:a,xmax:c,ymin:m,ymax:u,spatialReference:n})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,i){const o=this.rasterInfo.storageInfo.blockBoundary[e];return!o||o.maxRow<t||o.maxCol<i||o.minRow>t||o.minCol>i}updateImageSpaceRasterInfo(e){const{pixelSize:t}=e,{width:i,height:o}=e,n=m.WebMercator;e.spatialReference=n,e.extent=e.nativeExtent=new f({xmin:-.5,ymax:.5,xmax:i-.5,ymin:.5-o,spatialReference:n}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new u({x:1,y:1,spatialReference:n});const{extent:r,storageInfo:s}=e;if(s){s.origin=new u({x:r.xmin,y:r.ymax,spatialReference:n});const{pyramidResolutions:i,tileInfo:o}=s;if(i&&i.forEach(e=>{e.x/=t.x,e.y/=t.y}),o){o.origin=s.origin;const t=(e.nativePixelSize.x+e.nativePixelSize.y)/2;o.lods.forEach((e,i)=>{e.resolution=t*2**i,e.scale=96*e.resolution/.0254})}}}async _fetchPixels(e,t,i,o={}){let n=L(e);if(n>=2)return{extent:e,pixelBlock:null};const r=this._getSourceDataInfo(e,t,i,o),{pyramidLevel:s,srcResolution:l,srcExtent:a,srcWidth:c,srcHeight:f,ul:m}=r;if(0===c||0===f)return{extent:e,srcExtent:a,pixelBlock:null};const{rasterInfo:h}=this,p=h.transform,d="gcs-shift"===p?.type,x=null!=M(e.spatialReference);!d&&x||(n=L(r.srcExtent,d));const y=await this._fetchRawTiles(s,m,{width:c,height:f,wrapCount:n},o);if(!y)return{extent:e,srcExtent:a,pixelBlock:null};const g=h.storageInfo,I=s>0?g.pyramidBlockWidth:g.blockWidth,R=s>0?g.pyramidBlockHeight:g.blockHeight;let{x:w,y:S}=h.pixelSize;if(s>0){const{pyramidResolutions:e,pyramidScalingFactor:t}=g;if(null!=e&&e[s-1])({x:w,y:S}=e[s-1]);else{const e=t**s;w*=e,S*=e}}const b=h.spatialReference,k=new u({x:w,y:S,spatialReference:b}),T=I===c&&R===f&&m.x%I===0&&m.y%R===0,_=new u({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),C=!e.spatialReference.equals(b),H=b.isGeographic?1e-9:1e-4,{datumTransformation:z}=o;if(!C&&T&&1===y.pixelBlocks.length&&I===t&&R===i&&Y(l,_,H))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:y.pixelBlocks[0]};const E=x&&null!=M(a.spatialReference)&&this._hasNoneOrGCSShiftTransform,D=o.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");D&&!this.rasterJobHandler&&await W();const O=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:_.toJSON(),datumTransformation:z,rasterTransform:p,hasWrapAround:n>0||E,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:D},o):j({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:_,datumTransformation:z,rasterTransform:p,hasWrapAround:n>0||E,isAdaptive:!1,includeGCSGrid:D});let q;const F=!o.requestRawData,G={rows:O.spacing[0],cols:O.spacing[1]},J=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,y.extent.xmin):void 0,{pixelBlocks:N,mosaicSize:V,isPartiallyFilled:U}=y;let Q=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:N,srcMosaicSize:V,destDimension:F?{width:t,height:i}:null,coefs:F?O.coefficients:null,sampleSpacing:F?G:null,projectDirections:D,gcsGrid:D?O.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:o.interpolation,alignmentInfo:J,blockWidths:null},o);({pixelBlock:q,localNorthDirections:Q}=e)}else{const e=v(N,V,{alignmentInfo:J});q=F?P(e,{width:t,height:i},O.coefficients,G,o.interpolation):e,D&&O.gcsGrid&&(Q=B({width:t,height:i},O.gcsGrid),q=A(q,this.rasterInfo.dataType,Q))}return o.requestRawData||D?{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:q,transformGrid:O,localNorthDirections:Q,isPartiallyFilled:U}:{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:q}}async _fetchRawTiles(e,t,i,o){const{origin:n,blockBoundary:r}=this.rasterInfo.storageInfo,{blockWidth:s,blockHeight:l}=this.getBlockWidthHeight(e);let{x:a,y:c}=t,{width:u,height:m,wrapCount:h}=i;const p=this._getRasterTileAlignmentInfo(e,0);o.buffer&&(a-=o.buffer.cols,c-=o.buffer.rows,u+=2*o.buffer.cols,m+=2*o.buffer.rows);let d=0,x=0,y=0;if(h&&null!=p){({worldColumnCountFromOrigin:x,originColumnOffset:y,rightPadding:d}=p);x*p.blockWidth-d>=a+u&&(d=0)}const g=Math.floor(a/s),I=Math.floor(c/l),R=Math.floor((a+u+d-1)/s),w=Math.floor((c+m+d-1)/l),S=r[e];if(!S)return null;const{minRow:b,minCol:k,maxCol:T,maxRow:v}=S;if(0===h&&(w<b||R<k||I>v||g>T))return null;const P=new Array;let B=!1;const _=null==this.ioConfig.allowPartialFill?o.allowPartialFill:this.ioConfig.allowPartialFill;for(let f=I;f<=w;f++)for(let t=g;t<=R;t++){let i=t;if(!o.disableWrapAround&&h&&null!=p&&x<=t&&(i=t-x-y),f>=b&&i>=k&&v>=f&&T>=i){const t=this._fetchRawTile(e,f,i,o);_?P.push(new Promise(e=>{t.then(t=>e(t)).catch(()=>{B=!0,e(null)})})):P.push(t)}else P.push(Promise.resolve(null))}if(0===P.length)return null;const M=await Promise.all(P),W={height:(w-I+1)*l,width:(R-g+1)*s},{spatialReference:C}=this.rasterInfo,H=this.getPyramidPixelSize(e),{x:z,y:L}=H;return{extent:new f({xmin:n.x+g*s*z,xmax:n.x+(R+1)*s*z,ymin:n.y-(w+1)*l*L,ymax:n.y-I*l*L,spatialReference:C}),pixelBlocks:M,mosaicSize:W,isPartiallyFilled:B}}_fetchRawTile(e,t,i,o){const{storageInfo:n}=this.rasterInfo,s=null!=n.transposeInfo&&!!o.transposedVariableName;if(!s){const o=n.blockBoundary[e];if(!o)return Promise.resolve(null);const{minRow:r,minCol:s,maxCol:l,maxRow:a}=o;if(t<r||i<s||t>a||i>l)return Promise.resolve(null)}const l=s?o.transposeVariableName:o.sliceId,a=n.isBsqTile?o.bandIds:null,c=I(this.rasterId,l,a),f=`${e}/${t}/${i}`;let u=R(c,o.registryId,f);if(null==u){const r=new AbortController,s=o.bandIds?.slice();if(s?.length&&n.isBsqTile){const n=new Set(s),l=[],a=Array.from(n);for(const s of a)l.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:i,options:{...o,bandIds:[s]}},{signal:r.signal}));u=Promise.all(l).then(e=>{if(e.some(e=>null==e))return null;if(a.length!==s.length){const t=[];for(const i of s){let o=e[a.indexOf(i)];t.includes(o)&&(o=o.clone()),t.push(o)}e=t}return this.rasterJobHandler?this.rasterJobHandler.compositeBands({pixelBlocks:e},{signal:r.signal,transferPixelsToWorker:!0}):_(e)})}else u=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:i,options:o},{signal:r.signal});w(c,o.registryId,f,u,r),u.catch(()=>S(c,o.registryId,f))}return o.signal&&r(o,()=>{b(c,o.registryId,f)}),u}_computeMagDirValues(e){const{bandCount:t,dataType:i}=this.rasterInfo;if(!(2===t&&"vector-magdir"===i||"vector-uv"===i)||2!==e?.length||!e[0]?.length)return null;const o=e[0].length;if("vector-magdir"===i){const t=e[1].map(e=>(e+360)%360);return[e[0],t]}const[n,r]=e,s=[],l=[];for(let a=0;a<o;a++){const[e,t]=q([n[a],r[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=D(this.rasterInfo)),null==this._rasterTileAlignmentInfo.pyramidsInfo?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,i,o={}){const n={datumTransformation:o.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};o.srcResolution&&(n.srcResolution=o.srcResolution,this._updateSourceDataInfo(e,n));const r=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=n,c=s/t,f=l/i,m=a<r&&c*f>=16,h=a===r&&this._requireTooManySrcTiles(s,l,t,i);if(m||h||(0===s||0===l)){const s=new u({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference});let l=O(s,this.rasterInfo.spatialReference,e,n.datumTransformation);const h=!l||o.srcResolution&&l.x+l.y<o.srcResolution.x+o.srcResolution.y;if(m&&o.srcResolution&&h){const e=Math.round(Math.log(Math.max(c,f))/Math.LN2)-1;if(r-a+3>=e){const t=2**e;l={x:o.srcResolution.x*t,y:o.srcResolution.y*t}}}l&&(n.srcResolution=l,this._updateSourceDataInfo(e,n))}return this._requireTooManySrcTiles(n.srcWidth,n.srcHeight,t,i)&&(n.srcWidth=0,n.srcHeight=0),n}_requireTooManySrcTiles(e,t,i,o){const{tileInfo:n}=this.rasterInfo.storageInfo,r=Math.ceil(e/n.size[0])*Math.ceil(t/n.size[1]),s=e/i,l=t/o,a=Math.max(1,(i+o)/1024);return r>=$*a||s>Q||l>Q}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,o=i.spatialReference,{srcResolution:n,datumTransformation:r}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=H(n,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||E(e,o,r);if(null==c)return;const f=i.transform;f&&(c=f.inverseTransform(c)),t.srcExtent=c;const{origin:u}=i.storageInfo,{width:m,height:h,ul:d}=p(c,u,l,s);t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=m,t.srcHeight=h,t.ul=d}_getRequestOptionsWithSliceId(e){return null!=this.rasterInfo.multidimensionalInfo&&null==e.sliceId&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){const{srcLocation:i,position:o,pyramidLevel:n,useTransposedTile:r}=t,s=e.pixels[0].length/e.width/e.height;if(!(!e.mask||e.mask[o]))return{location:i,value:null};const{multidimensionalInfo:l}=this.rasterInfo;if(null==l||!r){const t=e.pixels.map(e=>e[o]),r={location:i,value:t,pyramidLevel:n},s=this._computeMagDirValues(t.map(e=>[e]));return s?.length&&(r.magdirValue=s.map(e=>e[0])),r}let a=e.pixels.map(e=>e.slice(o*s,o*s+s)),c=this._computeMagDirValues(a);const{requestSomeSlices:f,identifyOptions:u}=t;let m=y(l,u.transposedVariableName);if(f){const e=g(m,u.multidimensionalDefinition,u.timeExtent);a=a.map(t=>e.map(e=>t[e])),c=c?.map(t=>e.map(e=>t[e])),m=e.map(e=>m[e])}const h=e.noDataValues||this.rasterInfo.noDataValue,p={pixels:a,pixelType:e.pixelType};let d;null!=h&&(k(p,h),d=p.mask);return{location:i,value:null,dataSeries:m.map((e,t)=>{const i={value:0===d?.[t]?null:a.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new J({...e,isSlice:!0}))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i}),pyramidLevel:n}}};function Y(e,t,i){return Math.abs(e.x-t.x)<i&&Math.abs(e.y-t.y)<i}e([l()],K.prototype,"_rasterTileAlignmentInfo",void 0),e([l()],K.prototype,"_tileFetchQueue",void 0),e([l({readOnly:!0})],K.prototype,"_isGlobalWrappableSource",null),e([l({readOnly:!0})],K.prototype,"_hasNoneOrGCSShiftTransform",null),e([l()],K.prototype,"_openPromise",void 0),e([l()],K.prototype,"rasterJobHandler",null),e([l({readOnly:!0})],K.prototype,"rasterId",null),e([l(G)],K.prototype,"url",null),e([l({type:String,json:{write:!0}})],K.prototype,"datasetName",void 0),e([l({type:String,json:{write:!0}})],K.prototype,"datasetFormat",void 0),e([l()],K.prototype,"hasUniqueSourceStorageInfo",void 0),e([l()],K.prototype,"rasterInfo",void 0),e([l()],K.prototype,"ioConfig",void 0),e([l()],K.prototype,"sourceJSON",void 0),K=e([a("esri.layers.raster.datasets.BaseRaster")],K);export{K as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as r,subclass as s}from"../../../core/accessorSupport/decorators.js";import a from"./BaseRaster.js";import{isXAxis as i,isYAxis as o,parseGridCoverage as n}from"./covJSONParser.js";import l from"./InMemoryRaster.js";import{computeStatisticsHistograms as c}from"../functions/stretchUtils.js";import m from"../../../rest/support/FeatureSet.js";let p=class extends a{constructor(){super(...arguments),this.datasetFormat="CovJSON"}fetchRawTile(e,t,r,s={}){return this._inMemoryRaster.fetchRawTile(e,t,r,s)}async _open(e){const{extent:t,pixelBlocks:r,multidimensionalInfo:s,attributeTable:a,bandNames:i}=await this._fetchData(e),{statistics:o,histograms:n}=c(r[0]),p=i?.map(e=>({BandName:e})),h={DataType:a?"Thematic":s?"Scientific":"Generic",BandProperties:p},d=new l({source:{extent:t,pixelBlocks:r,attributeTable:a?m.fromJSON(a):null,multidimensionalInfo:s,statistics:o,histograms:n,keyProperties:h,isPseudoSpatialReference:!1}});await d.open(),this._inMemoryRaster=d;const u=this.source?"":this.url.slice(this.url.lastIndexOf("/")+1);this._set("datasetName",u.slice(0,u.indexOf("."))),this._set("rasterInfo",d.rasterInfo)}async _fetchData(e){const r=this.source??(await this.request(this.url,{signal:e?.signal})).data,s="imagery-tile-layer:open-coverage-json";if("coverage"!==r.type?.toLowerCase()||"grid"!==r.domain?.domainType?.toLowerCase())throw new t(s,"Only coverage with Grid domain type is supported");if(!r.ranges)throw new t(s,"Missing ranges in the grid coverage data");if(!r.domain.referencing?.length)throw new t(s,"Missing domain referencing in the grid coverage data");const a=Object.values(r.ranges);for(let n=0;n<a.length;n++){const{axisNames:e,shape:r,type:l,values:c}=a[n];if(!("ndarray"===l.toLowerCase()&&c?.length&&e?.length&&r?.length))throw new t(s,"Only ranges with valid NdArray, axisNames, shape, and inline values are supported");if(!(i(e[e.length-1])&&o(e[e.length-2])))throw new t(s,"Only row-major ordered pixel values are supported. X axis must be the last axis.")}return n(r)}};e([r({type:String,json:{write:!0}})],p.prototype,"datasetFormat",void 0),e([r({constructOnly:!0})],p.prototype,"source",void 0),p=e([s("esri.layers.raster.datasets.CovJSONRaster")],p);const h=p;export{h as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import s from"../../../geometry/Polygon.js";import a from"./BaseRaster.js";import{clip as o}from"../functions/clipUtils.js";import{approximateTransform as n}from"../functions/pixelUtils.js";import{projectPolygon as l}from"../functions/rasterProjectionHelper.js";import c from"../../../rest/support/FeatureSet.js";const p=40;let m=class extends a{constructor(){super(...arguments),this.datasetFormat="Function",this.tileType="Raster",this.rasterFunction=null,this._clippingGeometry=new Map}async fetchPixels(t,e,r,i={}){const{rasters:s,rasterIds:a}=this.primaryRasters;let l=!1;const{interpolation:c}=i,p=this.rasterFunction.flatWebGLFunctionChain?.hasFocalFunction;!i.requestRawData&&p&&(l=1===s.length&&!i.skipRasterFunction,i={...i,interpolation:"bilinear",requestRawData:l}),i.requestRawData&&s.length>1&&!this.hasUniqueSourceStorageInfo&&(l=!1,i={...i,requestRawData:!1});const m=s.map(s=>s.fetchPixels(t,e,r,i)),u=await Promise.all(m),h=u.map(t=>t.pixelBlock),f=l||i.requestRawData?u.map(t=>t.srcTilePixelSize):null;if(i.skipRasterFunction||h.every(t=>null==t))return u[0];const d=u.find(t=>null!=t.pixelBlock)?.extent??t;let y=this.rasterJobHandler?await this.rasterJobHandler.process({extent:d,primaryPixelBlocks:h,primaryPixelSizes:f,primaryRasterIds:a}):this.rasterFunction.process({extent:d,primaryPixelBlocks:h,primaryPixelSizes:f,primaryRasterIds:a});const{transformGrid:g}=u[0];if(!l||null==y||null==g){const t=i.noClip?null:this.getClippingGeometry(d.spatialReference);return!i.noClip&&null!=y&&t&&(y=await o(y,d,t)),{...u[0],pixelBlock:y}}const x={rows:g.spacing[0],cols:g.spacing[1]};let R;if(this.rasterJobHandler){R=(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:[y],srcMosaicSize:{width:y.width,height:y.height},destDimension:{width:e,height:r},coefs:g.coefficients,sampleSpacing:x,projectDirections:!1,gcsGrid:null,isUV:!1,interpolation:c,alignmentInfo:void 0,blockWidths:null},i)).pixelBlock}else R=n(y,{width:e,height:r},g.coefficients,x,c);const w=i.noClip?null:this.getClippingGeometry(t.spatialReference);return i.noClip||null==R||null==w||(R=await o(R,t,w)),{extent:t,srcExtent:u[0].srcExtent,pixelBlock:R}}getClippingGeometry(t){const e=this._clippingGeometry.get("0");if(!t||!e)return e;const r=h(t);let i=this._clippingGeometry.get(r);return null!=i||(i=t.equals(e.spatialReference)?e:l(e,t),this._clippingGeometry.set(r,i)),i}async _open(t){const{rasterFunction:r}=this;r.isRoot=!0,this.primaryRasters?.rasters?.length?r.sourceRasters=this.primaryRasters.rasters:(this.primaryRasters=r.getPrimaryRasters(),this.rasterJobHandler&&this.primaryRasters.rasters?.forEach(t=>t.rasterJobHandler=this.rasterJobHandler));const{rasters:i,rasterIds:s}=this.primaryRasters,a=i.map(e=>e.rasterInfo?void 0:e.open(t));await Promise.all(a);const o=i.map(({rasterInfo:t})=>t),n=r.bind({rasterInfos:o,rasterIds:s});if(r.rawSourceRasterInfos=o,!n.success||0===o.length)throw new e("raster-function:open",`cannot bind the function: ${n.error??""}`);const l="Table"===r.functionName?r:r.functionArguments?.raster;"Table"===l?.functionName&&(r.rasterInfo.attributeTable=c.fromJSON(l.functionArguments.attributeTableAsRecordSet)),await this.syncJobHandler();const p=o[0];this.hasUniqueSourceStorageInfo=1===o.length||o.slice(1).every(t=>u(t,p)),this.set("sourceJSON",i[0].sourceJSON),this.set("rasterInfo",r.rasterInfo),await this._updateClipGeometry()}async syncJobHandler(){return this.rasterJobHandler?.updateRasterFunction(this.rasterFunction)}async _updateClipGeometry(){const t=this.rasterFunction.getClippingGeometries()[0];let e=t?.clippingGeometry;if(e&&"inside"===t.clippingType){const{extent:t}=this.rasterInfo,r=await import("../../../geometry/operators/densifyOperator.js"),i=await import("../../../geometry/operators/differenceOperator.js");let a=r.execute(s.fromExtent(t),2*(t.width+t.height)/p);a=l(a,e.spatialReference),e=i.execute(a,e)}this._clippingGeometry.clear(),e&&this._clippingGeometry.set("0",e)}};function u(t,e){const{storageInfo:r,pixelSize:i,spatialReference:s,extent:a}=t,{storageInfo:o,pixelSize:n,spatialReference:l,extent:c}=e;return i.x===n.x&&i.y===n.y&&s.equals(l)&&a.equals(c)&&r.blockHeight===o.blockHeight&&r.blockWidth===o.blockWidth&&r.maximumPyramidLevel===o.maximumPyramidLevel&&r.firstPyramidLevel===o.firstPyramidLevel&&r.pyramidBlockWidth===o.pyramidBlockWidth&&r.pyramidBlockHeight===o.pyramidBlockHeight&&r.pyramidScalingFactor===o.pyramidScalingFactor}function h(t){return String(t.wkid??t.wkt??t.wkt2)}t([r({type:String,json:{write:!0}})],m.prototype,"datasetFormat",void 0),t([r()],m.prototype,"tileType",void 0),t([r()],m.prototype,"rasterFunction",void 0),t([r()],m.prototype,"primaryRasters",void 0),m=t([i("esri.layers.raster.datasets.FunctionRaster")],m);export{m as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import has from"../../../core/has.js";import{eachAlways as s,createAbortError as r}from"../../../core/promiseUtils.js";import{property as a,subclass as o}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Extent.js";import n from"../../../geometry/SpatialReference.js";import l from"./BaseRaster.js";import m from"./InMemoryRaster.js";import{parsePAMInfo as f}from"./pamParser.js";import{getFormat as p}from"../formats/RasterCodec.js";import{estimateStatisticsFromHistograms as c}from"../functions/stretchUtils.js";import u from"../transforms/PolynomialTransform.js";let h=class extends l{fetchRawTile(t,e,s,r={}){return this._inMemoryRaster.fetchRawTile(t,e,s,r)}async _open(t){const e=await this._fetchData(t);let{spatialReference:s,statistics:r,histograms:a,transform:o}=await this._fetchAuxiliaryData(t);const l=!s;l&&(s=new n({wkid:3857})),a?.length&&null==r&&(r=c(a));const{width:f,height:p}=e;let u=new i({xmin:-.5,ymin:.5-p,xmax:f-.5,ymax:.5,spatialReference:s});const h=o?o.forwardTransform(u):u;let d=!0;if(o){const t=o.forwardCoefficients;d=t&&0===t[1]&&0===t[2],d&&(o=null,u=h)}const w=new m({source:{extent:h,nativeExtent:u,transform:o,pixelBlocks:[e],statistics:r,histograms:a,keyProperties:{DateType:"Processed"},isPseudoSpatialReference:l},ioConfig:{sampling:"closest",skipStatistics:!0}});this.ioConfig.skipMapInfo&&(w.ioConfig.skipMapInfo=!0),await w.open(),w.source=null,this._set("rasterInfo",w.rasterInfo),this._inMemoryRaster=w}async _fetchData(t){const{data:s}=await this.request(this.url,{responseType:"array-buffer",signal:t?.signal}),r=p(s).toUpperCase();if("JPG"!==r&&"PNG"!==r&&"GIF"!==r&&"BMP"!==r)throw new e("image-aux-raster:open","the data is not a supported format");this._set("datasetFormat",r);const a=r.toLowerCase(),o="gif"===a||"bmp"===a||!has("ios"),i=await this.decodePixelBlock(s,{format:a,useCanvas:o,hasNoZlibMask:!0});if(null==i)throw new e("image-aux-raster:open","the data cannot be decoded");return i}async _fetchAuxiliaryData(t){const e=t?.signal,{skipExtensions:a=[],skipMapInfo:o}=this.ioConfig,i=o||a.includes("aux.xml")?null:this.request(this.url+".aux.xml",{responseType:"xml",signal:e}),n=this.datasetFormat,l="JPG"===n?"jgw":"PNG"===n?"pgw":"BMP"===n?"bpw":null,m=l&&a.includes(l)?null:this.request(this.url.slice(0,this.url.lastIndexOf("."))+"."+l,{responseType:"text",signal:e}),p=await s([i,m]);if(e?.aborted)throw r();const c=f(p[0].value?.data);if(!c.transform){const t=p[1].value?p[1].value.data.split("\n").slice(0,6).map(t=>Number(t)):null;c.transform=6===t?.length?new u({forwardCoefficients:[t[4],t[5],t[0],-t[1],t[2],-t[3]]}):null}return c}};t([a({type:String,json:{write:!0}})],h.prototype,"datasetFormat",void 0),h=t([o("esri.layers.raster.datasets.ImageAuxRaster")],h);const d=h;export{d as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as i}from"../../../core/maybe.js";import{urlToObject as s}from"../../../core/urlUtils.js";import{property as a,subclass as r}from"../../../core/accessorSupport/decorators.js";import l from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{setValidBoundary as m}from"../functions/pixelUtils.js";import u from"../transforms/GCSShiftTransform.js";import h from"../../support/RasterInfo.js";import f from"../../support/RasterStorageInfo.js";import p from"../../support/TileInfo.js";import{TilemapCache as d}from"../../support/TilemapCache.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends c{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat="RasterTileServer",this.tileType=null}async fetchRawTile(e,t,i,s={}){const{storageInfo:a,extent:r}=this.rasterInfo,{transposeInfo:l}=a,n=null!=l&&!!s.transposedVariableName;if(this._slices&&!n&&null==s.sliceId)return null;const o=n?0:a.maximumPyramidLevel-e+this._levelOffset,c=`${this.url}/tile/${o}/${t}/${i}`,u=this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null;let h,f;if(a.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...u,bandId:e},responseType:"array-buffer",signal:s.signal})),t=await Promise.all(e),i=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),a=new Uint8Array(i);f=[];let r=0;for(const{data:s}of t)f.push(r),a.set(new Uint8Array(s),r),r+=s.byteLength;h=a.buffer}else{h=(await this.request(c,{query:u,responseType:"array-buffer",signal:s.signal})).data}if(!h)return null;const p=n?l.tileSize:a.tileInfo.size,d=await this.decodePixelBlock(h,{width:p[0],height:p[1],planes:f?.length,offsets:f,pixelType:null,isPoint:"Elevation"===this.tileType,returnInterleaved:n,noDataValue:this.rasterInfo.noDataValue});if(null==d)return null;const y=a.blockBoundary[e];if("jpg"!==a.compression||i>y.minCol&&i<y.maxCol&&t>y.minRow&&t<y.maxRow)return d;const{origin:x,blockWidth:g,blockHeight:v}=a,{x:S,y:I}=this.getPyramidPixelSize(e),w=Math.round((r.xmin-x.x)/S)%g,b=Math.round((r.xmax-x.x)/S)%g||g,M=Math.round((x.y-r.ymax)/I)%v,T=Math.round((x.y-r.ymin)/I)%v||v,_=i===y.minCol?w:0,j=t===y.minRow?M:0,O=i===y.maxCol?b:g,R=t===y.maxRow?T:v;return m(d,{x:_,y:j},{width:O-_,height:R-j}),d}getSliceIndex(e){if(!this._slices||null==e||0===e.length)return null;const t=e;for(let i=0;i<this._slices.length;i++){const e=this._slices[i].multidimensionalDefinition;if(e.length===t.length&&!e.some(e=>{const i=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);if(!i)return!0;return(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(i.values[0])?`${i.values[0][0]}-${i.values[0][1]}`:i.values[0])}))return i}return null}async fetchVariableStatisticsHistograms(e,t){const i=this.request(this.url+"/statistics",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.statistics),s=this.request(this.url+"/histograms",{query:{variable:e,f:"json"},signal:t}).then(e=>e.data?.histograms),a=await Promise.all([i,s]);return a[0]&&a[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),a[1]?.[0]?.counts?.length||(a[1]=null),{statistics:a[0]||null,histograms:a[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let i=this.identifyPixelLocation(e,0,t.datumTransformation);if(null===i)return null;let s=0;const{maximumPyramidLevel:a}=this.rasterInfo.storageInfo;let r=a-s+this._levelOffset;const l=i.srcLocation;for(;r>=0;){try{if("available"===await this._tilemapCache.fetchAvailability(r,i.row,i.col,t))break}catch{}if(r--,s++,i=this.identifyPixelLocation(l,s,t.datumTransformation),null===i)return null}return-1===r||null==i?null:s}async _open(e){const a=e?.signal,r=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:"json"},signal:a});r.ssl&&(this.url=this.url.replace(/^http:/i,"https:"));const l=r.data;if(this.sourceJSON=l,!l)throw new t("imageserverraster:open","cannot initialize tiled image service, missing service info");if(!l.tileInfo)throw new t("imageserverraster:open","use ImageryLayer to open non-tiled image services");this._fixScaleInServiceInfo();const n=["jpg","jpeg","png","png8","png24","png32","mixed"];this.tileType=l.cacheType,null==this.tileType&&(n.includes(l.tileInfo.format.toLowerCase())?this.tileType="Map":"lerc"===l.tileInfo.format.toLowerCase()?this.tileType="Elevation":this.tileType="Raster"),this.datasetName=l.name?.slice(l.name.indexOf("/")+1)??"";const o=await this._fetchRasterInfo({signal:a});if(null==o)throw new t("image-server-raster:open","cannot initialize image service");y(o,l);const c="Map"===this.tileType?v(l.tileInfo,l):p.fromJSON(l.tileInfo);i(c);const[m,u]=this._computeMinMaxLOD(o,c),{extent:h,pixelSize:x}=o,g=.5/o.width*x.x,I=Math.max(x.x,x.y),{lods:w}=c;("Map"!==this.tileType&&0!==l.maxScale||Math.abs(x.x-x.y)>g||!w.some(e=>Math.abs(e.resolution-I)<g))&&(x.x=x.y=m.resolution,o.width=Math.ceil((h.xmax-h.xmin)/x.x-.1),o.height=Math.ceil((h.ymax-h.ymin)/x.y-.1));const b=m.level-u.level,[M,T]=c.size,_=[],j=[];w.forEach((e,t)=>{e.level>=u.level&&e.level<=m.level&&_.push({x:e.resolution,y:e.resolution}),t<w.length-1&&j.push(Math.round(10*e.resolution/w[t+1].resolution)/10)}),_.sort((e,t)=>e.x-t.x);const O=this.computeBlockBoundary(h,M,T,c.origin,_,b),R=_.length>1?_.slice(1):null;let z;l.transposeInfo&&(z={tileSize:[l.transposeInfo.rows,l.transposeInfo.cols],packetSize:o.keyProperties?._yxs.PacketSize??0});const N=j.length<=1||j.length>=3&&j.slice(0,-1).every(e=>e===j[0])?j[0]??2:Math.round(10/(u.resolution/m.resolution)**(-1/b))/10;if(o.storageInfo=new f({blockWidth:c.size[0],blockHeight:c.size[1],pyramidBlockWidth:c.size[0],pyramidBlockHeight:c.size[1],pyramidResolutions:R,pyramidScalingFactor:N,compression:c.format,origin:c.origin,firstPyramidLevel:1,maximumPyramidLevel:b,tileInfo:c,isBsqTile:!!l.bsq,transposeInfo:z,blockBoundary:O}),S(o),this._set("rasterInfo",o),l.capabilities.toLowerCase().includes("tilemap")){const e={tileInfo:o.storageInfo.tileInfo,parsedUrl:s(this.url),url:this.url,tileServers:[]};this._tilemapCache=new d({layer:e})}}async _fetchRasterInfo(e){const t=this.sourceJSON;if("Map"===this.tileType){const e=t.fullExtent||t.extent,i=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),s=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),a=o.fromJSON(t.spatialReference||e.spatialReference),r=new n({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:a});return new h({width:i,height:s,bandCount:3,extent:l.fromJSON(e),spatialReference:a,pixelSize:r,pixelType:"u8",statistics:null,keyProperties:{DataType:"processed"}})}const{signal:i}=e,s=x(this.url,this.sourceJSON,{signal:i,query:this.ioConfig.customFetchParameters}),a=t.hasMultidimensions?this.request(`${this.url}/slices`,{query:{f:"json"},signal:i}).then(e=>e.data?.slices).catch(()=>null):null,r=await Promise.all([s,a]);return this._slices=r[1],r[0]}_fixScaleInServiceInfo(){const{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){const{pixelSize:i}=e,s=.5/e.width*i.x,{lods:a}=t,r=t.lodAt(Math.max.apply(null,a.map(e=>e.level))),l=t.lodAt(Math.min.apply(null,a.map(e=>e.level))),{tileType:n}=this;if("Map"===n)return this._levelOffset=a[0].level,[r,l];if("Raster"===n){return[a.find(e=>e.resolution===i.x)??r,l]}const{minScale:o,maxScale:c}=this.sourceJSON;let m=r;c>0&&(m=a.find(e=>Math.abs(e.scale-c)<s),m||(m=a.filter(e=>e.scale>c).sort((e,t)=>e.scale>t.scale?1:-1)[0]??r));let u=l;return o>0&&(u=a.find(e=>Math.abs(e.scale-o)<s)??l,this._levelOffset=u.level-l.level),[m,u]}};function v(e,t){if(!e)return null;const{minScale:i,maxScale:s,minLOD:a,maxLOD:r}=t;if(null!=a&&null!=r)return p.fromJSON({...e,lods:e.lods.filter(({level:e})=>null!=e&&e>=a&&e<=r)});if(0!==i&&0!==s){const t=e=>Math.round(1e4*e)/1e4,a=i?t(i):1/0,r=s?t(s):-1/0;return p.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=a&&i>=r})})}return p.fromJSON(e)}function S(e){const{extent:t,spatialReference:i}=e;t.xmin>-1&&t.xmax>181&&i?.wkid&&i.isGeographic&&(e.nativeExtent=e.extent,e.transform=new u,e.extent=e.transform.forwardTransform(t))}e([a({type:String,json:{write:!0}})],g.prototype,"datasetFormat",void 0),e([a()],g.prototype,"tileType",void 0),g=e([r("esri.layers.raster.datasets.ImageServerRaster")],g);const I=g;export{I as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{eachAlways as i}from"../../../core/promiseUtils.js";import{property as s,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import r from"../../../geometry/SpatialReference.js";import l from"./BaseRaster.js";import{getSliceIndex as n}from"./multidimensionalUtils.js";import{clipTile as m,split as p}from"../functions/pixelUtils.js";import{estimateStatisticsHistograms as c,computeStatisticsHistograms as u}from"../functions/stretchUtils.js";import h from"../../support/DimensionalDefinition.js";import d from"../../support/RasterInfo.js";let f=class extends l{constructor(){super(...arguments),this.datasetFormat="MEMORY",this.source=null}get url(){return""}fetchRawTile(t,e,i,s={}){if(!this._pixelBlockTiles){const{rasterInfo:a}=this,[o,r]=a.storageInfo.tileInfo.size,{sliceId:l}=s,{pixelBlocks:n}=this.source,p={pixelBlock:null==l?n[0]:n[l],useBilinear:"thematic"!==a.dataType,tileSize:{width:o,height:r},level:t,row:e,col:i},c=this.rasterJobHandler?this.rasterJobHandler.clipTile(p,s):m(p);return Promise.resolve(c)}const a=this._pixelBlockTiles.get(`${t}/${e}/${i}`);return Promise.resolve(a)}async _open(t){const e=this.source,{pixelBlocks:i,attributeTable:s,statistics:a,histograms:l,name:n,nativeExtent:m,transform:p,colormap:c}=e,u=i[0],{width:h,height:f,pixelType:x}=u,y=e.extent??new o({xmin:-.5,ymin:.5,xmax:h-.5,ymax:f-.5,spatialReference:new r({wkid:3857})}),g=e.isPseudoSpatialReference??!e.extent,b={x:y.width/h,y:y.height/f},I={...e.keyProperties};e.dataType&&(I.DataType=e.dataType),e.bandInfos&&(I.BandProperties=e.bandInfos.map(t=>t.toJSON())),s&&(I.DataType="Thematic");const v=new d({width:h,height:f,pixelType:x,extent:y,nativeExtent:m,attributeTable:s,colormap:c,transform:p,pixelSize:b,spatialReference:y.spatialReference,bandCount:u.pixels.length,keyProperties:I,multidimensionalInfo:e.multidimensionalInfo,statistics:a,isPseudoSpatialReference:g,histograms:l});this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(v),this.createRemoteDatasetStorageInfo(v,512,512),this._set("rasterInfo",v),this.updateTileInfo(),v.multidimensionalInfo?await this._buildMDimStats(e.pixelBlocks,v.multidimensionalInfo):await this._buildInMemoryRaster(u,{width:512,height:512},t),v.multidimensionalInfo||(this.source=null),this.datasetName=n}async _buildInMemoryRaster(t,s,a){const{rasterInfo:o}=this,r=o.storageInfo.maximumPyramidLevel??0,l="thematic"!==o.dataType,n=this.rasterJobHandler?this.rasterJobHandler.split({pixelBlock:t,tileSize:s,maximumPyramidLevel:r,useBilinear:l},a):Promise.resolve(p(t,s,r,l)),m=null!=o.statistics,u=null!=o.histograms,h=this.ioConfig.skipStatistics||m?Promise.resolve({statistics:null,histograms:null}):this.rasterJobHandler?this.rasterJobHandler.estimateStatisticsHistograms({pixelBlock:t},a):Promise.resolve(c(t)),d=await i([n,h]);if(!d[0].value&&d[1].value)throw new e("inmemory-raster:open","failed to build in memory raster");this._pixelBlockTiles=d[0].value,m||(o.statistics=d[1].value?.statistics),u||(o.histograms=d[1].value?.histograms)}async _buildMDimStats(t,e,i){for(let s=0;s<e.variables.length;s++){const a=e.variables[s];if(a.statistics)continue;const o=a.dimensions.map(t=>new h({variableName:a.name,dimensionName:t.name,values:[t.values?.[0]??t.extent?.[0]],isSlice:!0})),r=n(o,e),l=null==r?null:t[r];if(null==l)continue;const m=this.rasterJobHandler?await this.rasterJobHandler.computeStatisticsHistograms({pixelBlock:l},i):u(l);a.statistics=m.statistics,a.histograms||(a.histograms=m.histograms)}}};t([s({type:String,json:{write:!0}})],f.prototype,"datasetFormat",void 0),t([s()],f.prototype,"source",void 0),t([s()],f.prototype,"url",null),f=t([a("esri.layers.raster.datasets.InMemoryRaster")],f);const x=f;export{x as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as t}from"tslib";import e from"../../../core/Error.js";import{property as s,subclass as r}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import i from"../../../geometry/Point.js";import a from"../../../geometry/SpatialReference.js";import n from"./BaseRaster.js";import{parseSpatialReference as l,parsePAMInfo as f}from"./pamParser.js";import{getElement as c,getElementValue as h}from"./xmlUtilities.js";import{isPlatformLittleEndian as p}from"../formats/utils.js";import{estimateStatisticsFromHistograms as m}from"../functions/stretchUtils.js";import u from"../../support/PixelBlock.js";import g from"../../support/RasterInfo.js";import d from"../../support/RasterStorageInfo.js";const y=new Map;y.set("Int8","s8"),y.set("UInt8","u8"),y.set("Int16","s16"),y.set("UInt16","u16"),y.set("Int32","s32"),y.set("UInt32","u32"),y.set("Float32","f32"),y.set("Float64","f32"),y.set("Double64","f32");const x=new Map;x.set("none",{blobExtension:".til",isOneSegment:!0,decoderFormat:"bip"}),x.set("lerc",{blobExtension:".lrc",isOneSegment:!1,decoderFormat:"lerc"}),x.set("deflate",{blobExtension:".pzp",isOneSegment:!0,decoderFormat:"deflate"}),x.set("jpeg",{blobExtension:".pjg",isOneSegment:!0,decoderFormat:"jpg"}),x.set("qb3",{blobExtension:".pq3",isOneSegment:!0,decoderFormat:"qb3"});let b=class extends n{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this.datasetFormat="MRF"}async fetchRawTile(t,e,s,r={}){const{blockWidth:o,blockHeight:i,blockBoundary:a}=this.rasterInfo.storageInfo,n=a[t];if(!n||n.maxRow<e||n.maxCol<s||n.minRow>e||n.minCol>s)return null;const{bandCount:l,pixelType:f}=this.rasterInfo,{ranges:c,actualTileWidth:h,actualTileHeight:p}=this._getTileLocation(t,e,s);if(!c||0===c.length)return null;if(0===c[0].from&&0===c[0].to){const t=new Uint8Array(o*i);return new u({width:o,height:i,pixels:void 0,mask:t,validPixelCount:0})}const{bandIds:m}=this.ioConfig,g=this._getBandSegmentCount(),d=[];let y=0;for(y=0;y<g;y++)m&&!m.includes(y)||d.push(this.request(this._files.data,{range:{from:c[y].from,to:c[y].to},responseType:"array-buffer",signal:r.signal}));const b=await Promise.all(d),w=b.map(t=>t.data.byteLength).reduce((t,e)=>t+e),I=new Uint8Array(w),A=[];let R=0;for(y=0;y<g;y++)A.push(R),I.set(new Uint8Array(b[y].data),R),R+=b[y].data.byteLength;const F=x.get(this.rasterInfo.storageInfo.compression).decoderFormat,S=await this.decodePixelBlock(I.buffer,{width:o,height:i,format:F,planes:m?.length||l,offsets:A,pixelType:f}).catch(()=>null);if(null==S)return null;let{noDataValue:_}=this.rasterInfo;if(null!=_&&"lerc"!==F&&!S.mask&&(_=_[0],null!=_)){const t=S.width*S.height,e=new Uint8Array(t);if(Math.abs(_)>1e24)for(y=0;y<t;y++)Math.abs((S.pixels[0][y]-_)/_)>1e-6&&(e[y]=1);else for(y=0;y<t;y++)S.pixels[0][y]!==_&&(e[y]=1);S.mask=e}let M=0,k=0;if(h!==o||p!==i){let t=S.mask;if(t)for(y=0;y<i;y++)if(k=y*o,y<p)for(M=h;M<o;M++)t[k+M]=0;else for(M=0;M<o;M++)t[k+M]=0;else for(t=new Uint8Array(o*i),S.mask=t,y=0;y<p;y++)for(k=y*o,M=0;M<h;M++)t[k+M]=1}return S}async _open(t){this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1);const e=t?t.signal:null,s=await this.request(this.url,{responseType:"xml",signal:e}),{rasterInfo:r,files:o}=this._parseHeader(s.data),{skipMapInfo:i,skipExtensions:a=[]}=this.ioConfig;if(!a.includes("aux.xml")&&!i){const e=await this._fetchAuxiliaryData(t);null!=e&&(r.statistics=e.statistics??r.statistics,r.histograms=e.histograms,e.histograms&&null==r.statistics&&(r.statistics=m(e.histograms)))}i&&this.updateImageSpaceRasterInfo(r),this._set("rasterInfo",r),this._files=o;const n=await this.request(o.index,{responseType:"array-buffer",signal:e});this._storageIndex=w(n.data);const{blockWidth:l,blockHeight:f}=this.rasterInfo.storageInfo,c=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:h,height:p}=this.rasterInfo,u=[],g=this._getBandSegmentCount();let d=0,y=-1;for(;d<this._storageIndex.length;){y++;const t=Math.ceil(h/l/c**y)-1,e=Math.ceil(p/f/c**y)-1;d+=(t+1)*(e+1)*g*4,u.push({maxRow:e,maxCol:t,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=u,y>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=y),this.updateTileInfo()}_getBandSegmentCount(){return x.get(this.rasterInfo.storageInfo.compression).isOneSegment?1:this.rasterInfo.bandCount}_getTileLocation(t,e,s){const{blockWidth:r,blockHeight:o,pyramidScalingFactor:i}=this.rasterInfo.storageInfo,{width:a,height:n}=this.rasterInfo,l=this._getBandSegmentCount();let f,c,h,p=0,m=0;for(h=0;h<t;h++)m=i**h,f=Math.ceil(a/r/m),c=Math.ceil(n/o/m),p+=f*c;m=i**t,f=Math.ceil(a/r/m),c=Math.ceil(n/o/m),p+=e*f+s,p*=4*l;const u=this._storageIndex.subarray(p,p+4*l);let g=0,d=0;const y=[];for(let x=0;x<l;x++)g=u[4*x]*2**32+u[4*x+1],d=g+u[4*x+2]*2**32+u[4*x+3]-1,y.push({from:g,to:d});return{ranges:y,actualTileWidth:s<f-1?r:Math.ceil(a/m)-r*(f-1),actualTileHeight:e<c-1?o:Math.ceil(n/m)-o*(c-1)}}_parseHeader(t){const s=c(t,"MRF_META/Raster");if(!s)throw new e("mrf:open","not a valid MRF format");const r=c(s,"Size"),n=parseInt(r.getAttribute("x"),10),f=parseInt(r.getAttribute("y"),10),p=parseInt(r.getAttribute("c"),10),m=(h(s,"Compression")||"none").toLowerCase();if(!x.has(m))throw new e("mrf:open","currently does not support compression "+m);const u=h(s,"DataType")||"UInt8",b=y.get(u);if(null==b)throw new e("mrf:open","currently does not support pixel type "+u);const w=c(s,"PageSize"),I=parseInt(w.getAttribute("x"),10),A=parseInt(w.getAttribute("y"),10),R=c(s,"DataValues");let F,S;R&&(S=R.getAttribute("NoData"),null!=S&&(F=S.trim().split(" ").map(t=>parseFloat(t))));if(c(t,"MRF_META/CachedSource"))throw new e("mrf:open","currently does not support MRF referencing other data files");const _=c(t,"MRF_META/GeoTags"),M=c(_,"BoundingBox");let k,T=!1;if(null!=M){const t=parseFloat(M.getAttribute("minx")),e=parseFloat(M.getAttribute("miny")),s=parseFloat(M.getAttribute("maxx")),r=parseFloat(M.getAttribute("maxy")),i=h(_,"Projection")||"";let n=a.WGS84;if("LOCAL_CS[]"!==i)if(i.toLowerCase().startsWith("epsg:")){const t=Number(i.slice(5));isNaN(t)||0===t||(n=new a({wkid:t}))}else n=l(i)??a.WGS84;else T=!0,n=new a({wkid:3857});k=new o(t,e,s,r),k.spatialReference=n}else T=!0,k=new o({xmin:-.5,ymin:.5-f,xmax:n-.5,ymax:.5,spatialReference:new a({wkid:3857})});const C=c(t,"MRF_META/Rsets"),j=parseInt(C?.getAttribute("scale")||"2",10),U=k.spatialReference,B=new d({origin:new i({x:k.xmin,y:k.ymax,spatialReference:U}),blockWidth:I,blockHeight:A,pyramidBlockWidth:I,pyramidBlockHeight:A,compression:m,pyramidScalingFactor:j}),E=new i({x:k.width/n,y:k.height/f,spatialReference:U}),L=new g({width:n,height:f,extent:k,isPseudoSpatialReference:T,spatialReference:U,bandCount:p,pixelType:b,pixelSize:E,noDataValue:F,storageInfo:B}),P=h(t,"datafile"),W=h(t,"IndexFile");return{rasterInfo:L,files:{mrf:this.url,index:W||this.url.replace(".mrf",".idx"),data:P||this.url.replace(".mrf",x.get(m).blobExtension)}}}async _fetchAuxiliaryData(t){try{const{data:e}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:t?.signal});return f(e)}catch{return null}}};function w(t){if(t.byteLength%16>0)throw new Error("invalid array buffer must be multiples of 16");let e,s,r,o,i,a;if(p){for(s=new Uint8Array(t),o=new ArrayBuffer(t.byteLength),r=new Uint8Array(o),i=0;i<t.byteLength/4;i++)for(a=0;a<4;a++)r[4*i+a]=s[4*i+3-a];e=new Uint32Array(o)}else e=new Uint32Array(t);return e}t([s()],b.prototype,"_files",void 0),t([s()],b.prototype,"_storageIndex",void 0),t([s({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),b=t([r("esri.layers.raster.datasets.MRFRaster")],b);const I=b;export{I as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import e from"../../../geometry/Point.js";import n from"./EphemeralBlockCache.js";import{projectExtent as t,projectResolution as o,snapPyramid as l}from"../functions/rasterProjectionHelper.js";const r=new Map,c=new n;function i(e,n,t){const o=[];return null!=n&&o.push(`sliceId=${n}`),null!=t&&o.push(`bandIds=${t.join(",")}`),o.length?`${e}?${o.join("&")}`:e}function u(e,n){const t={extent:null,rasterInfo:n,cache:new Map},o=r.get(e);return o?(o.push(t),o.length-1):(r.set(e,[t]),0)}function a(e,n){const t=r.get(e);t&&(t[n]=null,t.some(e=>null!=e)||r.delete(e))}function f(e){r.delete(e)}function s(e,n,t){const o=r.get(e);if(!o)return null==n?c.decreaseRefCount(e,t):0;if(null==n||null==o[n])return c.decreaseRefCount(e,t);const l=o[n]?.cache,i=l?.get(t);if(l&&i){if(i.refCount--,0===i.refCount){l.delete(t);for(let e=0;e<o.length;e++)o[e]?.cache.delete(t);i.controller&&i.controller.abort()}return i.refCount}return 0}function m(e,n,t){const o=r.get(e);if(!o)return null==n?c.getBlock(e,t):null;if(null==n||null==o[n]){for(let e=0;e<o.length;e++){const n=o[e]?.cache.get(t);if(n)return n.refCount++,n.block}return c.getBlock(e,t)}const l=o[n]?.cache.get(t);if(l)return l.refCount++,l.block;for(let r=0;r<o.length;r++){if(r===n||!o[r])continue;const e=o[r]?.cache,l=e?.get(t);if(e&&l)return l.refCount++,e.set(t,l),l.block}return null}function h(e,n,t,o,l=null){const i=r.get(e);if(!i)return void(null==n&&c.putBlock(e,t,o,l));if(null==n||null==i[n])return void c.putBlock(e,t,o,l);const u={refCount:1,block:o,isResolved:!1,isRejected:!1,controller:l};o.then(()=>u.isResolved=!0).catch(()=>u.isRejected=!0),i[n]?.cache.set(t,u)}function x(e,n,t){const o=r.get(e);o?null!=n&&null!=o[n]?o[n]?.cache.delete(t):c.deleteBlock(e,t):null==n&&c.deleteBlock(e,t)}function d(e,n){const t=r.get(e);return t?t[n]??null:null}function g(n,r,c,i,u,a,f=null){const s=d(n,r);if(!s)return;const m=s.extent,{cache:h,rasterInfo:x}=s;if(m&&m.xmin===c.xmin&&m.xmax===c.xmax&&m.ymin===c.ymin&&m.ymax===c.ymax)return;i=i??0;const g=c.clone().normalize(),{spatialReference:p,transform:y}=x,k=new Set;for(let d=0;d<g.length;d++){const n=g[d];if(n.xmax-n.xmin<=i||n.ymax-n.ymin<=i)continue;let r=t(n,p,f);if(null==r)continue;if(null!=y&&(r=y.inverseTransform(r),null==r))continue;const c=new e({x:i,y:i,spatialReference:n.spatialReference});if(null==u&&!(u=o(c,p,n,f)))return;const{pyramidLevel:s,pyramidResolution:m,excessiveReading:h}=l(u,x,a||"closest");if(h)return;const{storageInfo:M}=x,{origin:R}=M,{x:C,y:B}=m,b=Math.max(0,Math.floor((r.xmin-R.x)/C)),j=Math.max(0,Math.floor((R.y-r.ymax)/B)),v=Math.ceil(r.width/C-.1),w=Math.ceil(r.height/B-.1),$=s>0?M.pyramidBlockWidth:M.blockWidth,I=s>0?M.pyramidBlockHeight:M.blockHeight,H=M.blockBoundary[s];if(!H)continue;const E=1,P=Math.max(H.minCol,Math.floor(b/$)-E),W=Math.max(H.minRow,Math.floor(j/I)-E),z=Math.min(H.maxCol,Math.floor((b+v-1)/$)+E),L=Math.min(H.maxRow,Math.floor((j+w-1)/I)+E);for(let e=W;e<=L;e++)for(let n=P;n<=z;n++)k.add(`${s}/${e}/${n}`)}h.forEach((e,n)=>{if(!k.has(n)){const e=h.get(n);(null==e||e.isResolved||e.isRejected)&&h.delete(n)}}),s.extent={xmin:c.xmin,ymin:c.ymin,xmax:c.xmax,ymax:c.ymax}}export{s as decreaseRefCount,x as deleteBlock,f as deleteRaster,m as getBlock,i as getRasterId,h as putBlock,u as register,a as unregister,g as update};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import i from"../../../core/Logger.js";import{property as r,subclass as s}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import f from"./BaseRaster.js";import l from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as c}from"./pamParser.js";import{parseSignature as h,getPyramidIFDs as p,getMaskIFDs as d,parseIFD as m,parseFieldValues as y,isBSQConfig as g,getImageInfo as x}from"../formats/TiffDecoder.js";import{tiffTags as w,geoKeys as I}from"../formats/tiffTag.js";import{estimateStatisticsFromHistograms as T}from"../functions/stretchUtils.js";import R from"../transforms/PolynomialTransform.js";import _ from"../../support/RasterInfo.js";import O from"../../support/RasterStorageInfo.js";import F from"../../../rest/support/FeatureSet.js";const S=(e,t)=>e.get(t)?.values,b=(e,t)=>e.get(t)?.values?.[0];let E=class extends f{constructor(){super(...arguments),this._files=null,this._headerInfo=null,this._bufferSize=1048576,this._chunkSize=10485760,this.datasetFormat="TIFF"}async fetchRawTile(e,t,i,r={}){if(!this._headerInfo?.isSupported||this.isBlockOutside(e,t,i))return null;const s=await this._fetchRawTiffTile(e,t,i,!1,r);if(null!=s&&this._headerInfo.hasMaskBand){const a=await this._fetchRawTiffTile(e,t,i,!0,r);null!=a&&a.pixels[0]instanceof Uint8Array&&(s.mask=a.pixels[0])}return s}async _open(e){const r=e?e.signal:null,{data:s}=await this.request(this.url,{range:{from:0,to:this._bufferSize},responseType:"array-buffer",signal:r});if(!s)throw new t("tiffraster:open","failed to open url "+this.url);this.datasetName=this.url.slice(this.url.lastIndexOf("/")+1,this.url.lastIndexOf("."));const{littleEndian:a,firstIFDPos:n,isBigTiff:o}=h(s),f=[],l={fileChunk:s,posIFD:n,fileOffset:0};await this._readIFDs(f,l,a,o?8:4,r);const{imageInfo:u,rasterInfo:c}=k(f),m=p(f),y=d(f);if(this._headerInfo={littleEndian:a,isBigTiff:o,ifds:f,pyramidIFDs:m,maskIFDs:y,...u},this._set("rasterInfo",c),!u.isSupported)throw new t("tiffraster:open","this tiff is not supported: "+u.message);if(!u.tileWidth)throw new t("tiffraster:open","none-tiled tiff is not optimized for access, convert to COG and retry.");c.isPseudoSpatialReference&&i.getLogger(this).warn("The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.");const g=f[0].get("PREDICTOR")?.values?.[0],x=f[0].get("SAMPLEFORMAT")?.values?.[0];if(3===x&&2===g)throw new t("tiffraster:open","unsupported horizontal difference encoding. Predictor=3 is supported for floating point data");const{skipMapInfo:w,skipExtensions:I=[]}=this.ioConfig;if(!I.includes("aux.xml")&&!w){const t=await this._fetchAuxiliaryMetaData(e);null!=t&&v(t,c)}I.includes("vat.dbf")||1!==c.bandCount||"u8"!==c.pixelType||w||(c.attributeTable=await this._fetchAuxiliaryTable(e),null!=c.attributeTable&&(c.keyProperties.DataType="thematic")),w&&this.updateImageSpaceRasterInfo(c),this.updateTileInfo()}async _validateOrFetchHeaderBuffer(e,t){let{fileChunk:i,fileOffset:r,posIFD:s}=e;if(s+8>=i.byteLength||s<0){r=s+r;i=(await this.request(this.url,{range:{from:r,to:r+this._bufferSize},responseType:"array-buffer",signal:t})).data,s=0}return{fileChunk:i,fileOffset:r,posIFD:s}}async _readIFDs(e,i,r,s=4,a){if(!i.posIFD)return null;i=await this._validateOrFetchHeaderBuffer(i,a);const n=await this._readIFD(i,r,w,s,a);if(!n?.ifd)throw new t("tiffraster:open","cannot parse tiff header. failed to open url "+this.url);if(e.push(n.ifd),!n.nextIFD)return null;i.posIFD=n.nextIFD-i.fileOffset,await this._readIFDs(e,i,r,s,a)}async _readIFD(e,t,i=w,r=4,s){let{fileChunk:a,posIFD:n,fileOffset:o}=e;if(!e.fileChunk)return null;const f=m(a,t,n,o,i,r);if(f.success){const e=[];if(f.ifd?.forEach(t=>{t.values||e.push(t)}),e.length>0&&await this._fillOffsets(e,t,f.nextIFD,s),f.ifd?.has("GEOKEYDIRECTORY")){const e=f.ifd.get("GEOKEYDIRECTORY"),i=e?.values;if(i&&i.length>4){const r=i[0]+"."+i[1]+"."+i[2];n=e.valueOffset+6-o;const f=await this._validateOrFetchHeaderBuffer({fileChunk:a,posIFD:n,fileOffset:o},s),l=await this._readIFD(f,t,I,2,s);e.data=l?.ifd,e.data&&e.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[r]})}}return f}if(f.requiredBufferSize){return a=(await this.request(this.url,{range:{from:o,to:o+n+f.requiredBufferSize+8},responseType:"array-buffer",signal:s})).data,a.byteLength<n+f.requiredBufferSize?null:(e.fileChunk=a,e.fileOffset=o,this._readIFD(e,t,i,r,s))}return null}async _fillOffsets(e,t,i,r){const s=e.filter(e=>null!=e.offlineOffsetSize);if(0===s.length)return;const a=s.map(e=>e.offlineOffsetSize),n=Math.min.apply(null,a.map(e=>e[0])),o=Math.max.apply(null,a.map(e=>e[0]+e[1]));let f=1===a.length||o-n<=this._bufferSize;if(!f&&a.length>1){a.sort((e,t)=>e[0]-t[0]);f=a.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,a[0][0])===o}if(f){const e=await this._fetchOffsets(n,Math.max(o,n+this._bufferSize),r);return void s.forEach(i=>y(e,t,i,n))}const l=s.map(async e=>{const i=e.offlineOffsetSize,s=await this._fetchOffsets(i[0],i[1]+i[0],r);y(s,t,e,i[0])});await Promise.all(l)}async _fetchOffsets(e,t,i){const r=[],s=this._chunkSize,a=Math.ceil((t-e)/s);let n=e;for(let l=0;l<a;l++)r.push(this.request(this.url,{range:{from:n,to:l===a-1?t:n+s-1},responseType:"array-buffer",signal:i})),n+=s;const o=await Promise.all(r);if(1===a)return o[0].data;const f=new Uint8Array(t-e+1);for(let l=0;l<a;l++)f.set(new Uint8Array(o[l].data),l*s);return f.buffer}async _fetchRawTiffTile(e,t,i,r,s={}){const a=this._getTileLocation(e,t,i,r);if(!a)return null;const{ranges:n,actualTileWidth:o,actualTileHeight:f,ifd:l}=a,u=n.map(e=>this.request(this.url,{range:e,responseType:"array-buffer",signal:s.signal})),c=await Promise.all(u),h=c.map(e=>e.data.byteLength).reduce((e,t)=>e+t),p=1===c.length?c[0].data:new ArrayBuffer(h),d=[0],m=[0];if(c.length>1){const e=new Uint8Array(p);for(let t=0,i=0;t<c.length;t++){const r=c[t].data;e.set(new Uint8Array(r),i),d[t]=i,i+=r.byteLength,m[t]=r.byteLength}}const{blockWidth:y,blockHeight:g}=this.getBlockWidthHeight(e),x=await this.decodePixelBlock(p,{format:"tiff",customOptions:{headerInfo:this._headerInfo,ifd:l,offsets:d,sizes:m},width:y,height:g,planes:null,pixelType:null});if(null==x)return null;let w,I,T;if(o!==y||f!==g){let e=x.mask;if(e)for(w=0;w<g;w++)if(T=w*y,w<f)for(I=o;I<y;I++)e[T+I]=0;else for(I=0;I<y;I++)e[T+I]=0;else for(e=new Uint8Array(y*g),x.mask=e,w=0;w<f;w++)for(T=w*y,I=0;I<o;I++)e[T+I]=1}return x}_getTileLocation(e,t,i,r=!1){const{firstPyramidLevel:s,blockBoundary:a}=this.rasterInfo.storageInfo,n=0===e?0:e-(s-1),{_headerInfo:o}=this;if(!o)return null;const f=r?o.maskIFDs[n]:0===n?o?.ifds[0]:o?.pyramidIFDs[n-1];if(!f)return null;const l=g(f,o),u=S(f,"TILEOFFSETS");if(void 0===u)return null;const c=S(f,"TILEBYTECOUNTS"),{minRow:h,minCol:p,maxRow:d,maxCol:m}=a[n];if(t>d||i>m||t<h||i<p)return null;const y=b(f,"IMAGEWIDTH"),x=b(f,"IMAGELENGTH"),w=b(f,"TILEWIDTH"),I=b(f,"TILELENGTH"),T=[];if(l){const{bandCount:e}=this.rasterInfo;for(let r=0;r<e;r++){const e=r*(d+1)*(m+1)+t*(m+1)+i;T[r]={from:u[e],to:u[e]+c[e]-1}}}else{const e=t*(m+1)+i;T.push({from:u[e],to:u[e]+c[e]-1})}for(let g=0;g<T.length;g++)if(null==T[g].from||!T[g].to||T[g].to<0)return null;return{ranges:T,ifd:f,actualTileWidth:i===m&&y%w||w,actualTileHeight:t===d&&x%I||I}}async _fetchAuxiliaryMetaData(e){try{const{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{const{data:t}=await this.request(this.url+".vat.dbf",{responseType:"array-buffer",signal:e?.signal}),i=l.parse(t);return i?.recordSet?F.fromJSON(i.recordSet):null}catch{return null}}};function k(e){const t=x(e),{width:i,height:r,tileWidth:s,tileHeight:f,planes:l,pixelType:u,compression:h,firstPyramidLevel:p,maximumPyramidLevel:d,pyramidBlockWidth:m,pyramidBlockHeight:y,pyramidResolutions:g,tileBoundary:w,affine:I,metadata:T}=t,F=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid;let E=c(F),k=!!t.isPseudoGeographic;null==E&&(k=!0,E=new o({wkid:3857}));const v=new a({...t.extent,spatialReference:E}),D=new n(v?{x:v.xmin,y:v.ymax,spatialReference:E}:{x:0,y:0}),P=new O({blockWidth:s,blockHeight:f,pyramidBlockWidth:m,pyramidBlockHeight:y,compression:h,origin:D,firstPyramidLevel:p,maximumPyramidLevel:d,pyramidResolutions:g,blockBoundary:w}),B=new n({x:(v.xmax-v.xmin)/i,y:(v.ymax-v.ymin)/r,spatialReference:E}),z=T?{BandProperties:T.bandProperties,DataType:T.dataType}:{};let C=null;const L=b(e[0],"PHOTOMETRICINTERPRETATION"),j=S(e[0],"COLORMAP");if(L<=3&&j?.length>3&&j.length%3==0){C=[];const e=j.length/3;for(let t=0;t<e;t++)C.push([t,j[t]>>>8,j[t+e]>>>8,j[t+2*e]>>>8])}const A=new _({width:i,height:r,bandCount:l,pixelType:u,pixelSize:B,storageInfo:P,spatialReference:E,isPseudoSpatialReference:k,keyProperties:z,extent:v,colormap:C,statistics:T?T.statistics:null});if(I?.length&&(A.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:i-.5,ymax:.5,spatialReference:E}),A.transform=new R({polynomialOrder:1,forwardCoefficients:[I[2]+I[0]/2,I[5]-I[3]/2,I[0],I[3],-I[1],-I[4]]}),A.extent=A.transform.forwardTransform(A.nativeExtent),A.pixelSize=new n({x:(v.xmax-v.xmin)/i,y:(v.ymax-v.ymin)/r,spatialReference:E}),P.origin.x=-.5,P.origin.y=.5),g){const{x:e,y:t}=A.pixelSize;g.forEach(i=>{i.x*=e,i.y*=t})}return{imageInfo:t,rasterInfo:A}}function v(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&null==t.statistics&&(t.statistics=T(e.histograms)),e.transform&&null==t.transform){t.transform=e.transform,t.nativeExtent=t.extent;const i=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new n({x:(i.xmax-i.xmin)/t.width,y:(i.ymax-i.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=i}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}e([r()],E.prototype,"_files",void 0),e([r()],E.prototype,"_headerInfo",void 0),e([r()],E.prototype,"_bufferSize",void 0),e([r()],E.prototype,"_chunkSize",void 0),e([r({type:String,json:{write:!0}})],E.prototype,"datasetFormat",void 0),E=e([s("esri.layers.raster.datasets.TIFFRaster")],E);const D=E;export{D as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import i from"../../../core/Logger.js";import{property as n,subclass as s}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as r}from"../../ogc/crsUtils.js";import{getCapabilities as a,describeCoverage as l}from"../../ogc/wcsUtils.js";import c from"./BaseRaster.js";import{convertOleDateTimeToEpoch as d}from"./multidimensionalUtils.js";import{parse as f}from"./multipartParser.js";import{standardizeInterpolations as u}from"./wcsCoverageParser.js";import{getFormat as h}from"../formats/RasterCodec.js";import{clip as p}from"../functions/pixelUtils.js";import m from"../../support/DimensionalDefinition.js";const g=["nearest neighbor","bilinear","bicubic"],w=["nearest","linear","cubic"],v="response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode",y="response is not a supported multipart mediaType with inline tiff",x="response is base64 encoded which may impact layer display performance",I="server returns an exception",C=new Set(["1.0.0","1.1.0","1.1.1","1.1.2","2.0.1"]);let b=class extends c{constructor(){super(...arguments),this.datasetFormat="WCSServer",this.tileType="Raster"}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,i,n,s={}){if(this.isBlockOutside(e,i,n))return null;const{nativePixelSize:o,spatialReference:r}=this.rasterInfo,a=2**e,l=o.x*a,c=o.y*a,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:u}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:c},i,n,u,r,[d,f]),m=this.rasterInfo.extent,g=h.xmax>m.xmax,w=h.ymin<m.ymin,v=g||w;let y=h,x=d,I=f;if(v&&(y=h.clone().intersection(m),null!=y&&(g&&(x=Math.floor((y.xmax-y.xmin)/l),y.xmax=y.xmin+l*x),w&&(I=Math.floor((y.ymax-y.ymin)/c),y.ymin=y.ymax-c*I))),null==y||x<=1||I<=1)return null;const C=await this._getCoverage(y,x,I,a,s);if(!C)return null;const{coverageDescription:b}=this.coverageInfo,{noDataValue:$,multidimensionalInfo:S}=this.rasterInfo,{multidimensionalDefinition:j}=s;let T;if(null!=S&&null!=j&&j.length){const e=j[0].variableName;if("2.0"===b.version){const t=b.rangeType[0].find(t=>t.name===e);T=t?.nilValue}else if("1.1"===b.version){const t=b.range.find(t=>t.identifier===e);T=t?.nullValues}}const L=T??$,P=await this.decodePixelBlock(C,{width:x,height:I,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(L)?L[0]:L,matchAllNoData:!0});if(null==P)return null;if(P&&(P.width!==x||P.height!==I))throw new t("wcsraster-fetch",`the response has unexpected dimension width: ${P.width}, height: {pixelBlock.height}`);return v?p(P,{x:0,y:0},{width:f,height:f}):P}async _open(e){const{customFetchParameters:i}=this.ioConfig,n=e?.signal,s=await a(this.url,{version:i?.version??this.version,customParameters:i,signal:n});if(this.capabilities=s,!this.version){let e=s.version.slice(0,3);"2.0"===e||"1.1"===e||"1.0"===e?this.version=s.version:(e=s.supportedVersions.find(e=>"2.0.1"===e)||s.supportedVersions.find(e=>e.startsWith("2.0"))||s.supportedVersions.find(e=>e.startsWith("1.1"))||s.supportedVersions.find(e=>e.startsWith("1.0"))||"1.0.0",this.version=e)}const{version:o}=this;if(!C.has(o))throw new t("wcsraster-open",`unsupported WCS version ${o}`);const{gridCoverages:r}=s;if(!r.length)throw new t("wcsraster-open","cannot find rectified grid coverages");this.coverageId??=r[0].id;const{coverageId:c}=this,d=r.find(e=>e.id===c);if(null==d)throw new t("wcsraster-open",`the coverageId ${c} does not exist in capabilities`);const f=await l(this.url,{coverageIds:[c],version:o,customParameters:i,signal:n});if(this.coverageInfo=f[0],o.startsWith("2.0")){const{coverageInfo:e}=this;e.lonLatEnvelope=d.lonLatEnvelope,e.supportedInterpolations=u(s.supportedInterpolations),this._patchDimensionValues201(c,n)}this.datasetName=this.coverageInfo.title;const{rasterInfo:h}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(h,512,512),this._set("rasterInfo",h),null==h.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${c}`);const{pixelType:p,bandCount:m}=await this._getPixelTypeAndBandCount(n);h.pixelType=p,1===h.bandCount&&m>1&&(h.bandCount=m),this.updateTileInfo()}async _patchDimensionValues201(e,t){const{coverageInfo:i}=this,n=i.rasterInfo.multidimensionalInfo?.variables,s=C.has("1.1.2")?"1.1.2":C.has("1.1.1")?"1.1.1":C.has("1.1.0")?"1.1.0":null,{customFetchParameters:o}=this.ioConfig;if(n&&s)try{const i=this.url.includes("/ImageServer/"),r=e.length>8&&e.startsWith("Coverage")&&i?e.slice(8):e,a=await l(this.url,{coverageIds:[r??e],version:s,customParameters:o,signal:t}).catch(()=>{if(r)return l(this.url,{coverageIds:[e],version:s,customParameters:o,signal:t})}),c=a?.[0].rasterInfo.multidimensionalInfo?.variables;if(c)for(const e of n){const t=c.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let n=e.dimensions.length-1;n>=0;n--){const s=e.dimensions[n],o=t.dimensions.find(({name:e})=>e===s.name);o?o.values&&o.extent?.join(",")===s.extent?.join(",")&&(e.dimensions[n]={...s,values:o.values}):i&&e.dimensions.splice(n,1)}}}catch{}}async _getPixelTypeAndBandCount(e){const{pixelSize:n,extent:s,multidimensionalInfo:r}=this.rasterInfo,a=s.center,l=new o({xmin:a.x-n.x,xmax:a.x+n.x,ymin:a.y-n.y,ymax:a.y+n.y,spatialReference:s.spatialReference});let c=[];if(null!=r){const e=r.variables[0];c=[],e.dimensions.forEach(t=>{c.push(new m({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}const{coverageDescription:d}=this.coverageInfo,f={interpolation:"nearest",multidimensionalDefinition:c,signal:e},{version:u}=d,{ioConfig:h}=this,p="2.0"===u&&null==h.allowAnyMediaType||"1.1"===u&&null==h.use2GridOffsets;let g;try{g=await this._getCoverage(l,2,2,1,f,!0)}catch(y){if(!p)throw y;if("1.1"===u){if(!y.details?.isResolutionMismatch)throw y;h.use2GridOffsets=!0}}if(!g&&p&&("2.0"===u&&(h.allowAnyMediaType=!0),g=await this._getCoverage(l,2,2,1,f),g&&i.getLogger(this).warn("wcsraster:getcoverage",v)),!g)throw new t("wcsraster-open","unable to determine pixel type");const w=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null});if(null==w)throw new t("wcsraster-open","unable to determine pixel type");return{pixelType:w.pixelType,bandCount:w.getPlaneCount()??0}}async _getCoverage(e,n,s,o,r,a=!1){const{coverageDescription:l}=this.coverageInfo,{version:c}=l,d="2.0"===c?this._getCoverage201Parameters(e,n,s,o,r,l):"1.1"===c?this._getCoverage110Parameters(e,n,s,r,l):this._getCoverage100Parameters(e,n,s,r),u="2.0"===c?await this.request(this._constructWCS201Url(d),{signal:r.signal,responseType:"array-buffer"}):await this.request(this.url,{query:d,signal:r.signal,responseType:"array-buffer"});if("1.0"===c)return u.data;if("2.0"===c&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===h(u.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),u.data}const p=f(u);if(p.isMultipart&&p.data){const e=p.data.find(e=>e.isValidImage);return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const m=new Uint8Array(u.data,0,Math.min(u.data.byteLength,2e3)),g=String.fromCharCode.apply(null,m).toLowerCase().includes("exception"),w=g&&String.fromCharCode.apply(null,m).includes("A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided");if(g)throw new t("wcsraster:getcoverage",I,{isResolutionMismatch:w});throw new t("wcsraster:getcoverage",y)}_getInterpolationIndex(e){return e&&this.coverageInfo.supportedInterpolations?.includes(e)?"nearest"===e?0:"bilinear"===e?1:"cubic"===e?2:0:0}_getCoverage100Parameters(e,t,i,n){const s=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,o=e.spatialReference.wkid,r=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"GEOTIFF",{bandIds:a,interpolation:l}=n,c=this._getInterpolationIndex(l),d=a?a.map(e=>this.coverageInfo.bandNames[e]):null,f=g[c],{multidimensionalDefinition:u}=n;let h;if(null!=u&&null!=this.rasterInfo.multidimensionalInfo){const e=u.find(e=>"StdTime"===e.dimensionName);let t=e?.values;t&&t.length>0&&(Array.isArray(t[0])&&(t=t[0]),h=t.map(e=>$(e)).join(","))}return{service:"WCS",request:"GetCoverage",version:this.version,coverage:this.coverageId,format:r,crs:`EPSG:${o}`,bbox:s,width:t,height:i,time:h,interpolation:f,band:d?.join(",")}}_getCoverage110Parameters(e,t,i,n,s){const{multidimensionalDefinition:o,bandIds:a,interpolation:l}=n,c=e.spatialReference.wkid,d=`urn:ogc:def:crs:EPSG::${c}`,f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",u=this._getInterpolationIndex(l),h=w[u],p=null==l||0===this.coverageInfo.supportedInterpolations?.indexOf(l),m=s.domain.spatialDomain,g=m.origin.x<=m.envelope.xmin&&m.origin.y<=m.envelope.ymin,v=e.width/t,y=e.height/i*(g?1:-1),x=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],I=m.useEPSGAxis&&r(c),C=I?`${x[1]},${x[0]}`:`${x[0]},${x[1]}`,b=this.ioConfig.use2GridOffsets,S=I?b?`${y},${v}`:`${y},0,0,${v}`:b?`${v},${y}`:`${v},0,0,${y}`,j=v/2,T=e.xmin+j,L=e.xmax-j,P=Math.abs(y)/2,R=e.ymin+P,_=e.ymax-P,A=I?`${R},${T},${_},${L},${d}`:`${T},${R},${L},${_},${d}`,D=s.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes("band")));let E,W=D&&h&&a?p?`${D.identifier}[${D.axis[0].identifier}[${a.join(",")}]]`:`${D.identifier}:${h}[${D.axis[0].identifier}[${a.join(",")}]]`:null;if(null!=o&&o.length)for(let r=0;r<o.length;r++){let e=o[r].values;const t=o[r].dimensionName?.toLowerCase(),i=o[r].variableName?.toLowerCase(),n=s.range.find(e=>e.identifier.toLowerCase()===i);if(e.length>0)if(Array.isArray(e[0])&&(e=e[0]),"stdtime"===t)E=e.map(e=>$(e)).join(",");else if(n){const i=n.axis.find(e=>e.identifier.toLowerCase()===t);i&&(W=p?n.identifier+"["+i.identifier+"["+e.join(",")+"]]":n.identifier+":"+h+"["+i.identifier+"["+e.join(",")+"]]")}r===o.length-1&&n&&!W&&(W=p?n.identifier:n.identifier+":"+h)}return{service:"WCS",request:"GetCoverage",version:this.version,identifier:this.coverageId,format:f,crs:`EPSG:${c}`,boundingbox:A,gridCS:"urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS",gridType:"urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs",gridOrigin:C,gridOffsets:S,gridBaseCRS:d,timeSequence:E,rangeSubset:W}}_getCoverage201Parameters(e,t,i,n,s,o){const{multidimensionalDefinition:r,interpolation:a}=s,l=this._getInterpolationIndex(a);let c=null;const{supportedInterpolations:d}=this.capabilities;if(d?.length)switch(l){case 0:c=d.find(e=>e.toLowerCase().includes("nearest"));break;case 1:c=d.find(e=>e.toLowerCase().includes("linear"));break;case 2:c=d.find(e=>e.toLowerCase().includes("cubic")||e.toLowerCase().includes("quadratic"))}const f=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes("tiff"))||"image/tiff",{bandNames:u}=this.coverageInfo,{boundedBy:h,domainSet:p,rangeType:m}=o,g=h.isEastFirst?0:1,w=1-g,{axisLabels:v}=h,y=v[g],x=v[w],I=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=I,b=[];b.push(`${y}(${e.xmin},${e.xmax})`),b.push(`${x}(${e.ymin},${e.ymax})`);const S=[];if(v.length>2)for(let _=2;_<v.length;_++){const e=p.origin[_];if(v[_].toLowerCase().includes("time")){let t=e.toString();h.uomLabels?.[_].toLowerCase().includes("ole")&&(S.push(v[_]),t=$(e,!0)),b.push(v[_]+",http://www.opengis.net("+t+")")}else b.push(v[_]+",http://www.opengis.net("+e+")")}let j=null;if(null!=r&&r.length){const e=[];m.forEach(t=>t.forEach(t=>e.push(t.name)));const t=[];for(let i=0;i<r.length;i++){const n=v.find(e=>e===r[i].dimensionName),s=e.find(e=>e===r[i].variableName);if(t.includes(s)||t.push(s),n){let e=r[i].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t="";t=n.toLowerCase().includes("time")?e.map(e=>$(e)).join(","):e.join(",");const i=b.findIndex(e=>e.startsWith(n+",http://www.opengis.net"));-1===i&&b.push(n+",http://www.opengis.net("+t+")"),-1===i||b[i].includes("("+t+")")||b.splice(i,1,n+",http://www.opengis.net("+t+")")}}}t.length&&(j=t.join(","))}else if(u?.length>=2){j=(s.bandIds?s.bandIds.map(e=>u[e]):u).join(",")}const T=b.join("&subset="),L=!o.domainSet.hasSameAxisLabelsAsBoundedBy&&!1!==this.ioConfig.allowScaleFactor,P=L?null:`${y}(${t}),${x}(${i})`,R=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:P,scaleFactor:R,subset:T,format:f,mediaType:this.ioConfig.allowAnyMediaType?null:"multipart/related",outputcrs:I,subsettingcrs:C}}_constructWCS201Url(e){const t={...this.ioConfig.customFetchParameters,...e},i=[];Object.keys(t).forEach(e=>{const n=t[e];null!=n&&("subset"===e?"string"==typeof n&&n.split("&subset=").forEach(e=>{e&&i.push(`subset=${encodeURIComponent(e)}`)}):i.push(`${e}=${encodeURIComponent(n)}`))});return`${encodeURI(this.url)}?${i.join("&")}`}};function $(e,t=!1){return(t?new Date(d(e)):new Date(e)).toISOString()}e([n({type:String,json:{write:!0}})],b.prototype,"datasetFormat",void 0),e([n({readOnly:!0})],b.prototype,"tileType",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"version",void 0),e([n({type:String,json:{write:!0}})],b.prototype,"coverageId",void 0),e([n({readOnly:!0})],b.prototype,"rasterId",null),b=e([s("esri.layers.raster.datasets.WCSRaster")],b);export{b as default};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import e from"../../../Color.js";import t from"../../../geometry/Extent.js";import n from"../../../geometry/SpatialReference.js";import{getLocaleLanguage as l}from"../../../intl/locale.js";import{getIntegerPixelType as s}from"../formats/pixelRangeUtils.js";import a from"../../support/PixelBlock.js";function i(e){return["x","e","east","long","longitude"].includes(e.toLowerCase())}function r(e){return["y","n","west","lat","latitude"].includes(e.toLowerCase())}function o(e){const{axes:l}=e.domain,s=Object.keys(l),a=[],o=[];let u=-1,m=-1,c=[];for(let t=0;t<s.length;t++){const e=s[t];i(e)?u=t:r(e)&&(m=t);const n=l[e],d=[];if("values"in n){n.values.forEach(e=>d.push("string"==typeof e?new Date(e).getTime():e));const e=d[1]-d[0];a.push([d[0]-.5*e,d[d.length-1]+.5*e]),o.push(e)}else{const{start:e,stop:t,num:l}=n,s=(t-e)/(l-1);a.push([e-.5*s,t+.5*s]),o.push(s);for(let n=0;n<l;n++)d.push(e+s*n)}c.push({name:e,values:d,extent:[d[0],d[d.length-1]]})}u>-1&&-1===m?m=0===u?1:0:m>-1&&-1===u?u=0===m?1:0:-1===m&&-1===u&&(u=0,m=1),c=c.filter((e,t)=>!(t===u||t===m));const{referencing:d}=e.domain,f=d.find(e=>e.coordinates.includes(s[u])).system.id,p=f?.slice(f.lastIndexOf("/")+1),h=null==p||"CRS84"===p?4326:Number(p),g=new n({wkid:h}),[b,y]=a[u],[x,j]=a[m],v=new t({xmin:b,xmax:y,ymin:x,ymax:j,spatialReference:g});return{width:Math.round(v.width/o[u]),height:Math.round(v.height/o[m]),extent:v,dimensions:c}}function u(e){const t=l();return t?e[t]??Object.values(e)[0]:Object.values(e)[0]}function m(){return Math.round(255*Math.random())}function c(t){const n={},{parameters:l}=t;if(!l)return n;for(const[s,a]of Object.entries(l)){const{type:t,description:l,unit:i,categoryEncoding:r,observedProperty:o}=a;if("Parameter"===t&&(n[s]={},l&&(n[s].description=u(l)),i&&(n[s].unit=i.label?u(i.label):null,n[s].symbol=i.symbol?.value),r)){const t=Object.entries(r).map((e,t)=>({OID:t,Value:Number(e[1]),ClassName:e[0].slice(e[0].lastIndexOf("/")+1),Count:1}));let l=!1;o?.categories?.length&&(o.categories.forEach(n=>{if(!n.id)return;const s=n.id.slice(n.id.lastIndexOf("/")+1),a=t.find(e=>e.ClassName===s);if(!a)return;const i=n.label?u(n.label):null;if(a.Label=i,n.preferredColor){const t=e.fromHex(n.preferredColor);t&&(l=!0,a.Red=t.r,a.Green=t.g,a.Blue=t.b)}}),l&&t.forEach(e=>{null==e.Red&&(e.Red=m(),e.Green=m(),e.Blue=m())}));const a={objectIdFieldName:"",fields:[{name:"OID",type:"esriFieldTypeOID",alias:"OID",domain:null},{name:"Value",type:"esriFieldTypeInteger",alias:"Value",domain:null},{name:"Count",type:"esriFieldTypeDouble",alias:"Count",domain:null},{name:"ClassName",type:"esriFieldTypeString",alias:"ClassName",domain:null,length:50},{name:"Label",type:"esriFieldTypeString",alias:"Label",domain:null,length:50}],features:t.map(e=>({attributes:e}))};l&&a.fields.push({name:"Red",type:"esriFieldTypeInteger",alias:"Red",domain:null},{name:"Green",type:"esriFieldTypeInteger",alias:"Green",domain:null},{name:"Blue",type:"esriFieldTypeInteger",alias:"Blue",domain:null}),n[s].attributeTable=a}}return n}function d(e){let t=Number.MAX_VALUE,n=-Number.MAX_VALUE;for(let l=0;l<e.length;l++){const s=e[l];null!=s&&(s<t&&(t=s),s>n&&(n=s))}return s(t,n)}function f(e,t,n){const l=e.map((e,n)=>({name:e,count:t[n]})).sort((e,t)=>e.name>t.name?-1:1),s=(a=1,e=>a*=e.count);var a;const i=[...l.slice(1),{name:"",count:1}].reverse().map(s).reverse();let r=0;for(let o=e.length-1;o>=0;o--){r+=i[l.findIndex(({name:t})=>t===e[o])]*(n%t[o]),n=Math.floor(n/t[o])}return r}function p(e){const{width:t,height:n,extent:l,dimensions:s}=o(e),{ranges:i}=e,r=Object.keys(i).sort((e,t)=>e<t?-1:1),u=[];for(let a=0;a<r.length;a++){const e=r[a];s?.length&&u.push({name:e,dimensions:s})}const m=c(e);u.forEach(e=>m[e.name]&&Object.assign(e,m[e.name]));const p=u.length?{variables:u}:void 0,h=[];for(let o=0;o<r.length;o++){const e=r[o],{values:l,dataType:u,axisNames:m,shape:c}=i[e],p=c.length>2?o*c.slice(0,-2).reduce((e,t)=>e*t):0,g=m.slice(0,-2),b=c.slice(0,-2),y="float"===u?"f32":d(l),x=t*n,j=l.length/x;for(let i=0;i<j;i++){const e=a.createEmptyBand(y,x),r=new Uint8Array(x).fill(255);let u=!1;const m=i*x;for(let t=0;t<x;t++){const n=l[m+t];null==n?(r[t]=0,u=!0):e[t]=n}if(0===o||s?.length){const l=new a({width:t,height:n,mask:u?r:null,pixels:[e],pixelType:y});if(l.updateStatistics(),s?.length){h[f(g,b,i)+p]=l}else h.push(l)}else{const t=h[i];t.pixels.push(e),u?t.mask&&(t.mask=a.combineBandMasks([t.mask,r])):t.mask=u?r:null}}}const g=Object.values(m).find(e=>e.attributeTable)?.attributeTable;return{extent:l,pixelBlocks:h,multidimensionalInfo:p,attributeTable:g,bandNames:p?void 0:r}}export{i as isXAxis,r as isYAxis,p as parseGridCoverage};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{isSome as e}from"../../../core/arrayUtils.js";import n from"../../../geometry/Point.js";import{polygonCentroidPoint as t}from"../../../geometry/support/centroid.js";import i from"../../support/DimensionalDefinition.js";function a(e,n,t){const i=n.shift();if(0===t.length){const e=[];t.push({sliceId:-1,multidimensionalDefinition:e})}const s=t.length;for(let a=0;a<s;a++){const n=t.shift().multidimensionalDefinition;i.values?.forEach(a=>{t.push({sliceId:-1,multidimensionalDefinition:[...n,{variableName:e,dimensionName:i.name,values:[a]}]})})}n.length&&a(e,n,t)}function s(e,n){const t=[];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);a(e.name,s,n),n.forEach(e=>{t.push({...e,sliceId:i++})})}),t}function r(e,n,t){let i=e;if(n&&(n=[...n].sort((e,n)=>e.dimensionName<n.dimensionName?-1:1)).forEach(({dimensionName:e,values:n,isSlice:t})=>{n.length&&(i=i.filter(i=>{const a=i.multidimensionalDefinition.find(n=>n.dimensionName===e);if(null==a)return!1;const s=a.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])}))}),i.length&&null!=t?.start&&null!=t.end){const e=t.start.getTime(),n=t.end.getTime(),a=i[0].multidimensionalDefinition.findIndex(e=>"StdTime"===e.dimensionName);a>-1&&(i=i.filter(t=>{const i=t.multidimensionalDefinition[a].values[0];return e<=i&&n>=i}))}return i.map(e=>e.sliceId)}function l(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 u(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 o(e){return 1===e.length?[e[0],e[0]]:[e[0],e[e.length-1]]}function m(e,n,t){if(!n?.subsetDefinitions?.length)return e;let i;if(t){const{variables:a}=n;if(a.length&&!a.includes(t))return null;const s=n.subsetDefinitions.find(n=>n.dimensionName===e.name&&n.variableName===t);if(!s?.values?.length)return e;i=o(s.values)}else{const t=n.dimensions.find(({name:n})=>n===e.name);i=t?.extent}const a=i;if(!a?.length)return e;const s=e.values.filter(e=>l(e,a));return{...e,extent:[...a],values:s}}function c(e,n,t){if(!n?.subsetDefinitions?.length)return!1;const{variables:i}=n;if(i.length&&e.some(({variableName:e})=>e&&!i.includes(e)))return!0;for(let a=0;a<e.length;a++){const i=e[a],s=n.subsetDefinitions.find(e=>(""===i.variableName||e.variableName===i.variableName)&&e.dimensionName===i.dimensionName);if(s?.values.length){const e=o(s.values);if(!i.isSlice&&2===i.values.length&&!Array.isArray(i.values[0])&&i.values[0]!==i.values[1]&&t){if(!u(i.values,e))return!0}else if(i.values.some(n=>!l(n,e)))return!0}}return!1}function f(e,n){if(null==e)return{isOutside:!1};const{geometry:t,timeExtent:i,multidimensionalDefinition:a}=n;let s=null;if(null!=i&&(s=h(e,i),null==s))return{isOutside:!0};const{areaOfInterest:r}=e;if(r&&t){const e=d(t);if(e&&!r.contains(e))return{isOutside:!0}}return null!=a&&a.length&&c(a,e,!0)?{isOutside:!0}:{isOutside:!1,intersection:{geometry:t,timeExtent:s,multidimensionalDefinition:a}}}function d(e){switch(e.type){case"point":return e;case"extent":return e.center;case"polygon":{const i=t(e);return i?n.fromJSON(i):null}}return null}function h(e,n){const t=e.dimensions.find(({name:e})=>"StdTime"===e);if(null==t||null==n.start&&null==n.end)return n;n=n.clone();const{start:a,end:s}=n.toJSON(),r=a===s?[a]:null!=a&&null!=s?[a,s]:[a??s];if(2===r.length&&t?.extent.length&&(r[0]=Math.max(r[0],t.extent[0]),r[1]=Math.min(r[1],t.extent[1]??t.extent[0]),r[1]<r[0]))return null;return c([new i({variableName:"",dimensionName:"StdTime",isSlice:1===r.length,values:r})],e,!0)?null:(n.start=new Date(r[0]),n.end=new Date(r[1]??r[0]),n)}function g(e){const{rasterInfo:n,multidimensionalSubset:t}=e,{multidimensionalInfo:i}=n;if(null==i)return null;let a=e.multidimensionalDefinition?.length?e.multidimensionalDefinition:b(n,{multidimensionalSubset:t});if(!a?.length)return null;if(a.some(e=>!e.dimensionName)){const{variableName:e}=a[0],i=b(n,{multidimensionalSubset:t,variableName:e});i?.forEach(e=>{const n=a?.find(({dimensionName:n})=>n===e.dimensionName);n?.values?.length&&(e.values=n.values,e.isSlice=n.isSlice)}),a=i}const{timeExtent:s}=e;if(null!=a&&null!=s&&(null!=s.start||null!=s.end)){a=a.map(e=>e.clone());const e=i.variables.find(({name:e})=>e===a[0].variableName)?.dimensions?.find(({name:e})=>"StdTime"===e),n=a.find(({dimensionName:e})=>"StdTime"===e);if(!e||!n)return null;const{start:t,end:r}=s,l=null==t?null:t.getTime(),u=null==r?null:r.getTime(),o=l??u,m=u??l;if(null!=e.values){const t=e.values.filter(e=>{if(Array.isArray(e)){if(o===m)return e[0]<=o&&e[1]>=o;const n=e[0]<=o&&e[1]>o||e[0]<m&&e[1]>=m,t=e[0]>=o&&e[1]<=m||e[0]<o&&e[1]>m;return n||t}return o===m?e===o:e>=o&&e<=m});if(t.length){const e=t.sort((e,n)=>{const t=Array.isArray(e)?e[0]:e,i=Array.isArray(e)?e[1]:e,a=Array.isArray(n)?n[0]:n,s=Array.isArray(n)?n[1]:n;if(o===m)return t-a;return Math.abs(i-m)-Math.abs(s-m)})[0];n.values=[e]}else a=null}else if(e.hasRegularIntervals&&e.extent){const[t,i]=e.extent;o>i||m<t?a=null:n.values=o===m?[o]:[Math.max(t,o),Math.min(i,m)]}}return null!=a&&c(a,t)?null:a}function v(e,n={}){const{multidimensionalInfo:t,keyProperties:i}=e;if(null==t)return null;const{variableName:a,multidimensionalSubset:s,multidimensionalDefinition:r}=n,l=null!=r?r[0]?.variableName:null,u=a||l||i?.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 b(e,n={}){const t=v(e,n);if(!t)return null;const a=[],{dimensions:s,name:r}=t;if(0===s.length)return[new i({variableName:r,dimensionName:"",values:[],isSlice:!0})];for(let l=0;l<s.length;l++){const e=m(s[l],n.multidimensionalSubset,r);if(!e)return null;const{values:t,extent:u}=e;let o=t?.[0]??u?.[0];"stdz"===e.name.toLowerCase()&&!e.hasRanges&&u&&Math.abs(u[1])<=Math.abs(u[0])&&(o=t?.length?t[t.length-1]:u[1]),a.push(new i({variableName:r,dimensionName:e.name,values:[o],isSlice:!n.useRangeForRangedDimensionInfo||!!e.hasRanges}))}return a}function y(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 D(n,t){if(null==t||null==n)return null;let i=t.variables.map(e=>({...e}));return n?.variables?.length&&(i=i.filter(({name:e})=>n.variables.includes(e)),i.forEach(t=>{t.dimensions=t.dimensions.map(e=>m(e,n,t.name)).filter(e)})),i}function N(e,n){const{values:t}=n;if(t?.length){const n=Array.isArray(t[0]),i=Array.isArray(e);return n!==i?-1:n&&i?t.findIndex(n=>n[0]===e[0]&&n[1]===e[1]):t.indexOf(e)}const{extent:i}=n;if(Array.isArray(e)||!i||e<i[0]||e>i[1])return-1;const a=n.interval||1;if("ISO8601"!==n.unit)return Math.round((e-i[0])/a);const s=i[0];let r=-1;switch(n.intervalUnit?.toLowerCase()||"days"){case"seconds":r=Math.round((e-s)/1e3/a);break;case"minutes":r=Math.round((e-s)/6e4/a);break;case"hours":r=Math.round((e-s)/36e5/a);break;case"days":r=Math.round((e-s)/864e5/a);break;case"months":{const n=new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear(),t=new Date(s).getUTCMonth(),i=new Date(e).getUTCMonth();r=0===n?i-t:i+11-t+12*(n-1)}break;case"years":r=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/a);break;case"decades":r=Math.round((new Date(e).getUTCFullYear()-new Date(s).getUTCFullYear())/10/a)}return r}function T(e){let n=e.values?.length;if(n)return n;const{extent:t,unit:i}=e,a=e.interval||1,s=t?t[1]-t[0]:0;if("ISO8601"!==i)return Math.round(s/a);switch(e.intervalUnit?.toLowerCase()??"seconds"){case"seconds":n=Math.round(s/1e3/a);break;case"minutes":n=Math.round(s/6e4/a);break;case"hours":n=Math.round(s/36e5/a);break;case"days":n=Math.round(s/864e5/a);break;case"months":if(t){const e=new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear(),i=new Date(t[0]).getUTCMonth(),a=new Date(t[1]).getUTCMonth();n=0===e?a-i+1:a+11-i+12*(e-1)+1}else n=0;break;case"years":n=t?Math.round((new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear())/a):0;break;case"decades":n=t?Math.round((new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear())/10/a):0;break;default:n=0}return n}function w(e){if(2!==e.extent?.length||!e.interval)return[];const{extent:[n,t],interval:i}=e;if("ISO8601"===e.unit){const a=e.intervalUnit?.toLowerCase()??"days";return["decades","years","months","days","hours","minutes","seconds"].includes(a)?M(n,t,i,a):[]}const a=Math.round((t-n)/i);return Array.from({length:a},(e,s)=>s===a-1?t:n+s*i)}function M(e,n,t,i){const a=[];let s=e;const r=new Date(e);for(;s<=n;)switch(a.push(s),i){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===a.length?a[1]=n:a[a.length-1]=n,a}function C(e,n){let t=0;const i=e[0].variableName,a=[...n.variables].sort((e,n)=>e.name>n.name?1:-1);for(let s=0;s<a.length;s++){const n=a[s],r=[...n.dimensions].sort((e,n)=>e.name>n.name?-1:1);if(n.name!==i){t+=r.map(e=>T(e)).reduce((e,n)=>e*n);continue}const l=r.map(e=>T(e)),u=r.length;for(let i=0;i<u;i++){const n=e.find(e=>e.dimensionName===r[i].name);if(null==n)return null;const a=N(n.values[0],r[i]);if(-1===a)return null;l.shift(),t+=i===u-1?a:a*l.reduce((e,n)=>e*n)}break}return t}function p(e){return Math.round(24*(e-25569)*3600*1e3)}export{p as convertOleDateTimeToEpoch,s as createSlices,b as getDefaultMultidimensionalDefinition,v as getDefaultVariableInfo,w as getDimensionValues,g as getEffectiveMultidimensionalDefinition,r as getSliceIds,C as getSliceIndex,D as getSubsetVariablesFromMdInfo,M as getTimeDimensionValues,c as hasExcludedVariableOrDimension,f as intersectMultimensionalSubset,y as isMultiSliceOrRangeDefinition};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{isSome as e}from"../../../core/arrayUtils.js";import t from"../../../geometry/SpatialReference.js";import{isWKT2 as n}from"../../../geometry/support/spatialReferenceUtils.js";import{isSameTagIgnoreNS as r,getElementValue as s,getElements as a,getElement as i,getElementNumericValue as l,getElementNumericValues as o}from"./xmlUtilities.js";import f from"../transforms/PolynomialTransform.js";function u(e,t){if(!e||!t)return null;const n=[];for(let r=0;r<e.length;r++)n.push(e[r]),n.push(t[r]);return n}function c(e){const t=i(e,"GeodataXform"),n=d(l(t,"SpatialReference/WKID")||s(t,"SpatialReference/WKT"));if("typens:PolynomialXform"!==t.getAttribute("xsi:type"))return{spatialReference:n,transform:null};const r=l(t,"PolynomialOrder")??1,a=o(t,"CoeffX/Double"),c=o(t,"CoeffY/Double"),m=o(t,"InverseCoeffX/Double"),p=o(t,"InverseCoeffY/Double"),S=u(a,c),C=u(m,p);return{spatialReference:n,transform:S&&C&&S.length&&C.length?new f({spatialReference:n,polynomialOrder:r,forwardCoefficients:S,inverseCoefficients:C}):null}}function m(e){const t=l(e,"NoDataValue"),n=i(e,"Histograms/HistItem"),r=l(n,"HistMin"),o=l(n,"HistMax"),f=l(n,"BucketCount"),u=s(n,"HistCounts")?.split("|").map(e=>Number(e));let c,m,d,p;a(e,"Metadata/MDI").forEach(e=>{const t=Number(e.textContent??e.nodeValue);switch(e.getAttribute("key").toUpperCase()){case"STATISTICS_MINIMUM":c=t;break;case"STATISTICS_MAXIMUM":m=t;break;case"STATISTICS_MEAN":d=t;break;case"STATISTICS_STDDEV":p=t}});const S=l(e,"Metadata/SourceBandIndex");return{noDataValue:t,histogram:u?.length&&null!=r&&null!=o?{min:r,max:o,size:f||u.length,counts:u}:null,sourceBandIndex:S,statistics:null!=c&&null!=m?{min:c,max:m,avg:d,stddev:p}:null}}function d(e){if(!e)return null;let r=Number(e);if(!isNaN(r)&&0!==r)return new t({wkid:r});if(e=String(e).trim(),n(e))return new t({wkt2:e});const s=e.toUpperCase();if(s.startsWith("COMPD_CS")){if(!s.includes("VERTCS")||!s.includes("GEOGCS")&&!s.startsWith("PROJCS"))return null;const n=s.indexOf("VERTCS"),a=s.indexOf("PROJCS"),i=a>-1?a:s.indexOf("GEOGCS");if(-1===i)return null;const l=e.slice(i,e.lastIndexOf("]",n)+1).trim(),o=e.slice(n,e.lastIndexOf("]")).trim();r=p(l);const f=new t(r?{wkid:r}:{wkt:l}),u=p(o);return u&&(f.vcsWkid=u),f}return s.startsWith("GEOGCS")||s.startsWith("PROJCS")?(r=p(e),new t(0!==r?{wkid:r}:{wkt:e})):null}function p(e){const t=e.replaceAll("]","[").replaceAll('"',"").split("[").map(e=>e.trim()).filter(e=>""!==e),n=t[t.length-1].split(","),r=n[0]?.toLowerCase();if(("epsg"===r||"esri"===r)&&e.endsWith('"]]')){const e=Number(n[1]);if(!isNaN(e)&&0!==e)return e}return 0}function S(t){if("pamdataset"!==t?.documentElement.tagName?.toLowerCase())return{};const n={spatialReference:null,transform:null,metadata:{},rasterBands:[],statistics:null,histograms:null};t.documentElement.childNodes.forEach(e=>{if(1===e.nodeType)if(r(e,"SRS")){if(!n.spatialReference){const t=s(e);n.spatialReference=d(t)}}else if(r(e,"Metadata"))if("xml:ESRI"===e.getAttribute("domain")){const{spatialReference:t,transform:r}=c(e);n.transform=r,n.spatialReference||(n.spatialReference=t)}else{a(e,"MDI").forEach(e=>n.metadata[e.getAttribute("key")]=s(e))}else if(r(e,"PAMRasterBand")){const t=m(e);null!=t.sourceBandIndex&&null==n.rasterBands[t.sourceBandIndex]?n.rasterBands[t.sourceBandIndex]=t:n.rasterBands.push(t)}});const i=n.rasterBands;if(i.length){const t=!!i[0].statistics;n.statistics=t?i.map(e=>e.statistics).filter(e):null;const r=!!i[0].histogram;n.histograms=r?i.map(e=>e.histogram).filter(e):null}return n}export{S as parsePAMInfo,d as parseSpatialReference};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import e from"../../../core/Error.js";import{throwIfAborted as t}from"../../../core/promiseUtils.js";import i from"../../../geometry/Extent.js";import n from"../../../geometry/Point.js";import{getByteCount as o}from"../formats/pixelRangeUtils.js";import{snapToRaster as a,clip as r}from"../functions/clipUtils.js";import{transformPixels as s}from"../functions/pixelTransformUtils.js";import{mapPixelValueToAttribute as l,pixelIdFieldName as c,convertPixelBlockToFeatures as p,getValidPixels as f,mosaic as u,countCategoricalPixels as m}from"../functions/pixelUtils.js";import{load as x,projectPolygon as h}from"../functions/rasterProjectionHelper.js";import{computeBoxStatistics as d,computeStatisticsHistograms as y}from"../functions/stretchUtils.js";import w from"../../support/Field.js";import g from"../../support/PixelBlock.js";import{getBandNames as k}from"../../../renderers/support/rasterRendererHelper.js";import b from"../../../rest/support/ImageIdentifyParameters.js";const B=2**30,S=2048,P=2**20,j=20,I=100;async function R(e,t){return"imagery"===e.type?await e.generateRasterInfo(e.rasterFunction,t):e.raster.rasterInfo}function T(e){const t=[new w({name:c,alias:"Pixel ID",type:"oid"})],{pixelType:i}=e,n="f32"===i?"single":"f64"===i?"double":"integer";return k(e).forEach(e=>{t.push(new w({name:e,alias:e,type:n}))}),t.map(e=>e.toJSON())}async function v(t,i){if(t.spatialReference.equals(i))return t;if("polyline"===t.type){const n=(await import("../../../geometry/operators/projectOperator.js")).execute(t,i);if(null==n)throw new e("read-pixels","failed to project the geometry into the layer's spatial reference");return n}if("extent"===t.type||t.rings[0].length<j){const e=(await import("../../../geometry/operators/lengthOperator.js")).execute(t,{unit:"meters"})/I;t=(await import("../../../geometry/operators/densifyOperator.js")).execute(t,e,{unit:"meters"}),await x(),t=h(t,i)}return t}async function z(e,t,i=!1){const{spatialReference:o}=e,r=t?.geometry,s=await v(r??e.extent,o),l="extent"===s.type?s:s.extent,c=null==r||"extent"===r.type&&r.spatialReference.equals(o)?void 0:s,p=new n({x:e.pixelSize.x,y:e.pixelSize.y,spatialReference:o}),f=!!t?.autoResample,u=f?p:t?.pixelSize??p;let{extent:m,width:x,height:h}=a(e,l,u);if(!f)return{extent:m,clipGeometry:c,width:x,height:h,pixelSize:u};const d=e.storageInfo?.pyramidScalingFactor??2;let{x:y,y:w}=u;const g=t?.maxPixelCount??P;for(;x*h>g&&(!i||Math.max(x,h)>1024);)y*=d,w*=d,x/=d,h/=d;return x=Math.round(x),h=Math.round(h),{extent:m,clipGeometry:c,width:x,height:h,pixelSize:new n({x:y,y:w,spatialReference:o})}}async function*M(e,n,o=!1,a){const{extent:s,clipGeometry:l,width:c,height:p}=n,f=s.width/c,u=s.height/p,m=Math.ceil(c/S),x=Math.ceil(p/S),h=f*S,d=u*S,{xmin:y,xmax:w,ymin:g,ymax:k}=s,b=x*m,B={bandIds:n.bandIds?.length?n.bandIds:void 0,interpolation:"nearest",...a};for(let P=0;P<x;P++)for(let n=0;n<m;n++){t(B);const a=new i({xmin:y+n*h,xmax:o?Math.min(w,y+(n+1)*h):y+(n+1)*h,ymax:k-P*d,ymin:o?Math.max(g,k-(P+1)*d):k-(P+1)*d,spatialReference:s.spatialReference}),c={row:P,col:n},p=P*m+n+1;if(l&&!a.intersects(l)){yield{extent:a,pixelBlock:null,id:c,total:b,current:p};continue}const x=o?Math.round(a.width/f):S,j=o?Math.round(a.height/u):S;let{pixelBlock:I}=await e.fetchPixels(a,x,j,B).catch(()=>({pixelBlock:void 0}));I&&l&&(I=await r(I,a,l)),yield{extent:a,pixelBlock:I,id:c,total:b,current:p}}}async function*F(e,i,n){const o=await R(e,n),a=T(o),r={...i,geometry:i?.geometry??o.extent},s=M(e,await z(o,r),!0,n),l=o.width;for await(const c of s){if(!c.pixelBlock){yield{...c};continue}const r=V(e),{pixelBlock:s}=c,{statistics:p,histograms:f}=await K({pixelBlock:s,rasterJobHandler:r},n),u=c;u.statistics=p,u.histograms=f;const m=c.id.row*o.width*S+c.id.col*S;t(n),u.featureSet=await _({pixelBlock:s,extent:c.extent,fields:a,skipFactor:i?.skipFactor??1,rasterJobHandler:r,pixelIdOffset:m,imageRowSize:l},n),t(n),yield u}}function H(t,i,n){const a=o(i),{width:r,height:s}=t;if(r*s*a>B)throw new e("fetch-pixels","failed to fetch pixels as pixel byte count exceeds the 1GB limit");if(n&&r*s>n)throw new e("fetch-pixels",`failed to fetch pixels as pixel count exceeds the ${n} limit`)}async function C(t,i,n){if(!i.geometry)throw new e("fetch-pixels","geometry is required to fetch pixel feature set");const o=await R(t),a=await z(o,i,!0);H(a,o.pixelType);const{extent:r,pixelSize:s}=a,l=Math.round(o.extent.width/s.x),c=T(o),p={fields:c,features:[]},f=p.features,{maxPixelCount:u}=i,m=!!i.autoResample&&null!=u&&a.width*a.height>u,x=m?1:i.skipFactor??1,h=a.width<=S||a.height<=S,d=M(t,a,1===x||h,n);for await(const e of d){if(!e.pixelBlock)continue;const i=V(t),a=Math.floor((o.extent.ymax-e.extent.ymax)/s.y)*l+Math.floor((e.extent.xmin-o.extent.xmin)/s.x),r=await _({pixelBlock:e.pixelBlock,extent:e.extent,fields:c,skipFactor:x,rasterJobHandler:i,pixelIdOffset:a,imageRowSize:l},n);if(r?.features?.length){const{features:e}=r,t=e.length;for(let i=0;i<t;i++){const t=e.pop();f.push(t)}}}if(m&&u){const e=u/(i.skipFactor??1)**2;if(f.length>e){const t=f.length/e,i=[...f],n=f.length-1;f.length=0;for(let o=0,a=0;o<e-1;o++){a+=t;const e=Math.round(a);e<n&&f.push(i[e])}}}return{extent:r,featureSet:p,pixelSize:s}}async function O(e,t,i){const{geometry:n}=t;if("multipoint"===n.type)return J(e,n,i);if("polyline"===n.type)return U(e,n,i);const o=await $(e,{geometry:n},i);if(!o)return null;return d(o)}async function J(e,t,i){const n=await R(e,i),o=t.points.map((e,i)=>t.getPoint(i)).map(t=>q(e,t,i)),a=(await Promise.all(o)).filter(e=>null!=e);if(a.length<=1)return N(a[0]);const r=a[0].map((e,t)=>a.map(e=>e[t]));return d(new g({pixels:r,pixelType:n.pixelType}))}async function q(e,t,i){if("imagery"===e.type){const n=await e.identify(new b({geometry:t,returnCatalogItems:!1}),i).catch(()=>null);return null==n?.value||n.value.includes("NoData")?null:n.value.replaceAll(", "," ").split(" ").map(e=>Number(e))}const n=await e.identify(t,i).catch(()=>null);return n?.value}function N(e){return e?.map(e=>({min:e,max:e,avg:e,median:e,quartile1:e,quartile3:e}))}async function U(e,t,i){const n=await D(e,{geometry:t},i),o=await R(e,i),{bandCount:a,pixelType:r}=o,s=new Array(a).fill(0).map(()=>g.createEmptyBand(r,n.length));let l=0;for(let c=0;c<n.length;c++){const e=n[c];if(null!=e.value){l++;for(let t=0;t<a;t++)s[t][c]=e.value[t]}}l!==n.length&&s.forEach((e,t)=>{s[t]=e.subarray(0,l)});return d(new g({pixels:s,pixelType:r}))}async function A(t,i,n){const o=await R(t,n);if(!o.attributeTable||!o.pixelType.startsWith("u"))return null;const a=o.attributeTable.clone(),r=a.fields.find(e=>"value"===e.name.toLowerCase()),s=a.fields.find(e=>"count"===e.name.toLowerCase());if(!r||!s)throw new e("compute-attribute-table","Value or count field not found in attribute table");const l=2**Number(o.pixelType.slice(1)),c=new Uint32Array(l),{geometry:p}=i;return await L(t,p,(e,t)=>m(e,c),n),a.features.forEach(e=>{const t=e.attributes[r.name];e.attributes[s.name]=c[t]}),a}async function E(e,t,i){const{geometry:n}=t;if("point"===n.type)return q(e,n,i);if("multipoint"===n.type){const t=n.points.map((e,t)=>n.getPoint(t)).map(t=>q(e,t,i)),o=(await Promise.all(t)).filter(e=>null!=e);if(0===o.length)return null;return G(o).map(e=>e/o.length)}const o=await L(e,n,(e,t)=>W(e),i),a=o?.filter(e=>e.count>0);if(!a?.length)return null;const r=G(a.map(e=>e.bandSum)),s=a.map(e=>e.count).reduce((e,t)=>e+t);return r.map(e=>e/s)}function G(e){return e.reduce((e,t)=>e.map((e,i)=>e+t[i]))}function W(e){const{width:t,height:i,pixels:n,mask:o}=e,a=new Array(n.length).fill(0);let r=0;for(let s=0;s<i;s++)for(let e=0;e<t;e++){const i=s*t+e;if(!o||o[i]){for(let e=0;e<n.length;e++)a[e]+=n[e][i];r++}}return{bandSum:a,count:r}}async function D(e,t,i){const n=await L(e,t.geometry,f,i);return n?.flat()??[]}async function L(i,n,o,a){const s=i.spatialReference;if("polyline"===n.type&&!n.spatialReference.equals(s)){const t=(await import("../../../geometry/operators/projectOperator.js")).execute(n,s);if(null==t)throw new e("read-pixels","failed to fetch pixels");n=t}const l="polyline"===n.type?n.extent:n,c=await v(l,s),p="polyline"===n.type?n:c,f=await R(i,a),u={geometry:c,autoResample:!1},m=[],x=M(i,await z(f,u),!0,a);for await(const e of x){if(!e.pixelBlock)continue;const{extent:i}=e,n=o(await r(e.pixelBlock,i,p),i);m.push(n),t(a)}return m}async function K(e,t){const{rasterJobHandler:i}=e,{pixelBlock:n}=e,{statistics:o,histograms:a}=i?await i.computeStatisticsHistograms({pixelBlock:n},t):y(n);return{statistics:o,histograms:a}}async function _(e,t){const{extent:i,fields:n,skipFactor:o,rasterJobHandler:a,pixelIdOffset:r,imageRowSize:s}=e,{pixelBlock:l}=e,c=n.map(({name:e})=>e),f=a?await a.convertPixelBlockToFeatures({pixelBlock:l,extent:i,fieldNames:c,skipFactor:o,pixelIdOffset:r,imageRowSize:s},t):p({pixelBlock:l,extent:i,fieldNames:c,skipFactor:o,pixelIdOffset:r,imageRowSize:s});return f?{fields:n,features:f}:void 0}function V(e){return"_rasterJobHandler"in e?e._rasterJobHandler:null}async function $(e,t,i){const n=await R(e);t={...t,maxPixelCount:t.maxPixelCount??2**28};const o=await z(n,t);o.bandIds=t.bandIds?.length?t.bandIds:void 0,H(o,n.pixelType,t.maxPixelCount);const{width:a,height:r}=o;if(a<=S&&r<=S){const t=o.bandIds?.length?o.bandIds:void 0,{pixelBlock:n}=await e.fetchPixels(o.extent,a,r,{bandIds:t,interpolation:"nearest",...i});return n}const s=[],l=M(e,o,!1,i);for await(const u of l)s.push(u.pixelBlock);if(!s.some(e=>null!=e))return null;const c=Math.ceil(a/S),p=Math.ceil(r/S),f={width:c*S,height:p*S};let m;const x=V(e);if(x){const e=await x.mosaicAndTransform({srcPixelBlocks:s,srcMosaicSize:f,destDimension:f},{...i,transferPixelsToWorker:!0});m=e?.pixelBlock}else m=u(s,f);return m}async function Q(t,i,n){if(!i.geometry)throw new e("compute-statistics-histograms","geometry is required to fetch pixel feature set");let o=await $(t,i,n);if(!o)throw new e("compute-statistics-histograms","failed to get intersecting pixels");const{valueAttributeFieldName:a}=i;if(a&&"value"!==a.toLowerCase()){const e=await R(t,n);o=l(o,e,a)}const r=V(t),{transformType:c}=i;if(c){const e={lambda:i.lambda,shift:i.shift};o=r?await r.transformPixels({pixelBlock:o,transformType:c,transformParameters:e},{...n,transferPixelsToWorker:!0}):s(o,c,e)}const p=i.histogramSize??void 0;return r?await r.computeStatisticsHistograms({pixelBlock:o,histogramSize:p,includeSkewnessKurtosis:!0},{...n,transferPixelsToWorker:!0}):y(o,{histogramSize:p,includeSkewnessKurtosis:!0})}export{O as computeBoxStatistics,A as computeRasterAttributeTable,Q as computeStatisticsHistograms,F as createPixelFeatureSetCursor,C as fetchPixelFeatureSet,E as identifyAveragePixelValue,D as readIntersectingPixels};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import e from"../../../geometry/Extent.js";import t from"../../../geometry/Polygon.js";import{isAxesOrderReversedForWkid as n}from"../../ogc/crsUtils.js";import{convertOleDateTimeToEpoch as i,getDimensionValues as s}from"./multidimensionalUtils.js";import{getElements as a,isSameTagIgnoreNS as o,getElementValue as l,getElementValues as r,getNodeNameIgnoreNS as u,getElement as m,getSpaceDelimitedNumericValues as p}from"./xmlUtilities.js";import c from"../../support/RasterInfo.js";function d(e){e.variables.forEach(e=>e.dimensions.forEach(e=>e.values??=s(e)))}function f(e){return{requestResponseCRSs:r(e,"requestResponseCRSs").map(e=>e.split(":")[1]),nativeCRSs:r(e,"nativeCRSs").map(e=>e.split(":")[1])}}function g(e,t){const n=r(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):l(e,"InterpolationMethods/Default");return null!=i?[i].concat(n.filter(e=>e.toLowerCase()!==i.toLowerCase())):n}function h(e){return null==e?["nearest"]:e.map(e=>{const t=e.toLowerCase();return t.includes("nearest")?"nearest":t.includes("linear")?"bilinear":t.includes("cubic")?"cubic":null}).filter(e=>!!e)}function b(t){const n=a(t,"pos"),i=p(n[0]),s=p(n[1]);return new e({xmin:i[0],ymin:i[1],xmax:s[0],ymax:s[1],spatialReference:{wkid:4326}})}function x(e,t){const n=r(e,t);return n?.length&&""!==n[0]&&!isNaN(Number(n[0]))?n.map(e=>Number(e)):null}function v(e){const t=p(e,"MinimumValue"),n=p(e,"MaximumValue");return t.length&&n.length?t.map((e,t)=>({min:e,max:n[t],avg:-1,stddev:-1})):null}function D(e){return null==e?null:e.every(t=>t===e[0])?e[0]:e}function y(e){const t=[],n=a(e,"RangeSet");let i=[];for(let s=0;s<n.length;s++){const e=l(n[s],"name"),o=l(n[s],"label"),u=[],m=x(n[s],"nullValues/singleValue"),p=a(n[s],"AxisDescription");for(let t=0;t<p.length;t++){const e=l(p[t],"name"),n=l(p[t],"label"),s=r(p[t],"singleValue");if(0===s.length){const e=l(p[t],"min"),n=l(p[t],"max"),i=Number(l(p[t],"res"))||1;if(null!==e&&null!==n)for(let t=parseInt(e,10);t<=parseInt(n,10);t+=i)s.push(t.toString())}"band"===e.toLowerCase()&&(i=s),u.push({name:e,label:n,values:s})}t.push({name:e,label:o,nullValues:m,axis:u})}return{rangeSet:t,bandNames:i}}function w(e=null){if(!e)return{resolution:null,units:null};let t=e.toUpperCase();const n=["Y","M","D"],i=["H","M","S"],s=["Years","Months","Days","Hours","Minutes","Seconds"];let a,o,l;return t.includes("PT")?(t=t.slice(2),l=i.findIndex(e=>t.includes(e)),a=s[3+l],o=parseFloat(t.slice(0,-1))):(t=t.slice(1),l=n.findIndex(e=>t.includes(e)),l>-1&&(a=s[l]),o=parseFloat(t.slice(0,-1))),{resolution:o,units:a}}function S(e){const t=a(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(l(t[n])));return{begin:e[0],end:e[e.length-1],values:e}}const n=m(e,"timePeriod")||m(e,"TimePeriod");if(n){return{begin:new Date(l(n,"beginPosition")||l(n,"BeginPosition")),end:new Date(l(n,"endPosition")||l(n,"EndPosition")),...w(l(n,"timeResolution")||l(n,"TimeResolution"))}}return null}function I(t){const n=m(t,"spatialDomain"),i=m(n,"Envelope")||m(n,"EnvelopeWithTimePeriod"),s=i.getAttribute("srsName").split(":"),o=s[s.length-1],r=a(i,"pos"),u=p(r[0]),c=p(r[1]),d=parseInt(o,10),f=isNaN(d)?null:{wkid:d},g=new e({xmin:u[0],ymin:u[1],xmax:c[0],ymax:c[1],spatialReference:f}),h=m(n,"RectifiedGrid"),b=l(h,"low").split(" "),x=l(h,"high").split(" "),v=parseInt(x[0],10)-parseInt(b[0],10)+1,D=parseInt(x[1],10)-parseInt(b[1],10)+1,y=p(n,"origin/pos"),w=a(n,"offsetVector"),I={envelope:g,columns:v,rows:D,offset:{x:parseFloat(l(w[0]).split(" ")[0]),y:parseFloat(l(w[1]).split(" ")[1])},origin:{x:y[0],y:y[1]}},L=m(t,"temporalDomain")||m(t,"TemporalDomain");return{spatialDomain:I,temporalDomain:L?S(L):null}}function L(e){const t={version:"1.0"};let n,i=[];for(let c=0;c<e.childNodes.length;c++){const s=e.childNodes[c];if(1===s.nodeType)if(o(s,"description"))t.description=l(s);else if(o(s,"name"))t.name=l(s);else if(o(s,"label"))t.label=l(s);else if(o(s,"supportedFormats"))t.supportedFormats=r(s,"formats");else if(o(s,"supportedCRSs"))t.supportedCRSs=f(s);else if(o(s,"supportedInterpolations"))t.supportedInterpolations=g(s,"1.0.0");else if(o(s,"lonLatEnvelope"))t.lonLatEnvelope=b(s);else if(o(s,"rangeSet")){const e=y(s);t.rangeSet=e.rangeSet,i=e.bandNames;const a=e.rangeSet[0].nullValues;a?.length&&(n=D(a))}else o(s,"domainSet")&&(t.domainSet=I(s))}const s=h(t.supportedInterpolations),{name:a,description:u,label:m,lonLatEnvelope:p,supportedFormats:d}=t,{spatialDomain:x}=t.domainSet,v={x:Math.abs(x.offset.x),y:Math.abs(x.offset.y)},w=C(t.domainSet),S=new c({width:x.columns,height:x.rows,pixelSize:v,pixelType:"unknown",extent:x.envelope,spatialReference:x.envelope.spatialReference,bandCount:i.length||1,noDataValue:n,multidimensionalInfo:w});return{id:a,title:t.name,description:u||m,lonLatEnvelope:p,rasterInfo:S,bandNames:i,supportedFormats:d,supportedInterpolations:s,coverageDescription:t,version:"1.0.0",useEPSGAxis:!1}}function C(e){if(!e.temporalDomain)return null;const{begin:t,end:n,values:i,units:s,resolution:a}=e.temporalDomain,o={variables:[{name:"default",description:"",dimensions:[{name:"StdTime",description:"",unit:"ISO8601",values:i?.map(e=>e.getTime()),hasRegularIntervals:!i,interval:a,intervalUnit:s,extent:[t.getTime(),n.getTime()]}]}]};return d(o),o}function T(e,t){const n=[],i=a(e,"Field");let s,o=[];for(let u=0;u<i.length;u++){const e=l(i[u],"Identifier"),p=l(i[u],"Description"),c=l(i[u],"Definition"),d=l(i[u],"Abstract"),f=l(i[u],"Title"),h=x(i[u],"NullValue"),b=m(i[u],"AllowedValues"),D=b?v(b):null,y=g(i[u],"1.1.0"),w=[],S=a(i[u],"Axis");for(let n=0;n<S.length;n++){const e=S[n].getAttribute("identifier"),i=l(S[n],"UOM"),a=l(S[n],"DataType"),u=r(S[n],"Key");t&&!e.toLowerCase().includes("band")||(o=u,s=h),w.push({identifier:e,uom:i,dataType:a,values:u,bandNoDataValues:s})}n.push({identifier:e,description:p,definition:c,abstract:d,title:f,supportedInterpolations:y,axis:w,nullValues:h,statistics:D})}return{rangeSet:n,bandNames:o,bandNoDataValues:s,statistics:n[0].statistics}}function R(e,t){if(!t.temporalDomain)return null;const n=e.filter(e=>!e.identifier.toLowerCase().includes("field_1")&&!e.axis.some(e=>e.identifier.includes("band"))),i=[];if(n.length&&n.forEach(e=>{const t=e.axis.map(e=>{const t=e.values.map(t=>{if("ISO8601"===e.uom){return(t=t.trim()).toLowerCase().includes("z")?new Date(t).getTime():new Date(t+"Z").getTime()}return parseFloat(t.trim())}),n=[Math.min.apply(null,t),Math.max.apply(null,t)];return{name:e.identifier.trim(),description:"",field:e.identifier.trim(),unit:e.uom?e.uom.trim():"",hasRegularIntervals:!1,values:t,extent:n}});i.push({name:e.identifier.trim(),description:e.description?.trim()??"",unit:"",dimensions:t,statistics:e.statistics})}),t.temporalDomain){const{begin:e,end:n,values:s,units:a,resolution:o}=t.temporalDomain;i.some(e=>e.dimensions.some(e=>"stdtime"===e.name.toLowerCase()))||i.forEach(t=>{t.dimensions.push({name:"StdTime",description:"",unit:"ISO8601",values:s?.map(e=>e.getTime()),hasRegularIntervals:!s,interval:o,intervalUnit:a,extent:[e.getTime(),n.getTime()]})})}if(i.length){const e={variables:i};return d(e),e}return null}function M(t){const i=m(t,"SpatialDomain"),s=m(i,"GridCRS"),o=l(s,"GridBaseCRS"),r=l(s,"GridOrigin"),u=r?.split(" ").map(e=>parseFloat(e))??[0,0],c=p(s,"GridOffsets"),d=a(i,"BoundingBox");let f,g,h,b;for(let n=0;n<d.length;n++){const t=d[n].getAttribute("crs")?.toLowerCase();if(null!=t)if(t.includes("imagecrs")){const e=p(d[n],"LowerCorner"),t=p(d[n],"UpperCorner");f=t[0]-e[0]+1,g=t[1]-e[1]+1}else if(t.indexOf("epsg")>0){const i=t.split(":");h=parseInt(i[i.length-1],10);const s=p(d[n],"LowerCorner"),a=p(d[n],"UpperCorner");b=new e({xmin:s[0],ymin:s[1],xmax:a[0],ymax:a[1],spatialReference:{wkid:h}})}}const x=f>g,v=b.xmax-b.xmin>b.ymax-b.ymin;let D=!1;n(h)&&(x===v?D=!1:(D=!0,b=new e({xmin:b.ymin,ymin:b.xmin,xmax:b.ymax,ymax:b.xmax,spatialReference:{wkid:h}})));const y={columns:f,rows:g,origin:{x:u[0],y:u[1]},offset:{x:c[0],y:c[c.length-1]},gridBaseCRS:o,envelope:b,useEPSGAxis:D},w=m(t,"temporalDomain")||m(t,"TemporalDomain");return{spatialDomain:y,temporalDomain:w?S(w):null}}function N(e,t){const n=[],i=[],s={supportedFormats:n,supportedCRSs:i,version:"1.1"};let a,o,r=[];for(let c=0;c<e.childNodes.length;c++){const t=e.childNodes[c];if(1!==t.nodeType)continue;const m=u(t).toLowerCase();switch(m){case"title":case"abstract":case"identifier":s[m]=l(t);break;case"supportedformat":{const e=l(t);n.includes(e)||n.push(e)}break;case"supportedcrs":{const e=l(t);i.includes(e)||i.push(e)}break;case"range":{const e=T(t,!!s.domain?.temporalDomain);s.range=e.rangeSet,r=e.bandNames;const{bandNoDataValues:n}=e;n?.length&&(a=D(n)),o=e.statistics}break;case"domain":s.domain=M(t)}}const m=h(s.range[0].supportedInterpolations),{identifier:p,abstract:d,title:f,domain:g,range:b}=s,x={x:Math.abs(g.spatialDomain.offset.x),y:Math.abs(g.spatialDomain.offset.y)},v=R(b,g);v&&(a=b[0].nullValues,1===a?.length&&(a=a[0]));const y=new c({width:g.spatialDomain.columns,height:g.spatialDomain.rows,pixelSize:x,pixelType:"unknown",extent:g.spatialDomain.envelope,spatialReference:g.spatialDomain.envelope.spatialReference,bandCount:r.length||1,noDataValue:a,statistics:o,multidimensionalInfo:v});return{id:p,title:s.title,description:d||f,bandNames:r,rasterInfo:y,supportedFormats:n,supportedInterpolations:m,coverageDescription:s,version:t,useEPSGAxis:g.spatialDomain.useEPSGAxis}}function P(t){const n=m(t,"Envelope")||m(t,"EnvelopeWithTimePeriod"),i=n.getAttribute("srsName"),s=i.slice(i.lastIndexOf("/")+1),a=n.getAttribute("axisLabels").split(" ").map(e=>e.trim()).filter(e=>""!==e.trim()),r=p(n,"lowerCorner"),u=p(n,"upperCorner"),c=!["y","lat","latitude","north","nor","n","b"].includes(a[0].toLowerCase());let d;const f=parseInt(s,10),g=isNaN(f)?null:{wkid:f};d=new e(c?{xmin:r[0],ymin:r[1],xmax:u[0],ymax:u[1],spatialReference:g}:{xmin:r[1],ymin:r[0],xmax:u[1],ymax:u[0],spatialReference:g});const h={mins:r,maxs:u},b=n.getAttribute("uomLabels").trim().split(" ");let x,v;if(o(n,"EnvelopeWithTimePeriod")){x=new Date(l(t,"beginPosition")||l(t,"BeginPosition")),v=new Date(l(t,"endPosition")||l(t,"EndPosition"));const e=b?.findIndex(e=>"oledatetime"===e?.toLowerCase());e>-1&&(b[e]="ISO8601")}return{envelope:d,axisLabels:a,uomLabels:b.length?b:null,envelopeAllDims:h,beginPosition:x,endPosition:v,isEastFirst:c}}function E(e,t){const n=[],i=a(e,"DataRecord"),s=[];let o,r=[];for(let u=0;u<i.length;u++){const e=a(i[u],"field"),c=[];for(let n=0;n<e.length;n++){const i=e[n].getAttribute("name"),a=l(e[n],"description")||"",u=m(e[n],"uom")?.getAttribute("code")||"",d=p(e[n],"interval"),f=x(e[n],"nilValue")?.[0];t&&!i.toLowerCase().includes("band")||(s.push(i),d?.length&&(o=o||[],o.push({min:d[0],max:d[1],avg:-1,stddev:-1})),r.push(f)),c.push({name:i,description:a,uom:u,allowedValues:d,nilValue:f})}n.push(c)}return r.some(e=>null!=e)||(r=null),{rangeType:n,bandNames:s,bandStats:o,bandNoDataValues:r}}function V(e){let t=1,n="";const i=.01;return Math.abs(e-1/24)<1/24*i?n="Hours":Math.abs(e-1)<1*i?n="Days":e<1?(t=Math.round(24*e),n="Hours"):e>28-i&&e<31+i||Math.round(e/30)<12?n="Months":e>365-i&&e<366+i&&(n="Years"),{interval:t,intervalUnit:n}}function A(e,t,n){if(n.axisLabels.length<=2)return null;const s=[];for(let i=0;i<e.length;i++){const t=e[i];for(let e=0;e<t.length;e++)t[e].name.toLowerCase().includes("band")||s.push(t[e])}const a=[];if(s.length){const e=[];for(let s=2;s<n.axisLabels.length;s++){const a=t.uomLabels?.[s]?.trim()??"",o=n.axisLabels[s].toLowerCase().includes("time")||"iso8601"===a.toLowerCase()||"oledatetime"===a.toLowerCase();let l,r;if(o){const e=V(n.offset[s]);l=e.interval,r=e.intervalUnit}else l=n.offset[s],r=a;const u=[];o?(u.push(i(t.envelopeAllDims.mins[s])),u.push(i(t.envelopeAllDims.maxs[s]))):(u.push(t.envelopeAllDims.mins[s]),u.push(t.envelopeAllDims.maxs[s])),e.push({name:n.axisLabels[s].trim(),description:n.axisLabels[s].trim(),unit:o?"ISO8601":a,hasRegularIntervals:!0,extent:u,interval:l,intervalUnit:r})}if(s.forEach(t=>{const{allowedValues:n}=t,i=2===n?.length?[{min:n[0],max:n[1],avg:-1,stddev:-1}]:null;a.push({name:t.name.trim(),description:t.description?.trim()??"",unit:t.uom.trim(),statistics:i,dimensions:[...e]})}),a.length){const e={variables:a};return d(e),e}}return null}function F(e,t){const n=m(e,"RectifiedGrid"),i=p(n,"low"),s=p(n,"high"),o=[];for(let a=0;a<i.length;a++)o.push(s[a]-i[a]+1);const r=l(n,"axisLabels").split(" "),u=p(n,"origin/pos"),c=a(n,"offsetVector"),d=[];for(let a=0;a<c.length;a++){const e=p(c[a]),t=e.findIndex(e=>0!==e);d[t]=e[t]}const f=["y","lat","latitude","north","nor","n","b"];let g=!1;if(t?.length&&r?.length){g=[...t].sort((e,t)=>e<t?-1:1).join(",")===[...r].sort((e,t)=>e<t?-1:1).join(",")}const h=g?r:t;let b,x,v;return f.includes(h[0].toLowerCase())?(b=o[1],x=o[0],v={y:Math.abs(d[0]),x:Math.abs(d[1])}):(b=o[0],x=o[1],v={x:Math.abs(d[0]),y:Math.abs(d[1])}),{columns:b,rows:x,origin:u,offset:d,resolution:v,gridSamples:o,axisLabels:r,hasSameAxisLabelsAsBoundedBy:g}}function O(e){const n=m(e,"EarthObservation");if(!n)return null;const i=m(n,"phenomenonTime"),s=i?S(i):null,a=m(n,"phenomenonTime"),o=a?S(a):null,r=l(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let u=null;if(r){const e=r.split(" ").map(e=>e.trim()).filter(e=>null!=e&&""!==e).map(Number);if(e.length){const n=[];for(let t=0;t<e.length/2;t+=2)n.push(e[t],e[t+1]);u=new t({rings:[[n]]})}}return{observation:{phenomenonTime:s,resultTime:o,footprint:u,identifier:l(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:l(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:l(e,"metaDataProperty/EarthObservationMetaData/status")}}}function B(e){const t={version:"2.0"};let n,i,s=[];for(let c=0;c<e.childNodes.length;c++){const a=e.childNodes[c];if(1===a.nodeType)if(o(a,"coverageId"))t.coverageId=l(a);else if(o(a,"ServiceParameters"))t.serviceParameters={supportedFormats:r(a,"nativeFormat")};else if(o(a,"boundedBy"))t.boundedBy=P(a);else if(o(a,"rangeType")){const e=E(a,t.boundedBy?.axisLabels.length>2||t.domainSet?.axisLabels.length>2);t.rangeType=e.rangeType,s=e.bandNames,n=e.bandStats;const{bandNoDataValues:o}=e;o?.length&&(i=D(o))}else if(o(a,"domainSet"))t.domainSet=F(a,t.boundedBy?.axisLabels);else if(o(a,"metadata")){const e=m(a,"EOMetadata");t.eoMetadata=e?O(e):null}}const{coverageId:a,boundedBy:u,domainSet:p,rangeType:d,serviceParameters:f}=t,g=A(d,u,p);!n&&g&&(n=g?.variables[0].statistics),null!=g&&(i=d[0][0].nilValue);return{id:a,title:a,description:a,bandNames:s,rasterInfo:new c({width:p.columns,height:p.rows,pixelSize:p.resolution,pixelType:"unknown",extent:u.envelope,spatialReference:u.envelope.spatialReference,bandCount:s.length||1,statistics:n,noDataValue:i,multidimensionalInfo:g}),supportedFormats:f.supportedFormats,coverageDescription:t,version:"2.0.1",useEPSGAxis:!1}}function k(e,t){let n=null;if("string"==typeof e){n=(new DOMParser).parseFromString(e,"text/xml")}else n=e;if("1.0.0"===t){return a(n,"CoverageOffering").map(e=>L(e))}const i=a(n,"CoverageDescription");return"1.1.0"===t||"1.1.1"===t||"1.1.2"===t?i.map(e=>N(e,t)):i.map(e=>B(e))}export{k as parseCoverages,h as standardizeInterpolations};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{getAssetUrl as e}from"../../../assets.js";const t=[{pixelType:"S8",size:1,ctor:Int8Array,range:[-128,127]},{pixelType:"U8",size:1,ctor:Uint8Array,range:[0,255]},{pixelType:"S16",size:2,ctor:Int16Array,range:[-32768,32767]},{pixelType:"U16",size:2,ctor:Uint16Array,range:[0,65536]},{pixelType:"S32",size:4,ctor:Int32Array,range:[-2147483648,2147483647]},{pixelType:"U32",size:4,ctor:Uint32Array,range:[0,4294967296]},{pixelType:"F32",size:4,ctor:Float32Array,range:[-34027999387901484e22,34027999387901484e22]},{pixelType:"F64",size:8,ctor:Float64Array,range:[-17976931348623157e292,17976931348623157e292]}];let n=null;function r(){return n||(n=import("../../../chunks/lerc-wasm.js").then(e=>e.l).then(({default:t})=>t({locateFile:t=>e(`esri/layers/raster/formats/${t}`)})).then(e=>{l(e)}),n)}const a={getBlobInfo:null,decode:null};function o(e){return 16+(e>>3<<3)}function s(e,t,n){n.set(e.slice(t,t+n.length))}function l(e){const{_malloc:n,_free:r,_lerc_getBlobInfo:l,_lerc_getDataRanges:i,_lerc_decode_4D:u,asm:f}=e;let c;const h=Object.values(f).find(t=>t&&"buffer"in t&&t.buffer===e.HEAPU8.buffer),y=e=>{const t=e.map(e=>o(e)),r=t.reduce((e,t)=>e+t),a=n(r);c=new Uint8Array(h.buffer);let s=t[0];t[0]=a;for(let n=1;n<t.length;n++){const e=t[n];t[n]=t[n-1]+s,s=e}return t};a.getBlobInfo=e=>{const t=12,n=3,a=new Uint8Array(4*t),o=new Uint8Array(8*n),[u,f,p]=y([e.length,a.length,o.length]);c.set(e,u),c.set(a,f),c.set(o,p);let g=l(u,e.length,f,p,t,n);if(g)throw r(u),new Error(`lerc-getBlobInfo: error code is ${g}`);c=new Uint8Array(h.buffer),s(c,f,a),s(c,p,o);const d=new Uint32Array(a.buffer),b=new Float64Array(o.buffer),[w,A,,m,U,x,C,V,T,D,z]=d,I={version:w,depthCount:D,width:m,height:U,validPixelCount:C,bandCount:x,blobSize:V,maskCount:T,dataType:A,minValue:b[0],maxValue:b[1],maxZerror:b[2],statistics:[],bandCountWithNoData:z};if(z&&D>1)return r(u),I;if(1===D&&1===x)return r(u),I.statistics.push({minValue:b[0],maxValue:b[1]}),I;const F=D*x*8,_=new Uint8Array(F),k=new Uint8Array(F);let B=u,S=0,v=0,E=!1;if(c.byteLength<u+2*F?(r(u),E=!0,[B,S,v]=y([e.length,F,F]),c.set(e,B)):[S,v]=y([F,F]),c.set(_,S),c.set(k,v),g=i(B,e.length,D,x,S,v),g)throw r(B),E||r(S),new Error(`lerc-getDataRanges: error code is ${g}`);c=new Uint8Array(h.buffer),s(c,S,_),s(c,v,k);const O=new Float64Array(_.buffer),$=new Float64Array(k.buffer),j=I.statistics;for(let r=0;r<x;r++)if(D>1){const e=O.slice(r*D,(r+1)*D),t=$.slice(r*D,(r+1)*D),n=Math.min.apply(null,e),a=Math.max.apply(null,t);j.push({minValue:n,maxValue:a,depthStats:{minValues:e,maxValues:t}})}else j.push({minValue:O[r],maxValue:$[r]});return r(B),E||r(S),I},a.decode=(e,n)=>{const{maskCount:a,depthCount:o,bandCount:l,width:i,height:f,dataType:p,bandCountWithNoData:g}=n,d=t[p],b=i*f,w=new Uint8Array(b*l),A=b*o*l*d.size,m=new Uint8Array(A),U=new Uint8Array(l),x=new Uint8Array(8*l),[C,V,T,D,z]=y([e.length,w.length,m.length,U.length,x.length]);c.set(e,C),c.set(w,V),c.set(m,T),c.set(U,D),c.set(x,z);const I=u(C,e.length,a,V,o,i,f,l,p,T,D,z);if(I)throw r(C),new Error(`lerc-decode: error code is ${I}`);c=new Uint8Array(h.buffer),s(c,T,m),s(c,V,w);let F=null;if(g){s(c,D,U),s(c,z,x),F=[];const e=new Float64Array(x.buffer);for(let t=0;t<U.length;t++)F.push(U[t]?e[t]:null)}return r(C),{data:m,maskData:w,noDataValues:F}}}function i(e,t,n,r,a){if(n<2)return e;const o=new r(t*n);for(let s=0,l=0;s<t;s++)for(let r=0,a=s;r<n;r++,a+=t)o[a]=e[l++];return o}function u(e,n={}){const r=n.inputOffset??0,o=e instanceof Uint8Array?e.subarray(r):new Uint8Array(e,r),s=a.getBlobInfo(o),{data:l,maskData:u,noDataValues:f}=a.decode(o,s),{width:c,height:h,bandCount:y,depthCount:p,dataType:g,maskCount:d,statistics:b}=s,w=t[g],A=new w.ctor(l.buffer),m=[],U=[],x=c*h,C=x*p;for(let t=0;t<y;t++){const e=A.subarray(t*C,(t+1)*C);if(n.returnInterleaved)m.push(e);else{const t=i(e,x,p,w.ctor);m.push(t)}U.push(u.subarray(t*C,(t+1)*C))}const V=0===d?null:1===d?U[0]:new Uint8Array(x);if(d>1){V.set(U[0]);for(let e=1;e<U.length;e++){const t=U[e];for(let e=0;e<x;e++)V[e]=V[e]&t[e]}}const{noDataValue:T}=n,D=null!=T&&w.range[0]<=T&&w.range[1]>=T;if(d>0&&D)for(let t=0;t<y;t++){const e=m[t],n=U[t]||V;for(let t=0;t<x;t++)0===n[t]&&(e[t]=T)}const z=d===y&&y>1?U:null,{pixelType:I}=w;return{width:c,height:h,bandCount:y,pixelType:I,depthCount:p,statistics:b,pixels:m,mask:V,bandMasks:z,noDataValues:f}}function f(e,t={}){const n=e instanceof Uint8Array?e.subarray(t.inputOffset??0):new Uint8Array(e,t.inputOffset??0);return a.getBlobInfo(n)}export{u as decode,f as getBlobInfo,r as load,t as pixelTypeInfoMap};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/*
|
|
2
|
+
All material copyright Esri, All Rights Reserved, unless otherwise specified.
|
|
3
|
+
See https://js.arcgis.com/5.0/esri/copyright.txt for details.
|
|
4
|
+
*/
|
|
5
|
+
import{getAssetUrl as t}from"../../../assets.js";const n=new Set(["uint8","int8","uint16","int16","uint32","int32","int64","uint64"]),r=new Map([["uint8",{byteCount:1,ctor:Uint8Array}],["int8",{byteCount:1,ctor:Int8Array}],["uint16",{byteCount:2,ctor:Uint16Array}],["int16",{byteCount:2,ctor:Int16Array}],["uint32",{byteCount:4,ctor:Uint32Array}],["int32",{byteCount:4,ctor:Int32Array}],["uint64",{byteCount:8,ctor:BigUint64Array}],["int64",{byteCount:8,ctor:BigInt64Array}]]);let e;function o(){return e??=import("../../../chunks/qb3-wasm.js").then(({default:n})=>n({locateFile:n=>t(`esri/layers/raster/formats/${n}`)})).then(t=>{u(t)}),e}const i={getBlobInfo:null,decode:null};function a(t){if(!r.has(t))throw new Error("Unsupported data type: "+t);return r.get(t)}function u(t){const{_GetInfo:r,_decode:e,_malloc:o,_free:u,writeArrayToMemory:c,UTF8ToString:l}=t;i.getBlobInfo=t=>{t.length>1e3&&(t=t.slice(0,1e3));const n=o(t.length);c(t,n);const e=r(n,t.length);if(u(n),!e)return null;const i=l(e);u(e);try{const t=JSON.parse(i);return{width:t.xsize,height:t.ysize,bandCount:t.nbands,dataType:t.dtype,mode:t.mode,bandMap:t.bandmap}}catch{return null}},i.decode=(r,o)=>{const{dataType:i,width:u,height:c,bandCount:l}=o;if(!n.has(i))throw new Error("Unsupported data type: "+i);const{_malloc:s,_free:y}=t,d=s(r.length);t.writeArrayToMemory(r,d);const{ctor:f,byteCount:h}=a(i),g=u*c*l*h,b=s(g),w=s(1024);if(0===e(d,r.length,b,w))throw y(d),y(b),y(w),new Error("Decoding failed: "+t.UTF8ToString(w));const A=new f(t.HEAPU8.slice(b,b+g).buffer);if(y(d),y(b),y(w),A instanceof BigInt64Array||A instanceof BigUint64Array){const t=new Float64Array(A.length);for(let n=0;n<A.length;n++)t[n]=Number(A[n]);return t}return A}}function c(t){const n=new Uint8Array(t),r=i.getBlobInfo(n);if(!r)return null;const e=i.decode(n,r);if(!e)return null;const{width:o,height:u,bandCount:c,dataType:l}=r,{ctor:s}=a(l),y=s===BigInt64Array||s===BigUint64Array?Float64Array:s,d=Array.from({length:c},()=>new y(o*u));for(let i=0,a=0;i<o*u;i++)for(let t=0;t<c;t++)d[t][i]=e[a++];return{width:o,height:u,pixels:d}}export{c as decode,o as load};
|