@arcgis/core 5.0.0-next.43 → 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/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/{324d66962aeec17d3e28.js → 1e0e7cef7ef947894bbe.js} +1 -1
- 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/{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/{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/897ce6fc9cefb1e14a64.js +1 -0
- package/assets/esri/core/workers/chunks/992e9bbdf9d3787ddb0e.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/{385cfd3087f00dbd1146.js → ca1c65eb7f5900c60170.js} +1 -1
- package/assets/esri/core/workers/chunks/cddce67919e13e2f365e.js +1 -0
- package/assets/esri/core/workers/chunks/e6784251bbb8b71ead93.js +1 -0
- package/assets/esri/core/workers/chunks/{96f798ee286b59396131.js → ea3cba01c60d9bc72719.js} +1 -1
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/config.js +1 -1
- package/interfaces.d.ts +78 -2
- 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/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/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/layers/ImageryLayerView2D.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.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/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Graphics3DMeshFillSymbolLayer.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/lib/TextureBackedBuffer/TextureBackedBufferLayout.js +1 -1
- package/views/3d/webgl-engine/lib/TextureBackedBuffer/TextureBufferView.js +1 -1
- package/views/3d/webgl-engine/materials/ColorMaterial.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/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/DOMContainer.js +1 -1
- package/views/GroundView.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/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/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/646f58b69d2354f1ef27.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/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
|
@@ -1,5 +0,0 @@
|
|
|
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 r from"../../../core/Logger.js";import{onAbort as n}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{sanitizeUrl as h}from"../arcgisLayerUrl.js";import{url as p}from"../commonProperties.js";import d from"../DimensionalDefinition.js";import x from"../LOD.js";import y from"../RasterStorageInfo.js";import g from"../TileInfo.js";import{isFunctionRaster as I,getPixelSpaceCoverage as R}from"./datasetUtils.js";import{isMultiSliceOrRangeDefinition as w,getSliceIndex as S,createSlices as b,getSliceIds as k}from"./multidimensionalUtils.js";import{getRasterId as T,getBlock as v,putBlock as P,deleteBlock as B,decreaseRefCount as _}from"./RawBlockCache.js";import{convertNoDataToMask as M}from"../rasterFormats/pixelRangeUtils.js";import{decode as W}from"../rasterFormats/RasterCodec.js";import{mosaic as C,approximateTransform as H,getLocalArithmeticNorthRotations as z,compositeBands as L}from"../rasterFunctions/pixelUtils.js";import{getWorldWidth as E,load as j,projectPoint as D,snapPyramid as O,shiftExtent as F,getWorldWrapCount as A,projectExtent as q,getProjectionOffsetGrid as G,getRasterDatasetAlignmentInfo as J,projectResolution as N}from"../rasterFunctions/rasterProjectionHelper.js";import{convertToLocalDirections as V,uvComponentToVector as U}from"../rasterFunctions/vectorFieldUtils.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:g.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){const{rasterInfo:e}=this,t=E(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),I(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||"rasterId-"+X++}set url(e){this._set("url",h(e,r.getLogger(this)))}async open(e){return this._openPromise??=j().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,o,r={}){const n=r.tileInfo||this.rasterInfo.storageInfo.tileInfo,s=this.getTileExtentFromTileInfo(e,t,o,n);if(!s)throw new i("imagery-tile:out-of-bounds","Level for fetch tile out of range");return r={noClip:!0,...r},this.fetchPixels(s,n.size[0],n.size[1],r)}async identify(e,t={}){e=c(u,e).clone().normalize();const{multidimensionalDefinition:i,timeExtent:o}=t,{rasterInfo:r}=this,{hasMultidimensionalTranspose:n,multidimensionalInfo:s}=r;let{transposedVariableName:l}=t;const a=null!=s&&n&&(null!=o||w(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:h}=r,{datumTransformation:p}=t;let d=D(e,m,p);if(!h.intersects(d))return{location:d,value:null};if(null!=r.transform){const e=r.transform.inverseTransform(d);if(!r.nativeExtent.intersects(e))return{location:e,value:null};d=e}let x=0;const y=null!=l&&null!=s&&r.hasMultidimensionalTranspose;if(I(this)){const e=this.primaryRasters.rasters[0];if(y)return e.identify(d,t);const{pixelSize:o}=r,n=3,s=o.x*n/2,l=o.y*n/2,a=new f({xmin:d.x-s,xmax:d.x+s,ymin:d.y-l,ymax:d.y+l,spatialReference:m}),c={interpolation:"nearest",multidimensionalDefinition:i,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:u}=await e.fetchPixels(a,n,n,c),{pixelBlock:h}=await this.fetchPixels(a,n,n,c);if(null==u)return{location:d,value:null};const p=Math.floor(n*n*.5),x=!u.mask||u.mask[p]?u.pixels.map(e=>e[p]):null;let g;return null!=h&&(g=!h.mask||h.mask[p]?h.pixels.map(e=>e[p]):void 0),{location:d,value:x,processedValue:g,pyramidLevel:0}}if(!y)if(t.srcResolution){x=O(t.srcResolution,r,this.ioConfig.sampling).pyramidLevel}else if(x=await this.computeBestPyramidLevelForLocation(e,t),null==x)return{location:d,value:null};const g=this.identifyPixelLocation(d,x,null,y);if(null===g)return{location:d,value:null};const{row:R,col:S,rowOffset:b,colOffset:k,blockWidth:T}=g,v=await this._fetchRawTile(x,R,S,t);if(!v?.pixels?.length)return{location:d,value:null};const P=b*T+k;return this._processIdentifyResult(v,{srcLocation:d,position:P,pyramidLevel:x,useTransposedTile:!!y,requestSomeSlices:a,identifyOptions:t})}async fetchPixels(e,t,i,o={}){e=F(e),o=this._getRequestOptionsWithSliceId(o);const{_hasNoneOrGCSShiftTransform:r}=this;if(o.requestRawData&&r)return this._fetchPixels(e,t,i,o);const n=E(e.spatialReference),s=A(e);if(null==n||0===s||1===s&&this._isGlobalWrappableSource&&r)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(n/(c-a)*t),m=u-Math.round((n/2-a)/(c-a)*t);let h=0;const p=[];for(let g=0;g<=s;g++){const r=new f({xmin:0===g?a:-n/2,xmax:g===s?c-n*g:n/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(r,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=C(d,y,{blockWidths:p});return{extent:e,srcExtent:q(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 r=await this._fetchRawTiles(e,t,i,o),{nativeExtent:n,nativePixelSize:s,storageInfo:l}=this.rasterInfo,a=2**e,c=s.x*a,u=s.y*a,m=new f({xmin:n.xmin+c*t.x,xmax:n.xmin+c*(t.x+i.width-1),ymin:n.ymax-u*(t.y+i.height-1),ymax:n.ymax-u*t.y,spatialReference:n.spatialReference});if(!r)return{extent:m,srcExtent:m,pixelBlock:null};const{pixelBlocks:h,mosaicSize:p}=r;if(1===h.length&&null!=h[0]&&h[0].width===i.width&&h[0].height===i.height)return{extent:m,srcExtent:m,pixelBlock:r.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=C(h,p,{clipOffset:y,clipSize:i});return{extent:m,srcExtent:m,pixelBlock:g}}fetchRawTile(e,t,o,r){throw new i("BaseRaster:read-not-implemented","fetchRawTile() is not implemented")}computeExtent(e){return q(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return!this.rasterJobHandler||t.useCanvas?W(e,t):this.rasterJobHandler.decode({data:e,options:t})}async request(e,i,o=0){const{customFetchParameters:r}=this.ioConfig,{range:n,query:s,headers:l}=i;o=o??i.retryCount??this.ioConfig.retryCount;const a=n?{Range:`bytes=${n.from}-${n.to}`}:null;try{return await t(e,{...i,query:{...s,...r},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:S(e,t)}getTileExtentFromTileInfo(e,t,i,o){const r=o.lodAt(e);return r?this.getTileExtent({x:r.resolution,y:r.resolution},t,i,o.origin,o.spatialReference,o.size):null}updateTileInfo(){const{storageInfo:e,spatialReference:t,extent:i,pixelSize:o}=this.rasterInfo,{pyramidResolutions:r}=e;if(!e.tileInfo){const n=[],s=e.maximumPyramidLevel||0;let l=(o.x+o.y)/2,a=1/.0254*96*l;for(let e=0;e<=s&&(n.unshift(new x({level:s-e,resolution:l,scale:a})),e!==s);e++)if(r){const t=(r[e].x+r[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 g({origin:c,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:n}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,i=512,o){const{width:r,height:n,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(r,n))/Math.LN2-8)));const f=this.computeBlockBoundary(s,512,512,{x:s.xmin,y:s.ymax},[l],o);e.storageInfo=new y({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,r,n=0,s=2){if(1===r.length&&n>0){r=[...r];let{x:e,y:t}=r[0];for(let i=0;i<n;i++)e*=s,t*=s,r.push({x:e,y:t})}const l=[],{x:a,y:c}=o;for(let f=0;f<r.length;f++){const{x:o,y:n}=r[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*n)/i/n),maxRow:Math.floor((c-e.ymin-.1*n)/i/n)})}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 r=o**e;return{x:t.x*r,y:t.y*r}}identifyPixelLocation(e,t,i,o){const{spatialReference:r,nativeExtent:n,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=D(e,r,i);if(!n.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,r,n){const[s,l]=n,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:r})}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,r=m.WebMercator;e.spatialReference=r,e.extent=e.nativeExtent=new f({xmin:-.5,ymax:.5,xmax:i-.5,ymin:.5-o,spatialReference:r}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new u({x:1,y:1,spatialReference:r});const{extent:n,storageInfo:s}=e;if(s){s.origin=new u({x:n.xmin,y:n.ymax,spatialReference:r});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 r=A(e);if(r>=2)return{extent:e,pixelBlock:null};const n=this._getSourceDataInfo(e,t,i,o),{pyramidLevel:s,srcResolution:l,srcExtent:a,srcWidth:c,srcHeight:f,ul:m}=n;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!=E(e.spatialReference);!d&&x||(r=A(n.srcExtent,d));const y=await this._fetchRawTiles(s,m,{width:c,height:f,wrapCount:r},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,v=new u({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/i,spatialReference:e.spatialReference}),P=!e.spatialReference.equals(b),B=b.isGeographic?1e-9:1e-4,{datumTransformation:_}=o;if(!P&&T&&1===y.pixelBlocks.length&&I===t&&R===i&&Y(l,v,B))return{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:y.pixelBlocks[0]};const M=x&&null!=E(a.spatialReference)&&this._hasNoneOrGCSShiftTransform,W=o.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith("vector");W&&!this.rasterJobHandler&&await j();const L=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:v.toJSON(),datumTransformation:_,rasterTransform:p,hasWrapAround:r>0||M,isAdaptive:!1!==this.ioConfig.optimizeProjectionAccuracy,includeGCSGrid:W},o):G({projectedExtent:e,srcBufferExtent:y.extent,pixelSize:v,datumTransformation:_,rasterTransform:p,hasWrapAround:r>0||M,isAdaptive:!1,includeGCSGrid:W});let D;const O=!o.requestRawData,F={rows:L.spacing[0],cols:L.spacing[1]},q=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(s,y.extent.xmin):void 0,{pixelBlocks:J,mosaicSize:N,isPartiallyFilled:U}=y;let Q=null;if(this.rasterJobHandler){const e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:J,srcMosaicSize:N,destDimension:O?{width:t,height:i}:null,coefs:O?L.coefficients:null,sampleSpacing:O?F:null,projectDirections:W,gcsGrid:W?L.gcsGrid:null,isUV:"vector-uv"===this.rasterInfo.dataType,interpolation:o.interpolation,alignmentInfo:q,blockWidths:null},o);({pixelBlock:D,localNorthDirections:Q}=e)}else{const e=C(J,N,{alignmentInfo:q});D=O?H(e,{width:t,height:i},L.coefficients,F,o.interpolation):e,W&&L.gcsGrid&&(Q=z({width:t,height:i},L.gcsGrid),D=V(D,this.rasterInfo.dataType,Q))}return o.requestRawData||W?{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:D,transformGrid:L,localNorthDirections:Q,isPartiallyFilled:U}:{extent:e,srcExtent:a,srcTilePixelSize:k,pixelBlock:D}}async _fetchRawTiles(e,t,i,o){const{origin:r,blockBoundary:n}=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=n[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:r.x+g*s*z,xmax:r.x+(R+1)*s*z,ymin:r.y-(w+1)*l*L,ymax:r.y-I*l*L,spatialReference:C}),pixelBlocks:M,mosaicSize:W,isPartiallyFilled:B}}_fetchRawTile(e,t,i,o){const{storageInfo:r}=this.rasterInfo,s=null!=r.transposeInfo&&!!o.transposedVariableName;if(!s){const o=r.blockBoundary[e];if(!o)return Promise.resolve(null);const{minRow:n,minCol:s,maxCol:l,maxRow:a}=o;if(t<n||i<s||t>a||i>l)return Promise.resolve(null)}const l=s?o.transposeVariableName:o.sliceId,a=r.isBsqTile?o.bandIds:null,c=T(this.rasterId,l,a),f=`${e}/${t}/${i}`;let u=v(c,o.registryId,f);if(null==u){const n=new AbortController,s=o.bandIds?.slice();if(s?.length&&r.isBsqTile){const r=new Set(s),l=[],a=Array.from(r);for(const s of a)l.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:i,options:{...o,bandIds:[s]}},{signal:n.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:n.signal,transferPixelsToWorker:!0}):L(e)})}else u=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:i,options:o},{signal:n.signal});P(c,o.registryId,f,u,n),u.catch(()=>B(c,o.registryId,f))}return o.signal&&n(o,()=>{_(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[r,n]=e,s=[],l=[];for(let a=0;a<o;a++){const[e,t]=U([r[a],n[a]]);s.push(e),l.push(t)}return[s,l]}_getRasterTileAlignmentInfo(e,t){return null==this._rasterTileAlignmentInfo&&(this._rasterTileAlignmentInfo=J(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 r={datumTransformation:o.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};o.srcResolution&&(r.srcResolution=o.srcResolution,this._updateSourceDataInfo(e,r));const n=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:s,srcHeight:l,pyramidLevel:a}=r,c=s/t,f=l/i,m=a<n&&c*f>=16,h=a===n&&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=N(s,this.rasterInfo.spatialReference,e,r.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(n-a+3>=e){const t=2**e;l={x:o.srcResolution.x*t,y:o.srcResolution.y*t}}}l&&(r.srcResolution=l,this._updateSourceDataInfo(e,r))}return this._requireTooManySrcTiles(r.srcWidth,r.srcHeight,t,i)&&(r.srcWidth=0,r.srcHeight=0),r}_requireTooManySrcTiles(e,t,i,o){const{tileInfo:r}=this.rasterInfo.storageInfo,n=Math.ceil(e/r.size[0])*Math.ceil(t/r.size[1]),s=e/i,l=t/o,a=Math.max(1,(i+o)/1024);return n>=$*a||s>Q||l>Q}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;const{rasterInfo:i}=this,o=i.spatialReference,{srcResolution:r,datumTransformation:n}=t,{pyramidLevel:s,pyramidResolution:l,excessiveReading:a}=O(r,i,this.ioConfig.sampling);if(a)return;let c=t.srcExtent||q(e,o,n);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:p}=R(c,u,l,s);t.pyramidLevel=s,t.pyramidResolution=l,t.srcWidth=m,t.srcHeight=h,t.ul=p}_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:r,useTransposedTile:n}=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||!n){const t=e.pixels.map(e=>e[o]),n={location:i,value:t,pyramidLevel:r},s=this._computeMagDirValues(t.map(e=>[e]));return s?.length&&(n.magdirValue=s.map(e=>e[0])),n}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=b(l,u.transposedVariableName);if(f){const e=k(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 x;null!=h&&(M(p,h),x=p.mask);return{location:i,value:null,dataSeries:m.map((e,t)=>{const i={value:0===x?.[t]?null:a.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new d({...e,isSlice:!0}))};return c?.length&&(i.magdirValue=[c[0][t],c[1][t]]),i}),pyramidLevel:r}}};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(p)],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.support.rasterDatasets.BaseRaster")],K);export{K as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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 o,isYAxis as i,parseGridCoverage as n}from"./covJSONParser.js";import l from"./InMemoryRaster.js";import{computeStatisticsHistograms as c}from"../rasterFunctions/stretchUtils.js";import p from"../../../rest/support/FeatureSet.js";let m=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:o}=await this._fetchData(e),{statistics:i,histograms:n}=c(r[0]),m=o?.map(e=>({BandName:e})),h={DataType:a?"Thematic":s?"Scientific":"Generic",BandProperties:m},d=new l({source:{extent:t,pixelBlocks:r,attributeTable:a?p.fromJSON(a):null,multidimensionalInfo:s,statistics:i,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(!(o(e[e.length-1])&&i(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}})],m.prototype,"datasetFormat",void 0),e([r({constructOnly:!0})],m.prototype,"source",void 0),m=e([s("esri.layers.support.rasterDatasets.CovJSONRaster")],m);const h=m;export{h as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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"../rasterFunctions/clipUtils.js";import{approximateTransform as n}from"../rasterFunctions/pixelUtils.js";import{projectPolygon as l}from"../rasterFunctions/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.support.rasterDatasets.FunctionRaster")],m);export{m as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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"../rasterFormats/RasterCodec.js";import{estimateStatisticsFromHistograms as c}from"../rasterFunctions/stretchUtils.js";import u from"../rasterTransforms/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.support.rasterDatasets.ImageAuxRaster")],h);const d=h;export{d as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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"../RasterInfo.js";import m from"../RasterStorageInfo.js";import u from"../TileInfo.js";import{TilemapCache as h}from"../TilemapCache.js";import f from"./BaseRaster.js";import{setValidBoundary as p}from"../rasterFunctions/pixelUtils.js";import d from"../rasterTransforms/GCSShiftTransform.js";import{patchServiceInfo as y,fetchServiceRasterInfo as x}from"../../../rest/imageService/fetchRasterInfo.js";let g=class extends f{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}`,m=this._slices?n?{variable:s.transposedVariableName}:{sliceId:s.sliceId||0}:null;let u,h;if(a.isBsqTile){const e=(s.bandIds?.length?s.bandIds:[0,1,2]).map(e=>this.request(c,{query:{...m,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);h=[];let r=0;for(const{data:s}of t)h.push(r),a.set(new Uint8Array(s),r),r+=s.byteLength;u=a.buffer}else{u=(await this.request(c,{query:m,responseType:"array-buffer",signal:s.signal})).data}if(!u)return null;const f=n?l.tileSize:a.tileInfo.size,d=await this.decodePixelBlock(u,{width:f[0],height:f[1],planes:h?.length,offsets:h,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,T=Math.round((x.y-r.ymax)/I)%v,M=Math.round((x.y-r.ymin)/I)%v||v,_=i===y.minCol?w:0,j=t===y.minRow?T:0,O=i===y.maxCol?b:g,R=t===y.maxRow?M:v;return p(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):u.fromJSON(l.tileInfo);i(c);const[f,p]=this._computeMinMaxLOD(o,c),{extent:d,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=f.resolution,o.width=Math.ceil((d.xmax-d.xmin)/x.x-.1),o.height=Math.ceil((d.ymax-d.ymin)/x.y-.1));const b=f.level-p.level,[T,M]=c.size,_=[],j=[];w.forEach((e,t)=>{e.level>=p.level&&e.level<=f.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(d,T,M,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/(p.resolution/f.resolution)**(-1/b))/10;if(o.storageInfo=new m({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 h({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 c({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 u.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 u.fromJSON({...e,lods:e.lods.filter(e=>{const i=t(e.scale);return i<=a&&i>=r})})}return u.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 d,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.support.rasterDatasets.ImageServerRaster")],g);const I=g;export{I as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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 r from"../../../geometry/Extent.js";import o from"../../../geometry/SpatialReference.js";import l from"../DimensionalDefinition.js";import n from"../RasterInfo.js";import m from"./BaseRaster.js";import{getSliceIndex as p}from"./multidimensionalUtils.js";import{clipTile as c,split as u}from"../rasterFunctions/pixelUtils.js";import{estimateStatisticsHistograms as h,computeStatisticsHistograms as d}from"../rasterFunctions/stretchUtils.js";let f=class extends m{constructor(){super(...arguments),this.datasetFormat="MEMORY",this.source=null}get url(){return""}fetchRawTile(t,e,i,s={}){if(!this._pixelBlockTiles){const{rasterInfo:a}=this,[r,o]=a.storageInfo.tileInfo.size,{sliceId:l}=s,{pixelBlocks:n}=this.source,m={pixelBlock:null==l?n[0]:n[l],useBilinear:"thematic"!==a.dataType,tileSize:{width:r,height:o},level:t,row:e,col:i},p=this.rasterJobHandler?this.rasterJobHandler.clipTile(m,s):c(m);return Promise.resolve(p)}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:m,nativeExtent:p,transform:c,colormap:u}=e,h=i[0],{width:d,height:f,pixelType:x}=h,y=e.extent??new r({xmin:-.5,ymin:.5,xmax:d-.5,ymax:f-.5,spatialReference:new o({wkid:3857})}),g=e.isPseudoSpatialReference??!e.extent,b={x:y.width/d,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 n({width:d,height:f,pixelType:x,extent:y,nativeExtent:p,attributeTable:s,colormap:u,transform:c,pixelSize:b,spatialReference:y.spatialReference,bandCount:h.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(h,{width:512,height:512},t),v.multidimensionalInfo||(this.source=null),this.datasetName=m}async _buildInMemoryRaster(t,s,a){const{rasterInfo:r}=this,o=r.storageInfo.maximumPyramidLevel??0,l="thematic"!==r.dataType,n=this.rasterJobHandler?this.rasterJobHandler.split({pixelBlock:t,tileSize:s,maximumPyramidLevel:o,useBilinear:l},a):Promise.resolve(u(t,s,o,l)),m=null!=r.statistics,p=null!=r.histograms,c=this.ioConfig.skipStatistics||m?Promise.resolve({statistics:null,histograms:null}):this.rasterJobHandler?this.rasterJobHandler.estimateStatisticsHistograms({pixelBlock:t},a):Promise.resolve(h(t)),d=await i([n,c]);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||(r.statistics=d[1].value?.statistics),p||(r.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 r=a.dimensions.map(t=>new l({variableName:a.name,dimensionName:t.name,values:[t.values?.[0]??t.extent?.[0]],isSlice:!0})),o=p(r,e),n=null==o?null:t[o];if(null==n)continue;const m=this.rasterJobHandler?await this.rasterJobHandler.computeStatisticsHistograms({pixelBlock:n},i):d(n);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.support.rasterDatasets.InMemoryRaster")],f);const x=f;export{x as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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 i from"../../../geometry/Extent.js";import o from"../../../geometry/Point.js";import a from"../../../geometry/SpatialReference.js";import n from"../PixelBlock.js";import l from"../RasterInfo.js";import f from"../RasterStorageInfo.js";import c from"./BaseRaster.js";import{parseSpatialReference as h,parsePAMInfo as m}from"./pamParser.js";import{getElement as p,getElementValue as u}from"./xmlUtilities.js";import{isPlatformLittleEndian as g}from"../rasterFormats/utils.js";import{estimateStatisticsFromHistograms as d}from"../rasterFunctions/stretchUtils.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 c{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this.datasetFormat="MRF"}async fetchRawTile(t,e,s,r={}){const{blockWidth:i,blockHeight:o,blockBoundary:a}=this.rasterInfo.storageInfo,l=a[t];if(!l||l.maxRow<e||l.maxCol<s||l.minRow>e||l.minCol>s)return null;const{bandCount:f,pixelType:c}=this.rasterInfo,{ranges:h,actualTileWidth:m,actualTileHeight:p}=this._getTileLocation(t,e,s);if(!h||0===h.length)return null;if(0===h[0].from&&0===h[0].to){const t=new Uint8Array(i*o);return new n({width:i,height:o,pixels:void 0,mask:t,validPixelCount:0})}const{bandIds:u}=this.ioConfig,g=this._getBandSegmentCount(),d=[];let y=0;for(y=0;y<g;y++)u&&!u.includes(y)||d.push(this.request(this._files.data,{range:{from:h[y].from,to:h[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),F=[];let A=0;for(y=0;y<g;y++)F.push(A),I.set(new Uint8Array(b[y].data),A),A+=b[y].data.byteLength;const R=x.get(this.rasterInfo.storageInfo.compression).decoderFormat,S=await this.decodePixelBlock(I.buffer,{width:i,height:o,format:R,planes:u?.length||f,offsets:F,pixelType:c}).catch(()=>null);if(null==S)return null;let{noDataValue:_}=this.rasterInfo;if(null!=_&&"lerc"!==R&&!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(m!==i||p!==o){let t=S.mask;if(t)for(y=0;y<o;y++)if(k=y*i,y<p)for(M=m;M<i;M++)t[k+M]=0;else for(M=0;M<i;M++)t[k+M]=0;else for(t=new Uint8Array(i*o),S.mask=t,y=0;y<p;y++)for(k=y*i,M=0;M<m;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:i}=this._parseHeader(s.data),{skipMapInfo:o,skipExtensions:a=[]}=this.ioConfig;if(!a.includes("aux.xml")&&!o){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=d(e.histograms)))}o&&this.updateImageSpaceRasterInfo(r),this._set("rasterInfo",r),this._files=i;const n=await this.request(i.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:m}=this.rasterInfo,p=[],u=this._getBandSegmentCount();let g=0,y=-1;for(;g<this._storageIndex.length;){y++;const t=Math.ceil(h/l/c**y)-1,e=Math.ceil(m/f/c**y)-1;g+=(t+1)*(e+1)*u*4,p.push({maxRow:e,maxCol:t,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=p,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:i,pyramidScalingFactor:o}=this.rasterInfo.storageInfo,{width:a,height:n}=this.rasterInfo,l=this._getBandSegmentCount();let f,c,h,m=0,p=0;for(h=0;h<t;h++)p=o**h,f=Math.ceil(a/r/p),c=Math.ceil(n/i/p),m+=f*c;p=o**t,f=Math.ceil(a/r/p),c=Math.ceil(n/i/p),m+=e*f+s,m*=4*l;const u=this._storageIndex.subarray(m,m+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/p)-r*(f-1),actualTileHeight:e<c-1?i:Math.ceil(n/p)-i*(c-1)}}_parseHeader(t){const s=p(t,"MRF_META/Raster");if(!s)throw new e("mrf:open","not a valid MRF format");const r=p(s,"Size"),n=parseInt(r.getAttribute("x"),10),c=parseInt(r.getAttribute("y"),10),m=parseInt(r.getAttribute("c"),10),g=(u(s,"Compression")||"none").toLowerCase();if(!x.has(g))throw new e("mrf:open","currently does not support compression "+g);const d=u(s,"DataType")||"UInt8",b=y.get(d);if(null==b)throw new e("mrf:open","currently does not support pixel type "+d);const w=p(s,"PageSize"),I=parseInt(w.getAttribute("x"),10),F=parseInt(w.getAttribute("y"),10),A=p(s,"DataValues");let R,S;A&&(S=A.getAttribute("NoData"),null!=S&&(R=S.trim().split(" ").map(t=>parseFloat(t))));if(p(t,"MRF_META/CachedSource"))throw new e("mrf:open","currently does not support MRF referencing other data files");const _=p(t,"MRF_META/GeoTags"),M=p(_,"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")),o=u(_,"Projection")||"";let n=a.WGS84;if("LOCAL_CS[]"!==o)if(o.toLowerCase().startsWith("epsg:")){const t=Number(o.slice(5));isNaN(t)||0===t||(n=new a({wkid:t}))}else n=h(o)??a.WGS84;else T=!0,n=new a({wkid:3857});k=new i(t,e,s,r),k.spatialReference=n}else T=!0,k=new i({xmin:-.5,ymin:.5-c,xmax:n-.5,ymax:.5,spatialReference:new a({wkid:3857})});const C=p(t,"MRF_META/Rsets"),j=parseInt(C?.getAttribute("scale")||"2",10),U=k.spatialReference,B=new f({origin:new o({x:k.xmin,y:k.ymax,spatialReference:U}),blockWidth:I,blockHeight:F,pyramidBlockWidth:I,pyramidBlockHeight:F,compression:g,pyramidScalingFactor:j}),E=new o({x:k.width/n,y:k.height/c,spatialReference:U}),L=new l({width:n,height:c,extent:k,isPseudoSpatialReference:T,spatialReference:U,bandCount:m,pixelType:b,pixelSize:E,noDataValue:R,storageInfo:B}),P=u(t,"datafile"),W=u(t,"IndexFile");return{rasterInfo:L,files:{mrf:this.url,index:W||this.url.replace(".mrf",".idx"),data:P||this.url.replace(".mrf",x.get(g).blobExtension)}}}async _fetchAuxiliaryData(t){try{const{data:e}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:t?.signal});return m(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,i,o,a;if(g){for(s=new Uint8Array(t),i=new ArrayBuffer(t.byteLength),r=new Uint8Array(i),o=0;o<t.byteLength/4;o++)for(a=0;a<4;a++)r[4*o+a]=s[4*o+3-a];e=new Uint32Array(i)}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.support.rasterDatasets.MRFRaster")],b);const I=b;export{I as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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"../rasterFunctions/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),F=Math.min(H.maxRow,Math.floor((j+w-1)/I)+E);for(let e=W;e<=F;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};
|
|
@@ -1,5 +0,0 @@
|
|
|
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"../RasterInfo.js";import l from"../RasterStorageInfo.js";import u from"./BaseRaster.js";import c from"./DBFParser.js";import{parsePAMInfo as h,parseSpatialReference as p}from"./pamParser.js";import{parseSignature as d,getPyramidIFDs as m,getMaskIFDs as y,parseIFD as g,parseFieldValues as x,isBSQConfig as w,getImageInfo as I}from"../rasterFormats/TiffDecoder.js";import{tiffTags as T,geoKeys as R}from"../rasterFormats/tiffTag.js";import{estimateStatisticsFromHistograms as _}from"../rasterFunctions/stretchUtils.js";import O from"../rasterTransforms/PolynomialTransform.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 u{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}=d(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),h=m(f),p=y(f);if(this._headerInfo={littleEndian:a,isBigTiff:o,ifds:f,pyramidIFDs:h,maskIFDs:p,...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&&D(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,T,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=T,r=4,s){let{fileChunk:a,posIFD:n,fileOffset:o}=e;if(!e.fileChunk)return null;const f=g(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,R,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=>x(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);x(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=w(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"),g=b(f,"IMAGELENGTH"),x=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 w=0;w<T.length;w++)if(null==T[w].from||!T[w].to||T[w].to<0)return null;return{ranges:T,ifd:f,actualTileWidth:i===m&&y%x||x,actualTileHeight:t===d&&g%I||I}}async _fetchAuxiliaryMetaData(e){try{const{data:t}=await this.request(this.url+".aux.xml",{responseType:"xml",signal:e?.signal});return h(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=c.parse(t);return i?.recordSet?F.fromJSON(i.recordSet):null}catch{return null}}};function k(e){const t=I(e),{width:i,height:r,tileWidth:s,tileHeight:u,planes:c,pixelType:h,compression:d,firstPyramidLevel:m,maximumPyramidLevel:y,pyramidBlockWidth:g,pyramidBlockHeight:x,pyramidResolutions:w,tileBoundary:T,affine:R,metadata:_}=t,F=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid;let E=p(F),k=!!t.isPseudoGeographic;null==E&&(k=!0,E=new o({wkid:3857}));const D=new a({...t.extent,spatialReference:E}),v=new n(D?{x:D.xmin,y:D.ymax,spatialReference:E}:{x:0,y:0}),P=new l({blockWidth:s,blockHeight:u,pyramidBlockWidth:g,pyramidBlockHeight:x,compression:d,origin:v,firstPyramidLevel:m,maximumPyramidLevel:y,pyramidResolutions:w,blockBoundary:T}),B=new n({x:(D.xmax-D.xmin)/i,y:(D.ymax-D.ymin)/r,spatialReference:E}),z=_?{BandProperties:_.bandProperties,DataType:_.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 f({width:i,height:r,bandCount:c,pixelType:h,pixelSize:B,storageInfo:P,spatialReference:E,isPseudoSpatialReference:k,keyProperties:z,extent:D,colormap:C,statistics:_?_.statistics:null});if(R?.length&&(A.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:i-.5,ymax:.5,spatialReference:E}),A.transform=new O({polynomialOrder:1,forwardCoefficients:[R[2]+R[0]/2,R[5]-R[3]/2,R[0],R[3],-R[1],-R[4]]}),A.extent=A.transform.forwardTransform(A.nativeExtent),A.pixelSize=new n({x:(D.xmax-D.xmin)/i,y:(D.ymax-D.ymin)/r,spatialReference:E}),P.origin.x=-.5,P.origin.y=.5),w){const{x:e,y:t}=A.pixelSize;w.forEach(i=>{i.x*=e,i.y*=t})}return{imageInfo:t,rasterInfo:A}}function D(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&null==t.statistics&&(t.statistics=_(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.support.rasterDatasets.TIFFRaster")],E);const v=E;export{v as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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"../DimensionalDefinition.js";import d from"./BaseRaster.js";import{convertOleDateTimeToEpoch as f}from"./multidimensionalUtils.js";import{parse as u}from"./multipartParser.js";import{standardizeInterpolations as h}from"./wcsCoverageParser.js";import{getFormat as p}from"../rasterFormats/RasterCodec.js";import{clip as m}from"../rasterFunctions/pixelUtils.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 d{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]),p=this.rasterInfo.extent,g=h.xmax>p.xmax,w=h.ymin<p.ymin,v=g||w;let y=h,x=d,I=f;if(v&&(y=h.clone().intersection(p),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?m(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=h(s.supportedInterpolations),this._patchDimensionValues201(c,n)}this.datasetName=this.coverageInfo.title;const{rasterInfo:u}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(u,512,512),this._set("rasterInfo",u),null==u.spatialReference)throw new t("wcsraster-open",`coverage without spatial reference is not supported: ${c}`);const{pixelType:p,bandCount:m}=await this._getPixelTypeAndBandCount(n);u.pixelType=p,1===u.bandCount&&m>1&&(u.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 d=[];if(null!=r){const e=r.variables[0];d=[],e.dimensions.forEach(t=>{d.push(new c({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}const{coverageDescription:f}=this.coverageInfo,u={interpolation:"nearest",multidimensionalDefinition:d,signal:e},{version:h}=f,{ioConfig:p}=this,m="2.0"===h&&null==p.allowAnyMediaType||"1.1"===h&&null==p.use2GridOffsets;let g;try{g=await this._getCoverage(l,2,2,1,u,!0)}catch(y){if(!m)throw y;if("1.1"===h){if(!y.details?.isResolutionMismatch)throw y;p.use2GridOffsets=!0}}if(!g&&m&&("2.0"===h&&(p.allowAnyMediaType=!0),g=await this._getCoverage(l,2,2,1,u),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),f="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 f.data;if("2.0"===c&&!1!==this.ioConfig.allowAnyMediaType){if("tiff"===p(f.data))return a&&(this.ioConfig.allowAnyMediaType=!0,i.getLogger(this).warn("wcsraster:getcoverage",v)),f.data}const h=u(f);if(h.isMultipart&&h.data){const e=h.data.find(e=>e.isValidImage);return a&&"base64"===e?.contentTransferEncoding&&i.getLogger(this).warn("wcsraster:getcoverage",x),e?.contentData}const m=new Uint8Array(f.data,0,Math.min(f.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,D=e.ymin+P,R=e.ymax-P,_=I?`${D},${T},${R},${L},${d}`:`${T},${D},${L},${R},${d}`,A=s.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes("band")));let E,W=A&&h&&a?p?`${A.identifier}[${A.axis[0].identifier}[${a.join(",")}]]`:`${A.identifier}:${h}[${A.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:_,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 R=2;R<v.length;R++){const e=p.origin[R];if(v[R].toLowerCase().includes("time")){let t=e.toString();h.uomLabels?.[R].toLowerCase().includes("ole")&&(S.push(v[R]),t=$(e,!0)),b.push(v[R]+",http://www.opengis.net("+t+")")}else b.push(v[R]+",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})`,D=L?1/n:null;return{service:"WCS",request:"GetCoverage",version:this.version,coverageId:this.coverageId,rangesubset:j,interpolation:c,scaleSize:P,scaleFactor:D,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(f(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.support.rasterDatasets.WCSRaster")],b);export{b as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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 s from"../PixelBlock.js";import{getIntegerPixelType as a}from"../rasterFormats/pixelRangeUtils.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 a(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:a}=o(e),{ranges:i}=e,r=Object.keys(i).sort((e,t)=>e<t?-1:1),u=[];for(let s=0;s<r.length;s++){const e=r[s];a?.length&&u.push({name:e,dimensions:a})}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=s.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||a?.length){const l=new s({width:t,height:n,mask:u?r:null,pixels:[e],pixelType:y});if(l.updateStatistics(),a?.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=s.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};
|
|
@@ -1,5 +0,0 @@
|
|
|
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"../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 U(e){return Math.round(24*(e-25569)*3600*1e3)}export{U 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};
|
|
@@ -1,5 +0,0 @@
|
|
|
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"../rasterTransforms/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};
|
|
@@ -1,5 +0,0 @@
|
|
|
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 a from"../Field.js";import r from"../PixelBlock.js";import{getByteCount as o}from"../rasterFormats/pixelRangeUtils.js";import{snapToRaster as s,clip as l}from"../rasterFunctions/clipUtils.js";import{transformPixels as c}from"../rasterFunctions/pixelTransformUtils.js";import{mapPixelValueToAttribute as p,pixelIdFieldName as u,convertPixelBlockToFeatures as f,getValidPixels as m,mosaic as x,countCategoricalPixels as h}from"../rasterFunctions/pixelUtils.js";import{load as d,projectPolygon as y}from"../rasterFunctions/rasterProjectionHelper.js";import{computeBoxStatistics as w,computeStatisticsHistograms as g}from"../rasterFunctions/stretchUtils.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 F(e){const t=[new a({name:u,alias:"Pixel ID",type:"oid"})],{pixelType:i}=e,n="f32"===i?"single":"f64"===i?"double":"integer";return k(e).forEach(e=>{t.push(new a({name:e,alias:e,type:n}))}),t.map(e=>e.toJSON())}async function T(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 d(),t=y(t,i)}return t}async function v(e,t,i=!1){const{spatialReference:a}=e,r=t?.geometry,o=await T(r??e.extent,a),l="extent"===o.type?o:o.extent,c=null==r||"extent"===r.type&&r.spatialReference.equals(a)?void 0:o,p=new n({x:e.pixelSize.x,y:e.pixelSize.y,spatialReference:a}),u=!!t?.autoResample,f=u?p:t?.pixelSize??p;let{extent:m,width:x,height:h}=s(e,l,f);if(!u)return{extent:m,clipGeometry:c,width:x,height:h,pixelSize:f};const d=e.storageInfo?.pyramidScalingFactor??2;let{x:y,y:w}=f;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:a})}}async function*z(e,n,a=!1,r){const{extent:o,clipGeometry:s,width:c,height:p}=n,u=o.width/c,f=o.height/p,m=Math.ceil(c/S),x=Math.ceil(p/S),h=u*S,d=f*S,{xmin:y,xmax:w,ymin:g,ymax:k}=o,b=x*m,B={bandIds:n.bandIds?.length?n.bandIds:void 0,interpolation:"nearest",...r};for(let P=0;P<x;P++)for(let n=0;n<m;n++){t(B);const r=new i({xmin:y+n*h,xmax:a?Math.min(w,y+(n+1)*h):y+(n+1)*h,ymax:k-P*d,ymin:a?Math.max(g,k-(P+1)*d):k-(P+1)*d,spatialReference:o.spatialReference}),c={row:P,col:n},p=P*m+n+1;if(s&&!r.intersects(s)){yield{extent:r,pixelBlock:null,id:c,total:b,current:p};continue}const x=a?Math.round(r.width/u):S,j=a?Math.round(r.height/f):S;let{pixelBlock:I}=await e.fetchPixels(r,x,j,B).catch(()=>({pixelBlock:void 0}));I&&s&&(I=await l(I,r,s)),yield{extent:r,pixelBlock:I,id:c,total:b,current:p}}}async function*M(e,i,n){const a=await R(e,n),r=F(a),o={...i,geometry:i?.geometry??a.extent},s=z(e,await v(a,o),!0,n),l=a.width;for await(const c of s){if(!c.pixelBlock){yield{...c};continue}const o=V(e),{pixelBlock:s}=c,{statistics:p,histograms:u}=await K({pixelBlock:s,rasterJobHandler:o},n),f=c;f.statistics=p,f.histograms=u;const m=c.id.row*a.width*S+c.id.col*S;t(n),f.featureSet=await _({pixelBlock:s,extent:c.extent,fields:r,skipFactor:i?.skipFactor??1,rasterJobHandler:o,pixelIdOffset:m,imageRowSize:l},n),t(n),yield f}}function H(t,i,n){const a=o(i),{width:r,height:s}=t;if(r*s*a>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 a=await R(t),r=await v(a,i,!0);H(r,a.pixelType);const{extent:o,pixelSize:s}=r,l=Math.round(a.extent.width/s.x),c=F(a),p={fields:c,features:[]},u=p.features,{maxPixelCount:f}=i,m=!!i.autoResample&&null!=f&&r.width*r.height>f,x=m?1:i.skipFactor??1,h=r.width<=S||r.height<=S,d=z(t,r,1===x||h,n);for await(const e of d){if(!e.pixelBlock)continue;const i=V(t),r=Math.floor((a.extent.ymax-e.extent.ymax)/s.y)*l+Math.floor((e.extent.xmin-a.extent.xmin)/s.x),o=await _({pixelBlock:e.pixelBlock,extent:e.extent,fields:c,skipFactor:x,rasterJobHandler:i,pixelIdOffset:r,imageRowSize:l},n);if(o?.features?.length){const{features:e}=o,t=e.length;for(let i=0;i<t;i++){const t=e.pop();u.push(t)}}}if(m&&f){const e=f/(i.skipFactor??1)**2;if(u.length>e){const t=u.length/e,i=[...u],n=u.length-1;u.length=0;for(let a=0,r=0;a<e-1;a++){r+=t;const e=Math.round(r);e<n&&u.push(i[e])}}}return{extent:o,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 a=await $(e,{geometry:n},i);if(!a)return null;return w(a)}async function J(e,t,i){const n=await R(e,i),a=t.points.map((e,i)=>t.getPoint(i)).map(t=>q(e,t,i)),o=(await Promise.all(a)).filter(e=>null!=e);if(o.length<=1)return N(o[0]);const s=o[0].map((e,t)=>o.map(e=>e[t]));return w(new r({pixels:s,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),a=await R(e,i),{bandCount:o,pixelType:s}=a,l=new Array(o).fill(0).map(()=>r.createEmptyBand(s,n.length));let c=0;for(let r=0;r<n.length;r++){const e=n[r];if(null!=e.value){c++;for(let t=0;t<o;t++)l[t][r]=e.value[t]}}c!==n.length&&l.forEach((e,t)=>{l[t]=e.subarray(0,c)});return w(new r({pixels:l,pixelType:s}))}async function A(t,i,n){const a=await R(t,n);if(!a.attributeTable||!a.pixelType.startsWith("u"))return null;const r=a.attributeTable.clone(),o=r.fields.find(e=>"value"===e.name.toLowerCase()),s=r.fields.find(e=>"count"===e.name.toLowerCase());if(!o||!s)throw new e("compute-attribute-table","Value or count field not found in attribute table");const l=2**Number(a.pixelType.slice(1)),c=new Uint32Array(l),{geometry:p}=i;return await L(t,p,(e,t)=>h(e,c),n),r.features.forEach(e=>{const t=e.attributes[o.name];e.attributes[s.name]=c[t]}),r}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)),a=(await Promise.all(t)).filter(e=>null!=e);if(0===a.length)return null;return G(a).map(e=>e/a.length)}const a=await L(e,n,(e,t)=>W(e),i),r=a?.filter(e=>e.count>0);if(!r?.length)return null;const o=G(r.map(e=>e.bandSum)),s=r.map(e=>e.count).reduce((e,t)=>e+t);return o.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:a}=e,r=new Array(n.length).fill(0);let o=0;for(let s=0;s<i;s++)for(let e=0;e<t;e++){const i=s*t+e;if(!a||a[i]){for(let e=0;e<n.length;e++)r[e]+=n[e][i];o++}}return{bandSum:r,count:o}}async function D(e,t,i){const n=await L(e,t.geometry,m,i);return n?.flat()??[]}async function L(i,n,a,r){const o=i.spatialReference;if("polyline"===n.type&&!n.spatialReference.equals(o)){const t=(await import("../../../geometry/operators/projectOperator.js")).execute(n,o);if(null==t)throw new e("read-pixels","failed to fetch pixels");n=t}const s="polyline"===n.type?n.extent:n,c=await T(s,o),p="polyline"===n.type?n:c,u=await R(i,r),f={geometry:c,autoResample:!1},m=[],x=z(i,await v(u,f),!0,r);for await(const e of x){if(!e.pixelBlock)continue;const{extent:i}=e,n=a(await l(e.pixelBlock,i,p),i);m.push(n),t(r)}return m}async function K(e,t){const{rasterJobHandler:i}=e,{pixelBlock:n}=e,{statistics:a,histograms:r}=i?await i.computeStatisticsHistograms({pixelBlock:n},t):g(n);return{statistics:a,histograms:r}}async function _(e,t){const{extent:i,fields:n,skipFactor:a,rasterJobHandler:r,pixelIdOffset:o,imageRowSize:s}=e,{pixelBlock:l}=e,c=n.map(({name:e})=>e),p=r?await r.convertPixelBlockToFeatures({pixelBlock:l,extent:i,fieldNames:c,skipFactor:a,pixelIdOffset:o,imageRowSize:s},t):f({pixelBlock:l,extent:i,fieldNames:c,skipFactor:a,pixelIdOffset:o,imageRowSize:s});return p?{fields:n,features:p}: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 a=await v(n,t);a.bandIds=t.bandIds?.length?t.bandIds:void 0,H(a,n.pixelType,t.maxPixelCount);const{width:r,height:o}=a;if(r<=S&&o<=S){const t=a.bandIds?.length?a.bandIds:void 0,{pixelBlock:n}=await e.fetchPixels(a.extent,r,o,{bandIds:t,interpolation:"nearest",...i});return n}const s=[],l=z(e,a,!1,i);for await(const x of l)s.push(x.pixelBlock);if(!s.some(e=>null!=e))return null;const c=Math.ceil(r/S),p=Math.ceil(o/S),u={width:c*S,height:p*S};let f;const m=V(e);if(m){const e=await m.mosaicAndTransform({srcPixelBlocks:s,srcMosaicSize:u,destDimension:u},{...i,transferPixelsToWorker:!0});f=e?.pixelBlock}else f=x(s,u);return f}async function Q(t,i,n){if(!i.geometry)throw new e("compute-statistics-histograms","geometry is required to fetch pixel feature set");let a=await $(t,i,n);if(!a)throw new e("compute-statistics-histograms","failed to get intersecting pixels");const{valueAttributeFieldName:r}=i;if(r&&"value"!==r.toLowerCase()){const e=await R(t,n);a=p(a,e,r)}const o=V(t),{transformType:s}=i;if(s){const e={lambda:i.lambda,shift:i.shift};a=o?await o.transformPixels({pixelBlock:a,transformType:s,transformParameters:e},{...n,transferPixelsToWorker:!0}):c(a,s,e)}const l=i.histogramSize??void 0;return o?await o.computeStatisticsHistograms({pixelBlock:a,histogramSize:l,includeSkewnessKurtosis:!0},{...n,transferPixelsToWorker:!0}):g(a,{histogramSize:l,includeSkewnessKurtosis:!0})}export{O as computeBoxStatistics,A as computeRasterAttributeTable,Q as computeStatisticsHistograms,M as createPixelFeatureSetCursor,C as fetchPixelFeatureSet,E as identifyAveragePixelValue,D as readIntersectingPixels};
|
|
@@ -1,5 +0,0 @@
|
|
|
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 i from"../RasterInfo.js";import{convertOleDateTimeToEpoch as s,getDimensionValues as a}from"./multidimensionalUtils.js";import{getElements as o,isSameTagIgnoreNS as l,getElementValue as r,getElementValues as u,getNodeNameIgnoreNS as m,getElement as p,getSpaceDelimitedNumericValues as c}from"./xmlUtilities.js";function d(e){e.variables.forEach(e=>e.dimensions.forEach(e=>e.values??=a(e)))}function f(e){return{requestResponseCRSs:u(e,"requestResponseCRSs").map(e=>e.split(":")[1]),nativeCRSs:u(e,"nativeCRSs").map(e=>e.split(":")[1])}}function g(e,t){const n=u(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):r(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=o(t,"pos"),i=c(n[0]),s=c(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=u(e,t);return n?.length&&""!==n[0]&&!isNaN(Number(n[0]))?n.map(e=>Number(e)):null}function v(e){const t=c(e,"MinimumValue"),n=c(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=o(e,"RangeSet");let i=[];for(let s=0;s<n.length;s++){const e=r(n[s],"name"),a=r(n[s],"label"),l=[],m=x(n[s],"nullValues/singleValue"),p=o(n[s],"AxisDescription");for(let t=0;t<p.length;t++){const e=r(p[t],"name"),n=r(p[t],"label"),s=u(p[t],"singleValue");if(0===s.length){const e=r(p[t],"min"),n=r(p[t],"max"),i=Number(r(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),l.push({name:e,label:n,values:s})}t.push({name:e,label:a,nullValues:m,axis:l})}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=o(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(r(t[n])));return{begin:e[0],end:e[e.length-1],values:e}}const n=p(e,"timePeriod")||p(e,"TimePeriod");if(n){return{begin:new Date(r(n,"beginPosition")||r(n,"BeginPosition")),end:new Date(r(n,"endPosition")||r(n,"EndPosition")),...w(r(n,"timeResolution")||r(n,"TimeResolution"))}}return null}function I(t){const n=p(t,"spatialDomain"),i=p(n,"Envelope")||p(n,"EnvelopeWithTimePeriod"),s=i.getAttribute("srsName").split(":"),a=s[s.length-1],l=o(i,"pos"),u=c(l[0]),m=c(l[1]),d=parseInt(a,10),f=isNaN(d)?null:{wkid:d},g=new e({xmin:u[0],ymin:u[1],xmax:m[0],ymax:m[1],spatialReference:f}),h=p(n,"RectifiedGrid"),b=r(h,"low").split(" "),x=r(h,"high").split(" "),v=parseInt(x[0],10)-parseInt(b[0],10)+1,D=parseInt(x[1],10)-parseInt(b[1],10)+1,y=c(n,"origin/pos"),w=o(n,"offsetVector"),I={envelope:g,columns:v,rows:D,offset:{x:parseFloat(r(w[0]).split(" ")[0]),y:parseFloat(r(w[1]).split(" ")[1])},origin:{x:y[0],y:y[1]}},L=p(t,"temporalDomain")||p(t,"TemporalDomain");return{spatialDomain:I,temporalDomain:L?S(L):null}}function L(e){const t={version:"1.0"};let n,s=[];for(let i=0;i<e.childNodes.length;i++){const a=e.childNodes[i];if(1===a.nodeType)if(l(a,"description"))t.description=r(a);else if(l(a,"name"))t.name=r(a);else if(l(a,"label"))t.label=r(a);else if(l(a,"supportedFormats"))t.supportedFormats=u(a,"formats");else if(l(a,"supportedCRSs"))t.supportedCRSs=f(a);else if(l(a,"supportedInterpolations"))t.supportedInterpolations=g(a,"1.0.0");else if(l(a,"lonLatEnvelope"))t.lonLatEnvelope=b(a);else if(l(a,"rangeSet")){const e=y(a);t.rangeSet=e.rangeSet,s=e.bandNames;const i=e.rangeSet[0].nullValues;i?.length&&(n=D(i))}else l(a,"domainSet")&&(t.domainSet=I(a))}const a=h(t.supportedInterpolations),{name:o,description:m,label:p,lonLatEnvelope:c,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 i({width:x.columns,height:x.rows,pixelSize:v,pixelType:"unknown",extent:x.envelope,spatialReference:x.envelope.spatialReference,bandCount:s.length||1,noDataValue:n,multidimensionalInfo:w});return{id:o,title:t.name,description:m||p,lonLatEnvelope:c,rasterInfo:S,bandNames:s,supportedFormats:d,supportedInterpolations:a,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=o(e,"Field");let s,a=[];for(let l=0;l<i.length;l++){const e=r(i[l],"Identifier"),m=r(i[l],"Description"),c=r(i[l],"Definition"),d=r(i[l],"Abstract"),f=r(i[l],"Title"),h=x(i[l],"NullValue"),b=p(i[l],"AllowedValues"),D=b?v(b):null,y=g(i[l],"1.1.0"),w=[],S=o(i[l],"Axis");for(let n=0;n<S.length;n++){const e=S[n].getAttribute("identifier"),i=r(S[n],"UOM"),o=r(S[n],"DataType"),l=u(S[n],"Key");t&&!e.toLowerCase().includes("band")||(a=l,s=h),w.push({identifier:e,uom:i,dataType:o,values:l,bandNoDataValues:s})}n.push({identifier:e,description:m,definition:c,abstract:d,title:f,supportedInterpolations:y,axis:w,nullValues:h,statistics:D})}return{rangeSet:n,bandNames:a,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=p(t,"SpatialDomain"),s=p(i,"GridCRS"),a=r(s,"GridBaseCRS"),l=r(s,"GridOrigin"),u=l?.split(" ").map(e=>parseFloat(e))??[0,0],m=c(s,"GridOffsets"),d=o(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=c(d[n],"LowerCorner"),t=c(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=c(d[n],"LowerCorner"),a=c(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:m[0],y:m[m.length-1]},gridBaseCRS:a,envelope:b,useEPSGAxis:D},w=p(t,"temporalDomain")||p(t,"TemporalDomain");return{spatialDomain:y,temporalDomain:w?S(w):null}}function N(e,t){const n=[],s=[],a={supportedFormats:n,supportedCRSs:s,version:"1.1"};let o,l,u=[];for(let i=0;i<e.childNodes.length;i++){const t=e.childNodes[i];if(1!==t.nodeType)continue;const p=m(t).toLowerCase();switch(p){case"title":case"abstract":case"identifier":a[p]=r(t);break;case"supportedformat":{const e=r(t);n.includes(e)||n.push(e)}break;case"supportedcrs":{const e=r(t);s.includes(e)||s.push(e)}break;case"range":{const e=T(t,!!a.domain?.temporalDomain);a.range=e.rangeSet,u=e.bandNames;const{bandNoDataValues:n}=e;n?.length&&(o=D(n)),l=e.statistics}break;case"domain":a.domain=M(t)}}const p=h(a.range[0].supportedInterpolations),{identifier:c,abstract:d,title:f,domain:g,range:b}=a,x={x:Math.abs(g.spatialDomain.offset.x),y:Math.abs(g.spatialDomain.offset.y)},v=R(b,g);v&&(o=b[0].nullValues,1===o?.length&&(o=o[0]));const y=new i({width:g.spatialDomain.columns,height:g.spatialDomain.rows,pixelSize:x,pixelType:"unknown",extent:g.spatialDomain.envelope,spatialReference:g.spatialDomain.envelope.spatialReference,bandCount:u.length||1,noDataValue:o,statistics:l,multidimensionalInfo:v});return{id:c,title:a.title,description:d||f,bandNames:u,rasterInfo:y,supportedFormats:n,supportedInterpolations:p,coverageDescription:a,version:t,useEPSGAxis:g.spatialDomain.useEPSGAxis}}function P(t){const n=p(t,"Envelope")||p(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()),o=c(n,"lowerCorner"),u=c(n,"upperCorner"),m=!["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(m?{xmin:o[0],ymin:o[1],xmax:u[0],ymax:u[1],spatialReference:g}:{xmin:o[1],ymin:o[0],xmax:u[1],ymax:u[0],spatialReference:g});const h={mins:o,maxs:u},b=n.getAttribute("uomLabels").trim().split(" ");let x,v;if(l(n,"EnvelopeWithTimePeriod")){x=new Date(r(t,"beginPosition")||r(t,"BeginPosition")),v=new Date(r(t,"endPosition")||r(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:m}}function E(e,t){const n=[],i=o(e,"DataRecord"),s=[];let a,l=[];for(let u=0;u<i.length;u++){const e=o(i[u],"field"),m=[];for(let n=0;n<e.length;n++){const i=e[n].getAttribute("name"),o=r(e[n],"description")||"",u=p(e[n],"uom")?.getAttribute("code")||"",d=c(e[n],"interval"),f=x(e[n],"nilValue")?.[0];t&&!i.toLowerCase().includes("band")||(s.push(i),d?.length&&(a=a||[],a.push({min:d[0],max:d[1],avg:-1,stddev:-1})),l.push(f)),m.push({name:i,description:o,uom:u,allowedValues:d,nilValue:f})}n.push(m)}return l.some(e=>null!=e)||(l=null),{rangeType:n,bandNames:s,bandStats:a,bandNoDataValues:l}}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 i=[];for(let s=0;s<e.length;s++){const t=e[s];for(let e=0;e<t.length;e++)t[e].name.toLowerCase().includes("band")||i.push(t[e])}const a=[];if(i.length){const e=[];for(let i=2;i<n.axisLabels.length;i++){const a=t.uomLabels?.[i]?.trim()??"",o=n.axisLabels[i].toLowerCase().includes("time")||"iso8601"===a.toLowerCase()||"oledatetime"===a.toLowerCase();let l,r;if(o){const e=V(n.offset[i]);l=e.interval,r=e.intervalUnit}else l=n.offset[i],r=a;const u=[];o?(u.push(s(t.envelopeAllDims.mins[i])),u.push(s(t.envelopeAllDims.maxs[i]))):(u.push(t.envelopeAllDims.mins[i]),u.push(t.envelopeAllDims.maxs[i])),e.push({name:n.axisLabels[i].trim(),description:n.axisLabels[i].trim(),unit:o?"ISO8601":a,hasRegularIntervals:!0,extent:u,interval:l,intervalUnit:r})}if(i.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=p(e,"RectifiedGrid"),i=c(n,"low"),s=c(n,"high"),a=[];for(let o=0;o<i.length;o++)a.push(s[o]-i[o]+1);const l=r(n,"axisLabels").split(" "),u=c(n,"origin/pos"),m=o(n,"offsetVector"),d=[];for(let o=0;o<m.length;o++){const e=c(m[o]),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&&l?.length){g=[...t].sort((e,t)=>e<t?-1:1).join(",")===[...l].sort((e,t)=>e<t?-1:1).join(",")}const h=g?l:t;let b,x,v;return f.includes(h[0].toLowerCase())?(b=a[1],x=a[0],v={y:Math.abs(d[0]),x:Math.abs(d[1])}):(b=a[0],x=a[1],v={x:Math.abs(d[0]),y:Math.abs(d[1])}),{columns:b,rows:x,origin:u,offset:d,resolution:v,gridSamples:a,axisLabels:l,hasSameAxisLabelsAsBoundedBy:g}}function O(e){const n=p(e,"EarthObservation");if(!n)return null;const i=p(n,"phenomenonTime"),s=i?S(i):null,a=p(n,"phenomenonTime"),o=a?S(a):null,l=r(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let u=null;if(l){const e=l.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:r(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:r(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:r(e,"metaDataProperty/EarthObservationMetaData/status")}}}function B(e){const t={version:"2.0"};let n,s,a=[];for(let i=0;i<e.childNodes.length;i++){const o=e.childNodes[i];if(1===o.nodeType)if(l(o,"coverageId"))t.coverageId=r(o);else if(l(o,"ServiceParameters"))t.serviceParameters={supportedFormats:u(o,"nativeFormat")};else if(l(o,"boundedBy"))t.boundedBy=P(o);else if(l(o,"rangeType")){const e=E(o,t.boundedBy?.axisLabels.length>2||t.domainSet?.axisLabels.length>2);t.rangeType=e.rangeType,a=e.bandNames,n=e.bandStats;const{bandNoDataValues:i}=e;i?.length&&(s=D(i))}else if(l(o,"domainSet"))t.domainSet=F(o,t.boundedBy?.axisLabels);else if(l(o,"metadata")){const e=p(o,"EOMetadata");t.eoMetadata=e?O(e):null}}const{coverageId:o,boundedBy:m,domainSet:c,rangeType:d,serviceParameters:f}=t,g=A(d,m,c);!n&&g&&(n=g?.variables[0].statistics),null!=g&&(s=d[0][0].nilValue);return{id:o,title:o,description:o,bandNames:a,rasterInfo:new i({width:c.columns,height:c.rows,pixelSize:c.resolution,pixelType:"unknown",extent:m.envelope,spatialReference:m.envelope.spatialReference,bandCount:a.length||1,statistics:n,noDataValue:s,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 o(n,"CoverageOffering").map(e=>L(e))}const i=o(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};
|
|
@@ -1,5 +0,0 @@
|
|
|
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/support/rasterFormats/${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,F={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),F;if(1===D&&1===x)return r(u),F.statistics.push({minValue:b[0],maxValue:b[1]}),F;const I=D*x*8,_=new Uint8Array(I),k=new Uint8Array(I);let B=u,S=0,v=0,E=!1;if(c.byteLength<u+2*I?(r(u),E=!0,[B,S,v]=y([e.length,I,I]),c.set(e,B)):[S,v]=y([I,I]),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=F.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),F},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 F=u(C,e.length,a,V,o,i,f,l,p,T,D,z);if(F)throw r(C),new Error(`lerc-decode: error code is ${F}`);c=new Uint8Array(h.buffer),s(c,T,m),s(c,V,w);let I=null;if(g){s(c,D,U),s(c,z,x),I=[];const e=new Float64Array(x.buffer);for(let t=0;t<U.length;t++)I.push(U[t]?e[t]:null)}return r(C),{data:m,maskData:w,noDataValues:I}}}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:F}=w;return{width:c,height:h,bandCount:y,pixelType:F,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};
|
|
@@ -1,5 +0,0 @@
|
|
|
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/support/rasterFormats/${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:h,byteCount:f}=a(i),g=u*c*l*f,b=s(g),p=s(1024);if(0===e(d,r.length,b,p))throw y(d),y(b),y(p),new Error("Decoding failed: "+t.UTF8ToString(p));const w=new h(t.HEAPU8.slice(b,b+g).buffer);if(y(d),y(b),y(p),w instanceof BigInt64Array||w instanceof BigUint64Array){const t=new Float64Array(w.length);for(let n=0;n<w.length;n++)t[n]=Number(w[n]);return t}return w}}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};
|
|
@@ -1,5 +0,0 @@
|
|
|
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 t from"../../../core/Error.js";import{assertIsSome as e}from"../../../core/maybe.js";import a from"../PixelBlock.js";import{SimpleBandStatistics as i}from"../SimpleBandStatistics.js";import s from"./ImageCanvasDecoder.js";import r from"./JpgPlus.js";import{load as n,decode as o}from"./Lerc.js";import{decode as h}from"./Lzw.js";import{convertNoDataToMask as c}from"./pixelRangeUtils.js";import{Z as l}from"../../../chunks/Zlib.js";import{load as p,decode as d}from"./Qb3.js";import u from"./Raw.js";import{decodeTileOrStrip as f,decode as m}from"./TiffDecoder.js";import{isPlatformLittleEndian as g}from"./utils.js";var w=function(t){var e,a,i,s,r,n;function o(t){var e,a,i,s,r,n,o,h,c,l,p,d,u;for(this.data=t,this.pos=8,this.palette=[],this.imgData=[],this.transparency={},this.animation=null,this.text={},r=null;;){switch(e=this.readUInt32(),h=function(){var t,e;for(e=[],t=0;t<4;++t)e.push(String.fromCharCode(this.data[this.pos++]));return e}.call(this).join(""),h){case"IHDR":this.width=this.readUInt32(),this.height=this.readUInt32(),this.bits=this.data[this.pos++],this.colorType=this.data[this.pos++],this.compressionMethod=this.data[this.pos++],this.filterMethod=this.data[this.pos++],this.interlaceMethod=this.data[this.pos++];break;case"acTL":this.animation={numFrames:this.readUInt32(),numPlays:this.readUInt32()||1/0,frames:[]};break;case"PLTE":this.palette=this.read(e);break;case"fcTL":r&&this.animation.frames.push(r),this.pos+=4,r={width:this.readUInt32(),height:this.readUInt32(),xOffset:this.readUInt32(),yOffset:this.readUInt32()},s=this.readUInt16(),i=this.readUInt16()||100,r.delay=1e3*s/i,r.disposeOp=this.data[this.pos++],r.blendOp=this.data[this.pos++],r.data=[];break;case"IDAT":case"fdAT":for("fdAT"===h&&(this.pos+=4,e-=4),t=(null!=r?r.data:void 0)||this.imgData,p=0;0<=e?p<e:p>e;0<=e?++p:--p)t.push(this.data[this.pos++]);break;case"tRNS":switch(this.transparency={},this.colorType){case 3:if(this.transparency.indexed=this.read(e),(c=255-this.transparency.indexed.length)>0)for(d=0;0<=c?d<c:d>c;0<=c?++d:--d)this.transparency.indexed.push(255);break;case 0:this.transparency.grayscale=this.read(e)[0];break;case 2:this.transparency.rgb=this.read(e)}break;case"tEXt":n=(l=this.read(e)).indexOf(0),o=String.fromCharCode.apply(String,l.slice(0,n)),this.text[o]=String.fromCharCode.apply(String,l.slice(n+1));break;case"IEND":return r&&this.animation.frames.push(r),this.colors=function(){switch(this.colorType){case 0:case 3:case 4:return 1;case 2:case 6:return 3}}.call(this),this.hasAlphaChannel=4===(u=this.colorType)||6===u,a=this.colors+(this.hasAlphaChannel?1:0),this.pixelBitlength=this.bits*a,this.colorSpace=function(){switch(this.colors){case 1:return"DeviceGray";case 3:return"DeviceRGB"}}.call(this),void(this.imgData=new Uint8Array(this.imgData));default:this.pos+=e}if(this.pos+=4,this.pos>this.data.length)throw new Error("Incomplete or corrupt PNG file")}}return o.load=function(t,e,a){var i;return"function"==typeof e&&(a=e),(i=new XMLHttpRequest).open("GET",t,!0),i.responseType="arraybuffer",i.onload=function(){var t;return t=new o(new Uint8Array(i.response||i.mozResponseArrayBuffer)),"function"==typeof(null!=e?e.getContext:void 0)&&t.render(e),"function"==typeof a?a(t):void 0},i.send(null)},a=1,i=2,e=0,o.prototype.read=function(t){var e,a;for(a=[],e=0;0<=t?e<t:e>t;0<=t?++e:--e)a.push(this.data[this.pos++]);return a},o.prototype.readUInt32=function(){return this.data[this.pos++]<<24|this.data[this.pos++]<<16|this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.readUInt16=function(){return this.data[this.pos++]<<8|this.data[this.pos++]},o.prototype.decodePixels=function(t){var e,a,i,s,r,n,o,h,c,p,d,u,f,m,g,w,y,b,x,k,T,C,I;if(null==t&&(t=this.imgData),0===t.length)return new Uint8Array(0);for(t=(t=new l(t)).getBytes(),w=(u=this.pixelBitlength/8)*this.width,f=new Uint8Array(w*this.height),n=t.length,g=0,m=0,a=0;m<n;){switch(t[m++]){case 0:for(s=x=0;x<w;s=x+=1)f[a++]=t[m++];break;case 1:for(s=k=0;k<w;s=k+=1)e=t[m++],r=s<u?0:f[a-u],f[a++]=(e+r)%256;break;case 2:for(s=T=0;T<w;s=T+=1)e=t[m++],i=(s-s%u)/u,y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(y+e)%256;break;case 3:for(s=C=0;C<w;s=C+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],y=g&&f[(g-1)*w+i*u+s%u],f[a++]=(e+Math.floor((r+y)/2))%256;break;case 4:for(s=I=0;I<w;s=I+=1)e=t[m++],i=(s-s%u)/u,r=s<u?0:f[a-u],0===g?y=b=0:(y=f[(g-1)*w+i*u+s%u],b=i&&f[(g-1)*w+(i-1)*u+s%u]),o=r+y-b,h=Math.abs(o-r),p=Math.abs(o-y),d=Math.abs(o-b),c=h<=p&&h<=d?r:p<=d?y:b,f[a++]=(e+c)%256;break;default:throw new Error("Invalid filter algorithm: "+t[m-1])}g++}return f},o.prototype.decodePalette=function(){var t,e,a,i,s,r,n,o,h;for(a=this.palette,r=this.transparency.indexed||[],s=new Uint8Array((r.length||0)+a.length),i=0,a.length,t=0,e=n=0,o=a.length;n<o;e=n+=3)s[i++]=a[e],s[i++]=a[e+1],s[i++]=a[e+2],s[i++]=null!=(h=r[t++])?h:255;return s},o.prototype.copyToImageData=function(t,e){var a,i,s,r,n,o,h,c,l,p,d;if(i=this.colors,l=null,a=this.hasAlphaChannel,this.palette.length&&(l=null!=(d=this._decodedPalette)?d:this._decodedPalette=this.decodePalette(),i=4,a=!0),c=(s=t.data||t).length,n=l||e,r=o=0,1===i)for(;r<c;)h=l?4*e[r/4]:o,p=n[h++],s[r++]=p,s[r++]=p,s[r++]=p,s[r++]=a?n[h++]:this.transparency.grayscale&&this.transparency.grayscale===p?0:255,o=h;else for(;r<c;)h=l?4*e[r/4]:o,s[r++]=n[h++],s[r++]=n[h++],s[r++]=n[h++],s[r++]=a?n[h++]:this.transparency.rgb&&this.transparency.rgb[1]===n[h-3]&&this.transparency.rgb[3]===n[h-2]&&this.transparency.rgb[5]===n[h-1]?0:255,o=h},o.prototype.decode=function(){var t;return t=new Uint8Array(this.width*this.height*4),this.copyToImageData(t,this.decodePixels()),t},r=t.document&&t.document.createElement("canvas"),n=r&&r.getContext("2d"),s=function(t){var e;return n.width=t.width,n.height=t.height,n.clearRect(0,0,t.width,t.height),n.putImageData(t,0,0),(e=new Image).src=r.toDataURL(),e},o.prototype.decodeFrames=function(t){var e,a,i,r,n,o,h,c;if(this.animation){for(c=[],a=n=0,o=(h=this.animation.frames).length;n<o;a=++n)e=h[a],i=t.createImageData(e.width,e.height),r=this.decodePixels(new Uint8Array(e.data)),this.copyToImageData(i,r),e.imageData=i,c.push(e.image=s(i));return c}},o.prototype.renderFrame=function(t,s){var r,n,o;return r=(n=this.animation.frames)[s],o=n[s-1],0===s&&t.clearRect(0,0,this.width,this.height),(null!=o?o.disposeOp:void 0)===a?t.clearRect(o.xOffset,o.yOffset,o.width,o.height):(null!=o?o.disposeOp:void 0)===i&&t.putImageData(o.imageData,o.xOffset,o.yOffset),r.blendOp===e&&t.clearRect(r.xOffset,r.yOffset,r.width,r.height),t.drawImage(r.image,r.xOffset,r.yOffset)},o.prototype.animate=function(t){var e,a,i,s,r,n,o=this;return a=0,n=this.animation,s=n.numFrames,i=n.frames,r=n.numPlays,(e=function(){var n,h;if(n=a++%s,h=i[n],o.renderFrame(t,n),s>1&&a/s<r)return o.animation._timeout=setTimeout(e,h.delay)})()},o.prototype.stopAnimation=function(){var t;return clearTimeout(null!=(t=this.animation)?t._timeout:void 0)},o.prototype.render=function(t){var e,a;return t._png&&t._png.stopAnimation(),t._png=this,t.width=this.width,t.height=this.height,e=t.getContext("2d"),this.animation?(this.decodeFrames(e),this.animate(e)):(a=e.createImageData(this.width,this.height),this.copyToImageData(a,this.decodePixels()),e.putImageData(a,0,0))},o}(self);const y=new Set(["jpg","png","bmp","gif"]);async function b(e,s){if(!g)throw new t("rasterCoded:decode","lerc decoder is not supported on big endian platform");await n();const{offset:r}=s,{width:h,height:c,pixelType:l,statistics:p,depthCount:d,noDataValues:u,bandMasks:f,pixels:m,mask:w}=o(e,{inputOffset:r,returnInterleaved:s.returnInterleaved}),y=new a({width:h,height:c,pixelType:l.toLowerCase(),pixels:m,mask:w,statistics:p.map(({minValue:t,maxValue:e})=>new i(t,e)),bandMasks:f,depthCount:d,noDataValues:u});return p?.length||y.updateStatistics(),y}async function x(e,i){await p();const s=d(e);if(!s)throw new t("rasterCodec:decode","failed to decode the input data.");const{width:r,height:n,pixels:o}=s,h=new a({width:r,height:n,pixelType:"u16",pixels:o});return h.updateStatistics(),h}async function k(t,i){const s=await m(t,{...i,noDataValue:i.tiffNoDataValue,matchAllNoData:i.matchAllNoData});e(s);const r=new a({width:s.width,height:s.height,pixels:s.pixels,pixelType:s.pixelType.toLowerCase(),mask:s.mask,bandMasks:s.bandMasks,statistics:null});return r.updateStatistics(),r}async function T(t,e){const i=await f(t,e.customOptions),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:i.pixelType.toLowerCase(),mask:i.mask,statistics:null});return s.updateStatistics(),s}function C(t,e){const i=e.pixelType||"u8",s=a.getPixelArrayConstructor(i),r="u8"===i?t:new s(t.buffer),n=[],o=e.planes||1;if(1===o)n.push(r);else for(let a=0;a<o;a++){const i=(e.width||1)*(e.height||t.length),h=new s(i);for(let t=0;t<i;t++)h[t]=r[t*o+a];n.push(h)}const h=new a({width:e.width||1,height:e.height||t.length,pixels:n,pixelType:i,statistics:null});return h.updateStatistics(),h}function I(t,e){return C(new l(new Uint8Array(t)).getBytes(),e)}function A(t,e){return C(h(t,e.offset,e.eof,!e.isInputBigEndian),e)}function v(t,e,i){const{pixelTypeCtor:s}=P(e.pixelType),r=(0,u.decode)(t,{width:e.width,height:e.height,pixelType:s,format:i}),n=new a({width:e.width,height:e.height,pixels:r.pixels,pixelType:e.pixelType,mask:r.mask,statistics:null});return n.updateStatistics(),n}function D(t,e){const i=r.decode(t,e.hasNoZlibMask??void 0),s=new a({width:i.width,height:i.height,pixels:i.pixels,pixelType:"u8",mask:i.mask,statistics:null});return s.updateStatistics(),s}function U(t,e){const i=new Uint8Array(t),s=new w(i),{width:r,height:n}=e,o=r*n,h=s.decode();let c,l=0,p=0;const d=new Uint8Array(o);for(l=0;l<o;l++)d[l]=h[4*l+3];const u=new a({width:r,height:n,pixels:[],pixelType:"u8",mask:d,statistics:[]});for(l=0;l<3;l++){for(c=new Uint8Array(o),p=0;p<o;p++)c[p]=h[4*p+l];u.addData({pixels:c})}return u.updateStatistics(),u}async function S(t,e,i,r){const n=new s,o={applyJpegMask:!1,format:e,...i},h=await n.decode(t,o,r),c=new a(h);return c.updateStatistics(),c}function j(e){if(null==e)throw new t("rasterCodec:decode","parameter encodeddata is required.");const a=new Uint8Array(e,0,10);let i="";return 255===a[0]&&216===a[1]?i="jpg":137===a[0]&&80===a[1]&&78===a[2]&&71===a[3]?i="png":67===a[0]&&110===a[1]&&116===a[2]&&90===a[3]&&73===a[4]&&109===a[5]&&97===a[6]&&103===a[7]&&101===a[8]&&32===a[9]?i="lerc":76===a[0]&&101===a[1]&&114===a[2]&&99===a[3]&&50===a[4]&&32===a[5]?i="lerc2":73===a[0]&&73===a[1]&&42===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&42===a[3]||73===a[0]&&73===a[1]&&43===a[2]&&0===a[3]||77===a[0]&&77===a[1]&&0===a[2]&&43===a[3]?i="tiff":71===a[0]&&73===a[1]&&70===a[2]?i="gif":66===a[0]&&77===a[1]?i="bmp":81===a[0]&&66===a[1]&&51===a[2]?i="qb3":String.fromCharCode.apply(null,a).toLowerCase().includes("error")&&(i="error"),i}function O(e){let a=null;switch(e){case"lerc":case"lerc2":a=b;break;case"jpg":a=D;break;case"png":a=U;break;case"bsq":case"bip":a=(t,a)=>v(t,a,e);break;case"tiff":a=k;break;case"deflate":a=I;break;case"lzw":a=A;break;case"qb3":a=x;break;case"error":a=()=>{throw new t("rasterCodec:decode","input data contains error")};break;default:a=()=>{throw new t("rasterCodec:decode","unsupported raster format")}}return a}function P(t){let e=null,a=null;switch(t?t.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":a=255,e=Uint8Array;break;case"u16":a=a||65535,e=Uint16Array;break;case"u32":a=a||2**32-1,e=Uint32Array;break;case"s8":a=a||-128,e=Int8Array;break;case"s16":a=a||-32768,e=Int16Array;break;case"s32":a=a||0-2**31,e=Int32Array;break;default:e=Float32Array}return{pixelTypeCtor:e,noDataValue:a}}function M(t,e=1){if(!t)return;const{pixels:i,width:s,height:r,mask:n}=t;if(!i||0===i.length)return;const o=i.length,h=s-1,c=r-1,l=[];let p,d,u,f,m,g,w=null;const y=a.getPixelArrayConstructor(t.pixelType);if(0===e){for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=m[f+u];l.push(g)}if(null!=n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=n[f+u]}else{for(p=0;p<o;p++){for(m=i[p],g=new y(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)g[d*h+u]=(m[f+u]+m[f+u+1]+m[f+s+u]+m[f+s+u+1])/4;l.push(g)}if(n)for(w=new Uint8Array(h*c),d=0;d<c;d++)for(f=d*s,u=0;u<h;u++)w[d*h+u]=Math.min.apply(null,[n[f+u],n[f+u+1],n[f+s+u],n[f+s+u+1]])}t.width=h,t.height=c,t.mask=w,t.pixels=l}function L(t){let e=j(t);return"lerc2"===e?e="lerc":"error"===e&&(e=""),e}async function R(e,i={},s){if(null==e)throw new t("rasterCodec:decode","missing encodeddata parameter.");let r=i.format?.toLowerCase();if(!("bsq"!==r&&"bip"!==r||null!=i.width&&null!=i.height))throw new t("rasterCodec:decode","requires width and height in options parameter.");if("tiff"===r&&i.customOptions)return T(e,i);if((!r||"bsq"!==r&&"bip"!==r&&"deflate"!==r&&"lzw"!==r)&&(r=j(e)),i.useCanvas&&y.has(r))return S(e,r,i,s);const n=O(r);let o;i.isPoint&&(null!=(i={...i}).width&&i.width++,null!=i.height&&i.height++);const{offsets:h}=i;if(h&&h.length>1){const t=h.map((t,a)=>n(e.slice(t,h[a+1]),i)),s=await Promise.all(t);o=s[0],o.pixels=s.map(t=>t.pixels[0]);const r=s.map(t=>t.mask);s.some(t=>null!=t)&&(r.forEach((t,e)=>{null==t&&(r[e]=new Uint8Array(o.width*o.height).fill(255))}),o.bandMasks=r,o.mask=a.combineBandMasks(r)),o.updateStatistics()}else o=await n(e,{...i,offset:h?.[0]??i.offset});return"jpg"!==r&&null!=i.noDataValue&&1===o.depthCount&&c(o,i.noDataValue,{customFloatTolerance:i.tolerance}),i.isPoint&&M(o),o}export{R as decode,L as getFormat};
|
|
@@ -1,5 +0,0 @@
|
|
|
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"../../../core/has.js";import{bytesToUTF8 as e}from"../rasterDatasets/byteStreamUtils.js";import{J as t}from"../../../chunks/Jpg.js";import{load as n,decode as a}from"./Lerc.js";import{decode as i}from"./Lzw.js";import{convertNoDataToMask as r}from"./pixelRangeUtils.js";import{tiffTags as s,ifdTags as l,getTagName as o,geoKeys as f}from"./tiffTag.js";import{isPlatformLittleEndian as u}from"./utils.js";import{Z as c}from"../../../chunks/Zlib.js";const h=[0,1,1,2,4,8,1,1,2,4,8,4,8,-1,-1,-1,8,8,8],g=4294967296,E=new Set([1,5,6,7,8,34712,34887]);function I(e,t){let n="unknown";return 3===e?n=64===t?"f64":"f32":1===e?1===t?n="u1":2===t?n="u2":4===t?n="u4":t<=8?n="u8":t<=16?n="u16":t<=32&&(n="u32"):2===e&&(t<=8?n="s8":t<=16?n="s16":t<=32&&(n="s32")),n}function T(e){let t=null;switch(e?e.toLowerCase():"f32"){case"u1":case"u2":case"u4":case"u8":t=Uint8Array;break;case"u16":t=Uint16Array;break;case"u32":t=Uint32Array;break;case"s8":t=Int8Array;break;case"s16":t=Int16Array;break;case"s32":t=Int32Array;break;case"f64":t=Float64Array;break;default:t=Float32Array}return t}function w(e,t){return{x:t[0]*e.x+t[1]*e.y+t[2],y:t[3]*e.x+t[4]*e.y+t[5]}}function p(e,t){return e.get(t)?.values}function d(e,t){return e.get(t)?.values}function m(e,t){return e.get(t)?.values?.[0]}function y(e,t){return e.get(t)?.values?.[0]}function A(e,t,n,a=0,i=s,r=4){const l=8===r,f=l?B(new DataView(e,n,8),0,t):new DataView(e,n,2).getUint16(0,t),u=4+2*r,c=l?8:2,h=c+f*u;if(n+h>e.byteLength)return{success:!1,ifd:null,nextIFD:null,requiredBufferSize:h};const g=8===r?8:4,E=n+h+g<=e.byteLength?W(new DataView(e,n+h,g),0,t,8===r):null,I=n+c,T=new Map;let w,p,d,m,y,A=0,S=0;for(let s=0;s<f;s++){p=new DataView(e,I+u*s,u),d=p.getUint16(0,t),y=p.getUint16(2,t),m=o(d,i);const n=[];2===r?(A=p.getUint16(4,t),S=p.getUint16(6,t)):4===r?(A=p.getUint32(4,t),S=p.getUint32(8,t)):8===r&&(A=W(p,4,t,!0),S=W(p,12,t,!0),n.push(p.getUint32(12,t)),n.push(p.getUint32(16,t))),w={id:d,type:y,valueCount:A,valueOffset:S,valueOffsets:n,values:null},N(e,t,w,a,!1,r),T.set(m,w)}return{success:!0,ifd:T,nextIFD:E,requiredBufferSize:h}}const S=(e,t)=>a(e,{inputOffset:t}).pixels[0];function M(e,t){if(t%8==0)return e;const n=t>16?32:t>8?16:8;n>8&&(e=b(e,32===n?4:2));const a=32===n?Uint32Array:16===n?Uint16Array:Uint8Array,i=new a(e),r=Math.floor(8*e.byteLength/t+1e-6),s=new a(r),l=(1<<t)-1;let o=0,f=0,u=0;for(let c=0;c<r;c++)if(0===f&&(u=i[o++],f=n),f>=t)s[c]=u>>>f-t&l,f-=t;else{const e=t-f;let a=(u&l)<<e&l;u=i[o++],f=n-e,a+=u>>>f,s[c]=a}return s.buffer}function P(e,n,a){const i=new t;i.parse(e),i.colorTransform=6===a?-1:0;const r=i.getData(i.width,i.height,1!==n&&4!==n);return new Uint8Array(r.buffer)}function O(e){const t=new c(e).getBytes(),n=new ArrayBuffer(t.length),a=new Uint8Array(n);return a.set(t),a}function b(e,t){const n=new Uint8Array(e),a=new Uint8Array(n.length);if(2===t)for(let i=0;i<n.length;i+=2)a[i]=n[i+1],a[i+1]=n[i];else if(4===t)for(let i=0;i<n.length;i+=4)a[i]=n[i+3],a[i+1]=n[i+2],a[i+2]=n[i+1],a[i+3]=n[i];else for(let i=0;i<n.length;i+=8)a[i]=n[i+7],a[i+1]=n[i+6],a[i+2]=n[i+5],a[i+3]=n[i+4],a[i+4]=n[i+3],a[i+5]=n[i+2],a[i+6]=n[i+1],a[i+7]=n[i];return a.buffer}async function x(e,t,a,r,s){const l=u===t,o=y(a,"BITSPERSAMPLE"),f=y(a,"SAMPLESPERPIXEL")??1,c=y(a,"PHOTOMETRICINTERPRETATION"),h=y(a,"SAMPLEFORMAT")??1,g=I(h,o),E=y(a,"COMPRESSION")??1,w=T(g);let p,d,m;if(34887===E)return await n(),S(e,r);if(1===E)p=e.slice(r,r+s),d=new Uint8Array(p);else if(8===E||32946===E)d=new Uint8Array(e,r,s),d=O(d),p=d.buffer;else if(6===E)d=new Uint8Array(e,r,s),d=P(d,f,c),p=d.buffer;else if(7===E){const t=a.get("JPEGTABLES").values,n=t.length-2;d=new Uint8Array(n+s-2);for(let e=0;e<n;e++)d[e]=t[e];const i=new Uint8Array(e,r+2,s-2);for(let e=0;e<i.length;e++)d[n+e]=i[e];d=P(d,f,c),p=d.buffer}else{if(5!==E)throw new Error("tiff-decode: unsupport compression "+E);d=i(e,r,s,t),p=d.buffer}if(p=M(p,o),l||o<=8)m=new w(p);else{const e=o>32?8:o>16?4:2;m=new w(b(d.buffer,e))}const A=y(a,"PREDICTOR")??1,x=y(a,"TILEWIDTH"),L=y(a,"TILELENGTH");if(A>1&&(5===E||8===E||32946===E)&&x&&L){const e=C(a),t=new w(m.length);t.set(m),m=j(t,L,x,3===h&&3===A,e?1:f)}return m}async function L(e,t,n){const a=d(n,"TILEOFFSETS");if(void 0===a)return null;const i=d(n,"TILEBYTECOUNTS"),{width:r,height:s,pixelType:l,tileWidth:o,tileHeight:f}=k([n]),u=C(n,t),c=y(n,"SAMPLESPERPIXEL")||t.planes,h=r*s,g=y(n,"BITSPERSAMPLE"),E=34887===(y(n,"COMPRESSION")??1),I=T(l),w=[];for(let T=0;T<c;T++)w.push(new I(h));let p,m,A,S,M,P,O,b,L,D,R,U,N;const G=Math.ceil(r/o),v=new Uint8Array(h).fill(255);let F=!1;if(g%8==0)if(E&&u&&c>1){const l=Math.round(a.length/c);for(p=0;p<l;p++){P=Math.floor(p/G)*f,O=p%G*o,b=P*r+O;for(let l=0;l<c;l++){const u=p*c+l;for(0===i[u]?(A=null,F=!0):A=await x(e,t.littleEndian,n,a[u],i[u]),D=0,L=b,U=Math.min(o,r-O),R=Math.min(f,s-P),N=w[l],S=0;S<R;S++)for(L=b+S*r,D=S*o,M=0;M<U;M++,L++,D++)A?N[L]=A[D]:v[L]=0}}}else for(p=0;p<a.length;p++)for(P=Math.floor(p/G)*f,O=p%G*o,b=P*r+O,0===i[p]?(A=null,F=!0):A=await x(e,t.littleEndian,n,a[p],i[p]),D=0,L=b,U=Math.min(o,r-O),R=Math.min(f,s-P),m=0;m<c;m++)if(N=w[m],u||E)for(S=0;S<R;S++)for(L=b+S*r,D=o*f*m+S*o,M=0;M<U;M++,L++,D++)A?N[L]=A[D]:v[L]=0;else for(S=0;S<R;S++)for(L=b+S*r,D=S*o*c+m,M=0;M<U;M++,L++,D+=c)A?N[L]=A[D]:v[L]=0;return{width:r,height:s,pixelType:l,pixels:w,mask:F?v:void 0}}const D=(e,t,n)=>{const a=u===t.littleEndian,r=d(n,"STRIPOFFSETS");if(void 0===r)return null;const{width:s,height:l,pixelType:o}=k([n]),f=y(n,"SAMPLESPERPIXEL")||t.planes,c=y(n,"PHOTOMETRICINTERPRETATION"),h=s*l,g=y(n,"BITSPERSAMPLE"),E=T(o),I=new E(h*f),w=d(n,"STRIPBYTECOUNTS"),p=y(n,"ROWSPERSTRIP"),m=y(n,"COMPRESSION")??1;let A,S,b,x,L,D,R,U,N;if(g%8==0)for(A=0;A<r.length;A++){if(L=A*(p*s)*f,"u8"===o||"s8"===o||a)8===m||32946===m?(R=new Uint8Array(e,r[A],w[A]),R=O(R),D=R.buffer):6===m?(R=new Uint8Array(e,r[A],w[A]),R=P(R,f,c),D=R.buffer):5===m?(R=i(e,r[A],w[A],t.littleEndian),D=R.buffer):D=e.slice(r[A],r[A]+w[A]),D=M(D,g),x=new E(D);else{switch(6===m||8===m||32946===m?(R=new Uint8Array(e,r[A],w[A]),U=O(R),D=U.buffer):(D=new ArrayBuffer(w[A]),R=new Uint8Array(e,r[A],w[A]),U=new Uint8Array(D)),o){case"u16":case"s16":for(b=0;b<R.length;b+=2)U[b]=R[b+1],U[b+1]=R[b];break;case"u32":case"s32":case"f32":for(b=0;b<R.length;b+=4)U[b]=R[b+3],U[b+1]=R[b+2],U[b+2]=R[b+1],U[b+3]=R[b]}D=M(D,g),x=new E(D)}I.set(x,L)}const C=[];if(1===f)C.push(I);else for(A=0;A<f;A++){for(N=new E(h),S=0;S<h;S++)N[S]=I[S*f+A];C.push(N)}return{width:s,height:l,pixelType:o,pixels:C}},R=(e,t,n)=>{if(!(e&&e.length>0&&t&&n))return null;let a,i,r;const s=e[0].length,l=e.length,o=new Uint8Array(s);for(let f=0;f<l;f++)if(a=e[f],i=t[f],r=n[f],0===f)for(let e=0;e<s;e++)o[e]=a[e]<i||a[e]>r?0:1;else for(let e=0;e<s;e++)o[e]&&(o[e]=a[e]<i||a[e]>r?0:1);return o},U=e=>{if(!e)return null;const t=e.match(/<Item(.*?)Item>/gi);if(!t||0===t.length)return null;const n=new Map;let a,i,r,s,l;for(let w=0;w<t.length;w++)a=t[w],i=a.slice(6,a.indexOf(">")),s=a.indexOf("sample="),s>-1&&(l=a.slice(s+8,a.indexOf('"',s+8))),s=a.indexOf("name="),s>-1&&(i=a.slice(s+6,a.indexOf('"',s+6))),i&&(r=a.slice(a.indexOf(">")+1,a.indexOf("</Item>")).trim(),null!=l?n.has(i)?n.get(i)[l]=r:n.set(i,[r]):n.set(i,r)),l=null;const o=n.get("STATISTICS_MINIMUM"),f=n.get("STATISTICS_MAXIMUM"),u=n.get("STATISTICS_MEAN"),c=n.get("STATISTICS_STDDEV");let h=null;if(o&&f){h=[];for(let e=0;e<o.length;e++)h.push({min:parseFloat(o[e]),max:parseFloat(f[e]),avg:u&&parseFloat(u[e]),stddev:c&&parseFloat(c[e])})}const g=n.get("BandName"),E=n.get("WavelengthMin"),I=n.get("WavelengthMax");let T=null;if(g){T=[];for(let e=0;e<g.length;e++)T.push({BandName:g[e],WavelengthMin:E&&parseFloat(E[e]),WavelengthMax:I&&parseFloat(I[e])})}return{statistics:h,bandProperties:T,dataType:n.get("DataType"),rawMetadata:n}};function N(e,t,n,a=0,i=!1,r=4){if(n.values)return!0;const s=n.type,l=n.valueCount;let o=n.valueOffset,f=[];const u=h[s],c=8*u,E=l*u,I=l*h[s]*8;let T,w;const p=8===r?64:32,d=n.valueOffsets;if(I>p){if(E>(i?e.byteLength:e?e.byteLength-o+a:0))return n.offlineOffsetSize=[o,E],n.values=null,!1}if(I<=p){if(!t)if(p<=32)o>>>=32-I;else{const e=d?.length?d[0]:o>>>0,t=d?.length?d[1]:Math.round((o-e)/g);I<=32?(o=e>>>32-I,d[0]=o):(o=e*2**(32-I)+(t>>>32-I),d[0]=e,d[1]=t>>>32-I)}if(1===l&&c===p)f=[o];else if(64===p){const e=d?.length?d[0]:o>>>0,t=d?.length?d[1]:Math.round((o-e)/g);let n=e,a=32;for(w=1;w<=l;w++){const e=32-c*w%32;if(a<c){const i=n<<e>>>32-a,r=t<<32-a>>>32-a;n=t,f.push(i+r*2**(c-a)),a-=32-(c-a)}else f.push(n<<e>>>32-c),a-=c;0===a&&(a=32,n=t)}}else for(w=1;w<=l;w++){const e=32-c*w;f.push(o<<e>>>32-c)}}else{o-=a,i&&(o=0);for(let n=o;n<o+E;n+=u){switch(s){case 1:case 2:case 7:T=new DataView(e,n,1).getUint8(0);break;case 3:T=new DataView(e,n,2).getUint16(0,t);break;case 4:case 13:T=new DataView(e,n,4).getUint32(0,t);break;case 5:T=new DataView(e,n,4).getUint32(0,t)/new DataView(e,n+4,4).getUint32(0,t);break;case 6:T=new DataView(e,n,1).getInt8(0);break;case 8:T=new DataView(e,n,2).getInt16(0,t);break;case 9:T=new DataView(e,n,4).getInt32(0,t);break;case 10:T=new DataView(e,n,4).getInt32(0,t)/new DataView(e,n+4,4).getInt32(0,t);break;case 11:T=new DataView(e,n,4).getFloat32(0,t);break;case 12:T=new DataView(e,n,8).getFloat64(0,t);break;case 16:case 18:T=B(new DataView(e,n,8),0,t);break;case 17:T=V(new DataView(e,n,8),0,t);break;default:T=null}f.push(T)}}if(2===s){let e="";const t=f;for(f=[],w=0;w<t.length;w++)0===t[w]&&""!==e?(f.push(e),e=""):e+=String.fromCharCode(t[w]);""===e&&0!==f.length||f.push(e)}return n.values=f,!0}function k(e){const t=e[0],n=y(t,"TILEWIDTH"),a=y(t,"TILELENGTH"),i=y(t,"IMAGEWIDTH"),r=y(t,"IMAGELENGTH"),s=y(t,"BITSPERSAMPLE"),l=y(t,"SAMPLESPERPIXEL"),o=y(t,"SAMPLEFORMAT")??1,f=I(o,s),u=C(t),c=p(t,"GDAL_NODATA");let h=null;c?.length&&(h=c.map(e=>parseFloat(e)),h.some(e=>isNaN(e))&&(h=null));const g=y(t,"COMPRESSION")??1;let T;switch(g){case 1:T="NONE";break;case 2:case 3:case 4:case 32771:T="CCITT";break;case 5:T="LZW";break;case 6:case 7:T="JPEG";break;case 32773:T="PACKBITS";break;case 8:case 32946:T="DEFLATE";break;case 34712:T="JPEG2000";break;case 34887:T="LERC";break;default:T=String(g)}let A=!0,S="";E.has(g)||(A=!1,S+="unsupported tag compression "+g),o>3&&(A=!1,S+="unsupported tag sampleFormat "+o),s>32&&64!==s&&(A=!1,S+="unsupported tag bitsPerSample "+s);const M=m(t,"GEOASCIIPARAMS");let P;if(M){const e=M.split("|").find(e=>e.includes("ESRI PE String = ")),t=e?e.replace("ESRI PE String = ",""):"";P=t.startsWith("COMPD_CS")||t.startsWith("PROJCS")||t.startsWith("GEOGCS")?{wkid:null,wkt:t}:null}const O=d(t,"GEOTIEPOINTS"),b=d(t,"GEOPIXELSCALE"),x=d(t,"GEOTRANSMATRIX"),L=t.has("GEOKEYDIRECTORY")?t.get("GEOKEYDIRECTORY").data:null;let D,R,N=!1,k=!1;if(L){N=2===y(L,"GTRasterTypeGeoKey");const e=y(L,"GTModelTypeGeoKey");if(2===e){const e=y(L,"GeographicTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e}),P||32767!==e||(k=!0,P={wkid:4326})}else if(1===e){const e=y(L,"ProjectedCSTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e})}}if(b&&O&&O.length>=6?(D=[b[0],0,O[3]-O[0]*b[0],0,-Math.abs(b[1]),O[4]-O[1]*b[1]],N&&(D[2]-=.5*D[0]+.5*D[1],D[5]-=.5*D[3]+.5*D[4])):x&&16===x.length&&(D=N?[x[0],x[1],x[3]-.5*x[0],x[4],x[5],x[7]-.5*x[5]]:[x[0],x[1],x[3],x[4],x[5],x[7]]),D){const e=[{x:0,y:r},{x:0,y:0},{x:i,y:r},{x:i,y:0}];let t,n=Number.POSITIVE_INFINITY,a=Number.POSITIVE_INFINITY,s=Number.NEGATIVE_INFINITY,l=Number.NEGATIVE_INFINITY;for(let i=0;i<e.length;i++)t=w(e[i],D),n=t.x>n?n:t.x,s=t.x<s?s:t.x,a=t.y>a?a:t.y,l=t.y<l?l:t.y;R={xmin:n,xmax:s,ymin:a,ymax:l,spatialReference:P}}else R={xmin:-.5,ymin:.5-r,xmax:i-.5,ymax:.5,spatialReference:P};k&&(R.xmax-R.xmin>400||Math.max(Math.abs(R.xmin),Math.abs(R.xmax))>361)&&(P=null,R.spatialReference=null);const F=G(e);let B,V,W,H,Y;if(F.length>0){W=Math.round(Math.log(i/y(F[0],"IMAGEWIDTH"))/Math.LN2);const e=F[F.length-1];H=F.length,B=y(e,"TILEWIDTH"),V=y(e,"TILELENGTH")}B=null!=H&&H>0?B||n:null,V=null!=H&&H>0?V||a:null,n&&(Y=[{maxCol:Math.ceil(i/n)-1,maxRow:Math.ceil(r/a)-1,minRow:0,minCol:0}],F.forEach(e=>{Y.push({maxCol:Math.ceil(y(e,"IMAGEWIDTH")/y(e,"TILEWIDTH"))-1,maxRow:Math.ceil(y(e,"IMAGELENGTH")/y(e,"TILELENGTH"))-1,minRow:0,minCol:0})}));const j=m(e[0],"GDAL_METADATA"),X=U(j);S+=" "+_({width:i,height:r,tileWidth:n,tileHeight:a,planes:l,ifds:e});const K=v(e).length===F.length+1,J=F?.length?F.map(e=>({x:i/y(e,"IMAGEWIDTH"),y:r/y(e,"IMAGELENGTH")})):void 0;return{width:i,height:r,tileWidth:n,tileHeight:a,planes:l,isBSQ:u,pixelType:f,compression:T,noData:h,hasMaskBand:K,isSupported:A,pyramidResolutions:J,message:S,extent:R,isPseudoGeographic:k,affine:b?null:D,firstPyramidLevel:W,maximumPyramidLevel:H,pyramidBlockWidth:B,pyramidBlockHeight:V,tileBoundary:Y,metadata:X}}function C(e,t){const n=p(e,"PLANARCONFIGURATION");return n?2===n[0]:!!t&&t.isBSQ}function G(e){return e.filter(e=>1===y(e,"NEWSUBFILETYPE"))}function v(e){return e.filter(e=>{const t=!(4&~(y(e,"NEWSUBFILETYPE")??0)),n=4===y(e,"PHOTOMETRICINTERPRETATION");return t&&n})}function F(e){const{littleEndian:t,isBigTiff:n,firstIFDPos:a}=H(e);let i=a;const r=[];do{const a=Y(e,t,i,0,s,n?8:4);if(!a.success)break;r.push(a.ifd),i=a.nextIFD}while(i>0);return{...k(r),littleEndian:t,isBigTiff:n,ifds:r,pyramidIFDs:G(r),maskIFDs:v(r)}}function B(e,t,n){const a=e.getUint32(t,n),i=e.getUint32(t+4,n);return n?i*g+a:a*g+i}function V(e,t,n){let a=n?e.getInt32(t,n):e.getUint32(t,n),i=n?e.getUint32(t+4,n):e.getInt32(t+4,n);const r=(n?a:i)>=0?1:-1;n?a*=r:i*=r;return r*(n?i*g+a:a*g+i)}function W(e,t,n,a){return a?B(e,t,n):e.getUint32(t,n)}function H(e){const t=new DataView(e,0,16),n=t.getUint16(0,!1);let a=null;if(18761===n)a=!0;else{if(19789!==n)throw new Error("unexpected endianess byte");a=!1}const i=t.getUint16(2,a);if(42!==i&&43!==i)throw new Error("unexpected tiff identifier");let r=4;const s=43===i;if(s){const e=t.getUint16(r,a);if(r+=2,8!==e)throw new Error("unsupported bigtiff version");if(0!==t.getUint16(r,a))throw new Error("unsupported bigtiff version");r+=2}return{littleEndian:a,isBigTiff:s,firstIFDPos:W(t,r,a,s)}}function Y(t,n,a,i=0,r=s,o=4){const u=A(t,n,a,i,r,o);let c;const h=u.ifd;if(h){if(l.forEach((e,a)=>{h.has(a)&&(c=h.get(a),c.data=A(t,n,c.valueOffset-i,i,e).ifd)}),h.has("GEOKEYDIRECTORY")){c=h.get("GEOKEYDIRECTORY");const e=c.values;if(e&&e.length>4){const a=e[0]+"."+e[1]+"."+e[2];c.data=A(t,n,c.valueOffset+6-i,i,f,2).ifd,c.data&&c.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[a]})}}if(h.has("XMP")){c=h.get("XMP");const t=c.values;"number"==typeof t[0]&&7===c.type&&(c.values=[e(new Uint8Array(t))])}}return u}function _(e){const{width:t,height:n,tileHeight:a,tileWidth:i}=e,r=e.planes,s=i?i*a:t*n,l=y(e.ifds[0],"BITSPERSAMPLE");let o="";return s*r>2**30/(l>8?l/8:1)&&(o=i?"tiled tiff exceeding 1 gigabits per tile is not supported":"scanline tiff exceeding 1 gigabits is not supported"),o}function j(e,t,n,a,i){const r=a?4:1,s=n*r*i;a&&(e=new Uint8Array(e.buffer));for(let f=0;f<t;f++){const t=f*s;for(let n=i;n<s;n++)e[t+n]+=e[t+n-i]}if(!a)return e;const l=new Uint8Array(e.length),o=n*i;for(let f=0;f<t;f++){const t=f*s;for(let n=0;n<o;n++)for(let a=0;a<r;a++)l[t+n*r+a]=e[t+n+(r-a-1)*o]}return new Float32Array(l.buffer)}async function X(e,t){const{headerInfo:n,ifd:a,offsets:i,sizes:s}=t,l=[];for(let r=0;r<i.length;r++){s[r];const t=await x(e,n.littleEndian,a,i[r],s[r]||e.byteLength);l.push(t)}const o=C(a,n),f=y(a,"BITSPERSAMPLE"),u=I(y(a,"SAMPLEFORMAT")??1,f),c=y(a,"SAMPLESPERPIXEL")||n.planes,h=T(u),g=y(a,"TILEWIDTH"),E=y(a,"TILELENGTH"),w=y(a,"COMPRESSION")??1,p=g*E;let d;const m=[];let A=l[0];const S=34887===w;for(let r=0;r<c;r++){if(d=new h(p),l.length===c)A=l[r],A.length===p&&(d=A);else if(A.length)if(o||S)d=A.length===p?A:A.slice(p*r,p*(r+1));else for(let e=0;e<p;e++)d[e]=A[e*c+r];m.push(d)}const M=n.noData?n.noData[0]:t.noDataValue,P=n.metadata?n.metadata.statistics:null,O=P?P.map(e=>e.min):null,b=P?P.map(e=>e.max):null,L={pixelType:u,width:g,height:E,pixels:m,noDataValue:M};return null!=M?r(L,M,{matchAllNoData:t?.matchAllNoData}):O&&b&&t.applyMinMaxConstraint&&(L.mask=R(m,O,b)),L}async function K(e,t={}){const n=t.pyramidLevel||0,a=t.headerInfo||F(e),{ifds:i,noData:s}=a;if(0===i.length)throw new Error("no valid image file directory");const l=_(a);if(l)throw l;let o=null;const f=-1===n?i[i.length-1]:i[n],u=s??t.noDataValue;if(o=a.tileWidth?await L(e,a,f):D(e,a,f),!o)return o;if(null!=u){r(o,u,{matchAllNoData:null==s&&t?.matchAllNoData})}return o}export{K as decode,X as decodeTileOrStrip,k as getImageInfo,v as getMaskIFDs,G as getPyramidIFDs,C as isBSQConfig,N as parseFieldValues,F as parseHeader,Y as parseIFD,H as parseSignature,M as unpackBits};
|
|
@@ -1,5 +0,0 @@
|
|
|
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{property as e,subclass as s}from"../../../core/accessorSupport/decorators.js";import{getPixelValueRange as r,isIntegerPixelType as o}from"../rasterFormats/pixelRangeUtils.js";import i from"./ArithmeticFunctionArguments.js";import n from"./BaseRasterFunction.js";import{arithmetic as u}from"./localUtils.js";let p=class extends n{constructor(){super(...arguments),this.functionName="Arithmetic",this.functionArguments=null,this.rasterArgumentNames=["raster","raster2"]}_bindSourceRasters(){const{operation:t}=this.functionArguments;if(t<1||t>6)return{success:!1,supportsGPU:!1,error:"unsupported operation"};const e=this.sourceRasterInfos[0].clone();this.outputPixelType=this._getOutputPixelType(e.pixelType),e.pixelType=this.outputPixelType,this._removeStatsHistColormapVAT(e),this.rasterInfo=e;return{success:!0,supportsGPU:e.bandCount<=3}}_processPixels(t){const{pixelBlocks:e}=t;return null==e?.[0]||null==e?.[1]?null:u(e,this.functionArguments.operation,this.outputPixelType)}_getWebGLParameters(){const{operation:t}=this.functionArguments,e=["","plus","minus","times","divide","power","mod"][t],s=this.outputPixelType??"f32";let[i,n]=r(s);const u=o(s);return u&&(i-=1e-4,n+=1e-4),{imageCount:2,operationName:e,domainRange:[i,n],isOutputRounded:u}}};t([e({json:{write:!0,name:"rasterFunction"}})],p.prototype,"functionName",void 0),t([e({type:i,json:{write:!0,name:"rasterFunctionArguments"}})],p.prototype,"functionArguments",void 0),t([e()],p.prototype,"rasterArgumentNames",void 0),p=t([s("esri.layers.support.rasterFunctions.ArithmeticFunction")],p);const a=p;export{a as default};
|
|
@@ -1,5 +0,0 @@
|
|
|
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{property as t,subclass as s}from"../../../core/accessorSupport/decorators.js";import{isIntegerPixelType as i}from"../rasterFormats/pixelRangeUtils.js";import n from"./BandArithmeticFunctionArguments.js";import{calculateBandIndex as r,getBandMatrix3 as a}from"./bandIndexUtils.js";import o from"./BaseRasterFunction.js";const c=new Set(["vari","mtvi2","rtvi-core","evi"]);let u=class extends o{constructor(){super(...arguments),this.functionName="BandArithmetic",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){this.outputPixelType=this._getOutputPixelType("f32");const e=this.sourceRasterInfos[0];if(e.bandCount<2)return{success:!1,supportsGPU:!1,error:"band-arithmetic-function: source raster has insufficient amount of raster bands"};const t=e.clone();t.pixelType=this.outputPixelType,t.bandCount="sultan"===this.functionArguments.method?3:1,this._removeStatsHistColormapVAT(t),t.keyProperties={...t.keyProperties,BandProperties:void 0},this.rasterInfo=t;return{success:!0,supportsGPU:!["custom","gvitm","sultan"].includes(this.functionArguments.method)}}_processPixels(e){const t=e.pixelBlocks?.[0];if(null==t)return t;const{method:s,bandIndexes:i}=this.functionArguments,n=i.split(" ").map(e=>parseFloat(e));if(this.rasterInfo.storageInfo.isBsqTile){const{rawInputBandIds:e}=this,t=c.has(this.functionArguments.method)?3:2,s=n.slice(0,t).map(t=>e.indexOf(t-1));n.splice(0,t,...s)}return r(t,{method:s,bandIndexes:n,equation:i,outputPixelType:this.outputPixelType})}_getWebGLParameters(){const e=this.functionArguments.bandIndexes.split(" ").map(e=>parseFloat(e)-1);2===e.length&&e.push(0);const t=this.isInputBandIdsSwizzled?[0,1,2]:e;let s,n;const r=new Float32Array(3),{method:o}=this.functionArguments;switch(o){case"gndvi":case"nbr":case"ndbi":case"ndvi":case"ndvi-re":case"ndsi":case"ndmi":case"mndwi":s=a([t[0],t[1],0]),n="ndxi";break;case"ndwi":s=a([t[1],t[0],0]),n="ndxi";break;case"sr":case"sr-re":case"iron-oxide":case"ferrous-minerals":case"clay-minerals":s=a([t[0],t[1],0]),n="sr";break;case"ci-g":case"ci-re":s=a([t[0],t[1],0]),n="ci";break;case"savi":s=a([t[0],t[1],0]),n="savi",r[0]=e[2]+1;break;case"tsavi":s=a([t[0],t[1],0]),n="tsavi",r[0]=e[2]+1,r[1]=e[3]+1,r[2]=e[4]+1;break;case"msavi":s=a([t[0],t[1],0]),n="msavi";break;case"gemi":s=a([t[0],t[1],0]),n="gemi";break;case"pvi":s=a([t[0],t[1],0]),n="tsavi",r[0]=e[2]+1,r[1]=e[3]+1;break;case"vari":s=a([t[0],t[1],t[2]]),n="vari";break;case"mtvi2":s=a([t[0],t[1],t[2]]),n="mtvi";break;case"rtvi-core":s=a([t[0],t[1],t[2]]),n="rtvicore";break;case"evi":s=a([t[0],t[1],t[2]]),n="evi";break;case"wndwi":s=a([t[0],t[1],0]),n="wndwi",r[0]=e[3]?e[3]+1:.5;break;case"bai":s=a([t[1],t[0],0]),n="bai";break;default:s=a([0,1,2]),n="custom"}return{bandIndexMat3:s,indexType:n,adjustments:r,isOutputRounded:i(this.outputPixelType)}}_getInputBandIds(e){if("custom"===this.functionArguments.method)return e;const t=this.functionArguments.bandIndexes.split(" ").map(e=>parseFloat(e)-1),s=e.length,i=t.map(e=>e>=s?s-1:e),n=c.has(this.functionArguments.method)?3:2,r=i.slice(0,n).map(t=>e[t]);return 2===r.length&&r.push(0),r}_swizzleBandIds(e){const t=this.functionArguments.bandIndexes.split(" ").map(e=>parseFloat(e)-1);2===t.length&&t.push(0);const{method:s}=this.functionArguments,i=(["vari","mtvi2","rtvi-core","evi"].includes(s)?t.slice(0,3):"bai"===s||"ndwi"===s?[t[1],t[0]]:t.slice(0,2)).map(t=>e.indexOf(t));return i[2]??=i[1],this.isInputBandIdsSwizzled=!0,this.swizzledBandSelection=i,!1}};e([t({json:{write:!0,name:"rasterFunction"}})],u.prototype,"functionName",void 0),e([t({type:n,json:{write:!0,name:"rasterFunctionArguments"}})],u.prototype,"functionArguments",void 0),e([t()],u.prototype,"rasterArgumentNames",void 0),u=e([s("esri.layers.support.rasterFunctions.BandArithmeticFunction")],u);const m=u;export{m as default};
|