@arcgis/core 4.28.0-next.20230719 → 4.28.0-next.20230721
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/Color.js +1 -1
- package/analysis/AreaMeasurementAnalysis.js +1 -1
- package/arcade/arcadeCompiler.js +1 -1
- package/arcade/featureSetUtils.js +1 -1
- package/arcade/featureset/actions/Top.js +1 -1
- package/arcade/featureset/sources/FeatureLayerDynamic.js +1 -1
- package/arcade/featureset/support/FeatureSet.js +1 -1
- package/arcade/featureset/support/FeatureSetIterator.js +1 -1
- package/arcade/functions/convertdirection.js +1 -1
- package/arcade/functions/featuresetbase.js +1 -1
- package/arcade/functions/geomasync.js +1 -1
- package/arcade/functions/geomsync.js +1 -1
- package/arcade/lib/comment-handler.js +1 -1
- package/arcade/lib/parser.js +1 -1
- package/arcade/lib/scanner.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{75c28da8d0b02d612d69.js → 040b3fc9c9c0736dd893.js} +1 -1
- package/assets/esri/core/workers/chunks/0652f6a8d5221e978033.js +1 -0
- package/assets/esri/core/workers/chunks/{e579ca7d4c1387e17305.js → 092fda62b6f62c2e4869.js} +2 -2
- package/assets/esri/core/workers/chunks/{57e0ad037188bd2997e7.js → 0af18a96cbd4e2d35436.js} +1 -1
- package/assets/esri/core/workers/chunks/0b5eeec0f66c87a46a0c.js +1 -0
- package/assets/esri/core/workers/chunks/{68e568b67b6fb34393db.js → 0cad2b991d0d0fd07846.js} +1 -1
- package/assets/esri/core/workers/chunks/0dccbc6c2559fdc0c2ad.js +1 -0
- package/assets/esri/core/workers/chunks/256a82f6f6e1405fbcc6.js +1 -0
- package/assets/esri/core/workers/chunks/{bb9213899049e1db90da.js → 2c57c9bd71637c5bed8a.js} +1 -1
- package/assets/esri/core/workers/chunks/2cdbabcbfe32286ec78d.js +1 -0
- package/assets/esri/core/workers/chunks/{2b1c83453a862e01954b.js → 2d9d80b2d0042a9c09fb.js} +1 -1
- package/assets/esri/core/workers/chunks/2f9aec2238ff6cb99e09.js +1 -0
- package/assets/esri/core/workers/chunks/{55705b1bbac91d7db0e7.js → 32d940b2c891bf6ff9a2.js} +1 -1
- package/assets/esri/core/workers/chunks/3a0349c79551a03c2d8e.js +1 -0
- package/assets/esri/core/workers/chunks/{7dbd3e6406fb3e3a1a8f.js → 3cf748c025f3936c1cb2.js} +1 -1
- package/assets/esri/core/workers/chunks/4481d1103363434f16da.js +1 -0
- package/assets/esri/core/workers/chunks/58e11ca7c6e27e0ece7e.js +1 -0
- package/assets/esri/core/workers/chunks/5ae325e6a795c72eac6c.js +1 -0
- package/assets/esri/core/workers/chunks/5e4dde2886a1027b4b96.js +1 -0
- package/assets/esri/core/workers/chunks/{357e0381b6d767585576.js → 675e16d99758e67e5f51.js} +1 -1
- package/assets/esri/core/workers/chunks/726bb661b9e6998572e7.js +1 -0
- package/assets/esri/core/workers/chunks/730eb7e5f617fdab4f10.js +1 -0
- package/assets/esri/core/workers/chunks/{5a2e6bed9431cf4f42b1.js → 740dc67038f554431f1b.js} +1 -1
- package/assets/esri/core/workers/chunks/7cab61c9e09580520990.js +1 -0
- package/assets/esri/core/workers/chunks/{09178454bda15bb7929a.js → 7fbdfd1527582c52f9b6.js} +1 -1
- package/assets/esri/core/workers/chunks/{26546aa98a338051df66.js → 807742f38885fa90b4fe.js} +1 -1
- package/assets/esri/core/workers/chunks/82dfbc175b52c7a10475.js +1 -0
- package/assets/esri/core/workers/chunks/870a05451e074b58f19a.js +1 -0
- package/assets/esri/core/workers/chunks/88038ad401e5ec02f4d3.js +1 -0
- package/assets/esri/core/workers/chunks/88d63d1e56732d148f67.js +1 -0
- package/assets/esri/core/workers/chunks/8b72cd9340e8a44358ac.js +1 -0
- package/assets/esri/core/workers/chunks/8c5a8c1dfb086069bb06.js +1 -0
- package/assets/esri/core/workers/chunks/99a5a434e0bad48c7a5c.js +1 -0
- package/assets/esri/core/workers/chunks/9a5916c66dad91d01d5b.js +1 -0
- package/assets/esri/core/workers/chunks/9c133fd8c1fbd0295b86.js +1 -0
- package/assets/esri/core/workers/chunks/9cddb504079d396779ea.js +1 -0
- package/assets/esri/core/workers/chunks/a3a1d4f32e518e97d071.js +1 -0
- package/assets/esri/core/workers/chunks/{9548aa449fe3a300c015.js → a4fa40dc77e116c954ac.js} +1 -1
- package/assets/esri/core/workers/chunks/a54ec9929a7db879d5db.js +1 -0
- package/assets/esri/core/workers/chunks/afc5b84693757fda2bc8.js +1 -0
- package/assets/esri/core/workers/chunks/{591b5c277cfd3a4101a4.js → b08f2a4aa94087c6c367.js} +1 -1
- package/assets/esri/core/workers/chunks/c0e12f6a7bb2360e4c21.js +1 -0
- package/assets/esri/core/workers/chunks/c8e656cd470a17f538e9.js +1 -0
- package/assets/esri/core/workers/chunks/d0e203405f95e14b1399.js +1 -0
- package/assets/esri/core/workers/chunks/d61506497275bafba384.js +1 -0
- package/assets/esri/core/workers/chunks/{ec72f492f24e67e008ae.js → d8e58dc14d3495f0830c.js} +1 -1
- package/assets/esri/core/workers/chunks/db9a303ee0468d018def.js +1 -0
- package/assets/esri/core/workers/chunks/ddc393a012588f799f42.js +1 -0
- package/assets/esri/core/workers/chunks/de3baa85b1639c25458d.js +1 -0
- package/assets/esri/core/workers/chunks/e66cea26064ba8353af0.js +1 -0
- package/assets/esri/core/workers/chunks/ea478f2f4a19463e13fd.js +1 -0
- package/assets/esri/core/workers/chunks/eba197e45507f56f3ed0.js +1 -0
- package/assets/esri/core/workers/chunks/ebd006fcd568a7731115.js +1 -0
- package/assets/esri/core/workers/chunks/ef9a9a7d66d818720e20.js +1 -0
- package/assets/esri/core/workers/chunks/f3b458f55236566c940b.js +1 -0
- package/assets/esri/core/workers/chunks/fd0a91b9e0216cc269c3.js +1 -0
- package/assets/esri/core/workers/chunks/{a4fe220a912b1f428e49.js → fdd6403a8390d629392b.js} +1 -1
- package/assets/esri/themes/base/widgets/_Directions.scss +13 -7
- package/assets/esri/themes/base/widgets/_OrientedImageryViewer.scss +108 -4
- package/assets/esri/themes/dark/main.css +1 -1
- package/assets/esri/themes/light/main.css +1 -1
- package/assets/esri/themes/light/view.css +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer.json +1 -1
- package/assets/esri/widgets/OrientedImageryViewer/t9n/OrientedImageryViewer_en.json +1 -1
- package/chunks/ComponentShader.glsl.js +1 -1
- package/chunks/LineSeries.js +1 -1
- package/chunks/Theme.js +1 -1
- package/chunks/array.js +1 -1
- package/chunks/chartUtilsAm5.js +1 -1
- package/core/Collection.js +1 -1
- package/core/accessorSupport/decorators/subclass.js +1 -1
- package/core/accessorSupport/ensureType.js +1 -1
- package/core/accessorSupport/get.js +1 -1
- package/core/accessorSupport/tracking.js +1 -1
- package/core/accessorSupport/utils.js +1 -1
- package/core/libs/rbush/PooledRBush.js +1 -1
- package/core/urlUtils.js +1 -1
- package/geometry/GeometryCursor.js +1 -1
- package/geometry/support/TileClipper.js +1 -1
- package/geometry/support/geodesicUtils.js +1 -1
- package/interfaces.d.ts +9 -3
- package/layers/BuildingSceneLayer.js +1 -1
- package/layers/IntegratedMeshLayer.js +1 -1
- package/layers/LinkChartLayer.js +1 -1
- package/layers/PointCloudLayer.js +1 -1
- package/layers/SceneLayer.js +1 -1
- package/layers/VectorTileLayer.js +1 -1
- package/layers/VoxelLayer.js +1 -1
- package/layers/VoxelWasmPerSceneView.js +1 -1
- package/layers/WCSLayer.js +1 -1
- package/layers/effects/EffectView.js +1 -1
- package/layers/graphics/sources/geojson/geojson.js +1 -1
- package/layers/knowledgeGraph/KnowledgeGraphLayerDataManager.js +1 -1
- package/layers/mixins/ArcGISCachedService.js +1 -1
- package/layers/orientedImagery/core/ExposurePoint.js +1 -1
- package/layers/orientedImagery/core/bestImageUtils.js +1 -1
- package/layers/orientedImagery/queries.js +1 -1
- package/layers/save/featureLayerUtils.js +1 -1
- package/layers/support/ElevationQuery.js +1 -1
- package/layers/support/MultidimensionalSubset.js +1 -1
- package/layers/support/Sublayer.js +1 -1
- package/layers/support/TileInfo.js +1 -1
- package/layers/support/TileInfoTilemapCache.js +1 -1
- package/layers/support/TilemapCache.js +1 -1
- package/layers/support/rasterDatasets/multidimensionalUtils.js +1 -1
- package/layers/support/rasterDatasets/pamParser.js +1 -1
- package/layers/support/rasterDatasets/wcsCoverageParser.js +1 -1
- package/layers/support/rasterFormats/Raw.js +1 -1
- package/layers/support/rasterFormats/TiffDecoder.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
- package/layers/support/rasterFunctions/colormaps.js +1 -1
- package/layers/support/rasterFunctions/pixelUtils.js +1 -1
- package/layers/support/rasterFunctions/rasterProjectionHelper.js +1 -1
- package/layers/video/VideoController.js +1 -1
- package/layers/voxel/VoxelDimension.js +1 -1
- package/layers/voxel/VoxelTransferFunctionStyle.js +1 -1
- package/layers/voxel/VoxelVolume.js +1 -1
- package/package.json +1 -1
- package/renderers/support/RasterSymbolizer.js +1 -1
- package/renderers/support/colorRampUtils.js +1 -1
- package/renderers/visualVariables/support/visualVariableUtils.js +1 -1
- package/rest/query/operations/pbfDehydratedFeatureSet.js +1 -1
- package/rest/query/operations/pbfJSONFeatureSet.js +1 -1
- package/rest/support/generateRendererUtils.js +1 -1
- package/smartMapping/raster/renderers/classBreaks.js +1 -1
- package/smartMapping/renderers/color.js +1 -1
- package/smartMapping/renderers/support/utils.js +1 -1
- package/smartMapping/renderers/type.js +1 -1
- package/smartMapping/renderers/univariateColorSize.js +1 -1
- package/smartMapping/support/adapters/support/utils.js +1 -1
- package/statistics/utils.js +1 -1
- package/support/elevationInfoUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/GeometryWalker.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/cim/effects/EffectArrow.js +1 -1
- package/symbols/cim/effects/EffectControlMeasureLine.js +1 -1
- package/symbols/support/symbolUtils.js +1 -1
- package/views/2d/constraints/ZoomConstraint.js +1 -1
- package/views/2d/engine/flow/dataUtils.js +1 -1
- package/views/2d/engine/flow/utils.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTile.js +1 -1
- package/views/2d/engine/vectorTiles/VectorTileContainer.js +1 -1
- package/views/2d/engine/vectorTiles/expression/expression.js +1 -1
- package/views/2d/engine/vectorTiles/style/VectorTileSource.js +1 -1
- package/views/2d/engine/vectorTiles/tileInfoUtils.js +1 -1
- package/views/2d/engine/webgl/TurboLine.js +1 -1
- package/views/2d/engine/webgl/mesh/MeshData.js +1 -1
- package/views/2d/engine/webgl/mesh/templates/shapingUtils.js +1 -1
- package/views/2d/interactive/editingTools/ControlPointsTransformTool.js +1 -1
- package/views/2d/interactive/editingTools/draw/DrawGraphicTool2D.js +1 -1
- package/views/2d/layers/BaseLayerView2D.js +1 -1
- package/views/2d/layers/BaseLayerViewGL2D.js +1 -1
- package/views/2d/layers/BitmapTileLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/VectorTileLayerView2D.js +1 -1
- package/views/2d/layers/WMTSLayerView2D.js +1 -1
- package/views/2d/layers/features/support/rendererUtils.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/support/vectorTileDebugUtils.js +5 -0
- package/views/2d/tiling/TileInfoView.js +1 -1
- package/views/2d/tiling/TileInfoViewPOT.js +1 -1
- package/views/2d/tiling/TileQueue.js +1 -1
- package/views/2d/tiling.js +1 -1
- package/views/3d/analysis/Slice/sliceToolUtils.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/EnvironmentRenderer.js +1 -1
- package/views/3d/externalRenderers/ExternalRendererStore.js +1 -1
- package/views/3d/interactive/editingTools/moveGraphic/GraphicMoveTool.js +1 -1
- package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
- package/views/3d/layers/ImageryTileLayerView3D.js +1 -1
- package/views/3d/layers/TiledLayerView3D.js +1 -1
- package/views/3d/layers/VectorTileLayerView3D.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/Labeler.js +1 -1
- package/views/3d/layers/i3s/PointRenderer.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/featureReference.js +1 -1
- package/views/3d/support/LaserLineRenderer.js +1 -1
- package/views/3d/terrain/Overlay.js +1 -1
- package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
- package/views/3d/terrain/OverlayManager.js +1 -1
- package/views/3d/terrain/OverlayRenderTarget.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/TerrainRenderer.js +1 -1
- package/views/3d/terrain/TerrainSurface.js +1 -1
- package/views/3d/terrain/TileCompositor.js +1 -1
- package/views/3d/terrain/TileRenderer.js +1 -1
- package/views/3d/terrain/TilingScheme.js +1 -1
- package/views/3d/webgl-engine/collections/Component/ComponentData.js +1 -1
- package/views/3d/webgl-engine/core/renderPasses/RenderPassManager.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/shading/EvaluateAmbientOcclusion.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderModules/interfaces.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPlugin.js +5 -0
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +5 -0
- package/views/3d/webgl-engine/effects/ScreenSpaceGeometry.js +5 -0
- package/views/3d/webgl-engine/effects/SmaaRenderPass.js +5 -0
- package/views/3d/webgl-engine/lib/CompositingHelper.js +1 -1
- package/views/3d/webgl-engine/lib/GLMaterials.js +1 -1
- package/views/3d/webgl-engine/lib/GeometryUtil.js +1 -1
- package/views/3d/webgl-engine/lib/OffscreenRendering.js +1 -1
- package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/RenderingContext.js +1 -1
- package/views/3d/webgl-engine/lib/SSAOHelper.js +1 -1
- package/views/3d/webgl-engine/lib/SortedRenderGeometryRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/WebGLLayer.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodComponentData.js +1 -1
- package/views/3d/webgl-engine/lib/lodRendering/LodRenderer.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/MergedRenderer.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/parts/requireUtils.js +1 -1
- package/views/3d/webgl-engine/statistics/RendererPerformanceInfo.js +1 -1
- package/views/LayerViewManager.js +1 -1
- package/views/MapView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/animation/pointToPoint/Path.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/createUtils.js +1 -1
- package/views/interactive/SegmentLabels.js +1 -1
- package/views/interactive/editGeometry/EditGeometry.js +1 -1
- package/views/interactive/editGeometry/EditGeometryOperations.js +1 -1
- package/views/interactive/editGeometry/operations/UndoGroup.js +1 -1
- package/views/layers/GroupLayerView.js +1 -1
- package/views/layers/ImageryTileLayerView.js +1 -1
- package/views/webgl/ProgramCache.js +1 -1
- package/webscene/spec-certification/api.js +1 -1
- package/webscene/spec-certification/spec.js +1 -1
- package/webscene/spec-certification/utils.js +1 -1
- package/widgets/BuildingExplorer/BuildingNumericFilterViewModel.js +1 -1
- package/widgets/BuildingExplorer/BuildingPhase.js +1 -1
- package/widgets/BuildingExplorer/support/validation.js +1 -1
- package/widgets/Directions/support/resources.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateRecordWorkflow.js +1 -1
- package/widgets/Editor/Workflow.js +1 -1
- package/widgets/Editor.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/FieldInput.js +1 -1
- package/widgets/FeatureForm/FormExpressionsManager.js +1 -1
- package/widgets/FeatureForm.js +1 -1
- package/widgets/FeatureTemplates/FeatureTemplatesViewModel.js +1 -1
- package/widgets/FeatureTemplates.js +1 -1
- package/widgets/Features.js +1 -1
- package/widgets/Histogram/HistogramViewModel.js +1 -1
- package/widgets/HistogramRangeSlider/HistogramRangeSliderViewModel.js +1 -1
- package/widgets/Legend/styles/Card.js +1 -1
- package/widgets/Legend/styles/support/univariateUtils.js +1 -1
- package/widgets/Legend/support/ActiveLayerInfo.js +1 -1
- package/widgets/Legend/support/colorRampUtils.js +1 -1
- package/widgets/Legend/support/sizeRampUtils.js +1 -1
- package/widgets/Legend/support/utils.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/arcUtils.js +5 -0
- package/widgets/OrientedImageryViewer/constants.js +5 -0
- package/widgets/OrientedImageryViewer/utils.js +5 -0
- package/widgets/OrientedImageryViewer.js +1 -1
- package/widgets/Popup/PopupViewModel.js +1 -1
- package/widgets/Popup.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRanges.js +1 -1
- package/widgets/ValuePicker/ValuePickerSlider.js +1 -1
- package/widgets/smartMapping/ClassedSizeSlider.js +1 -1
- package/widgets/smartMapping/ColorSizeSlider.js +1 -1
- package/widgets/smartMapping/HeatmapSlider/HeatmapSliderViewModel.js +1 -1
- package/widgets/smartMapping/SizeSlider.js +1 -1
- package/widgets/smartMapping/SmartMappingPrimaryHandleSliderViewModel.js +1 -1
- package/widgets/smartMapping/SmartMappingSliderViewModel.js +1 -1
- package/widgets/support/ColorPicker.js +1 -1
- package/assets/esri/core/workers/chunks/07bb40162d97d098bc19.js +0 -1
- package/assets/esri/core/workers/chunks/0a18317566c1fcb68422.js +0 -1
- package/assets/esri/core/workers/chunks/0de65e03db8c611af9fb.js +0 -1
- package/assets/esri/core/workers/chunks/1a60d23a92bcf91dbb22.js +0 -1
- package/assets/esri/core/workers/chunks/205a0b34b698d5329854.js +0 -1
- package/assets/esri/core/workers/chunks/2158a6ec165503ec4711.js +0 -1
- package/assets/esri/core/workers/chunks/25211d5904ee9d5f4a9d.js +0 -1
- package/assets/esri/core/workers/chunks/26b12d1ea713c1e07701.js +0 -1
- package/assets/esri/core/workers/chunks/2bfa7ee324c32a56b0d3.js +0 -1
- package/assets/esri/core/workers/chunks/370a992bd308bd806f48.js +0 -1
- package/assets/esri/core/workers/chunks/3892650ecc61322f6f7f.js +0 -1
- package/assets/esri/core/workers/chunks/38d168e9a29c40de179d.js +0 -1
- package/assets/esri/core/workers/chunks/4bf1c6c7e0a3051dc797.js +0 -1
- package/assets/esri/core/workers/chunks/524156c3f5383c2dd0e3.js +0 -1
- package/assets/esri/core/workers/chunks/59666ecb7c2c1f5a13b2.js +0 -1
- package/assets/esri/core/workers/chunks/5ae98195bdfd7dc0c44e.js +0 -1
- package/assets/esri/core/workers/chunks/5c005c9514354c77ec27.js +0 -1
- package/assets/esri/core/workers/chunks/5d46fd68878c973bcfab.js +0 -1
- package/assets/esri/core/workers/chunks/5dd23092c8a8a5ccd5d0.js +0 -1
- package/assets/esri/core/workers/chunks/620ec5c75561183d3d73.js +0 -1
- package/assets/esri/core/workers/chunks/68512670816f59c0e6a5.js +0 -1
- package/assets/esri/core/workers/chunks/6c7374ebc18b46b3480a.js +0 -1
- package/assets/esri/core/workers/chunks/75ba2af92da232067adb.js +0 -1
- package/assets/esri/core/workers/chunks/7c1f0598a016516dcec3.js +0 -1
- package/assets/esri/core/workers/chunks/8dcec8d1b670d2b7ea2b.js +0 -1
- package/assets/esri/core/workers/chunks/8e07dfb6fc2673b640cb.js +0 -1
- package/assets/esri/core/workers/chunks/9008dde941cb3973de20.js +0 -1
- package/assets/esri/core/workers/chunks/9050b167355588b7003d.js +0 -1
- package/assets/esri/core/workers/chunks/9230d68799f0b0b9ef36.js +0 -1
- package/assets/esri/core/workers/chunks/94d124453e90a5ab1706.js +0 -1
- package/assets/esri/core/workers/chunks/9ca312af9c056b1efe40.js +0 -1
- package/assets/esri/core/workers/chunks/b0a57718a0765d1c8df0.js +0 -1
- package/assets/esri/core/workers/chunks/b431b81a7bf45dd527da.js +0 -1
- package/assets/esri/core/workers/chunks/bda311ad48efdb265939.js +0 -1
- package/assets/esri/core/workers/chunks/da547c3cabe4a89c3ce6.js +0 -1
- package/assets/esri/core/workers/chunks/dd295fa57b45b7ec4ec5.js +0 -1
- package/assets/esri/core/workers/chunks/eb92aa372e706ce5a5eb.js +0 -1
- package/assets/esri/core/workers/chunks/f553b464e969d45bf451.js +0 -1
- package/assets/esri/core/workers/chunks/f5865294983eb160de8c.js +0 -1
- package/assets/esri/core/workers/chunks/fdb7b1fbdb6fe091ad83.js +0 -1
- package/assets/esri/core/workers/chunks/fe8544bf3bbbacd74b8b.js +0 -1
- package/views/2d/tiling/PagedTileQueue.js +0 -5
- package/views/3d/webgl-engine/lib/RenderPluginManager.js +0 -5
- package/views/3d/webgl-engine/lib/SmaaRenderPass.js +0 -5
- /package/views/3d/webgl-engine/{lib → effects}/SmaaRenderPassData.js +0 -0
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{isSome as e}from"../../../core/arrayUtils.js";import n from"../DimensionalDefinition.js";function t(e,n,i){const a=n.shift();if(0===i.length){const e=[];i.push({sliceId:-1,multidimensionalDefinition:e})}const s=i.length;for(let t=0;t<s;t++){const n=i.shift().multidimensionalDefinition;a.values?.forEach((t=>{i.push({sliceId:-1,multidimensionalDefinition:[...n,{variableName:e,dimensionName:a.name,values:[t]}]})}))}n.length&&t(e,n,i)}function i(e,n){const i=[];let a=0;return(n?e.variables.filter((e=>e.name.toLowerCase()===n.toLowerCase())):[...e.variables].sort(((e,n)=>e.name>n.name?1:-1))).forEach((e=>{const n=[],s=[...e.dimensions].sort(((e,n)=>e.name>n.name?-1:1));t(e.name,s,n),n.forEach((e=>{i.push({...e,sliceId:a++})}))})),i}function a(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&&t&&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 s(e,n){return Array.isArray(e)?n[0]===n[1]?e[0]===n[0]||e[1]===n[0]:e[0]>=n[0]&&e[0]<=n[1]&&e[1]>=n[0]&&e[1]<=n[1]:e>=n[0]&&e<=n[1]}function r(e,n){return e[0]<=n[0]&&e[1]>=n[0]||e[0]<=n[1]&&e[1]>=n[1]||e[0]>=n[0]&&e[1]<=n[1]}function l(e){return 1===e.length?[e[0],e[0]]:[e[0],e.
|
|
5
|
+
import{isSome as e}from"../../../core/arrayUtils.js";import n from"../DimensionalDefinition.js";function t(e,n,i){const a=n.shift();if(0===i.length){const e=[];i.push({sliceId:-1,multidimensionalDefinition:e})}const s=i.length;for(let t=0;t<s;t++){const n=i.shift().multidimensionalDefinition;a.values?.forEach((t=>{i.push({sliceId:-1,multidimensionalDefinition:[...n,{variableName:e,dimensionName:a.name,values:[t]}]})}))}n.length&&t(e,n,i)}function i(e,n){const i=[];let a=0;return(n?e.variables.filter((e=>e.name.toLowerCase()===n.toLowerCase())):[...e.variables].sort(((e,n)=>e.name>n.name?1:-1))).forEach((e=>{const n=[],s=[...e.dimensions].sort(((e,n)=>e.name>n.name?-1:1));t(e.name,s,n),n.forEach((e=>{i.push({...e,sliceId:a++})}))})),i}function a(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&&t&&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 s(e,n){return Array.isArray(e)?n[0]===n[1]?e[0]===n[0]||e[1]===n[0]:e[0]>=n[0]&&e[0]<=n[1]&&e[1]>=n[0]&&e[1]<=n[1]:e>=n[0]&&e<=n[1]}function r(e,n){return e[0]<=n[0]&&e[1]>=n[0]||e[0]<=n[1]&&e[1]>=n[1]||e[0]>=n[0]&&e[1]<=n[1]}function l(e){return 1===e.length?[e[0],e[0]]:[e[0],e[e.length-1]]}function u(e,n,t){if(!n?.subsetDefinitions?.length)return e;let 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=l(s.values)}else{const t=n.dimensions.find((({name:n})=>n===e.name));i=t?.extent}const a=i;if(!a||!a?.length)return e;const r=e.values.filter((e=>s(e,a)));return{...e,extent:[...a],values:r}}function o(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],u=n.subsetDefinitions.find((e=>(""===i.variableName||e.variableName===i.variableName)&&e.dimensionName===i.dimensionName));if(u?.values.length){const e=l(u.values);if(!i.isSlice&&2===i.values.length&&!Array.isArray(i.values[0])&&i.values[0]!==i.values[1]&&t){if(!r(i.values,e))return!0}else if(i.values.some((n=>!s(n,e))))return!0}}return!1}function m(e,n){if(null==e)return{isOutside:!1};const{geometry:t,timeExtent:i,multidimensionalDefinition:a}=n;let s=null;if(null!=i&&(s=c(e,i),null==s))return{isOutside:!0};const{areaOfInterest:r}=e;if(r&&t){const e="point"===t.type?t:"extent"===t.type?t.center:"polygon"===t.type?t.centroid:null;if(e&&!r.contains(e))return{isOutside:!0}}return null!=a&&a.length&&o(a,e,!0)?{isOutside:!0}:{isOutside:!1,intersection:{geometry:t,timeExtent:s,multidimensionalDefinition:a}}}function c(e,t){const i=e.dimensions.find((({name:e})=>"StdTime"===e));if(null==i||null==t.start&&null==t.end)return t;t=t.clone();const{start:a,end:s}=t.toJSON(),r=a===s?[a]:null!=a&&null!=s?[a,s]:[a??s];if(2===r.length&&i?.extent.length&&(r[0]=Math.max(r[0],i.extent[0]),r[1]=Math.min(r[1],i.extent[1]??i.extent[0]),r[1]<r[0]))return null;return o([new n({variableName:"",dimensionName:"StdTime",isSlice:1===r.length,values:r})],e,!0)?null:(t.start=new Date(r[0]),t.end=new Date(r[1]??r[0]),t)}function f(e,n={}){const{multidimensionalInfo:t,keyProperties: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 d(e,t={}){const i=f(e,t);if(!i)return null;const a=[],{dimensions:s,name:r}=i;if(0===s.length)return[new n({variableName:r,dimensionName:"",values:[],isSlice:!0})];for(let l=0;l<s.length;l++){const e=u(s[l],t.multidimensionalSubset,r);if(!e)return null;const{values:i,extent:o}=e;let m=i?.[0]??o[0];"stdz"===e.name.toLowerCase()&&!e.hasRanges&&Math.abs(o[1])<=Math.abs(o[0])&&(m=i?.length?i[i.length-1]:o[1]),a.push(new n({variableName:r,dimensionName:e.name,values:[m],isSlice:!t.useRangeForRangedDimensionInfo||!!e.hasRanges}))}return a}function h(e){return!(null==e||!e.length)&&e.some((e=>{if(null==e.values)return!0;const n=e.values.length;return 0===n||n>1||!e.isSlice&&Array.isArray(e.values[0])}))}function g(n,t){if(null==t||null==n)return null;let 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=>u(e,n,t.name))).filter(e)}))),i}function v(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)||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()||"seconds"){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 b(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":{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}break;case"years":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear())/a);break;case"decades":n=Math.round((new Date(t[1]).getUTCFullYear()-new Date(t[0]).getUTCFullYear())/10/a);break;default:n=0}return n}function D(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=>b(e))).reduce(((e,n)=>e*n));continue}const l=r.map((e=>b(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=v(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}export{i as createSlices,d as getDefaultMultidimensionalDefinition,f as getDefaultVariablInfo,a as getSliceIds,D as getSliceIndex,g as getSubsetVariablesFromMdInfo,o as hasExcludedVariableOrDimension,m as intersectMultimensionalSubset,h as isMultiSliceOrRangeDefinition};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../geometry.js";import{isSome as e}from"../../../core/arrayUtils.js";import{isSameTagIgnoreNS as t,getElementValue as n,getElements as r,getElement as s,getElementNumericValue as a,getElementNumericValues as i}from"./xmlUtilities.js";import l from"../rasterTransforms/PolynomialTransform.js";import o from"../../../geometry/SpatialReference.js";function f(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 u(e){const t=s(e,"GeodataXform"),r=m(a(t,"SpatialReference/WKID")||n(t,"SpatialReference/WKT"));if("typens:PolynomialXform"!==t.getAttribute("xsi:type"))return{spatialReference:r,transform:null};const o=a(t,"PolynomialOrder")??1,u=i(t,"CoeffX/Double"),c=i(t,"CoeffY/Double"),d=i(t,"InverseCoeffX/Double"),p=i(t,"InverseCoeffY/Double"),S=f(u,c),C=f(d,p);return{spatialReference:r,transform:S&&C&&S.length&&C.length?new l({spatialReference:r,polynomialOrder:o,forwardCoefficients:S,inverseCoefficients:C}):null}}function c(e){const t=a(e,"NoDataValue"),i=s(e,"Histograms/HistItem"),l=a(i,"HistMin"),o=a(i,"HistMax"),f=a(i,"BucketCount"),u=n(i,"HistCounts")?.split("|").map((e=>Number(e)));let c,m,d,p;r(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=a(e,"Metadata/SourceBandIndex");return{noDataValue:t,histogram:u?.length&&null!=l&&null!=o?{min:l,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 m(e){if(!e)return null;let t=Number(e);if(!isNaN(t)&&0!==t)return new o({wkid:t});if((e=String(e)).startsWith("COMPD_CS")){if(!e.includes("VERTCS")||!e.includes("GEOGCS")&&!e.startsWith("PROJCS"))return null;const n=e.indexOf("VERTCS"),r=e.indexOf("PROJCS"),s=r>-1?r:e.indexOf("GEOGCS");if(-1===s)return null;const a=e.slice(s,e.lastIndexOf("]",n)+1).trim(),i=e.slice(n,e.lastIndexOf("]")).trim();t=d(a);const l=new o(t?{wkid:t}:{wkt:a}),f=d(i);return f&&(l.vcsWkid=f),l}return e.startsWith("GEOGCS")||e.startsWith("PROJCS")?(t=d(e),new o(0!==t?{wkid:t}:{wkt:e})):null}function d(e){const t=e.replaceAll("]","[").replaceAll('"',"").split("[").map((e=>e.trim())).filter((e=>""!==e)).
|
|
5
|
+
import"../../../geometry.js";import{isSome as e}from"../../../core/arrayUtils.js";import{isSameTagIgnoreNS as t,getElementValue as n,getElements as r,getElement as s,getElementNumericValue as a,getElementNumericValues as i}from"./xmlUtilities.js";import l from"../rasterTransforms/PolynomialTransform.js";import o from"../../../geometry/SpatialReference.js";function f(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 u(e){const t=s(e,"GeodataXform"),r=m(a(t,"SpatialReference/WKID")||n(t,"SpatialReference/WKT"));if("typens:PolynomialXform"!==t.getAttribute("xsi:type"))return{spatialReference:r,transform:null};const o=a(t,"PolynomialOrder")??1,u=i(t,"CoeffX/Double"),c=i(t,"CoeffY/Double"),d=i(t,"InverseCoeffX/Double"),p=i(t,"InverseCoeffY/Double"),S=f(u,c),C=f(d,p);return{spatialReference:r,transform:S&&C&&S.length&&C.length?new l({spatialReference:r,polynomialOrder:o,forwardCoefficients:S,inverseCoefficients:C}):null}}function c(e){const t=a(e,"NoDataValue"),i=s(e,"Histograms/HistItem"),l=a(i,"HistMin"),o=a(i,"HistMax"),f=a(i,"BucketCount"),u=n(i,"HistCounts")?.split("|").map((e=>Number(e)));let c,m,d,p;r(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=a(e,"Metadata/SourceBandIndex");return{noDataValue:t,histogram:u?.length&&null!=l&&null!=o?{min:l,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 m(e){if(!e)return null;let t=Number(e);if(!isNaN(t)&&0!==t)return new o({wkid:t});if((e=String(e)).startsWith("COMPD_CS")){if(!e.includes("VERTCS")||!e.includes("GEOGCS")&&!e.startsWith("PROJCS"))return null;const n=e.indexOf("VERTCS"),r=e.indexOf("PROJCS"),s=r>-1?r:e.indexOf("GEOGCS");if(-1===s)return null;const a=e.slice(s,e.lastIndexOf("]",n)+1).trim(),i=e.slice(n,e.lastIndexOf("]")).trim();t=d(a);const l=new o(t?{wkid:t}:{wkt:a}),f=d(i);return f&&(l.vcsWkid=f),l}return e.startsWith("GEOGCS")||e.startsWith("PROJCS")?(t=d(e),new o(0!==t?{wkid:t}:{wkt:e})):null}function d(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 p(s){if("pamdataset"!==s?.documentElement.tagName?.toLowerCase())return{};const a={spatialReference:null,transform:null,metadata:{},rasterBands:[],statistics:null,histograms:null};s.documentElement.childNodes.forEach((e=>{if(1===e.nodeType)if(t(e,"SRS")){if(!a.spatialReference){const t=n(e);a.spatialReference=m(t)}}else if(t(e,"Metadata"))if("xml:ESRI"===e.getAttribute("domain")){const{spatialReference:t,transform:n}=u(e);a.transform=n,a.spatialReference||(a.spatialReference=t)}else{r(e,"MDI").forEach((e=>a.metadata[e.getAttribute("key")]=n(e)))}else if(t(e,"PAMRasterBand")){const t=c(e);null!=t.sourceBandIndex&&null==a.rasterBands[t.sourceBandIndex]?a.rasterBands[t.sourceBandIndex]=t:a.rasterBands.push(t)}}));const i=a.rasterBands;if(i.length){const t=!!i[0].statistics;a.statistics=t?i.map((e=>e.statistics)).filter(e):null;const n=!!i[0].histogram;a.histograms=n?i.map((e=>e.histogram)).filter(e):null}return a}export{p as parsePAMInfo,m as parseSpatialReference};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
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{getElements as s,isSameTagIgnoreNS as a,getElementValue as o,getElementValues as l,getNodeNameIgnoreNS as r,getElement as u,getSpaceDelimitedNumericValues as m}from"./xmlUtilities.js";function p(e){return{requestResponseCRSs:l(e,"requestResponseCRSs").map((e=>e.split(":")[1])),nativeCRSs:l(e,"nativeCRSs").map((e=>e.split(":")[1]))}}function d(e,t){const n=l(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):o(e,"InterpolationMethods/Default");return null!=i?[i].concat(n.filter((e=>e.toLowerCase()!==i.toLowerCase()))):n}function c(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 f(t){const n=s(t,"pos"),i=m(n[0]),a=m(n[1]);return new e({xmin:i[0],ymin:i[1],xmax:a[0],ymax:a[1],spatialReference:{wkid:4326}})}function g(e,t){const n=l(e,t);return n?.length&&""!==n[0]&&!isNaN(Number(n[0]))?n.map((e=>Number(e))):null}function h(e){return null==e?null:e.every((t=>t===e[0]))?e[0]:e}function b(e){const t=[],n=s(e,"RangeSet");let i=[];for(let a=0;a<n.length;a++){const e=o(n[a],"name"),r=o(n[a],"label"),u=[],m=g(n[a],"nullValues/singleValue"),p=s(n[a],"AxisDescription");for(let t=0;t<p.length;t++){const e=o(p[t],"name"),n=o(p[t],"label"),s=l(p[t],"singleValue");if(0===s.length){const e=o(p[t],"min"),n=o(p[t],"max"),i=Number(o(p[t],"res"))||1;if(null!==e&&null!==n)for(let t=parseInt(e,10);t<=parseInt(n,10);t+=i)s.push(t.toString())}"band"===e.toLowerCase()&&(i=s),u.push({name:e,label:n,values:s})}t.push({name:e,label:r,nullValues:m,axis:u})}return{rangeSet:t,bandNames:i}}function x(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.substring(0,t.length-1))):(t=t.slice(1),l=n.findIndex((e=>t.includes(e))),l>-1&&(a=s[l]),o=parseFloat(t.substring(0,t.length-1))),{resolution:o,units:a}}function v(e){const t=s(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(o(t[n])));return{begin:e[0],end:e.at(-1),values:e}}const n=u(e,"timePeriod")||u(e,"TimePeriod");if(n){return{begin:new Date(o(n,"beginPosition")||o(n,"BeginPosition")),end:new Date(o(n,"endPosition")||o(n,"EndPosition")),...x(o(n,"timeResolution")||o(n,"TimeResolution"))}}return null}function D(t){const n=u(t,"spatialDomain"),i=u(n,"Envelope")||u(n,"EnvelopeWithTimePeriod"),a=i.getAttribute("srsName").split(":").at(-1),l=s(i,"pos"),r=m(l[0]),p=m(l[1]),d=parseInt(a,10),c=isNaN(d)?null:{wkid:d},f=new e({xmin:r[0],ymin:r[1],xmax:p[0],ymax:p[1],spatialReference:c}),g=u(n,"RectifiedGrid"),h=o(g,"low").split(" "),b=o(g,"high").split(" "),x=parseInt(b[0],10)-parseInt(h[0],10)+1,D=parseInt(b[1],10)-parseInt(h[1],10)+1,w=m(n,"origin/pos"),y=s(n,"offsetVector"),S={envelope:f,columns:x,rows:D,offset:{x:parseFloat(o(y[0]).split(" ")[0]),y:parseFloat(o(y[1]).split(" ")[1])},origin:{x:w[0],y:w[1]}},L=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:S,temporalDomain:L?v(L):null}}function w(e){const t={version:"1.0"};let n,s=[];for(let i=0;i<e.childNodes.length;i++){const r=e.childNodes[i];if(1===r.nodeType)if(a(r,"description"))t.description=o(r);else if(a(r,"name"))t.name=o(r);else if(a(r,"label"))t.label=o(r);else if(a(r,"supportedFormats"))t.supportedFormats=l(r,"formats");else if(a(r,"supportedCRSs"))t.supportedCRSs=p(r);else if(a(r,"supportedInterpolations"))t.supportedInterpolations=d(r,"1.0.0");else if(a(r,"lonLatEnvelope"))t.lonLatEnvelope=f(r);else if(a(r,"rangeSet")){const e=b(r);t.rangeSet=e.rangeSet,s=e.bandNames;const i=e.rangeSet[0].nullValues;i?.length&&(n=h(i))}else a(r,"domainSet")&&(t.domainSet=D(r))}const r=c(t.supportedInterpolations),{name:u,description:m,label:g,lonLatEnvelope:x,supportedFormats:v}=t,{spatialDomain:w}=t.domainSet,S={x:Math.abs(w.offset.x),y:Math.abs(w.offset.y)},L=y(t.domainSet),I=new i({width:w.columns,height:w.rows,pixelSize:S,extent:w.envelope,spatialReference:w.envelope.spatialReference,bandCount:s.length||1,noDataValue:n,multidimensionalInfo:L});return{id:u,title:t.name,description:m||g,lonLatEnvelope:x,rasterInfo:I,bandNames:s,supportedFormats:v,supportedInterpolations:r,coverageDescription:t,version:"1.0.0",useEPSGAxis:!1}}function y(e){if(!e.temporalDomain)return null;const{begin:t,end:n,values:i,units:s,resolution:a}=e.temporalDomain;return{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()]}]}]}}function S(e,t){const n=[],i=s(e,"Field");let a,r=[];for(let u=0;u<i.length;u++){const e=o(i[u],"Identifier"),m=o(i[u],"Description"),p=o(i[u],"Definition"),c=o(i[u],"Abstract"),f=o(i[u],"Title"),h=g(i[u],"NullValue"),b=d(i[u],"1.1.0"),x=[],v=s(i[u],"Axis");for(let n=0;n<v.length;n++){const e=v[n].getAttribute("identifier"),i=o(v[n],"UOM"),s=o(v[n],"DataType"),u=l(v[n],"Key");t&&!e.toLowerCase().includes("band")||(r=u,a=h),x.push({identifier:e,uom:i,dataType:s,values:u,bandNoDataValues:a})}n.push({identifier:e,description:m,definition:p,abstract:c,title:f,supportedInterpolations:b,axis:x,nullValues:h})}return{rangeSet:n,bandNames:r,bandNoDataValues:a}}function L(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})})),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()]})}))}return i.length?{variables:i}:null}function I(t){const i=u(t,"SpatialDomain"),a=u(i,"GridCRS"),l=o(a,"GridBaseCRS"),r=o(a,"GridOrigin"),p=r?.split(" ").map((e=>parseFloat(e)))??[0,0],d=m(a,"GridOffsets"),c=s(i,"BoundingBox");let f,g,h,b;for(let n=0;n<c.length;n++){const t=c[n].getAttribute("crs")?.toLowerCase();if(null!=t)if(t.includes("imagecrs")){const e=m(c[n],"LowerCorner"),t=m(c[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.at(-1),10);const s=m(c[n],"LowerCorner"),a=m(c[n],"UpperCorner");b=new e({xmin:s[0],ymin:s[1],xmax:a[0],ymax:a[1],spatialReference:{wkid:h}})}}const x=f>g,D=b.xmax-b.xmin>b.ymax-b.ymin;let w=!1;n(h)&&(x===D?w=!1:(w=!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:p[0],y:p[1]},offset:{x:d[0],y:d.at(-1)},gridBaseCRS:l,envelope:b,useEPSGAxis:w},S=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:y,temporalDomain:S?v(S):null}}function C(e,t){const n=[],s=[],a={supportedFormats:n,supportedCRSs:s,version:"1.1"};let l,u=[];for(let i=0;i<e.childNodes.length;i++){const t=e.childNodes[i];if(1!==t.nodeType)continue;const m=r(t).toLowerCase();switch(m){case"title":case"abstract":case"identifier":a[m]=o(t);break;case"supportedformat":{const e=o(t);n.includes(e)||n.push(e)}break;case"supportedcrs":{const e=o(t);s.includes(e)||s.push(e)}break;case"range":{const e=S(t,!!a.domain?.temporalDomain);a.range=e.rangeSet,u=e.bandNames;const{bandNoDataValues:n}=e;n?.length&&(l=h(n))}break;case"domain":a.domain=I(t)}}const m=c(a.range[0].supportedInterpolations),{identifier:p,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=L(b,g);v&&(l=b[0].nullValues,1===l?.length&&(l=l[0]));const D=new i({width:g.spatialDomain.columns,height:g.spatialDomain.rows,pixelSize:x,extent:g.spatialDomain.envelope,spatialReference:g.spatialDomain.envelope.spatialReference,bandCount:u.length||1,noDataValue:l,multidimensionalInfo:v});return{id:p,title:a.title,description:d||f,lonLatEnvelope:null,bandNames:u,rasterInfo:D,supportedFormats:n,supportedInterpolations:m,coverageDescription:a,version:t,useEPSGAxis:g.spatialDomain.useEPSGAxis}}function R(t){const n=u(t,"Envelope")||u(t,"EnvelopeWithTimePeriod"),i=n.getAttribute("srsName"),s=i.slice(i.lastIndexOf("/")+1),l=n.getAttribute("axisLabels").split(" ").map((e=>e.trim())).filter((e=>""!==e.trim())),r=m(n,"lowerCorner"),p=m(n,"upperCorner"),d=!["y","lat","latitude","north","nor","n","b"].includes(l[0].toLowerCase());let c;const f=parseInt(s,10),g=isNaN(f)?null:{wkid:f};c=new e(d?{xmin:r[0],ymin:r[1],xmax:p[0],ymax:p[1],spatialReference:g}:{xmin:r[1],ymin:r[0],xmax:p[1],ymax:p[0],spatialReference:g});const h={mins:r,maxs:p},b=n.getAttribute("uomLabels").trim().split(" ");let x,v;if(a(n,"EnvelopeWithTimePeriod")){x=new Date(o(t,"beginPosition")||o(t,"BeginPosition")),v=new Date(o(t,"endPosition")||o(t,"EndPosition"));const e=b?.findIndex((e=>"oledatetime"===e?.toLowerCase()));e>-1&&(b[e]="ISO8601")}return{envelope:c,axisLabels:l,uomLabels:b.length?b:null,envelopeAllDims:h,beginPosition:x,endPosition:v,isEastFirst:d}}function T(e,t){const n=[],i=s(e,"DataRecord"),a=[];let l,r=[];for(let p=0;p<i.length;p++){const e=s(i[p],"field"),d=[];for(let n=0;n<e.length;n++){const i=e[n].getAttribute("name"),s=o(e[n],"description")||"",p=u(e[n],"uom")?.getAttribute("code")||"",c=m(e[n],"interval"),f=g(e[n],"nilValue")?.[0];t&&!i.toLowerCase().includes("band")||(a.push(i),c?.length&&(l=l||[],l.push({min:c[0],max:c[1],avg:-1,stddev:-1})),r.push(f)),d.push({name:i,description:s,uom:p,allowedValues:c,nilValue:f})}n.push(d)}return r.some((e=>null!=e))||(r=null),{rangeType:n,bandNames:a,bandStats:l,bandNoDataValues:r}}function N(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 M(e,t,n){if(n.axisLabels.length<=2)return null;const i=[];for(let a=0;a<e.length;a++){const t=e[a];for(let e=0;e<t.length;e++)t[e].name.toLowerCase().includes("band")||i.push(t[e])}const s=[];if(i.length){const e=[];for(let i=2;i<n.axisLabels.length;i++){const s=(t.uomLabels?.length??0)>i?t.uomLabels?.[i]:"",a=n.axisLabels[i].toLowerCase().includes("time")||"iso8601"===s.toLowerCase()||"oledatetime"===s.toLowerCase();let o,l;if(a){const e=N(n.offset[i]);o=e.interval,l=e.intervalUnit}else o=n.offset[i],l=s;const r=[];a?(r.push((new Date).setTime(24*(t.envelopeAllDims.mins[i]-25569)*3600*1e3)),r.push((new Date).setTime(24*(t.envelopeAllDims.maxs[i]-25569)*3600*1e3))):(r.push(t.envelopeAllDims.mins[i]),r.push(t.envelopeAllDims.maxs[i])),e.push({name:n.axisLabels[i].trim(),description:n.axisLabels[i].trim(),unit:t.uomLabels&&t.uomLabels.length>i?t.uomLabels[i].trim():"",hasRegularIntervals:!0,extent:r,interval:o,intervalUnit:l})}if(i.forEach((t=>{const{allowedValues:n}=t,i=2===n?.length?[{min:n[0],max:n[1],avg:-1,stddev:-1}]:null;s.push({name:t.name.trim(),description:t.description?.trim()??"",unit:t.uom.trim(),statistics:i,dimensions:e})})),s.length)return{variables:s}}return null}function P(e,t){const n=u(e,"RectifiedGrid"),i=m(n,"low"),a=m(n,"high"),l=[];for(let s=0;s<i.length;s++)l.push(a[s]-i[s]+1);const r=o(n,"axisLabels").split(" "),p=m(n,"origin/pos"),d=s(n,"offsetVector"),c=[];for(let s=0;s<d.length;s++){const e=m(d[s]),t=e.findIndex((e=>0!==e));c[t]=e[t]}const f=["y","lat","latitude","north","nor","n","b"];let g=!1;if(t?.length&&r?.length){g=[...t].sort(((e,t)=>e<t?-1:1)).join(",")===[...r].sort(((e,t)=>e<t?-1:1)).join(",")}const h=g?r:t;let b,x,v;return f.includes(h[0].toLowerCase())?(b=l[1],x=l[0],v={y:Math.abs(c[0]),x:Math.abs(c[1])}):(b=l[0],x=l[1],v={x:Math.abs(c[0]),y:Math.abs(c[1])}),{columns:b,rows:x,origin:p,offset:c,resolution:v,gridSamples:l,axisLabels:r,hasSameAxisLabelsAsBoundedBy:g}}function E(e){const n=u(e,"EarthObservation");if(!n)return null;const i=u(n,"phenomenonTime"),s=i?v(i):null,a=u(n,"phenomenonTime"),l=a?v(a):null,r=o(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let m=null;if(r){const e=r.split(" ").map((e=>e.trim())).filter((e=>null!=e&&""!==e));if(e.length){const n=[];for(let t=0;t<e.length/2;t+=2)n.push(e[t],e[t+1]);m=new t({rings:[n],spatialReference:{wkid:4326}})}}return{observation:{phenomenonTime:s,resultTime:l,footprint:m,identifier:o(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:o(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:o(e,"metaDataProperty/EarthObservationMetaData/status")}}}function A(e){const t={version:"2.0"};let n,s,r=[];for(let i=0;i<e.childNodes.length;i++){const m=e.childNodes[i];if(1===m.nodeType)if(a(m,"coverageId"))t.coverageId=o(m);else if(a(m,"ServiceParameters"))t.serviceParameters={supportedFormats:l(m,"nativeFormat")};else if(a(m,"boundedBy"))t.boundedBy=R(m);else if(a(m,"rangeType")){const e=T(m,t.boundedBy?.axisLabels.length>2||t.domainSet?.axisLabels.length>2);t.rangeType=e.rangeType,r=e.bandNames,n=e.bandStats;const{bandNoDataValues:i}=e;i?.length&&(s=h(i))}else if(a(m,"domainSet"))t.domainSet=P(m,t.boundedBy?.axisLabels);else if(a(m,"metadata")){const e=u(m,"EOMetadata");t.eoMetadata=e?E(e):null}}const{coverageId:m,boundedBy:p,domainSet:d,rangeType:c,serviceParameters:f}=t,g=M(c,p,d);!n&&g&&(n=g?.variables[0].statistics),null!=g&&(s=c[0][0].nilValue);return{id:m,title:m,description:m,lonLatEnvelope:null,bandNames:r,rasterInfo:new i({width:d.columns,height:d.rows,pixelSize:d.resolution,extent:p.envelope,spatialReference:p.envelope.spatialReference,bandCount:r.length||1,statistics:n,noDataValue:s,multidimensionalInfo:g}),supportedFormats:f.supportedFormats,supportedInterpolations:null,coverageDescription:t,version:"2.0.1",useEPSGAxis:!1}}function V(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 s(n,"CoverageOffering").map((e=>w(e)))}const i=s(n,"CoverageDescription");return"1.1.0"===t||"1.1.1"===t||"1.1.2"===t?i.map((e=>C(e,t))):i.map((e=>A(e)))}export{V as parseCoverages,c as standardizeInterpolations};
|
|
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{getElements as s,isSameTagIgnoreNS as a,getElementValue as o,getElementValues as l,getNodeNameIgnoreNS as r,getElement as u,getSpaceDelimitedNumericValues as m}from"./xmlUtilities.js";function p(e){return{requestResponseCRSs:l(e,"requestResponseCRSs").map((e=>e.split(":")[1])),nativeCRSs:l(e,"nativeCRSs").map((e=>e.split(":")[1]))}}function d(e,t){const n=l(e,"1.0.0"===t?"interpolationMethod":"InterpolationMethod"),i="1.0.0"===t?e.getAttribute("default"):o(e,"InterpolationMethods/Default");return null!=i?[i].concat(n.filter((e=>e.toLowerCase()!==i.toLowerCase()))):n}function c(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 f(t){const n=s(t,"pos"),i=m(n[0]),a=m(n[1]);return new e({xmin:i[0],ymin:i[1],xmax:a[0],ymax:a[1],spatialReference:{wkid:4326}})}function g(e,t){const n=l(e,t);return n?.length&&""!==n[0]&&!isNaN(Number(n[0]))?n.map((e=>Number(e))):null}function h(e){return null==e?null:e.every((t=>t===e[0]))?e[0]:e}function b(e){const t=[],n=s(e,"RangeSet");let i=[];for(let a=0;a<n.length;a++){const e=o(n[a],"name"),r=o(n[a],"label"),u=[],m=g(n[a],"nullValues/singleValue"),p=s(n[a],"AxisDescription");for(let t=0;t<p.length;t++){const e=o(p[t],"name"),n=o(p[t],"label"),s=l(p[t],"singleValue");if(0===s.length){const e=o(p[t],"min"),n=o(p[t],"max"),i=Number(o(p[t],"res"))||1;if(null!==e&&null!==n)for(let t=parseInt(e,10);t<=parseInt(n,10);t+=i)s.push(t.toString())}"band"===e.toLowerCase()&&(i=s),u.push({name:e,label:n,values:s})}t.push({name:e,label:r,nullValues:m,axis:u})}return{rangeSet:t,bandNames:i}}function x(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.substring(0,t.length-1))):(t=t.slice(1),l=n.findIndex((e=>t.includes(e))),l>-1&&(a=s[l]),o=parseFloat(t.substring(0,t.length-1))),{resolution:o,units:a}}function v(e){const t=s(e,"timeposition");if(t.length>0){const e=[];for(let n=0;n<t.length;n++)e.push(new Date(o(t[n])));return{begin:e[0],end:e[e.length-1],values:e}}const n=u(e,"timePeriod")||u(e,"TimePeriod");if(n){return{begin:new Date(o(n,"beginPosition")||o(n,"BeginPosition")),end:new Date(o(n,"endPosition")||o(n,"EndPosition")),...x(o(n,"timeResolution")||o(n,"TimeResolution"))}}return null}function D(t){const n=u(t,"spatialDomain"),i=u(n,"Envelope")||u(n,"EnvelopeWithTimePeriod"),a=i.getAttribute("srsName").split(":"),l=a[a.length-1],r=s(i,"pos"),p=m(r[0]),d=m(r[1]),c=parseInt(l,10),f=isNaN(c)?null:{wkid:c},g=new e({xmin:p[0],ymin:p[1],xmax:d[0],ymax:d[1],spatialReference:f}),h=u(n,"RectifiedGrid"),b=o(h,"low").split(" "),x=o(h,"high").split(" "),D=parseInt(x[0],10)-parseInt(b[0],10)+1,w=parseInt(x[1],10)-parseInt(b[1],10)+1,y=m(n,"origin/pos"),S=s(n,"offsetVector"),L={envelope:g,columns:D,rows:w,offset:{x:parseFloat(o(S[0]).split(" ")[0]),y:parseFloat(o(S[1]).split(" ")[1])},origin:{x:y[0],y:y[1]}},I=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:L,temporalDomain:I?v(I):null}}function w(e){const t={version:"1.0"};let n,s=[];for(let i=0;i<e.childNodes.length;i++){const r=e.childNodes[i];if(1===r.nodeType)if(a(r,"description"))t.description=o(r);else if(a(r,"name"))t.name=o(r);else if(a(r,"label"))t.label=o(r);else if(a(r,"supportedFormats"))t.supportedFormats=l(r,"formats");else if(a(r,"supportedCRSs"))t.supportedCRSs=p(r);else if(a(r,"supportedInterpolations"))t.supportedInterpolations=d(r,"1.0.0");else if(a(r,"lonLatEnvelope"))t.lonLatEnvelope=f(r);else if(a(r,"rangeSet")){const e=b(r);t.rangeSet=e.rangeSet,s=e.bandNames;const i=e.rangeSet[0].nullValues;i?.length&&(n=h(i))}else a(r,"domainSet")&&(t.domainSet=D(r))}const r=c(t.supportedInterpolations),{name:u,description:m,label:g,lonLatEnvelope:x,supportedFormats:v}=t,{spatialDomain:w}=t.domainSet,S={x:Math.abs(w.offset.x),y:Math.abs(w.offset.y)},L=y(t.domainSet),I=new i({width:w.columns,height:w.rows,pixelSize:S,extent:w.envelope,spatialReference:w.envelope.spatialReference,bandCount:s.length||1,noDataValue:n,multidimensionalInfo:L});return{id:u,title:t.name,description:m||g,lonLatEnvelope:x,rasterInfo:I,bandNames:s,supportedFormats:v,supportedInterpolations:r,coverageDescription:t,version:"1.0.0",useEPSGAxis:!1}}function y(e){if(!e.temporalDomain)return null;const{begin:t,end:n,values:i,units:s,resolution:a}=e.temporalDomain;return{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()]}]}]}}function S(e,t){const n=[],i=s(e,"Field");let a,r=[];for(let u=0;u<i.length;u++){const e=o(i[u],"Identifier"),m=o(i[u],"Description"),p=o(i[u],"Definition"),c=o(i[u],"Abstract"),f=o(i[u],"Title"),h=g(i[u],"NullValue"),b=d(i[u],"1.1.0"),x=[],v=s(i[u],"Axis");for(let n=0;n<v.length;n++){const e=v[n].getAttribute("identifier"),i=o(v[n],"UOM"),s=o(v[n],"DataType"),u=l(v[n],"Key");t&&!e.toLowerCase().includes("band")||(r=u,a=h),x.push({identifier:e,uom:i,dataType:s,values:u,bandNoDataValues:a})}n.push({identifier:e,description:m,definition:p,abstract:c,title:f,supportedInterpolations:b,axis:x,nullValues:h})}return{rangeSet:n,bandNames:r,bandNoDataValues:a}}function L(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})})),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()]})}))}return i.length?{variables:i}:null}function I(t){const i=u(t,"SpatialDomain"),a=u(i,"GridCRS"),l=o(a,"GridBaseCRS"),r=o(a,"GridOrigin"),p=r?.split(" ").map((e=>parseFloat(e)))??[0,0],d=m(a,"GridOffsets"),c=s(i,"BoundingBox");let f,g,h,b;for(let n=0;n<c.length;n++){const t=c[n].getAttribute("crs")?.toLowerCase();if(null!=t)if(t.includes("imagecrs")){const e=m(c[n],"LowerCorner"),t=m(c[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=m(c[n],"LowerCorner"),a=m(c[n],"UpperCorner");b=new e({xmin:s[0],ymin:s[1],xmax:a[0],ymax:a[1],spatialReference:{wkid:h}})}}const x=f>g,D=b.xmax-b.xmin>b.ymax-b.ymin;let w=!1;n(h)&&(x===D?w=!1:(w=!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:p[0],y:p[1]},offset:{x:d[0],y:d[d.length-1]},gridBaseCRS:l,envelope:b,useEPSGAxis:w},S=u(t,"temporalDomain")||u(t,"TemporalDomain");return{spatialDomain:y,temporalDomain:S?v(S):null}}function C(e,t){const n=[],s=[],a={supportedFormats:n,supportedCRSs:s,version:"1.1"};let l,u=[];for(let i=0;i<e.childNodes.length;i++){const t=e.childNodes[i];if(1!==t.nodeType)continue;const m=r(t).toLowerCase();switch(m){case"title":case"abstract":case"identifier":a[m]=o(t);break;case"supportedformat":{const e=o(t);n.includes(e)||n.push(e)}break;case"supportedcrs":{const e=o(t);s.includes(e)||s.push(e)}break;case"range":{const e=S(t,!!a.domain?.temporalDomain);a.range=e.rangeSet,u=e.bandNames;const{bandNoDataValues:n}=e;n?.length&&(l=h(n))}break;case"domain":a.domain=I(t)}}const m=c(a.range[0].supportedInterpolations),{identifier:p,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=L(b,g);v&&(l=b[0].nullValues,1===l?.length&&(l=l[0]));const D=new i({width:g.spatialDomain.columns,height:g.spatialDomain.rows,pixelSize:x,extent:g.spatialDomain.envelope,spatialReference:g.spatialDomain.envelope.spatialReference,bandCount:u.length||1,noDataValue:l,multidimensionalInfo:v});return{id:p,title:a.title,description:d||f,lonLatEnvelope:null,bandNames:u,rasterInfo:D,supportedFormats:n,supportedInterpolations:m,coverageDescription:a,version:t,useEPSGAxis:g.spatialDomain.useEPSGAxis}}function R(t){const n=u(t,"Envelope")||u(t,"EnvelopeWithTimePeriod"),i=n.getAttribute("srsName"),s=i.slice(i.lastIndexOf("/")+1),l=n.getAttribute("axisLabels").split(" ").map((e=>e.trim())).filter((e=>""!==e.trim())),r=m(n,"lowerCorner"),p=m(n,"upperCorner"),d=!["y","lat","latitude","north","nor","n","b"].includes(l[0].toLowerCase());let c;const f=parseInt(s,10),g=isNaN(f)?null:{wkid:f};c=new e(d?{xmin:r[0],ymin:r[1],xmax:p[0],ymax:p[1],spatialReference:g}:{xmin:r[1],ymin:r[0],xmax:p[1],ymax:p[0],spatialReference:g});const h={mins:r,maxs:p},b=n.getAttribute("uomLabels").trim().split(" ");let x,v;if(a(n,"EnvelopeWithTimePeriod")){x=new Date(o(t,"beginPosition")||o(t,"BeginPosition")),v=new Date(o(t,"endPosition")||o(t,"EndPosition"));const e=b?.findIndex((e=>"oledatetime"===e?.toLowerCase()));e>-1&&(b[e]="ISO8601")}return{envelope:c,axisLabels:l,uomLabels:b.length?b:null,envelopeAllDims:h,beginPosition:x,endPosition:v,isEastFirst:d}}function T(e,t){const n=[],i=s(e,"DataRecord"),a=[];let l,r=[];for(let p=0;p<i.length;p++){const e=s(i[p],"field"),d=[];for(let n=0;n<e.length;n++){const i=e[n].getAttribute("name"),s=o(e[n],"description")||"",p=u(e[n],"uom")?.getAttribute("code")||"",c=m(e[n],"interval"),f=g(e[n],"nilValue")?.[0];t&&!i.toLowerCase().includes("band")||(a.push(i),c?.length&&(l=l||[],l.push({min:c[0],max:c[1],avg:-1,stddev:-1})),r.push(f)),d.push({name:i,description:s,uom:p,allowedValues:c,nilValue:f})}n.push(d)}return r.some((e=>null!=e))||(r=null),{rangeType:n,bandNames:a,bandStats:l,bandNoDataValues:r}}function N(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 M(e,t,n){if(n.axisLabels.length<=2)return null;const i=[];for(let a=0;a<e.length;a++){const t=e[a];for(let e=0;e<t.length;e++)t[e].name.toLowerCase().includes("band")||i.push(t[e])}const s=[];if(i.length){const e=[];for(let i=2;i<n.axisLabels.length;i++){const s=(t.uomLabels?.length??0)>i?t.uomLabels?.[i]:"",a=n.axisLabels[i].toLowerCase().includes("time")||"iso8601"===s.toLowerCase()||"oledatetime"===s.toLowerCase();let o,l;if(a){const e=N(n.offset[i]);o=e.interval,l=e.intervalUnit}else o=n.offset[i],l=s;const r=[];a?(r.push((new Date).setTime(24*(t.envelopeAllDims.mins[i]-25569)*3600*1e3)),r.push((new Date).setTime(24*(t.envelopeAllDims.maxs[i]-25569)*3600*1e3))):(r.push(t.envelopeAllDims.mins[i]),r.push(t.envelopeAllDims.maxs[i])),e.push({name:n.axisLabels[i].trim(),description:n.axisLabels[i].trim(),unit:t.uomLabels&&t.uomLabels.length>i?t.uomLabels[i].trim():"",hasRegularIntervals:!0,extent:r,interval:o,intervalUnit:l})}if(i.forEach((t=>{const{allowedValues:n}=t,i=2===n?.length?[{min:n[0],max:n[1],avg:-1,stddev:-1}]:null;s.push({name:t.name.trim(),description:t.description?.trim()??"",unit:t.uom.trim(),statistics:i,dimensions:e})})),s.length)return{variables:s}}return null}function P(e,t){const n=u(e,"RectifiedGrid"),i=m(n,"low"),a=m(n,"high"),l=[];for(let s=0;s<i.length;s++)l.push(a[s]-i[s]+1);const r=o(n,"axisLabels").split(" "),p=m(n,"origin/pos"),d=s(n,"offsetVector"),c=[];for(let s=0;s<d.length;s++){const e=m(d[s]),t=e.findIndex((e=>0!==e));c[t]=e[t]}const f=["y","lat","latitude","north","nor","n","b"];let g=!1;if(t?.length&&r?.length){g=[...t].sort(((e,t)=>e<t?-1:1)).join(",")===[...r].sort(((e,t)=>e<t?-1:1)).join(",")}const h=g?r:t;let b,x,v;return f.includes(h[0].toLowerCase())?(b=l[1],x=l[0],v={y:Math.abs(c[0]),x:Math.abs(c[1])}):(b=l[0],x=l[1],v={x:Math.abs(c[0]),y:Math.abs(c[1])}),{columns:b,rows:x,origin:p,offset:c,resolution:v,gridSamples:l,axisLabels:r,hasSameAxisLabelsAsBoundedBy:g}}function E(e){const n=u(e,"EarthObservation");if(!n)return null;const i=u(n,"phenomenonTime"),s=i?v(i):null,a=u(n,"phenomenonTime"),l=a?v(a):null,r=o(n,"featureOfInterest/Footprint/multiExtentOf/MultiSurface/surfaceMembers/Polygon/exterior/LinearRing/posList");let m=null;if(r){const e=r.split(" ").map((e=>e.trim())).filter((e=>null!=e&&""!==e));if(e.length){const n=[];for(let t=0;t<e.length/2;t+=2)n.push(e[t],e[t+1]);m=new t({rings:[n],spatialReference:{wkid:4326}})}}return{observation:{phenomenonTime:s,resultTime:l,footprint:m,identifier:o(e,"metaDataProperty/EarthObservationMetaData/identifier"),acquisitionType:o(e,"metaDataProperty/EarthObservationMetaData/acquisitionType"),status:o(e,"metaDataProperty/EarthObservationMetaData/status")}}}function A(e){const t={version:"2.0"};let n,s,r=[];for(let i=0;i<e.childNodes.length;i++){const m=e.childNodes[i];if(1===m.nodeType)if(a(m,"coverageId"))t.coverageId=o(m);else if(a(m,"ServiceParameters"))t.serviceParameters={supportedFormats:l(m,"nativeFormat")};else if(a(m,"boundedBy"))t.boundedBy=R(m);else if(a(m,"rangeType")){const e=T(m,t.boundedBy?.axisLabels.length>2||t.domainSet?.axisLabels.length>2);t.rangeType=e.rangeType,r=e.bandNames,n=e.bandStats;const{bandNoDataValues:i}=e;i?.length&&(s=h(i))}else if(a(m,"domainSet"))t.domainSet=P(m,t.boundedBy?.axisLabels);else if(a(m,"metadata")){const e=u(m,"EOMetadata");t.eoMetadata=e?E(e):null}}const{coverageId:m,boundedBy:p,domainSet:d,rangeType:c,serviceParameters:f}=t,g=M(c,p,d);!n&&g&&(n=g?.variables[0].statistics),null!=g&&(s=c[0][0].nilValue);return{id:m,title:m,description:m,lonLatEnvelope:null,bandNames:r,rasterInfo:new i({width:d.columns,height:d.rows,pixelSize:d.resolution,extent:p.envelope,spatialReference:p.envelope.spatialReference,bandCount:r.length||1,statistics:n,noDataValue:s,multidimensionalInfo:g}),supportedFormats:f.supportedFormats,supportedInterpolations:null,coverageDescription:t,version:"2.0.1",useEPSGAxis:!1}}function V(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 s(n,"CoverageOffering").map((e=>w(e)))}const i=s(n,"CoverageDescription");return"1.1.0"===t||"1.1.1"===t||"1.1.2"===t?i.map((e=>C(e,t))):i.map((e=>A(e)))}export{V as parseCoverages,c as standardizeInterpolations};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
const e=(e,r)=>{const a=r.width*r.height,n=r.pixelType;return Math.floor(e.byteLength/(a*t(n)))},t=e=>{let t=1;switch(e){case Uint8Array:case Int8Array:t=1;break;case Uint16Array:case Int16Array:t=2;break;case Uint32Array:case Int32Array:case Float32Array:t=4;break;case Float64Array:t=8}return t},r=(e,t)=>{if(8*e.byteLength<t)return null;const r=new Uint8Array(e,0,Math.ceil(t/8)),a=new Uint8Array(t);let n=0,s=0,
|
|
5
|
+
const e=(e,r)=>{const a=r.width*r.height,n=r.pixelType;return Math.floor(e.byteLength/(a*t(n)))},t=e=>{let t=1;switch(e){case Uint8Array:case Int8Array:t=1;break;case Uint16Array:case Int16Array:t=2;break;case Uint32Array:case Int32Array:case Float32Array:t=4;break;case Float64Array:t=8}return t},r=(e,t)=>{if(8*e.byteLength<t)return null;const r=new Uint8Array(e,0,Math.ceil(t/8)),a=new Uint8Array(t);let n=0,s=0,l=0,i=0;for(l=0;l<r.length-1;l++)for(s=r[l],i=7;i>=0;i--)a[n++]=s>>i&1;for(i=7;n<t-1;)s=r[r.length-1],a[n++]=s>>i&1,i--;return a};class a{static decode(a,n){const s=n.pixelType,l=[],i=n.width*n.height,h=e(a,n),{bandIds:c,format:y}=n,o=c&&c.length||e(a,n),b=a.byteLength-a.byteLength%(i*t(s)),f=new s(a,0,i*h);let u,g,A,p,d=null;if("bip"===y)for(u=0;u<o;u++){for(A=new s(i),p=c?c[u]:u,g=0;g<i;g++)A[g]=f[g*h+p];l.push(A)}else if("bsq"===y)for(u=0;u<o;u++)p=c?c[u]:u,l.push(f.subarray(p*i,(p+1)*i));return b<a.byteLength-1&&(d=r(a.slice(b),i)),{pixels:l,mask:d}}}export{a as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
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 s from"./TiffTags.js";import{isPlatformLittleEndian as l}from"./utils.js";import{Z as o}from"../../../chunks/Zlib.js";const f=[0,1,1,2,4,8,1,1,2,4,8,4,8,-1,-1,-1,8,8,8],u=4294967296,c=new Set([1,5,6,7,8,34712,34887]);function h(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 g(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 E(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 T(e,t){return e.get(t)?.values}function I(e,t){return e.get(t)?.values}function w(e,t){return e.get(t)?.values?.[0]}function d(e,t){return e.get(t)?.values?.[0]}function p(e,t,n,a=0,i=s.TIFF_TAGS,r=4){const l=8===r,o=l?G(new DataView(e,n,8),0,t):new DataView(e,n,2).getUint16(0,t),f=4+2*r,u=l?8:2,c=u+o*f;if(n+c>e.byteLength)return{success:!1,ifd:null,nextIFD:null,requiredBufferSize:c};const h=n+c+4<=e.byteLength?C(new DataView(e,n+c,8===r?8:4),0,t,8===r):null,g=n+u,E=new Map;let T,I,w,d,p,y=0,S=0;for(let m=0;m<o;m++){I=new DataView(e,g+f*m,f),w=I.getUint16(0,t),p=I.getUint16(2,t),d=s.getTagName(w,i);const n=[];2===r?(y=I.getUint16(4,t),S=I.getUint16(6,t)):4===r?(y=I.getUint32(4,t),S=I.getUint32(8,t)):8===r&&(y=C(I,4,t,!0),S=C(I,12,t,!0),n.push(I.getUint32(12,t)),n.push(I.getUint32(16,t))),T={id:w,type:p,valueCount:y,valueOffset:S,valueOffsets:n,values:null},L(e,t,T,a,!1,r),E.set(d,T)}return{success:!0,ifd:E,nextIFD:h,requiredBufferSize:c}}const y=(e,t)=>a(e,{inputOffset:t}).pixels[0];function S(e,t){if(1!==t&&2!==t&&4!==t)return e;const n=new Uint8Array(e),a=8/t,i=new Uint8Array(e.byteLength*a);let r=0;const s=2**t-1;for(let l=0;l<n.length;l++){const e=n[l];for(let n=0;n<a;n++)i[r++]=e<<t*n>>>8-t&s}return i.buffer}function m(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 A(e){const t=new o(e).getBytes(),n=new ArrayBuffer(t.length),a=new Uint8Array(n);return a.set(t),a}async function M(e,t,a,r,s){const o=l===t,f=d(a,"BITSPERSAMPLE"),u=d(a,"SAMPLESPERPIXEL")??1,c=d(a,"PHOTOMETRICINTERPRETATION"),E=d(a,"SAMPLEFORMAT")??1,T=h(E,f),I=d(a,"COMPRESSION")??1,w=g(T);let p,M,P;if(34887===I)return await n(),y(e,r);if(1===I)p=e.slice(r,r+s),M=new Uint8Array(p);else if(8===I||32946===I)M=new Uint8Array(e,r,s),M=A(M),p=M.buffer;else if(6===I)M=new Uint8Array(e,r,s),M=m(M,u,c),p=M.buffer;else if(7===I){const t=a.get("JPEGTABLES").values,n=t.length-2;M=new Uint8Array(n+s-2);for(let e=0;e<n;e++)M[e]=t[e];const i=new Uint8Array(e,r+2,s-2);for(let e=0;e<i.length;e++)M[n+e]=i[e];M=m(M,u,c),p=M.buffer}else{if(5!==I)throw new Error("tiff-decode: unsupport compression "+I);M=i(e,r,s,t),p=M.buffer}if(p=S(p,f),"u8"===T||"s8"===T||o)P=new w(p);else{p=new ArrayBuffer(M.length);const e=new Uint8Array(p);switch(T){case"u16":case"s16":for(let t=0;t<M.length;t+=2)e[t]=M[t+1],e[t+1]=M[t];break;case"u32":case"s32":case"f32":for(let t=0;t<M.length;t+=4)e[t]=M[t+3],e[t+1]=M[t+2],e[t+2]=M[t+1],e[t+3]=M[t]}P=new w(p)}const O=d(a,"PREDICTOR")??1,b=d(a,"TILEWIDTH"),x=d(a,"TILELENGTH");if(O>1&&(5===I||8===I||32946===I)&&b&&x){const e=D(a),t=new w(P.length);t.set(P),P=W(t,x,b,3===E&&3===O,e?1:u)}return P}async function P(e,t,n){const a=I(n,"TILEOFFSETS");if(void 0===a)return null;const i=I(n,"TILEBYTECOUNTS"),{width:r,height:s,pixelType:l,tileWidth:o,tileHeight:f}=R([n]),u=D(n,t),c=d(n,"SAMPLESPERPIXEL")||t.planes,h=r*s,E=d(n,"BITSPERSAMPLE"),T=34887===(d(n,"COMPRESSION")??1),w=g(l),p=[];for(let g=0;g<c;g++)p.push(new w(h));let y,S,m,A,P,O,b,x,L,U,N,k,G;const F=Math.ceil(r/o),C=new Uint8Array(h).fill(255);let v=!1;if(E%8==0)if(T&&u&&c>1){const l=Math.round(a.length/c);for(y=0;y<l;y++){O=Math.floor(y/F)*f,b=y%F*o,x=O*r+b;for(let l=0;l<c;l++){const u=y*c+l;for(0===i[u]?(m=null,v=!0):m=await M(e,t.littleEndian,n,a[u],i[u]),U=0,L=x,k=Math.min(o,r-b),N=Math.min(f,s-O),G=p[l],A=0;A<N;A++)for(L=x+A*r,U=A*o,P=0;P<k;P++,L++,U++)m?G[L]=m[U]:C[L]=0}}}else for(y=0;y<a.length;y++)for(O=Math.floor(y/F)*f,b=y%F*o,x=O*r+b,0===i[y]?(m=null,v=!0):m=await M(e,t.littleEndian,n,a[y],i[y]),U=0,L=x,k=Math.min(o,r-b),N=Math.min(f,s-O),S=0;S<c;S++)if(G=p[S],u||T)for(A=0;A<N;A++)for(L=x+A*r,U=o*f*S+A*o,P=0;P<k;P++,L++,U++)m?G[L]=m[U]:C[L]=0;else for(A=0;A<N;A++)for(L=x+A*r,U=A*o*c+S,P=0;P<k;P++,L++,U+=c)m?G[L]=m[U]:C[L]=0;return{width:r,height:s,pixelType:l,pixels:p,mask:v?C:void 0}}const O=(e,t,n)=>{const a=l===t.littleEndian,r=I(n,"STRIPOFFSETS");if(void 0===r)return null;const{width:s,height:o,pixelType:f}=R([n]),u=d(n,"SAMPLESPERPIXEL")||t.planes,c=d(n,"PHOTOMETRICINTERPRETATION"),h=s*o,E=d(n,"BITSPERSAMPLE"),T=g(f),w=new T(h*u),p=I(n,"STRIPBYTECOUNTS"),y=d(n,"ROWSPERSTRIP"),M=d(n,"COMPRESSION")??1;let P,O,b,x,L,D,U,N,k,G=y;if(E%8==0)for(P=0;P<r.length;P++){if(L=P*(y*s)*u,G=(P+1)*y>o?o-P*y:y,"u8"===f||"s8"===f||a)8===M||32946===M?(U=new Uint8Array(e,r[P],p[P]),U=A(U),D=U.buffer):6===M?(U=new Uint8Array(e,r[P],p[P]),U=m(U,u,c),D=U.buffer):5===M?(U=i(e,r[P],p[P],t.littleEndian),D=U.buffer):(p[P]!==G*s*u*E/8&&console.log("strip byte counts is different than expected"),D=e.slice(r[P],r[P]+p[P])),D=S(D,E),x=new T(D);else{switch(6===M||8===M||32946===M?(U=new Uint8Array(e,r[P],p[P]),N=A(U),D=N.buffer):(p[P]!==G*s*u*E/8&&console.log("strip byte counts is different than expected"),D=new ArrayBuffer(p[P]),U=new Uint8Array(e,r[P],p[P]),N=new Uint8Array(D)),f){case"u16":case"s16":for(b=0;b<U.length;b+=2)N[b]=U[b+1],N[b+1]=U[b];break;case"u32":case"s32":case"f32":for(b=0;b<U.length;b+=4)N[b]=U[b+3],N[b+1]=U[b+2],N[b+2]=U[b+1],N[b+3]=U[b]}D=S(D,E),x=new T(D)}w.set(x,L)}const F=[];if(1===u)F.push(w);else for(P=0;P<u;P++){for(k=new T(h),O=0;O<h;O++)k[O]=w[O*u+P];F.push(k)}return{width:s,height:o,pixelType:f,pixels:F}},b=(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},x=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"),T=n.get("WavelengthMax");let I=null;if(g){I=[];for(let e=0;e<g.length;e++)I.push({BandName:g[e],WavelengthMin:E&&parseFloat(E[e]),WavelengthMax:T&&parseFloat(T[e])})}return{statistics:h,bandProperties:I,dataType:n.get("DataType"),rawMetadata:n}};function L(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,c=[];const h=f[s],g=8*h,E=l*h,T=l*f[s]*8;let I,w;const d=8===r?64:32,p=n.valueOffsets;if(T>d){if(E>(i?e.byteLength:e?e.byteLength-o+a:0))return n.offlineOffsetSize=[o,E],n.values=null,!1}if(T<=d){if(!t)if(d<=32)o>>>=32-T;else{const e=p?.length?p[0]:o>>>0,t=p?.length?p[1]:Math.round((o-e)/u);T<=32?(o=e>>>32-T,p[0]=o):(o=e*2**(32-T)+(t>>>32-T),p[0]=e,p[1]=t>>>32-T)}if(1===l&&g===d)c=[o];else if(64===d){const e=p?.length?p[0]:o>>>0,t=p?.length?p[1]:Math.round((o-e)/u);let n=e,a=32;for(w=1;w<=l;w++){const e=32-g*w%32;if(a<g){const i=n<<e>>>32-a,r=t<<32-a>>>32-a;n=t,c.push(i+r*2**(g-a)),a-=32-(g-a)}else c.push(n<<e>>>32-g),a-=g;0===a&&(a=32,n=t)}}else for(w=1;w<=l;w++){const e=32-g*w;c.push(o<<e>>>32-g)}}else{o-=a,i&&(o=0);for(let n=o;n<o+E;n+=h){switch(s){case 1:case 2:case 7:I=new DataView(e,n,1).getUint8(0);break;case 3:I=new DataView(e,n,2).getUint16(0,t);break;case 4:case 13:I=new DataView(e,n,4).getUint32(0,t);break;case 5:I=new DataView(e,n,4).getUint32(0,t)/new DataView(e,n+4,4).getUint32(0,t);break;case 6:I=new DataView(e,n,1).getInt8(0);break;case 8:I=new DataView(e,n,2).getInt16(0,t);break;case 9:I=new DataView(e,n,4).getInt32(0,t);break;case 10:I=new DataView(e,n,4).getInt32(0,t)/new DataView(e,n+4,4).getInt32(0,t);break;case 11:I=new DataView(e,n,4).getFloat32(0,t);break;case 12:I=new DataView(e,n,8).getFloat64(0,t);break;case 16:case 18:I=G(new DataView(e,n,8),0,t);break;case 17:I=F(new DataView(e,n,8),0,t);break;default:I=null}c.push(I)}}if(2===s){let e="";const t=c;for(c=[],w=0;w<t.length;w++)0===t[w]&&""!==e?(c.push(e),e=""):e+=String.fromCharCode(t[w]);""===e&&0!==c.length||c.push(e)}return n.values=c,!0}function R(e){const t=e[0],n=d(t,"TILEWIDTH"),a=d(t,"TILELENGTH"),i=d(t,"IMAGEWIDTH"),r=d(t,"IMAGELENGTH"),s=d(t,"BITSPERSAMPLE"),l=d(t,"SAMPLESPERPIXEL"),o=d(t,"SAMPLEFORMAT")??1,f=h(o,s),u=D(t),g=T(t,"GDAL_NODATA");let p=null;g?.length&&(p=g.map((e=>parseFloat(e))),p.some((e=>isNaN(e)))&&(p=null));const y=d(t,"COMPRESSION")??1;let S;switch(y){case 1:S="NONE";break;case 2:case 3:case 4:case 32771:S="CCITT";break;case 5:S="LZW";break;case 6:case 7:S="JPEG";break;case 32773:S="PACKBITS";break;case 8:case 32946:S="DEFLATE";break;case 34712:S="JPEG2000";break;case 34887:S="LERC";break;default:S=String(y)}let m=!0,A="";c.has(y)||(m=!1,A+="unsupported tag compression "+y),o>3&&(m=!1,A+="unsupported tag sampleFormat "+o),1!==s&&2!==s&&4!==s&&s%8!=0&&(m=!1,A+="unsupported tag bitsPerSample "+s);const M=w(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=I(t,"GEOTIEPOINTS"),b=I(t,"GEOPIXELSCALE"),L=I(t,"GEOTRANSMATRIX"),R=t.has("GEOKEYDIRECTORY")?t.get("GEOKEYDIRECTORY").data:null;let k,G,F=!1,C=!1;if(R){F=2===d(R,"GTRasterTypeGeoKey");const e=d(R,"GTModelTypeGeoKey");if(2===e){const e=d(R,"GeographicTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e}),P||32767!==e||(C=!0,P={wkid:4326})}else if(1===e){const e=d(R,"ProjectedCSTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e})}}if(b&&O&&O.length>=6?(k=[b[0],0,O[3]-O[0]*b[0],0,-Math.abs(b[1]),O[4]-O[1]*b[1]],F&&(k[2]-=.5*k[0]+.5*k[1],k[5]-=.5*k[3]+.5*k[4])):L&&16===L.length&&(k=F?[L[0],L[1],L[3]-.5*L[0],L[4],L[5],L[7]-.5*L[5]]:[L[0],L[1],L[3],L[4],L[5],L[7]]),k){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=E(e[i],k),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;G={xmin:n,xmax:s,ymin:a,ymax:l,spatialReference:P}}else G={xmin:-.5,ymin:.5-r,xmax:i-.5,ymax:.5,spatialReference:P};C&&(G.xmax-G.xmin>400||Math.max(Math.abs(G.xmin),Math.abs(G.xmax))>361)&&(P=null,G.spatialReference=null);const v=U(e);let B,W,H,Y,_;if(v.length>0){H=Math.round(Math.log(i/d(v[0],"IMAGEWIDTH"))/Math.LN2);const e=v.at(-1);Y=Math.round(Math.log(i/d(e,"IMAGEWIDTH"))/Math.LN2),B=d(e,"TILEWIDTH"),W=d(e,"TILELENGTH")}B=null!=Y&&Y>0?B||n:null,W=null!=Y&&Y>0?W||a:null,n&&(_=[{maxCol:Math.ceil(i/n)-1,maxRow:Math.ceil(r/a)-1,minRow:0,minCol:0}],v.forEach((e=>{_.push({maxCol:Math.ceil(d(e,"IMAGEWIDTH")/d(e,"TILEWIDTH"))-1,maxRow:Math.ceil(d(e,"IMAGELENGTH")/d(e,"TILELENGTH"))-1,minRow:0,minCol:0})})));const K=w(e[0],"GDAL_METADATA"),X=x(K);A+=" "+V({width:i,height:r,tileWidth:n,tileHeight:a,planes:l,ifds:e});return{width:i,height:r,tileWidth:n,tileHeight:a,planes:l,isBSQ:u,pixelType:f,compression:S,noData:p,hasMaskBand:N(e).length===v.length+1,isSupported:m,message:A,extent:G,isPseudoGeographic:C,affine:b?null:k,firstPyramidLevel:H,maximumPyramidLevel:Y,pyramidBlockWidth:B,pyramidBlockHeight:W,tileBoundary:_,metadata:X}}function D(e,t){const n=T(e,"PLANARCONFIGURATION");return n?2===n[0]:!!t&&t.isBSQ}function U(e){return e.filter((e=>1===d(e,"NEWSUBFILETYPE")))}function N(e){return e.filter((e=>{const t=4==(4&(d(e,"NEWSUBFILETYPE")??0)),n=4===d(e,"PHOTOMETRICINTERPRETATION");return t&&n}))}function k(e){const{littleEndian:t,isBigTiff:n,firstIFDPos:a}=v(e);let i=a;const r=[];do{const a=B(e,t,i,0,s.TIFF_TAGS,n?8:4);if(!a.success)break;r.push(a.ifd),i=a.nextIFD}while(i>0);return{...R(r),littleEndian:t,isBigTiff:n,ifds:r,pyramidIFDs:U(r),maskIFDs:N(r)}}function G(e,t,n){const a=e.getUint32(t,n),i=e.getUint32(t+4,n);return n?i*u+a:a*u+i}function F(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*u+a:a*u+i)}function C(e,t,n,a){return a?G(e,t,n):e.getUint32(t,n)}function v(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:C(t,r,a,s)}}function B(t,n,a,i=0,r=s.TIFF_TAGS,l=4){const o=p(t,n,a,i,r,l);let f;const u=o.ifd;if(u){if(s.ifdTags.forEach(((e,a)=>{u.has(a)&&(f=u.get(a),f.data=p(t,n,f.valueOffset-i,i,e).ifd)})),u.has("GEOKEYDIRECTORY")){f=u.get("GEOKEYDIRECTORY");const e=f.values;if(e&&e.length>4){const a=e[0]+"."+e[1]+"."+e[2];f.data=p(t,n,f.valueOffset+6-i,i,s.GEO_KEYS,2).ifd,f.data&&f.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[a]})}}if(u.has("XMP")){f=u.get("XMP");const t=f.values;"number"==typeof t[0]&&7===f.type&&(f.values=[e(new Uint8Array(t))])}}return o}function V(e){const{width:t,height:n,tileHeight:a,tileWidth:i}=e,r=e.planes,s=i?i*a:t*n,l=d(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 W(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 H(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 M(e,n.littleEndian,a,i[r],s[r]||e.byteLength);l.push(t)}const o=D(a,n),f=d(a,"BITSPERSAMPLE"),u=h(d(a,"SAMPLEFORMAT")??1,f),c=d(a,"SAMPLESPERPIXEL")||n.planes,E=g(u),T=d(a,"TILEWIDTH"),I=d(a,"TILELENGTH"),w=d(a,"COMPRESSION")??1,p=T*I;let y;const S=[];let m=l[0];const A=34887===w;for(let r=0;r<c;r++){if(y=new E(p),l.length===c)m=l[r],m.length===p&&(y=m);else if(m.length)if(o||A)y=m.length===p?m:m.slice(p*r,p*(r+1));else for(let e=0;e<p;e++)y[e]=m[e*c+r];S.push(y)}const P=n.noData?n.noData[0]:t.noDataValue,O=n.metadata?n.metadata.statistics:null,x=O?O.map((e=>e.min)):null,L=O?O.map((e=>e.max)):null,R={pixelType:u,width:T,height:I,pixels:S,noDataValue:P};return null!=P?r(R,P):x&&L&&t.applyMinMaxConstraint&&(R.mask=b(S,x,L)),R}async function Y(e,t={}){const n=t.pyramidLevel||0,a=t.headerInfo||k(e),{ifds:i,noData:s}=a;if(0===i.length)throw new Error("no valid image file directory");const l=V(a);if(l)throw l;let o=null;const f=-1===n?i.at(-1):i[n],u=s??t.noDataValue;return o=a.tileWidth?await P(e,a,f):await O(e,a,f),o?(null!=u&&r(o,u),o):o}export{Y as decode,H as decodeTileOrStrip,R as getImageInfo,N as getMaskIFDs,U as getPyramidIFDs,D as isBSQConfig,L as parseFieldValues,k as parseHeader,B as parseIFD,v as parseSignature};
|
|
5
|
+
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 s from"./TiffTags.js";import{isPlatformLittleEndian as l}from"./utils.js";import{Z as o}from"../../../chunks/Zlib.js";const f=[0,1,1,2,4,8,1,1,2,4,8,4,8,-1,-1,-1,8,8,8],u=4294967296,c=new Set([1,5,6,7,8,34712,34887]);function h(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 g(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 E(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 T(e,t){return e.get(t)?.values}function I(e,t){return e.get(t)?.values}function w(e,t){return e.get(t)?.values?.[0]}function d(e,t){return e.get(t)?.values?.[0]}function p(e,t,n,a=0,i=s.TIFF_TAGS,r=4){const l=8===r,o=l?G(new DataView(e,n,8),0,t):new DataView(e,n,2).getUint16(0,t),f=4+2*r,u=l?8:2,c=u+o*f;if(n+c>e.byteLength)return{success:!1,ifd:null,nextIFD:null,requiredBufferSize:c};const h=n+c+4<=e.byteLength?C(new DataView(e,n+c,8===r?8:4),0,t,8===r):null,g=n+u,E=new Map;let T,I,w,d,p,y=0,S=0;for(let m=0;m<o;m++){I=new DataView(e,g+f*m,f),w=I.getUint16(0,t),p=I.getUint16(2,t),d=s.getTagName(w,i);const n=[];2===r?(y=I.getUint16(4,t),S=I.getUint16(6,t)):4===r?(y=I.getUint32(4,t),S=I.getUint32(8,t)):8===r&&(y=C(I,4,t,!0),S=C(I,12,t,!0),n.push(I.getUint32(12,t)),n.push(I.getUint32(16,t))),T={id:w,type:p,valueCount:y,valueOffset:S,valueOffsets:n,values:null},L(e,t,T,a,!1,r),E.set(d,T)}return{success:!0,ifd:E,nextIFD:h,requiredBufferSize:c}}const y=(e,t)=>a(e,{inputOffset:t}).pixels[0];function S(e,t){if(1!==t&&2!==t&&4!==t)return e;const n=new Uint8Array(e),a=8/t,i=new Uint8Array(e.byteLength*a);let r=0;const s=2**t-1;for(let l=0;l<n.length;l++){const e=n[l];for(let n=0;n<a;n++)i[r++]=e<<t*n>>>8-t&s}return i.buffer}function m(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 A(e){const t=new o(e).getBytes(),n=new ArrayBuffer(t.length),a=new Uint8Array(n);return a.set(t),a}async function M(e,t,a,r,s){const o=l===t,f=d(a,"BITSPERSAMPLE"),u=d(a,"SAMPLESPERPIXEL")??1,c=d(a,"PHOTOMETRICINTERPRETATION"),E=d(a,"SAMPLEFORMAT")??1,T=h(E,f),I=d(a,"COMPRESSION")??1,w=g(T);let p,M,P;if(34887===I)return await n(),y(e,r);if(1===I)p=e.slice(r,r+s),M=new Uint8Array(p);else if(8===I||32946===I)M=new Uint8Array(e,r,s),M=A(M),p=M.buffer;else if(6===I)M=new Uint8Array(e,r,s),M=m(M,u,c),p=M.buffer;else if(7===I){const t=a.get("JPEGTABLES").values,n=t.length-2;M=new Uint8Array(n+s-2);for(let e=0;e<n;e++)M[e]=t[e];const i=new Uint8Array(e,r+2,s-2);for(let e=0;e<i.length;e++)M[n+e]=i[e];M=m(M,u,c),p=M.buffer}else{if(5!==I)throw new Error("tiff-decode: unsupport compression "+I);M=i(e,r,s,t),p=M.buffer}if(p=S(p,f),"u8"===T||"s8"===T||o)P=new w(p);else{p=new ArrayBuffer(M.length);const e=new Uint8Array(p);switch(T){case"u16":case"s16":for(let t=0;t<M.length;t+=2)e[t]=M[t+1],e[t+1]=M[t];break;case"u32":case"s32":case"f32":for(let t=0;t<M.length;t+=4)e[t]=M[t+3],e[t+1]=M[t+2],e[t+2]=M[t+1],e[t+3]=M[t]}P=new w(p)}const O=d(a,"PREDICTOR")??1,b=d(a,"TILEWIDTH"),x=d(a,"TILELENGTH");if(O>1&&(5===I||8===I||32946===I)&&b&&x){const e=D(a),t=new w(P.length);t.set(P),P=W(t,x,b,3===E&&3===O,e?1:u)}return P}async function P(e,t,n){const a=I(n,"TILEOFFSETS");if(void 0===a)return null;const i=I(n,"TILEBYTECOUNTS"),{width:r,height:s,pixelType:l,tileWidth:o,tileHeight:f}=R([n]),u=D(n,t),c=d(n,"SAMPLESPERPIXEL")||t.planes,h=r*s,E=d(n,"BITSPERSAMPLE"),T=34887===(d(n,"COMPRESSION")??1),w=g(l),p=[];for(let g=0;g<c;g++)p.push(new w(h));let y,S,m,A,P,O,b,x,L,U,N,k,G;const F=Math.ceil(r/o),C=new Uint8Array(h).fill(255);let v=!1;if(E%8==0)if(T&&u&&c>1){const l=Math.round(a.length/c);for(y=0;y<l;y++){O=Math.floor(y/F)*f,b=y%F*o,x=O*r+b;for(let l=0;l<c;l++){const u=y*c+l;for(0===i[u]?(m=null,v=!0):m=await M(e,t.littleEndian,n,a[u],i[u]),U=0,L=x,k=Math.min(o,r-b),N=Math.min(f,s-O),G=p[l],A=0;A<N;A++)for(L=x+A*r,U=A*o,P=0;P<k;P++,L++,U++)m?G[L]=m[U]:C[L]=0}}}else for(y=0;y<a.length;y++)for(O=Math.floor(y/F)*f,b=y%F*o,x=O*r+b,0===i[y]?(m=null,v=!0):m=await M(e,t.littleEndian,n,a[y],i[y]),U=0,L=x,k=Math.min(o,r-b),N=Math.min(f,s-O),S=0;S<c;S++)if(G=p[S],u||T)for(A=0;A<N;A++)for(L=x+A*r,U=o*f*S+A*o,P=0;P<k;P++,L++,U++)m?G[L]=m[U]:C[L]=0;else for(A=0;A<N;A++)for(L=x+A*r,U=A*o*c+S,P=0;P<k;P++,L++,U+=c)m?G[L]=m[U]:C[L]=0;return{width:r,height:s,pixelType:l,pixels:p,mask:v?C:void 0}}const O=(e,t,n)=>{const a=l===t.littleEndian,r=I(n,"STRIPOFFSETS");if(void 0===r)return null;const{width:s,height:o,pixelType:f}=R([n]),u=d(n,"SAMPLESPERPIXEL")||t.planes,c=d(n,"PHOTOMETRICINTERPRETATION"),h=s*o,E=d(n,"BITSPERSAMPLE"),T=g(f),w=new T(h*u),p=I(n,"STRIPBYTECOUNTS"),y=d(n,"ROWSPERSTRIP"),M=d(n,"COMPRESSION")??1;let P,O,b,x,L,D,U,N,k,G=y;if(E%8==0)for(P=0;P<r.length;P++){if(L=P*(y*s)*u,G=(P+1)*y>o?o-P*y:y,"u8"===f||"s8"===f||a)8===M||32946===M?(U=new Uint8Array(e,r[P],p[P]),U=A(U),D=U.buffer):6===M?(U=new Uint8Array(e,r[P],p[P]),U=m(U,u,c),D=U.buffer):5===M?(U=i(e,r[P],p[P],t.littleEndian),D=U.buffer):(p[P]!==G*s*u*E/8&&console.log("strip byte counts is different than expected"),D=e.slice(r[P],r[P]+p[P])),D=S(D,E),x=new T(D);else{switch(6===M||8===M||32946===M?(U=new Uint8Array(e,r[P],p[P]),N=A(U),D=N.buffer):(p[P]!==G*s*u*E/8&&console.log("strip byte counts is different than expected"),D=new ArrayBuffer(p[P]),U=new Uint8Array(e,r[P],p[P]),N=new Uint8Array(D)),f){case"u16":case"s16":for(b=0;b<U.length;b+=2)N[b]=U[b+1],N[b+1]=U[b];break;case"u32":case"s32":case"f32":for(b=0;b<U.length;b+=4)N[b]=U[b+3],N[b+1]=U[b+2],N[b+2]=U[b+1],N[b+3]=U[b]}D=S(D,E),x=new T(D)}w.set(x,L)}const F=[];if(1===u)F.push(w);else for(P=0;P<u;P++){for(k=new T(h),O=0;O<h;O++)k[O]=w[O*u+P];F.push(k)}return{width:s,height:o,pixelType:f,pixels:F}},b=(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},x=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"),T=n.get("WavelengthMax");let I=null;if(g){I=[];for(let e=0;e<g.length;e++)I.push({BandName:g[e],WavelengthMin:E&&parseFloat(E[e]),WavelengthMax:T&&parseFloat(T[e])})}return{statistics:h,bandProperties:I,dataType:n.get("DataType"),rawMetadata:n}};function L(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,c=[];const h=f[s],g=8*h,E=l*h,T=l*f[s]*8;let I,w;const d=8===r?64:32,p=n.valueOffsets;if(T>d){if(E>(i?e.byteLength:e?e.byteLength-o+a:0))return n.offlineOffsetSize=[o,E],n.values=null,!1}if(T<=d){if(!t)if(d<=32)o>>>=32-T;else{const e=p?.length?p[0]:o>>>0,t=p?.length?p[1]:Math.round((o-e)/u);T<=32?(o=e>>>32-T,p[0]=o):(o=e*2**(32-T)+(t>>>32-T),p[0]=e,p[1]=t>>>32-T)}if(1===l&&g===d)c=[o];else if(64===d){const e=p?.length?p[0]:o>>>0,t=p?.length?p[1]:Math.round((o-e)/u);let n=e,a=32;for(w=1;w<=l;w++){const e=32-g*w%32;if(a<g){const i=n<<e>>>32-a,r=t<<32-a>>>32-a;n=t,c.push(i+r*2**(g-a)),a-=32-(g-a)}else c.push(n<<e>>>32-g),a-=g;0===a&&(a=32,n=t)}}else for(w=1;w<=l;w++){const e=32-g*w;c.push(o<<e>>>32-g)}}else{o-=a,i&&(o=0);for(let n=o;n<o+E;n+=h){switch(s){case 1:case 2:case 7:I=new DataView(e,n,1).getUint8(0);break;case 3:I=new DataView(e,n,2).getUint16(0,t);break;case 4:case 13:I=new DataView(e,n,4).getUint32(0,t);break;case 5:I=new DataView(e,n,4).getUint32(0,t)/new DataView(e,n+4,4).getUint32(0,t);break;case 6:I=new DataView(e,n,1).getInt8(0);break;case 8:I=new DataView(e,n,2).getInt16(0,t);break;case 9:I=new DataView(e,n,4).getInt32(0,t);break;case 10:I=new DataView(e,n,4).getInt32(0,t)/new DataView(e,n+4,4).getInt32(0,t);break;case 11:I=new DataView(e,n,4).getFloat32(0,t);break;case 12:I=new DataView(e,n,8).getFloat64(0,t);break;case 16:case 18:I=G(new DataView(e,n,8),0,t);break;case 17:I=F(new DataView(e,n,8),0,t);break;default:I=null}c.push(I)}}if(2===s){let e="";const t=c;for(c=[],w=0;w<t.length;w++)0===t[w]&&""!==e?(c.push(e),e=""):e+=String.fromCharCode(t[w]);""===e&&0!==c.length||c.push(e)}return n.values=c,!0}function R(e){const t=e[0],n=d(t,"TILEWIDTH"),a=d(t,"TILELENGTH"),i=d(t,"IMAGEWIDTH"),r=d(t,"IMAGELENGTH"),s=d(t,"BITSPERSAMPLE"),l=d(t,"SAMPLESPERPIXEL"),o=d(t,"SAMPLEFORMAT")??1,f=h(o,s),u=D(t),g=T(t,"GDAL_NODATA");let p=null;g?.length&&(p=g.map((e=>parseFloat(e))),p.some((e=>isNaN(e)))&&(p=null));const y=d(t,"COMPRESSION")??1;let S;switch(y){case 1:S="NONE";break;case 2:case 3:case 4:case 32771:S="CCITT";break;case 5:S="LZW";break;case 6:case 7:S="JPEG";break;case 32773:S="PACKBITS";break;case 8:case 32946:S="DEFLATE";break;case 34712:S="JPEG2000";break;case 34887:S="LERC";break;default:S=String(y)}let m=!0,A="";c.has(y)||(m=!1,A+="unsupported tag compression "+y),o>3&&(m=!1,A+="unsupported tag sampleFormat "+o),1!==s&&2!==s&&4!==s&&s%8!=0&&(m=!1,A+="unsupported tag bitsPerSample "+s);const M=w(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=I(t,"GEOTIEPOINTS"),b=I(t,"GEOPIXELSCALE"),L=I(t,"GEOTRANSMATRIX"),R=t.has("GEOKEYDIRECTORY")?t.get("GEOKEYDIRECTORY").data:null;let k,G,F=!1,C=!1;if(R){F=2===d(R,"GTRasterTypeGeoKey");const e=d(R,"GTModelTypeGeoKey");if(2===e){const e=d(R,"GeographicTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e}),P||32767!==e||(C=!0,P={wkid:4326})}else if(1===e){const e=d(R,"ProjectedCSTypeGeoKey");e>=1024&&e<=32766&&(P={wkid:e})}}if(b&&O&&O.length>=6?(k=[b[0],0,O[3]-O[0]*b[0],0,-Math.abs(b[1]),O[4]-O[1]*b[1]],F&&(k[2]-=.5*k[0]+.5*k[1],k[5]-=.5*k[3]+.5*k[4])):L&&16===L.length&&(k=F?[L[0],L[1],L[3]-.5*L[0],L[4],L[5],L[7]-.5*L[5]]:[L[0],L[1],L[3],L[4],L[5],L[7]]),k){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=E(e[i],k),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;G={xmin:n,xmax:s,ymin:a,ymax:l,spatialReference:P}}else G={xmin:-.5,ymin:.5-r,xmax:i-.5,ymax:.5,spatialReference:P};C&&(G.xmax-G.xmin>400||Math.max(Math.abs(G.xmin),Math.abs(G.xmax))>361)&&(P=null,G.spatialReference=null);const v=U(e);let B,W,H,Y,_;if(v.length>0){H=Math.round(Math.log(i/d(v[0],"IMAGEWIDTH"))/Math.LN2);const e=v[v.length-1];Y=Math.round(Math.log(i/d(e,"IMAGEWIDTH"))/Math.LN2),B=d(e,"TILEWIDTH"),W=d(e,"TILELENGTH")}B=null!=Y&&Y>0?B||n:null,W=null!=Y&&Y>0?W||a:null,n&&(_=[{maxCol:Math.ceil(i/n)-1,maxRow:Math.ceil(r/a)-1,minRow:0,minCol:0}],v.forEach((e=>{_.push({maxCol:Math.ceil(d(e,"IMAGEWIDTH")/d(e,"TILEWIDTH"))-1,maxRow:Math.ceil(d(e,"IMAGELENGTH")/d(e,"TILELENGTH"))-1,minRow:0,minCol:0})})));const K=w(e[0],"GDAL_METADATA"),X=x(K);A+=" "+V({width:i,height:r,tileWidth:n,tileHeight:a,planes:l,ifds:e});return{width:i,height:r,tileWidth:n,tileHeight:a,planes:l,isBSQ:u,pixelType:f,compression:S,noData:p,hasMaskBand:N(e).length===v.length+1,isSupported:m,message:A,extent:G,isPseudoGeographic:C,affine:b?null:k,firstPyramidLevel:H,maximumPyramidLevel:Y,pyramidBlockWidth:B,pyramidBlockHeight:W,tileBoundary:_,metadata:X}}function D(e,t){const n=T(e,"PLANARCONFIGURATION");return n?2===n[0]:!!t&&t.isBSQ}function U(e){return e.filter((e=>1===d(e,"NEWSUBFILETYPE")))}function N(e){return e.filter((e=>{const t=4==(4&(d(e,"NEWSUBFILETYPE")??0)),n=4===d(e,"PHOTOMETRICINTERPRETATION");return t&&n}))}function k(e){const{littleEndian:t,isBigTiff:n,firstIFDPos:a}=v(e);let i=a;const r=[];do{const a=B(e,t,i,0,s.TIFF_TAGS,n?8:4);if(!a.success)break;r.push(a.ifd),i=a.nextIFD}while(i>0);return{...R(r),littleEndian:t,isBigTiff:n,ifds:r,pyramidIFDs:U(r),maskIFDs:N(r)}}function G(e,t,n){const a=e.getUint32(t,n),i=e.getUint32(t+4,n);return n?i*u+a:a*u+i}function F(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*u+a:a*u+i)}function C(e,t,n,a){return a?G(e,t,n):e.getUint32(t,n)}function v(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:C(t,r,a,s)}}function B(t,n,a,i=0,r=s.TIFF_TAGS,l=4){const o=p(t,n,a,i,r,l);let f;const u=o.ifd;if(u){if(s.ifdTags.forEach(((e,a)=>{u.has(a)&&(f=u.get(a),f.data=p(t,n,f.valueOffset-i,i,e).ifd)})),u.has("GEOKEYDIRECTORY")){f=u.get("GEOKEYDIRECTORY");const e=f.values;if(e&&e.length>4){const a=e[0]+"."+e[1]+"."+e[2];f.data=p(t,n,f.valueOffset+6-i,i,s.GEO_KEYS,2).ifd,f.data&&f.data.set("GEOTIFFVersion",{id:0,type:2,valueCount:1,valueOffset:null,values:[a]})}}if(u.has("XMP")){f=u.get("XMP");const t=f.values;"number"==typeof t[0]&&7===f.type&&(f.values=[e(new Uint8Array(t))])}}return o}function V(e){const{width:t,height:n,tileHeight:a,tileWidth:i}=e,r=e.planes,s=i?i*a:t*n,l=d(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 W(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 H(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 M(e,n.littleEndian,a,i[r],s[r]||e.byteLength);l.push(t)}const o=D(a,n),f=d(a,"BITSPERSAMPLE"),u=h(d(a,"SAMPLEFORMAT")??1,f),c=d(a,"SAMPLESPERPIXEL")||n.planes,E=g(u),T=d(a,"TILEWIDTH"),I=d(a,"TILELENGTH"),w=d(a,"COMPRESSION")??1,p=T*I;let y;const S=[];let m=l[0];const A=34887===w;for(let r=0;r<c;r++){if(y=new E(p),l.length===c)m=l[r],m.length===p&&(y=m);else if(m.length)if(o||A)y=m.length===p?m:m.slice(p*r,p*(r+1));else for(let e=0;e<p;e++)y[e]=m[e*c+r];S.push(y)}const P=n.noData?n.noData[0]:t.noDataValue,O=n.metadata?n.metadata.statistics:null,x=O?O.map((e=>e.min)):null,L=O?O.map((e=>e.max)):null,R={pixelType:u,width:T,height:I,pixels:S,noDataValue:P};return null!=P?r(R,P):x&&L&&t.applyMinMaxConstraint&&(R.mask=b(S,x,L)),R}async function Y(e,t={}){const n=t.pyramidLevel||0,a=t.headerInfo||k(e),{ifds:i,noData:s}=a;if(0===i.length)throw new Error("no valid image file directory");const l=V(a);if(l)throw l;let o=null;const f=-1===n?i[i.length-1]:i[n],u=s??t.noDataValue;return o=a.tileWidth?await P(e,a,f):await O(e,a,f),o?(null!=u&&r(o,u),o):o}export{Y as decode,H as decodeTileOrStrip,R as getImageInfo,N as getMaskIFDs,U as getPyramidIFDs,D as isBSQConfig,L as parseFieldValues,k as parseHeader,B as parseIFD,v as parseSignature};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as t}from"../../../chunks/tslib.es6.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{getBandMatrix3 as s}from"./bandIndexUtils.js";import r from"./BaseRasterFunction.js";import a from"./ExtractBandFunctionArguments.js";import{MissingBandAction as o}from"./pixelUtils.js";let i=class extends r{constructor(){super(...arguments),this.functionName="ExtractBand",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{functionArguments:t,sourceRasterInfos:e}=this,n=e[0],{method:s,bandNames:r,bandWavelengths:a,bandIds:i,missingBandAction:l}=t,u=r?.length&&("name"===s||"id"!==s&&!i?.length),c=a?.length&&("wavelength"===s||"id"!==s&&!i?.length),h=l===o.fail,d=u?this._matchBandNames(n,r):c?this._matchBandWavelengths(n,a,h):this._matchBandIds(n,i,h);if(null==d){return{success:!1,supportsGPU:!1,error:`extract-band-function: Invalid ${u?"band names":c?"band wavelengths":"band ids"} for the imagery data source`}}this.functionArguments.bandIds=d,this.functionArguments.method="id",this.outputPixelType=this._getOutputPixelType("f32");const m=n.clone();m.pixelType=this.outputPixelType,m.bandCount=d.length;const{statistics:p,histograms:g}=m;null!=p&&p.length&&(m.statistics=d.map((t=>p[t]||p.
|
|
5
|
+
import{_ as t}from"../../../chunks/tslib.es6.js";import{property as e}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/accessorSupport/ensureType.js";import"../../../core/arrayUtils.js";import"../../../core/has.js";import{subclass as n}from"../../../core/accessorSupport/decorators/subclass.js";import{getBandMatrix3 as s}from"./bandIndexUtils.js";import r from"./BaseRasterFunction.js";import a from"./ExtractBandFunctionArguments.js";import{MissingBandAction as o}from"./pixelUtils.js";let i=class extends r{constructor(){super(...arguments),this.functionName="ExtractBand",this.functionArguments=null,this.rasterArgumentNames=["raster"]}_bindSourceRasters(){const{functionArguments:t,sourceRasterInfos:e}=this,n=e[0],{method:s,bandNames:r,bandWavelengths:a,bandIds:i,missingBandAction:l}=t,u=r?.length&&("name"===s||"id"!==s&&!i?.length),c=a?.length&&("wavelength"===s||"id"!==s&&!i?.length),h=l===o.fail,d=u?this._matchBandNames(n,r):c?this._matchBandWavelengths(n,a,h):this._matchBandIds(n,i,h);if(null==d){return{success:!1,supportsGPU:!1,error:`extract-band-function: Invalid ${u?"band names":c?"band wavelengths":"band ids"} for the imagery data source`}}this.functionArguments.bandIds=d,this.functionArguments.method="id",this.outputPixelType=this._getOutputPixelType("f32");const m=n.clone();m.pixelType=this.outputPixelType,m.bandCount=d.length;const{statistics:p,histograms:g}=m;null!=p&&p.length&&(m.statistics=d.map((t=>p[t]||p[p.length-1]))),null!=g&&g.length&&(m.histograms=d.map((t=>g[t]||g[g.length-1])));let f=m.keyProperties?.BandProperties;f?.length&&(f=d.map((t=>t>=f.length?f[f.length-1]:f[t])),m.keyProperties={...m.keyProperties,BandProperties:f}),this.rasterInfo=m;return{success:!0,supportsGPU:m.bandCount<=3}}_processPixels(t){const e=t.pixelBlocks?.[0];if(null==e)return null;const n=e.pixels.length,s=this.functionArguments.bandIds.map((t=>t>=n?n-1:t));return e.extractBands(s)}_getWebGLParameters(){let t;if(this.isInputBandIdsSwizzled)t=this.swizzledBandSelection.length?this.swizzledBandSelection:[0,1,2];else{t=[...this.functionArguments.bandIds],0===t.length?t=[0,1,2]:t.length<3&&(t[1]=t[1]??t[0],t[2]=t[2]??t[1]);for(let e=0;e<3;e++)t[e]=Math.min(t[e],2)}return{bandIndexMat3:s(t)}}_getInputBandIds(t){const e=t.length;return this.functionArguments.bandIds.map((t=>t>=e?e-1:t)).map((e=>t[e]))}_matchBandNames(t,e){const n=t.bandInfos.map((({name:t})=>t.toLowerCase())),s=[];for(let r=0;r<e.length;r++){const t=e[r].toLowerCase();let a=n.indexOf(t);if(-1===a&&"nearinfrared"===t&&(a=n.findIndex((t=>t.startsWith("nearinfrared_1"))),-1===a&&(a=n.findIndex((t=>t.startsWith("nearinfrared"))))),-1===a)return null;s.push(a)}return s}_matchBandIds(t,e,n){const{bandCount:s}=t;return!e?.length||n&&e.some((t=>t<0||t>=s))?null:e}_matchBandWavelengths(t,e,n){const{bandInfos:s}=t,r=[];for(let i=0;i<s.length;i++){const{minWavelength:t,maxWavelength:e}=s[i];if(!t||!e)return null;r.push({minWavelength:t,maxWavelength:e})}const{wavelengthMatchTolerance:a}=this.functionArguments,o=[];for(let i=0;i<e.length;i++){const t=e[i];let s=!1,l=-1,u=Number.MAX_VALUE;for(let e=0;e<r.length;e++){const n=r[e],a=t>=n.minWavelength&&t<=n.maxWavelength,o=Math.abs(t-(n.minWavelength+n.maxWavelength)/2);a?o<u&&(s=!0,l=e,u=o):!s&&o<u&&(l=e,u=o)}if(!s&&a&&u<a&&(s=!0),!s&&n)return null;o.push(l)}return o}};t([e({json:{write:!0,name:"rasterFunction"}})],i.prototype,"functionName",void 0),t([e({type:a,json:{write:!0,name:"rasterFunctionArguments"}})],i.prototype,"functionArguments",void 0),t([e()],i.prototype,"rasterArgumentNames",void 0),i=t([n("esri.layers.support.rasterFunctions.ExtractBandFunction")],i);const l=i;export{l as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{convertColorRampToColors as r}from"../../../renderers/support/colorRampUtils.js";const t=[[36,0,255],[36,0,255],[36,0,255],[36,0,255],[112,75,3],[113,76,3],[114,77,3],[115,77,3],[116,78,3],[117,79,3],[118,79,3],[119,80,3],[121,81,4],[122,82,4],[123,82,4],[124,83,4],[125,84,4],[126,84,4],[127,85,4],[128,86,4],[129,86,4],[130,87,4],[131,88,4],[132,89,4],[133,89,4],[134,90,4],[135,91,4],[136,91,4],[137,92,4],[138,93,4],[139,94,4],[140,94,4],[142,95,5],[143,96,5],[144,96,5],[145,97,5],[146,98,5],[147,99,5],[148,99,5],[149,100,5],[150,101,5],[151,101,5],[152,102,5],[153,103,5],[154,104,5],[155,104,5],[156,105,5],[157,106,5],[158,106,5],[159,107,5],[160,108,5],[161,108,5],[162,109,5],[164,110,6],[165,111,6],[166,111,6],[167,112,6],[168,113,6],[169,113,6],[170,114,6],[171,115,6],[172,116,6],[173,116,6],[174,117,6],[245,0,0],[245,5,0],[245,10,0],[246,15,0],[246,20,0],[246,25,0],[246,30,0],[247,35,0],[247,40,0],[247,45,0],[247,50,0],[247,55,0],[248,60,0],[248,65,0],[248,70,0],[248,75,0],[249,81,0],[249,86,0],[249,91,0],[249,96,0],[250,101,0],[250,106,0],[250,111,0],[250,116,0],[250,121,0],[251,126,0],[251,131,0],[251,136,0],[251,141,0],[252,146,0],[252,151,0],[252,156,0],[252,156,0],[251,159,0],[250,162,0],[249,165,0],[248,168,0],[247,171,0],[246,174,0],[245,177,0],[245,179,0],[244,182,0],[243,185,0],[242,188,0],[241,191,0],[240,194,0],[239,197,0],[238,200,0],[237,203,0],[236,206,0],[235,209,0],[234,212,0],[233,215,0],[232,218,0],[231,221,0],[230,224,0],[230,226,0],[229,229,0],[228,232,0],[227,235,0],[226,238,0],[225,241,0],[224,244,0],[223,247,0],[165,247,0],[163,244,0],[161,240,0],[158,237,0],[156,233,1],[154,230,1],[152,227,1],[149,223,1],[147,220,1],[145,216,1],[143,213,1],[140,210,2],[138,206,2],[136,203,2],[134,200,2],[132,196,2],[129,193,2],[127,189,2],[125,186,3],[123,183,3],[120,179,3],[118,176,3],[116,172,3],[114,169,3],[111,166,3],[109,162,4],[107,159,4],[105,155,4],[103,152,4],[100,149,4],[98,145,4],[96,142,4],[94,138,5],[91,135,5],[89,132,5],[87,128,5],[85,125,5],[82,121,5],[80,118,5],[78,115,6],[76,111,6],[73,108,6],[71,105,6],[69,101,6],[67,98,6],[65,94,6],[62,91,7],[60,88,7],[58,84,7],[56,81,7],[53,77,7],[51,74,7],[49,71,7],[47,67,8],[44,64,8],[42,60,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8]],o=[[36,0,255],[36,0,255],[36,0,255],[36,0,255],[245,20,0],[245,24,0],[245,29,0],[245,31,0],[247,33,0],[247,33,0],[247,37,0],[247,41,0],[247,41,0],[247,41,0],[247,45,0],[247,45,0],[247,47,0],[247,49,0],[247,49,0],[247,54,0],[247,54,0],[247,56,0],[247,58,0],[247,58,0],[250,62,0],[250,62,0],[250,62,0],[250,67,0],[250,67,0],[250,67,0],[250,69,0],[250,71,0],[250,71,0],[250,75,0],[250,75,0],[250,78,0],[250,79,0],[250,79,0],[250,79,0],[250,81,0],[250,83,0],[250,83,0],[250,87,0],[250,87,0],[250,90,0],[250,92,0],[252,93,0],[252,93,0],[252,97,0],[252,97,0],[252,97,0],[252,97,0],[252,101,0],[252,101,0],[252,101,0],[252,101,0],[252,105,0],[252,105,0],[252,107,0],[252,109,0],[252,109,0],[252,113,13],[255,118,20],[255,119,23],[255,121,25],[255,126,33],[255,132,38],[255,133,40],[255,135,43],[255,141,48],[255,144,54],[255,150,59],[255,152,61],[255,153,64],[255,159,69],[255,163,77],[255,165,79],[255,168,82],[255,174,87],[255,176,92],[255,181,97],[255,183,99],[255,186,102],[255,191,107],[255,197,115],[255,201,120],[255,203,123],[255,205,125],[255,209,130],[255,214,138],[255,216,141],[255,218,143],[255,224,150],[255,228,156],[255,234,163],[255,236,165],[255,238,168],[255,243,173],[255,248,181],[255,252,186],[253,252,186],[250,252,187],[244,250,180],[238,247,176],[234,246,173],[231,245,169],[223,240,163],[217,237,157],[211,235,150],[205,233,146],[200,230,142],[195,227,136],[189,224,132],[184,222,126],[180,220,123],[174,217,119],[169,214,114],[163,212,108],[160,210,105],[154,207,101],[148,204,96],[143,201,93],[138,199,88],[134,197,84],[130,194,81],[126,191,77],[117,189,70],[115,186,68],[112,184,64],[106,181,60],[100,179,55],[94,176,49],[92,174,47],[90,173,45],[81,168,37],[75,166,33],[71,163,28],[66,160,24],[62,158,21],[56,156,14],[51,153,0],[51,153,0],[51,153,0],[50,150,0],[50,150,0],[50,150,0],[50,150,0],[49,148,0],[49,148,0],[49,148,0],[48,145,0],[48,145,0],[48,145,0],[48,145,0],[48,143,0],[48,143,0],[48,143,0],[48,143,0],[47,140,0],[47,140,0],[47,140,0],[47,140,0],[46,138,0],[46,138,0],[46,138,0],[46,138,0],[45,135,0],[45,135,0],[45,135,0],[45,135,0],[44,133,0],[44,133,0],[44,133,0],[43,130,0],[43,130,0],[43,130,0],[43,130,0],[43,130,0],[43,130,0],[42,128,0],[42,128,0],[42,128,0],[42,125,0],[42,125,0],[42,125,0],[42,125,0],[41,122,0],[41,122,0],[41,122,0],[41,122,0],[40,120,0],[40,120,0],[40,120,0],[40,120,0],[40,120,0],[39,117,0],[39,117,0],[39,117,0],[39,117,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0]];function e(t,o){const e=[],n=[];for(let r=0;r<t.length-1;r++)e.push({type:"algorithmic",algorithm:"esriHSVAlgorithm",fromColor:t[r].slice(1),toColor:t[r+1].slice(1)}),n.push(t[r+1][0]-t[r][0]);const s=t.
|
|
5
|
+
import{convertColorRampToColors as r}from"../../../renderers/support/colorRampUtils.js";const t=[[36,0,255],[36,0,255],[36,0,255],[36,0,255],[112,75,3],[113,76,3],[114,77,3],[115,77,3],[116,78,3],[117,79,3],[118,79,3],[119,80,3],[121,81,4],[122,82,4],[123,82,4],[124,83,4],[125,84,4],[126,84,4],[127,85,4],[128,86,4],[129,86,4],[130,87,4],[131,88,4],[132,89,4],[133,89,4],[134,90,4],[135,91,4],[136,91,4],[137,92,4],[138,93,4],[139,94,4],[140,94,4],[142,95,5],[143,96,5],[144,96,5],[145,97,5],[146,98,5],[147,99,5],[148,99,5],[149,100,5],[150,101,5],[151,101,5],[152,102,5],[153,103,5],[154,104,5],[155,104,5],[156,105,5],[157,106,5],[158,106,5],[159,107,5],[160,108,5],[161,108,5],[162,109,5],[164,110,6],[165,111,6],[166,111,6],[167,112,6],[168,113,6],[169,113,6],[170,114,6],[171,115,6],[172,116,6],[173,116,6],[174,117,6],[245,0,0],[245,5,0],[245,10,0],[246,15,0],[246,20,0],[246,25,0],[246,30,0],[247,35,0],[247,40,0],[247,45,0],[247,50,0],[247,55,0],[248,60,0],[248,65,0],[248,70,0],[248,75,0],[249,81,0],[249,86,0],[249,91,0],[249,96,0],[250,101,0],[250,106,0],[250,111,0],[250,116,0],[250,121,0],[251,126,0],[251,131,0],[251,136,0],[251,141,0],[252,146,0],[252,151,0],[252,156,0],[252,156,0],[251,159,0],[250,162,0],[249,165,0],[248,168,0],[247,171,0],[246,174,0],[245,177,0],[245,179,0],[244,182,0],[243,185,0],[242,188,0],[241,191,0],[240,194,0],[239,197,0],[238,200,0],[237,203,0],[236,206,0],[235,209,0],[234,212,0],[233,215,0],[232,218,0],[231,221,0],[230,224,0],[230,226,0],[229,229,0],[228,232,0],[227,235,0],[226,238,0],[225,241,0],[224,244,0],[223,247,0],[165,247,0],[163,244,0],[161,240,0],[158,237,0],[156,233,1],[154,230,1],[152,227,1],[149,223,1],[147,220,1],[145,216,1],[143,213,1],[140,210,2],[138,206,2],[136,203,2],[134,200,2],[132,196,2],[129,193,2],[127,189,2],[125,186,3],[123,183,3],[120,179,3],[118,176,3],[116,172,3],[114,169,3],[111,166,3],[109,162,4],[107,159,4],[105,155,4],[103,152,4],[100,149,4],[98,145,4],[96,142,4],[94,138,5],[91,135,5],[89,132,5],[87,128,5],[85,125,5],[82,121,5],[80,118,5],[78,115,6],[76,111,6],[73,108,6],[71,105,6],[69,101,6],[67,98,6],[65,94,6],[62,91,7],[60,88,7],[58,84,7],[56,81,7],[53,77,7],[51,74,7],[49,71,7],[47,67,8],[44,64,8],[42,60,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8],[40,57,8]],o=[[36,0,255],[36,0,255],[36,0,255],[36,0,255],[245,20,0],[245,24,0],[245,29,0],[245,31,0],[247,33,0],[247,33,0],[247,37,0],[247,41,0],[247,41,0],[247,41,0],[247,45,0],[247,45,0],[247,47,0],[247,49,0],[247,49,0],[247,54,0],[247,54,0],[247,56,0],[247,58,0],[247,58,0],[250,62,0],[250,62,0],[250,62,0],[250,67,0],[250,67,0],[250,67,0],[250,69,0],[250,71,0],[250,71,0],[250,75,0],[250,75,0],[250,78,0],[250,79,0],[250,79,0],[250,79,0],[250,81,0],[250,83,0],[250,83,0],[250,87,0],[250,87,0],[250,90,0],[250,92,0],[252,93,0],[252,93,0],[252,97,0],[252,97,0],[252,97,0],[252,97,0],[252,101,0],[252,101,0],[252,101,0],[252,101,0],[252,105,0],[252,105,0],[252,107,0],[252,109,0],[252,109,0],[252,113,13],[255,118,20],[255,119,23],[255,121,25],[255,126,33],[255,132,38],[255,133,40],[255,135,43],[255,141,48],[255,144,54],[255,150,59],[255,152,61],[255,153,64],[255,159,69],[255,163,77],[255,165,79],[255,168,82],[255,174,87],[255,176,92],[255,181,97],[255,183,99],[255,186,102],[255,191,107],[255,197,115],[255,201,120],[255,203,123],[255,205,125],[255,209,130],[255,214,138],[255,216,141],[255,218,143],[255,224,150],[255,228,156],[255,234,163],[255,236,165],[255,238,168],[255,243,173],[255,248,181],[255,252,186],[253,252,186],[250,252,187],[244,250,180],[238,247,176],[234,246,173],[231,245,169],[223,240,163],[217,237,157],[211,235,150],[205,233,146],[200,230,142],[195,227,136],[189,224,132],[184,222,126],[180,220,123],[174,217,119],[169,214,114],[163,212,108],[160,210,105],[154,207,101],[148,204,96],[143,201,93],[138,199,88],[134,197,84],[130,194,81],[126,191,77],[117,189,70],[115,186,68],[112,184,64],[106,181,60],[100,179,55],[94,176,49],[92,174,47],[90,173,45],[81,168,37],[75,166,33],[71,163,28],[66,160,24],[62,158,21],[56,156,14],[51,153,0],[51,153,0],[51,153,0],[50,150,0],[50,150,0],[50,150,0],[50,150,0],[49,148,0],[49,148,0],[49,148,0],[48,145,0],[48,145,0],[48,145,0],[48,145,0],[48,143,0],[48,143,0],[48,143,0],[48,143,0],[47,140,0],[47,140,0],[47,140,0],[47,140,0],[46,138,0],[46,138,0],[46,138,0],[46,138,0],[45,135,0],[45,135,0],[45,135,0],[45,135,0],[44,133,0],[44,133,0],[44,133,0],[43,130,0],[43,130,0],[43,130,0],[43,130,0],[43,130,0],[43,130,0],[42,128,0],[42,128,0],[42,128,0],[42,125,0],[42,125,0],[42,125,0],[42,125,0],[41,122,0],[41,122,0],[41,122,0],[41,122,0],[40,120,0],[40,120,0],[40,120,0],[40,120,0],[40,120,0],[39,117,0],[39,117,0],[39,117,0],[39,117,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0],[38,115,0]];function e(t,o){const e=[],n=[];for(let r=0;r<t.length-1;r++)e.push({type:"algorithmic",algorithm:"esriHSVAlgorithm",fromColor:t[r].slice(1),toColor:t[r+1].slice(1)}),n.push(t[r+1][0]-t[r][0]);const s=t[t.length-1][0];return r({type:"multipart",colorRamps:e},{numColors:s,weights:o=o??n})}function n(){return e([[0,0,191,191],[51,0,0,255],[102,255,0,255],[153,255,0,127],[204,191,63,127],[256,20,20,20]])}function s(){const r=e([[0,255,255,255],[70,0,255,0],[80,205,173,193],[100,150,150,150],[110,120,51,100],[130,120,100,200],[140,28,3,144],[160,6,0,55],[180,10,25,30],[201,6,7,27]]);for(let t=r.length;t<256;t++)r.push([6,27,7]);return r}function l(){return r({type:"algorithmic",algorithm:"esriHSVAlgorithm",fromColor:[0,0,0],toColor:[255,255,255]})}function i(){const r=[];for(let t=0;t<256;t++){const t=[];for(let r=0;r<3;r++)t.push(Math.round(255*Math.random()));r.push(t)}return r}function a(){return e([[0,38,41,54],[69,79,82,90],[131,156,156,156],[256,253,253,241]],[.268,.238,.495])}function c(r){let e;switch(r){case"elevation":e=n();break;case"gray":e=l();break;case"hillshade":e=a();break;case"ndvi":e=t;break;case"ndvi2":e=s();break;case"ndvi3":e=o;break;case"random":e=i()}return e?(e=e.map(((r,t)=>[t,...r])),e):null}export{c as getColormapByName};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import t from"../PixelBlock.js";import{getPixelValueRange as e}from"../rasterFormats/pixelRangeUtils.js";var n,l;!function(t){t[t.matchAny=0]="matchAny",t[t.matchAll=1]="matchAll"}(n||(n={})),function(t){t[t.bestMatch=0]="bestMatch",t[t.fail=1]="fail"}(l||(l={}));const i=6;function o(t){return null!=t&&"esri.layers.support.PixelBlock"===t.declaredClass&&t.pixels&&t.pixels.length>0}function s(t,e){return e?.length&&o(t)?t.extractBands(e):t}function r(e){if(!e?.length||e.some((t=>!o(t))))return null;if(1===e.length)return e[0]?.clone()??null;const n=e,{width:l,height:i,pixelType:s}=n[0];if(n.some((t=>t.width!==l||t.height!==i)))return null;const r=n.map((({mask:t})=>t)).filter((t=>null!=t));let a=null;r.length&&(a=new Uint8Array(l*i),a.set(r[0]),r.length>1&&m(r.slice(1),a));const h=[];n.forEach((({pixels:t})=>h.push(...t)));const f=n.map((({statistics:t})=>t)).filter((t=>t?.length)),c=[];return f.forEach((t=>c.push(...t))),new t({pixelType:s,width:l,height:i,mask:a,pixels:h,statistics:c.length?c:null})}function a(t){if(!t)return;const e=t.colormap;if(!e||0===e.length)return;const n=e.sort(((t,e)=>t[0]-e[0]));let l=0;n[0][0]<0&&(l=n[0][0]);const i=Math.max(256,n.at(-1)[0]-l+1),o=new Uint8Array(4*i),s=[];let r,a=0,h=0;const f=5===n[0].length;if(i>65536)return n.forEach((t=>{s[t[0]-l]=f?t.slice(1):t.slice(1).concat([255])})),{indexed2DColormap:s,offset:l,alphaSpecified:f};if(t.fillUnspecified)for(r=n[h],a=r[0]-l;a<i;a++)o[4*a]=r[1],o[4*a+1]=r[2],o[4*a+2]=r[3],o[4*a+3]=f?r[4]:255,a===r[0]-l&&(r=h===n.length-1?r:n[++h]);else for(a=0;a<n.length;a++)r=n[a],h=4*(r[0]-l),o[h]=r[1],o[h+1]=r[2],o[h+2]=r[3],o[h+3]=f?r[4]:255;return{indexedColormap:o,offset:l,alphaSpecified:f}}function h(t,e){if(!o(t))return t;if(!e||!e.indexedColormap&&!e.indexed2DColormap)return t;const n=t.clone(),l=n.pixels;let i=n.mask;const s=n.width*n.height;if(1!==l.length)return t;const{indexedColormap:r,indexed2DColormap:a,offset:h,alphaSpecified:f}=e;let c=0;const u=l[0],p=new Uint8Array(u.length),x=new Uint8Array(u.length),d=new Uint8Array(u.length);let m,g=0;if(r){const t=r.length-1;if(null!=i)for(c=0;c<s;c++)i[c]&&(g=4*(u[c]-h),g<h||g>t?i[c]=0:(p[c]=r[g],x[c]=r[g+1],d[c]=r[g+2],i[c]=r[g+3]));else{for(i=new Uint8Array(s),c=0;c<s;c++)g=4*(u[c]-h),g<h||g>t?i[c]=0:(p[c]=r[g],x[c]=r[g+1],d[c]=r[g+2],i[c]=r[g+3]);n.mask=i}}else if(a)if(null!=i)for(c=0;c<s;c++)i[c]&&(m=a[u[c]],p[c]=m[0],x[c]=m[1],d[c]=m[2],i[c]=m[3]);else{for(i=new Uint8Array(s),c=0;c<s;c++)m=a[u[c]],p[c]=m[0],x[c]=m[1],d[c]=m[2],i[c]=m[3];n.mask=i}return n.pixels=[p,x,d],n.statistics=null,n.pixelType="u8",n.maskIsAlpha=f,n}function f(e,n){if(!o(e))return null;const{pixels:l,mask:i}=e,s=l.length;let r=n.lut;const{offset:a}=n;r&&1===r[0].length&&(r=l.map((()=>r)));const h=[],f=n.outputPixelType||"u8";for(let t=0;t<s;t++){const e=c(l[t],i,r[t],a||0,f);h.push(e)}const u=new t({width:e.width,height:e.height,pixels:h,mask:i,pixelType:f});return u.updateStatistics(),u}function c(e,n,l,i,o){const s=e.length,r=t.createEmptyBand(o,s);if(n)for(let t=0;t<s;t++)n[t]&&(r[t]=l[e[t]-i]);else for(let t=0;t<s;t++)r[t]=l[e[t]-i];return r}function u(t,e){if(!o(t))return null;const n=t.clone(),{pixels:l}=n,i=n.width*n.height,s=e.length,r=Math.floor(s/2),a=e[Math.floor(r)],h=l[0];let f,c,u,p,x,d,m=!1;const g=new Uint8Array(i),y=new Uint8Array(i),w=new Uint8Array(i);let k=n.mask;const M=4===e[0].mappedColor.length;for(k||(k=new Uint8Array(i),k.fill(M?255:1),n.mask=k),x=0;x<i;x++)if(k[x]){for(f=h[x],m=!1,d=r,c=a,u=0,p=s-1;p-u>1;){if(f===c.value){m=!0;break}f>c.value?u=d:p=d,d=Math.floor((u+p)/2),c=e[Math.floor(d)]}m||(f===e[u].value?(c=e[u],m=!0):f===e[p].value?(c=e[p],m=!0):f<e[u].value?(m=!1,c=null):f>e[u].value&&(f<e[p].value?(c=e[u],m=!0):p===s-1?(m=!1,c=null):(c=e[p],m=!0))),m?(g[x]=c.mappedColor[0],y[x]=c.mappedColor[1],w[x]=c.mappedColor[2],k[x]=c.mappedColor[3]):g[x]=y[x]=w[x]=k[x]=0}return n.pixels=[g,y,w],n.mask=k,n.pixelType="u8",n.maskIsAlpha=M,n}function p(n,l){if(!o(n))return null;const{width:i,height:s}=n,{inputRanges:r,outputValues:a,outputPixelType:h,noDataRanges:f,allowUnmatched:c,isLastInputRangeInclusive:u}=l,p=n.pixels[0],x=t.createEmptyBand(h,p.length),d=n.mask,m=new Uint8Array(i*s);d?m.set(d):m.fill(255);const g=n.pixelType.startsWith("f")?1e-6:0,y=r.map((t=>t-g));y[0]=r[0],y[y.length-1]=r.at(-1)+(u?1e-6:0);const w=r.length/2,[k,M]=e(h);for(let t=0;t<s;t++)for(let e=0;e<i;e++){const n=t*i+e;if(m[n]){const t=p[n];let e=!1;for(let l=w-1;l>=0;l--)if(t===y[2*l]||t>y[2*l]&&t<y[2*l+1]){x[n]=a[l],e=!0;break}e||(c?x[n]=t>M?M:t<k?k:t:m[n]=0)}}const A=f?.length;if(A)for(let t=0;t<s;t++)for(let e=0;e<i;e++){const n=t*i+e;if(!d||d[n]){const t=p[n];for(let e=0;e<A;e+=2)if(t>=f[e]&&t<=f[e+1]){x[n]=0,m[n]=0;break}}}return new t({width:i,height:s,pixelType:h,pixels:[x],mask:m})}function x(t,e,n,l){const i=null!=n&&n.length>=2?new Set(n):null,o=1===n?.length?n[0]:null,s=!!e?.length;for(let r=0;r<t.length;r++)if(l[r]){const n=t[r];if(s){let t=!1;for(let l=0;l<e.length;l+=2)if(n>=e[l]&&n<=e[l+1]){t=!0;break}t||(l[r]=0)}l[r]&&(n===o||i?.has(n))&&(l[r]=0)}}function d(t,e){const n=t[0].length;for(let l=0;l<n;l++)if(e[l]){let n=!1;for(let e=0;e<t.length;e++)if(t[e][l]){n=!0;break}n||(e[l]=0)}}function m(t,e){const n=t[0].length;for(let l=0;l<n;l++)if(e[l]){let n=!1;for(let e=0;e<t.length;e++)if(0===t[e][l]){n=!0;break}n&&(e[l]=0)}}function g(e,n){if(!o(e))return null;const{width:l,height:i,pixels:s}=e,r=l*i,a=new Uint8Array(r);e.mask?a.set(e.mask):a.fill(255);const h=s.length,{includedRanges:f,noDataValues:u,outputPixelType:p,matchAll:g,lookups:y}=n;if(y){const t=[];for(let e=0;e<h;e++){const n=y[e],l=c(s[e],a,n.lut,n.offset||0,"u8");t.push(l)}1===t.length?a.set(t[0]):g?d(t,a):m(t,a)}else if(g){const t=[];for(let e=0;e<h;e++){const n=new Uint8Array(r);n.set(a),x(s[e],f?.slice(2*e,2*e+2),u?.[e],n),t.push(n)}1===t.length?a.set(t[0]):d(t,a)}else for(let t=0;t<h;t++)x(s[t],f?.slice(2*t,2*t+2),u?.[t],a);return new t({width:l,height:i,pixelType:p,pixels:s,mask:a})}function y(n){const{srcPixelType:l,inputRanges:i,outputValues:o,allowUnmatched:s,noDataRanges:r,isLastInputRangeInclusive:a,outputPixelType:h}=n;if("u8"!==l&&"s8"!==l&&"u16"!==l&&"s16"!==l)return null;const f=l.includes("16")?65536:256,c=l.includes("s")?-f/2:0,u=t.createEmptyBand(h,f),p=new Uint8Array(f);s&&p.fill(255);const[x,d]=e(h);if(i?.length&&o?.length){const t=1e-6,e=i.map((e=>e-t));e[0]=i[0],a&&(e[e.length-1]=i.at(-1));for(let n=0;n<e.length;n++){const t=o[n]>d?d:o[n]<x?x:o[n],l=Math.ceil(e[2*n]-c),i=Math.floor(e[2*n+1]-c);for(let e=l;e<=i;e++)u[e]=t,p[e]=255}}if(r?.length)for(let t=0;t<r.length;t++){const e=Math.ceil(r[2*t]-c),n=Math.floor(r[2*t+1]-c);for(let t=e;t<=n;t++)p[t]=0}return{lut:u,offset:c,mask:p}}function w(t,e,n){if("u8"!==t&&"s8"!==t&&"u16"!==t&&"s16"!==t)return null;const l=t.includes("16")?65536:256,i=t.includes("s")?-l/2:0,o=new Uint8Array(l);if(e)for(let s=0;s<e.length;s++){const t=Math.ceil(e[2*s]-i),n=Math.floor(e[2*s+1]-i);for(let e=t;e<=n;e++)o[e]=255}else o.fill(255);if(n)for(let s=0;s<n.length;s++)o[n[s]-i]=0;return{lut:o,offset:i}}function k(t,e,n,l,i,o,s,r){return{xmin:i<=n*t?0:i<n*t+t?i-n*t:t,ymin:o<=l*e?0:o<l*e+e?o-l*e:e,xmax:i+s<=n*t?0:i+s<n*t+t?i+s-n*t:t,ymax:o+r<=l*e?0:o+r<l*e+e?o+r-l*e:e}}function M(t,e){if(!t||0===t.length)return null;const n=t.find((t=>t.pixelBlock));if(!n||null==n.pixelBlock)return null;const l=(n.extent.xmax-n.extent.xmin)/n.pixelBlock.width,i=(n.extent.ymax-n.extent.ymin)/n.pixelBlock.height,o=.01*Math.min(l,i),s=t.sort(((t,e)=>Math.abs(t.extent.ymax-e.extent.ymax)>o?e.extent.ymax-t.extent.ymax:Math.abs(t.extent.xmin-e.extent.xmin)>o?t.extent.xmin-e.extent.xmin:0)),r=Math.min.apply(null,s.map((t=>t.extent.xmin))),a=Math.min.apply(null,s.map((t=>t.extent.ymin))),h=Math.max.apply(null,s.map((t=>t.extent.xmax))),f=Math.max.apply(null,s.map((t=>t.extent.ymax))),c={x:Math.round((e.xmin-r)/l),y:Math.round((f-e.ymax)/i)},u={width:Math.round((h-r)/l),height:Math.round((f-a)/i)},p={width:Math.round((e.xmax-e.xmin)/l),height:Math.round((e.ymax-e.ymin)/i)};if(Math.round(u.width/n.pixelBlock.width)*Math.round(u.height/n.pixelBlock.height)!==s.length||c.x<0||c.y<0||u.width<p.width||u.height<p.height)return null;return{extent:e,pixelBlock:U(s.map((t=>t.pixelBlock)),u,{clipOffset:c,clipSize:p})}}function A(t,e,n,l,i,o){const{width:s,height:r}=n.block,{x:a,y:h}=n.offset,{width:f,height:c}=n.mosaic,u=k(s,r,l,i,a,h,f,c);let p=0,x=0;if(o){const t=o.hasGCSSShiftTransform?360:o.halfWorldWidth??0,e=s*o.resolutionX,n=o.startX+l*e;n<t&&n+e>t?x=o.rightPadding:n>=t&&(p=o.leftMargin-o.rightPadding,x=0)}if(u.xmax-=x,"number"!=typeof e)for(let d=u.ymin;d<u.ymax;d++){const n=(i*r+d-h)*f+(l*s-a)+p,o=d*s;for(let l=u.xmin;l<u.xmax;l++)t[n+l]=e[o+l]}else for(let d=u.ymin;d<u.ymax;d++){const n=(i*r+d-h)*f+(l*s-a)+p;for(let l=u.xmin;l<u.xmax;l++)t[n+l]=e}}function U(e,n,l={}){const{clipOffset:i,clipSize:s,alignmentInfo:r,blockWidths:a}=l;if(a)return b(e,n,{blockWidths:a});const h=e.find((t=>o(t)));if(null==h)return null;const f=s?s.width:n.width,c=s?s.height:n.height,u=h.width,p=h.height,x=n.width/u,d=n.height/p,m={offset:i||{x:0,y:0},mosaic:s||n,block:{width:u,height:p}},g=h.pixelType,y=t.getPixelArrayConstructor(g),w=h.pixels.length,k=[];let M,U;for(let t=0;t<w;t++){U=new y(f*c);for(let n=0;n<d;n++)for(let l=0;l<x;l++){const i=e[n*x+l];o(i)&&(M=i.pixels[t],A(U,M,m,l,n,r))}k.push(U)}const T=e.some((t=>null==t||null!=t.mask&&t.mask.length>0)),v=e.some((t=>null!=t&&t.bandMasks&&t.bandMasks.length>1)),C=T?new Uint8Array(f*c):void 0,B=v?[]:void 0;if(C){for(let t=0;t<d;t++)for(let n=0;n<x;n++){const l=e[t*x+n],i=null!=l?l.mask:null;A(C,null!=i?i:l?255:0,m,n,t,r)}if(B)for(let t=0;t<w;t++){const n=new Uint8Array(f*c);for(let l=0;l<d;l++)for(let i=0;i<x;i++){const o=e[l*x+i],s=o?.bandMasks?.[t]??o?.mask;A(n,null!=s?s:o?255:0,m,i,l,r)}B.push(n)}}const S=new t({width:f,height:c,pixels:k,pixelType:g,bandMasks:B,mask:C});return S.updateStatistics(),S}function b(e,n,l){const i=e.find((t=>null!=t));if(null==i)return null;const s=e.some((t=>null==t||!!t.mask)),{width:r,height:a}=n,h=s?new Uint8Array(r*a):null,{blockWidths:f}=l,c=[],u=i.getPlaneCount(),p=t.getPixelArrayConstructor(i.pixelType);if(s)for(let t=0,y=0;t<e.length;y+=f[t],t++){const n=e[t];if(!o(n))continue;const l=n.mask;for(let e=0;e<a;e++)for(let i=0;i<f[t];i++)h[e*r+i+y]=null==l?255:l[e*n.width+i]}const x=e.some((t=>null!=t&&t.bandMasks&&t.bandMasks.length>1)),d=x?[]:void 0,m=r*a;for(let t=0;t<u;t++){const n=new p(m),l=x?new Uint8Array(m):void 0;for(let i=0,s=0;i<e.length;s+=f[i],i++){const h=e[i];if(!o(h))continue;const c=h.pixels[t];if(null!=c){for(let t=0;t<a;t++)for(let e=0;e<f[i];e++)n[t*r+e+s]=c[t*h.width+e];if(l){const e=h.bandMasks?.[t]??h.mask;for(let t=0;t<a;t++)for(let n=0;n<f[i];n++)l[t*r+n+s]=e?e[t*h.width+n]:255}}}c.push(n),d&&l&&d.push(l)}const g=new t({width:r,height:a,mask:h,bandMasks:d,pixels:c,pixelType:i.pixelType});return g.updateStatistics(),g}function T(t,e,n){if(!o(t))return null;const{width:l,height:i}=t,s=e.x,r=e.y,a=n.width+s,h=n.height+r;if(s<0||r<0||a>l||h>i)return t;if(0===s&&0===r&&a===l&&h===i)return t;t.mask||(t.mask=new Uint8Array(l*i));const f=t.mask;for(let o=0;o<i;o++){const t=o*l;for(let e=0;e<l;e++)f[t+e]=o<r||o>=h||e<s||e>=a?0:1}return t.updateStatistics(),t}function v(t){if(!o(t))return null;const e=t.clone(),{width:n,height:l,pixels:i}=t,s=i[0],r=e.pixels[0],a=t.mask;for(let o=2;o<l-1;o++){const t=new Map;for(let l=o-2;l<o+2;l++)for(let e=0;e<4;e++){const i=l*n+e;S(t,s[i],a?a[i]:1)}r[o*n]=C(t),r[o*n+1]=r[o*n+2]=r[o*n];let e=3;for(;e<n-1;e++){let l=(o-2)*n+e+1;S(t,s[l],a?a[l]:1),l=(o-1)*n+e+1,S(t,s[l],a?a[l]:1),l=o*n+e+1,S(t,s[l],a?a[l]:1),l=(o+1)*n+e+1,S(t,s[l],a?a[l]:1),l=(o-2)*n+e-3,B(t,s[l],a?a[l]:1),l=(o-1)*n+e-3,B(t,s[l],a?a[l]:1),l=o*n+e-3,B(t,s[l],a?a[l]:1),l=(o+1)*n+e-3,B(t,s[l],a?a[l]:1),r[o*n+e]=C(t)}r[o*n+e+1]=r[o*n+e]}for(let o=0;o<n;o++)r[o]=r[n+o]=r[2*n+o],r[(l-1)*n+o]=r[(l-2)*n+o];return e.updateStatistics(),e}function C(t){if(0===t.size)return 0;let e=0,n=-1,l=0;const i=t.keys();let o=i.next();for(;!o.done;)l=t.get(o.value),l>e&&(n=o.value,e=l),o=i.next();return n}function B(t,e,n){if(0===n)return;const l=t.get(e);1===l?t.delete(e):t.set(e,l-1)}function S(t,e,n){0!==n&&t.set(e,t.has(e)?t.get(e)+1:1)}function P(e,n,l){let{x:i,y:s}=n;const{width:r,height:a}=l;if(0===i&&0===s&&a===e.height&&r===e.width)return e;const{width:h,height:f}=e,c=Math.max(0,s),u=Math.max(0,i),p=Math.min(i+r,h),x=Math.min(s+a,f);if(p<0||x<0||!o(e))return null;i=Math.max(0,-i),s=Math.max(0,-s);const{pixels:d}=e,m=r*a,g=d.length,y=[];for(let o=0;o<g;o++){const n=d[o],l=t.createEmptyBand(e.pixelType,m);for(let t=c;t<x;t++){const e=t*h;let o=(t+s-c)*r+i;for(let t=u;t<p;t++)l[o++]=n[e+t]}y.push(l)}const w=new Uint8Array(m),k=e.mask;for(let t=c;t<x;t++){const e=t*h;let n=(t+s-c)*r+i;for(let t=u;t<p;t++)w[n++]=k?k[e+t]:1}const M=new t({width:l.width,height:l.height,pixelType:e.pixelType,pixels:y,mask:w});return M.updateStatistics(),M}function _(e,n=!0){if(!o(e))return null;const{pixels:l,width:i,height:s,mask:r,pixelType:a}=e,h=[],f=Math.round(i/2),c=Math.round(s/2),u=s-1,p=i-1;for(let o=0;o<l.length;o++){const e=l[o],r=t.createEmptyBand(a,f*c);let x=0;for(let t=0;t<s;t+=2)for(let l=0;l<i;l+=2){const o=e[t*i+l];if(n){const n=l===p?o:e[t*i+l+1],s=t===u?o:e[t*i+l+i],a=l===p?s:t===u?n:e[t*i+l+i+1];r[x++]=(o+n+s+a)/4}else r[x++]=o}h.push(r)}let x=null;if(null!=r){x=new Uint8Array(f*c);let t=0;for(let e=0;e<s;e+=2)for(let l=0;l<i;l+=2){const o=r[e*i+l];if(n){const n=l===p?o:r[e*i+l+1],s=e===u?o:r[e*i+l+i],a=l===p?s:e===u?n:r[e*i+l+i+1];x[t++]=o*n*s*a?1:0}else x[t++]=o}}return new t({width:f,height:c,pixelType:a,pixels:h,mask:x})}function W(t,e,n){if(!o(t))return null;const{width:l,height:i}=e;let{width:s,height:r}=t;const a=new Map,h={x:0,y:0},f=null==n?1:1+n;let c=t;for(let o=0;o<f;o++){const t=Math.ceil(s/l),n=Math.ceil(r/i);for(let s=0;s<n;s++){h.y=s*i;for(let n=0;n<t;n++){h.x=n*l;const t=P(c,h,e);a.set(`${o}/${s}/${n}`,t)}}o<f-1&&(c=_(c)),s=Math.round(s/2),r=Math.round(r/2)}return a}function E(t,e,n,l,i=0){const{width:o,height:s}=t,{width:r,height:a}=e,h=l.cols,f=l.rows,c=Math.ceil(r/h-.1/h),u=Math.ceil(a/f-.1/f);let p,x,d,m,g,y,w;const k=c*h,M=k*u*f,A=new Float32Array(M),U=new Float32Array(M),b=new Uint32Array(M),T=new Uint32Array(M);let v,C,B=0;for(let S=0;S<u;S++)for(let t=0;t<c;t++){p=12*(S*c+t),x=n[p],d=n[p+1],m=n[p+2],g=n[p+3],y=n[p+4],w=n[p+5];for(let e=0;e<f;e++){B=(S*f+e)*k+t*h,C=(e+.5)/f;for(let t=0;t<e;t++)v=(t+.5)/h,A[B+t]=(x*v+d*C+m)*o+i,U[B+t]=(g*v+y*C+w)*s+i,b[B+t]=Math.floor(A[B+t]),T[B+t]=Math.floor(U[B+t])}p+=6,x=n[p],d=n[p+1],m=n[p+2],g=n[p+3],y=n[p+4],w=n[p+5];for(let e=0;e<f;e++){B=(S*f+e)*k+t*h,C=(e+.5)/f;for(let t=e;t<h;t++)v=(t+.5)/h,A[B+t]=(x*v+d*C+m)*o+i,U[B+t]=(g*v+y*C+w)*s+i,b[B+t]=Math.floor(A[B+t]),T[B+t]=Math.floor(U[B+t])}}return{offsets_x:A,offsets_y:U,offsets_xi:b,offsets_yi:T,gridWidth:k}}function I(t,e){const{coefficients:n,spacing:l}=e,{offsets_x:i,offsets_y:o,gridWidth:s}=E(t,t,n,{rows:l[0],cols:l[1]}),{width:r,height:a}=t,h=new Float32Array(r*a),f=180/Math.PI;for(let c=0;c<a;c++)for(let t=0;t<r;t++){const e=c*s+t,n=0===c?e:e-s,l=c===a-1?e:e+s,u=i[n]-i[l],p=o[l]-o[n];if(isNaN(u)||isNaN(p))h[c*r+t]=90;else{let e=Math.atan2(p,u)*f;e=(360+e)%360,h[c*r+t]=e}}return h}function R(e,n,l,i,s="nearest"){if(!o(e))return null;"majority"===s&&(e=v(e));const{pixels:r,mask:a,bandMasks:h,pixelType:f}=e,c=e.width,u=e.height,p=t.getPixelArrayConstructor(f),x=r.length,{width:d,height:m}=n;let g=!1;for(let t=0;t<l.length;t+=3)-1===l[t]&&-1===l[t+1]&&-1===l[t+2]&&(g=!0);const{offsets_x:y,offsets_y:w,offsets_xi:k,offsets_yi:M,gridWidth:A}=E({width:c,height:u},n,l,i,"majority"===s?.5:0);let U;const b=(t,e,n,l)=>{const i=t instanceof Float32Array||t instanceof Float64Array?0:.5;for(let o=0;o<m;o++){U=o*A;for(let s=0;s<d;s++){if(y[U]<0||w[U]<0)t[o*d+s]=0;else if(l)t[o*d+s]=e[k[U]+M[U]*c];else{const l=Math.floor(y[U]),r=Math.floor(w[U]),a=Math.ceil(y[U]),h=Math.ceil(w[U]),f=y[U]-l,u=w[U]-r;if(!n||n[l+r*c]&&n[a+r*c]&&n[l+h*c]&&n[a+h*c]){const n=(1-f)*e[l+r*c]+f*e[a+r*c],p=(1-f)*e[l+h*c]+f*e[a+h*c];t[o*d+s]=(1-u)*n+u*p+i}else t[o*d+s]=e[k[U]+M[U]*c]}U++}}},T=[];let C;const B=h?.length===x,S=[];for(let t=0;t<x;t++){if(B){const e=new Uint8Array(d*m);b(e,h[t],h[t],!0),S.push(e)}C=new p(d*m),b(C,r[t],B?h[t]:a,"nearest"===s||"majority"===s),T.push(C)}const P=new t({width:d,height:m,pixelType:f,pixels:T,bandMasks:B?S:void 0});if(null!=a)P.mask=new Uint8Array(d*m),b(P.mask,a,a,!0);else if(g){P.mask=new Uint8Array(d*m);for(let t=0;t<d*m;t++)P.mask[t]=y[t]<0||w[t]<0?0:1}return P.updateStatistics(),P}export{i as MAX_MAP_SIZE_GPU,l as MissingBandAction,n as NoDataInterpretation,R as approximateTransform,P as clip,h as colorize,r as compositeBands,a as createColormapLUT,w as createMaskLUT,y as createRemapLUT,s as extractBands,k as getClipBounds,I as getLocalArithmeticNorthRotations,E as interpolateOffsets,o as isValidPixelBlock,c as lookupBandValues,f as lookupPixels,g as mask,U as mosaic,M as mosaicPixelData,p as remap,u as remapColor,v as resampleByMajority,T as setValidBoundary,W as split};
|
|
5
|
+
import t from"../PixelBlock.js";import{getPixelValueRange as e}from"../rasterFormats/pixelRangeUtils.js";var n,l;!function(t){t[t.matchAny=0]="matchAny",t[t.matchAll=1]="matchAll"}(n||(n={})),function(t){t[t.bestMatch=0]="bestMatch",t[t.fail=1]="fail"}(l||(l={}));const i=6;function o(t){return null!=t&&"esri.layers.support.PixelBlock"===t.declaredClass&&t.pixels&&t.pixels.length>0}function s(t,e){return e?.length&&o(t)?t.extractBands(e):t}function r(e){if(!e?.length||e.some((t=>!o(t))))return null;if(1===e.length)return e[0]?.clone()??null;const n=e,{width:l,height:i,pixelType:s}=n[0];if(n.some((t=>t.width!==l||t.height!==i)))return null;const r=n.map((({mask:t})=>t)).filter((t=>null!=t));let a=null;r.length&&(a=new Uint8Array(l*i),a.set(r[0]),r.length>1&&m(r.slice(1),a));const h=[];n.forEach((({pixels:t})=>h.push(...t)));const f=n.map((({statistics:t})=>t)).filter((t=>t?.length)),c=[];return f.forEach((t=>c.push(...t))),new t({pixelType:s,width:l,height:i,mask:a,pixels:h,statistics:c.length?c:null})}function a(t){if(!t)return;const e=t.colormap;if(!e||0===e.length)return;const n=e.sort(((t,e)=>t[0]-e[0]));let l=0;n[0][0]<0&&(l=n[0][0]);const i=Math.max(256,n[n.length-1][0]-l+1),o=new Uint8Array(4*i),s=[];let r,a=0,h=0;const f=5===n[0].length;if(i>65536)return n.forEach((t=>{s[t[0]-l]=f?t.slice(1):t.slice(1).concat([255])})),{indexed2DColormap:s,offset:l,alphaSpecified:f};if(t.fillUnspecified)for(r=n[h],a=r[0]-l;a<i;a++)o[4*a]=r[1],o[4*a+1]=r[2],o[4*a+2]=r[3],o[4*a+3]=f?r[4]:255,a===r[0]-l&&(r=h===n.length-1?r:n[++h]);else for(a=0;a<n.length;a++)r=n[a],h=4*(r[0]-l),o[h]=r[1],o[h+1]=r[2],o[h+2]=r[3],o[h+3]=f?r[4]:255;return{indexedColormap:o,offset:l,alphaSpecified:f}}function h(t,e){if(!o(t))return t;if(!e||!e.indexedColormap&&!e.indexed2DColormap)return t;const n=t.clone(),l=n.pixels;let i=n.mask;const s=n.width*n.height;if(1!==l.length)return t;const{indexedColormap:r,indexed2DColormap:a,offset:h,alphaSpecified:f}=e;let c=0;const u=l[0],p=new Uint8Array(u.length),x=new Uint8Array(u.length),d=new Uint8Array(u.length);let m,g=0;if(r){const t=r.length-1;if(null!=i)for(c=0;c<s;c++)i[c]&&(g=4*(u[c]-h),g<h||g>t?i[c]=0:(p[c]=r[g],x[c]=r[g+1],d[c]=r[g+2],i[c]=r[g+3]));else{for(i=new Uint8Array(s),c=0;c<s;c++)g=4*(u[c]-h),g<h||g>t?i[c]=0:(p[c]=r[g],x[c]=r[g+1],d[c]=r[g+2],i[c]=r[g+3]);n.mask=i}}else if(a)if(null!=i)for(c=0;c<s;c++)i[c]&&(m=a[u[c]],p[c]=m[0],x[c]=m[1],d[c]=m[2],i[c]=m[3]);else{for(i=new Uint8Array(s),c=0;c<s;c++)m=a[u[c]],p[c]=m[0],x[c]=m[1],d[c]=m[2],i[c]=m[3];n.mask=i}return n.pixels=[p,x,d],n.statistics=null,n.pixelType="u8",n.maskIsAlpha=f,n}function f(e,n){if(!o(e))return null;const{pixels:l,mask:i}=e,s=l.length;let r=n.lut;const{offset:a}=n;r&&1===r[0].length&&(r=l.map((()=>r)));const h=[],f=n.outputPixelType||"u8";for(let t=0;t<s;t++){const e=c(l[t],i,r[t],a||0,f);h.push(e)}const u=new t({width:e.width,height:e.height,pixels:h,mask:i,pixelType:f});return u.updateStatistics(),u}function c(e,n,l,i,o){const s=e.length,r=t.createEmptyBand(o,s);if(n)for(let t=0;t<s;t++)n[t]&&(r[t]=l[e[t]-i]);else for(let t=0;t<s;t++)r[t]=l[e[t]-i];return r}function u(t,e){if(!o(t))return null;const n=t.clone(),{pixels:l}=n,i=n.width*n.height,s=e.length,r=Math.floor(s/2),a=e[Math.floor(r)],h=l[0];let f,c,u,p,x,d,m=!1;const g=new Uint8Array(i),y=new Uint8Array(i),w=new Uint8Array(i);let k=n.mask;const M=4===e[0].mappedColor.length;for(k||(k=new Uint8Array(i),k.fill(M?255:1),n.mask=k),x=0;x<i;x++)if(k[x]){for(f=h[x],m=!1,d=r,c=a,u=0,p=s-1;p-u>1;){if(f===c.value){m=!0;break}f>c.value?u=d:p=d,d=Math.floor((u+p)/2),c=e[Math.floor(d)]}m||(f===e[u].value?(c=e[u],m=!0):f===e[p].value?(c=e[p],m=!0):f<e[u].value?(m=!1,c=null):f>e[u].value&&(f<e[p].value?(c=e[u],m=!0):p===s-1?(m=!1,c=null):(c=e[p],m=!0))),m?(g[x]=c.mappedColor[0],y[x]=c.mappedColor[1],w[x]=c.mappedColor[2],k[x]=c.mappedColor[3]):g[x]=y[x]=w[x]=k[x]=0}return n.pixels=[g,y,w],n.mask=k,n.pixelType="u8",n.maskIsAlpha=M,n}function p(n,l){if(!o(n))return null;const{width:i,height:s}=n,{inputRanges:r,outputValues:a,outputPixelType:h,noDataRanges:f,allowUnmatched:c,isLastInputRangeInclusive:u}=l,p=n.pixels[0],x=t.createEmptyBand(h,p.length),d=n.mask,m=new Uint8Array(i*s);d?m.set(d):m.fill(255);const g=n.pixelType.startsWith("f")?1e-6:0,y=r.map((t=>t-g));y[0]=r[0],y[y.length-1]=r[r.length-1]+(u?1e-6:0);const w=r.length/2,[k,M]=e(h);for(let t=0;t<s;t++)for(let e=0;e<i;e++){const n=t*i+e;if(m[n]){const t=p[n];let e=!1;for(let l=w-1;l>=0;l--)if(t===y[2*l]||t>y[2*l]&&t<y[2*l+1]){x[n]=a[l],e=!0;break}e||(c?x[n]=t>M?M:t<k?k:t:m[n]=0)}}const A=f?.length;if(A)for(let t=0;t<s;t++)for(let e=0;e<i;e++){const n=t*i+e;if(!d||d[n]){const t=p[n];for(let e=0;e<A;e+=2)if(t>=f[e]&&t<=f[e+1]){x[n]=0,m[n]=0;break}}}return new t({width:i,height:s,pixelType:h,pixels:[x],mask:m})}function x(t,e,n,l){const i=null!=n&&n.length>=2?new Set(n):null,o=1===n?.length?n[0]:null,s=!!e?.length;for(let r=0;r<t.length;r++)if(l[r]){const n=t[r];if(s){let t=!1;for(let l=0;l<e.length;l+=2)if(n>=e[l]&&n<=e[l+1]){t=!0;break}t||(l[r]=0)}l[r]&&(n===o||i?.has(n))&&(l[r]=0)}}function d(t,e){const n=t[0].length;for(let l=0;l<n;l++)if(e[l]){let n=!1;for(let e=0;e<t.length;e++)if(t[e][l]){n=!0;break}n||(e[l]=0)}}function m(t,e){const n=t[0].length;for(let l=0;l<n;l++)if(e[l]){let n=!1;for(let e=0;e<t.length;e++)if(0===t[e][l]){n=!0;break}n&&(e[l]=0)}}function g(e,n){if(!o(e))return null;const{width:l,height:i,pixels:s}=e,r=l*i,a=new Uint8Array(r);e.mask?a.set(e.mask):a.fill(255);const h=s.length,{includedRanges:f,noDataValues:u,outputPixelType:p,matchAll:g,lookups:y}=n;if(y){const t=[];for(let e=0;e<h;e++){const n=y[e],l=c(s[e],a,n.lut,n.offset||0,"u8");t.push(l)}1===t.length?a.set(t[0]):g?d(t,a):m(t,a)}else if(g){const t=[];for(let e=0;e<h;e++){const n=new Uint8Array(r);n.set(a),x(s[e],f?.slice(2*e,2*e+2),u?.[e],n),t.push(n)}1===t.length?a.set(t[0]):d(t,a)}else for(let t=0;t<h;t++)x(s[t],f?.slice(2*t,2*t+2),u?.[t],a);return new t({width:l,height:i,pixelType:p,pixels:s,mask:a})}function y(n){const{srcPixelType:l,inputRanges:i,outputValues:o,allowUnmatched:s,noDataRanges:r,isLastInputRangeInclusive:a,outputPixelType:h}=n;if("u8"!==l&&"s8"!==l&&"u16"!==l&&"s16"!==l)return null;const f=l.includes("16")?65536:256,c=l.includes("s")?-f/2:0,u=t.createEmptyBand(h,f),p=new Uint8Array(f);s&&p.fill(255);const[x,d]=e(h);if(i?.length&&o?.length){const t=1e-6,e=i.map((e=>e-t));e[0]=i[0],a&&(e[e.length-1]=i[i.length-1]);for(let n=0;n<e.length;n++){const t=o[n]>d?d:o[n]<x?x:o[n],l=Math.ceil(e[2*n]-c),i=Math.floor(e[2*n+1]-c);for(let e=l;e<=i;e++)u[e]=t,p[e]=255}}if(r?.length)for(let t=0;t<r.length;t++){const e=Math.ceil(r[2*t]-c),n=Math.floor(r[2*t+1]-c);for(let t=e;t<=n;t++)p[t]=0}return{lut:u,offset:c,mask:p}}function w(t,e,n){if("u8"!==t&&"s8"!==t&&"u16"!==t&&"s16"!==t)return null;const l=t.includes("16")?65536:256,i=t.includes("s")?-l/2:0,o=new Uint8Array(l);if(e)for(let s=0;s<e.length;s++){const t=Math.ceil(e[2*s]-i),n=Math.floor(e[2*s+1]-i);for(let e=t;e<=n;e++)o[e]=255}else o.fill(255);if(n)for(let s=0;s<n.length;s++)o[n[s]-i]=0;return{lut:o,offset:i}}function k(t,e,n,l,i,o,s,r){return{xmin:i<=n*t?0:i<n*t+t?i-n*t:t,ymin:o<=l*e?0:o<l*e+e?o-l*e:e,xmax:i+s<=n*t?0:i+s<n*t+t?i+s-n*t:t,ymax:o+r<=l*e?0:o+r<l*e+e?o+r-l*e:e}}function M(t,e){if(!t||0===t.length)return null;const n=t.find((t=>t.pixelBlock));if(!n||null==n.pixelBlock)return null;const l=(n.extent.xmax-n.extent.xmin)/n.pixelBlock.width,i=(n.extent.ymax-n.extent.ymin)/n.pixelBlock.height,o=.01*Math.min(l,i),s=t.sort(((t,e)=>Math.abs(t.extent.ymax-e.extent.ymax)>o?e.extent.ymax-t.extent.ymax:Math.abs(t.extent.xmin-e.extent.xmin)>o?t.extent.xmin-e.extent.xmin:0)),r=Math.min.apply(null,s.map((t=>t.extent.xmin))),a=Math.min.apply(null,s.map((t=>t.extent.ymin))),h=Math.max.apply(null,s.map((t=>t.extent.xmax))),f=Math.max.apply(null,s.map((t=>t.extent.ymax))),c={x:Math.round((e.xmin-r)/l),y:Math.round((f-e.ymax)/i)},u={width:Math.round((h-r)/l),height:Math.round((f-a)/i)},p={width:Math.round((e.xmax-e.xmin)/l),height:Math.round((e.ymax-e.ymin)/i)};if(Math.round(u.width/n.pixelBlock.width)*Math.round(u.height/n.pixelBlock.height)!==s.length||c.x<0||c.y<0||u.width<p.width||u.height<p.height)return null;return{extent:e,pixelBlock:U(s.map((t=>t.pixelBlock)),u,{clipOffset:c,clipSize:p})}}function A(t,e,n,l,i,o){const{width:s,height:r}=n.block,{x:a,y:h}=n.offset,{width:f,height:c}=n.mosaic,u=k(s,r,l,i,a,h,f,c);let p=0,x=0;if(o){const t=o.hasGCSSShiftTransform?360:o.halfWorldWidth??0,e=s*o.resolutionX,n=o.startX+l*e;n<t&&n+e>t?x=o.rightPadding:n>=t&&(p=o.leftMargin-o.rightPadding,x=0)}if(u.xmax-=x,"number"!=typeof e)for(let d=u.ymin;d<u.ymax;d++){const n=(i*r+d-h)*f+(l*s-a)+p,o=d*s;for(let l=u.xmin;l<u.xmax;l++)t[n+l]=e[o+l]}else for(let d=u.ymin;d<u.ymax;d++){const n=(i*r+d-h)*f+(l*s-a)+p;for(let l=u.xmin;l<u.xmax;l++)t[n+l]=e}}function U(e,n,l={}){const{clipOffset:i,clipSize:s,alignmentInfo:r,blockWidths:a}=l;if(a)return b(e,n,{blockWidths:a});const h=e.find((t=>o(t)));if(null==h)return null;const f=s?s.width:n.width,c=s?s.height:n.height,u=h.width,p=h.height,x=n.width/u,d=n.height/p,m={offset:i||{x:0,y:0},mosaic:s||n,block:{width:u,height:p}},g=h.pixelType,y=t.getPixelArrayConstructor(g),w=h.pixels.length,k=[];let M,U;for(let t=0;t<w;t++){U=new y(f*c);for(let n=0;n<d;n++)for(let l=0;l<x;l++){const i=e[n*x+l];o(i)&&(M=i.pixels[t],A(U,M,m,l,n,r))}k.push(U)}const T=e.some((t=>null==t||null!=t.mask&&t.mask.length>0)),v=e.some((t=>null!=t&&t.bandMasks&&t.bandMasks.length>1)),C=T?new Uint8Array(f*c):void 0,B=v?[]:void 0;if(C){for(let t=0;t<d;t++)for(let n=0;n<x;n++){const l=e[t*x+n],i=null!=l?l.mask:null;A(C,null!=i?i:l?255:0,m,n,t,r)}if(B)for(let t=0;t<w;t++){const n=new Uint8Array(f*c);for(let l=0;l<d;l++)for(let i=0;i<x;i++){const o=e[l*x+i],s=o?.bandMasks?.[t]??o?.mask;A(n,null!=s?s:o?255:0,m,i,l,r)}B.push(n)}}const S=new t({width:f,height:c,pixels:k,pixelType:g,bandMasks:B,mask:C});return S.updateStatistics(),S}function b(e,n,l){const i=e.find((t=>null!=t));if(null==i)return null;const s=e.some((t=>null==t||!!t.mask)),{width:r,height:a}=n,h=s?new Uint8Array(r*a):null,{blockWidths:f}=l,c=[],u=i.getPlaneCount(),p=t.getPixelArrayConstructor(i.pixelType);if(s)for(let t=0,y=0;t<e.length;y+=f[t],t++){const n=e[t];if(!o(n))continue;const l=n.mask;for(let e=0;e<a;e++)for(let i=0;i<f[t];i++)h[e*r+i+y]=null==l?255:l[e*n.width+i]}const x=e.some((t=>null!=t&&t.bandMasks&&t.bandMasks.length>1)),d=x?[]:void 0,m=r*a;for(let t=0;t<u;t++){const n=new p(m),l=x?new Uint8Array(m):void 0;for(let i=0,s=0;i<e.length;s+=f[i],i++){const h=e[i];if(!o(h))continue;const c=h.pixels[t];if(null!=c){for(let t=0;t<a;t++)for(let e=0;e<f[i];e++)n[t*r+e+s]=c[t*h.width+e];if(l){const e=h.bandMasks?.[t]??h.mask;for(let t=0;t<a;t++)for(let n=0;n<f[i];n++)l[t*r+n+s]=e?e[t*h.width+n]:255}}}c.push(n),d&&l&&d.push(l)}const g=new t({width:r,height:a,mask:h,bandMasks:d,pixels:c,pixelType:i.pixelType});return g.updateStatistics(),g}function T(t,e,n){if(!o(t))return null;const{width:l,height:i}=t,s=e.x,r=e.y,a=n.width+s,h=n.height+r;if(s<0||r<0||a>l||h>i)return t;if(0===s&&0===r&&a===l&&h===i)return t;t.mask||(t.mask=new Uint8Array(l*i));const f=t.mask;for(let o=0;o<i;o++){const t=o*l;for(let e=0;e<l;e++)f[t+e]=o<r||o>=h||e<s||e>=a?0:1}return t.updateStatistics(),t}function v(t){if(!o(t))return null;const e=t.clone(),{width:n,height:l,pixels:i}=t,s=i[0],r=e.pixels[0],a=t.mask;for(let o=2;o<l-1;o++){const t=new Map;for(let l=o-2;l<o+2;l++)for(let e=0;e<4;e++){const i=l*n+e;S(t,s[i],a?a[i]:1)}r[o*n]=C(t),r[o*n+1]=r[o*n+2]=r[o*n];let e=3;for(;e<n-1;e++){let l=(o-2)*n+e+1;S(t,s[l],a?a[l]:1),l=(o-1)*n+e+1,S(t,s[l],a?a[l]:1),l=o*n+e+1,S(t,s[l],a?a[l]:1),l=(o+1)*n+e+1,S(t,s[l],a?a[l]:1),l=(o-2)*n+e-3,B(t,s[l],a?a[l]:1),l=(o-1)*n+e-3,B(t,s[l],a?a[l]:1),l=o*n+e-3,B(t,s[l],a?a[l]:1),l=(o+1)*n+e-3,B(t,s[l],a?a[l]:1),r[o*n+e]=C(t)}r[o*n+e+1]=r[o*n+e]}for(let o=0;o<n;o++)r[o]=r[n+o]=r[2*n+o],r[(l-1)*n+o]=r[(l-2)*n+o];return e.updateStatistics(),e}function C(t){if(0===t.size)return 0;let e=0,n=-1,l=0;const i=t.keys();let o=i.next();for(;!o.done;)l=t.get(o.value),l>e&&(n=o.value,e=l),o=i.next();return n}function B(t,e,n){if(0===n)return;const l=t.get(e);1===l?t.delete(e):t.set(e,l-1)}function S(t,e,n){0!==n&&t.set(e,t.has(e)?t.get(e)+1:1)}function P(e,n,l){let{x:i,y:s}=n;const{width:r,height:a}=l;if(0===i&&0===s&&a===e.height&&r===e.width)return e;const{width:h,height:f}=e,c=Math.max(0,s),u=Math.max(0,i),p=Math.min(i+r,h),x=Math.min(s+a,f);if(p<0||x<0||!o(e))return null;i=Math.max(0,-i),s=Math.max(0,-s);const{pixels:d}=e,m=r*a,g=d.length,y=[];for(let o=0;o<g;o++){const n=d[o],l=t.createEmptyBand(e.pixelType,m);for(let t=c;t<x;t++){const e=t*h;let o=(t+s-c)*r+i;for(let t=u;t<p;t++)l[o++]=n[e+t]}y.push(l)}const w=new Uint8Array(m),k=e.mask;for(let t=c;t<x;t++){const e=t*h;let n=(t+s-c)*r+i;for(let t=u;t<p;t++)w[n++]=k?k[e+t]:1}const M=new t({width:l.width,height:l.height,pixelType:e.pixelType,pixels:y,mask:w});return M.updateStatistics(),M}function _(e,n=!0){if(!o(e))return null;const{pixels:l,width:i,height:s,mask:r,pixelType:a}=e,h=[],f=Math.round(i/2),c=Math.round(s/2),u=s-1,p=i-1;for(let o=0;o<l.length;o++){const e=l[o],r=t.createEmptyBand(a,f*c);let x=0;for(let t=0;t<s;t+=2)for(let l=0;l<i;l+=2){const o=e[t*i+l];if(n){const n=l===p?o:e[t*i+l+1],s=t===u?o:e[t*i+l+i],a=l===p?s:t===u?n:e[t*i+l+i+1];r[x++]=(o+n+s+a)/4}else r[x++]=o}h.push(r)}let x=null;if(null!=r){x=new Uint8Array(f*c);let t=0;for(let e=0;e<s;e+=2)for(let l=0;l<i;l+=2){const o=r[e*i+l];if(n){const n=l===p?o:r[e*i+l+1],s=e===u?o:r[e*i+l+i],a=l===p?s:e===u?n:r[e*i+l+i+1];x[t++]=o*n*s*a?1:0}else x[t++]=o}}return new t({width:f,height:c,pixelType:a,pixels:h,mask:x})}function W(t,e,n){if(!o(t))return null;const{width:l,height:i}=e;let{width:s,height:r}=t;const a=new Map,h={x:0,y:0},f=null==n?1:1+n;let c=t;for(let o=0;o<f;o++){const t=Math.ceil(s/l),n=Math.ceil(r/i);for(let s=0;s<n;s++){h.y=s*i;for(let n=0;n<t;n++){h.x=n*l;const t=P(c,h,e);a.set(`${o}/${s}/${n}`,t)}}o<f-1&&(c=_(c)),s=Math.round(s/2),r=Math.round(r/2)}return a}function E(t,e,n,l,i=0){const{width:o,height:s}=t,{width:r,height:a}=e,h=l.cols,f=l.rows,c=Math.ceil(r/h-.1/h),u=Math.ceil(a/f-.1/f);let p,x,d,m,g,y,w;const k=c*h,M=k*u*f,A=new Float32Array(M),U=new Float32Array(M),b=new Uint32Array(M),T=new Uint32Array(M);let v,C,B=0;for(let S=0;S<u;S++)for(let t=0;t<c;t++){p=12*(S*c+t),x=n[p],d=n[p+1],m=n[p+2],g=n[p+3],y=n[p+4],w=n[p+5];for(let e=0;e<f;e++){B=(S*f+e)*k+t*h,C=(e+.5)/f;for(let t=0;t<e;t++)v=(t+.5)/h,A[B+t]=(x*v+d*C+m)*o+i,U[B+t]=(g*v+y*C+w)*s+i,b[B+t]=Math.floor(A[B+t]),T[B+t]=Math.floor(U[B+t])}p+=6,x=n[p],d=n[p+1],m=n[p+2],g=n[p+3],y=n[p+4],w=n[p+5];for(let e=0;e<f;e++){B=(S*f+e)*k+t*h,C=(e+.5)/f;for(let t=e;t<h;t++)v=(t+.5)/h,A[B+t]=(x*v+d*C+m)*o+i,U[B+t]=(g*v+y*C+w)*s+i,b[B+t]=Math.floor(A[B+t]),T[B+t]=Math.floor(U[B+t])}}return{offsets_x:A,offsets_y:U,offsets_xi:b,offsets_yi:T,gridWidth:k}}function I(t,e){const{coefficients:n,spacing:l}=e,{offsets_x:i,offsets_y:o,gridWidth:s}=E(t,t,n,{rows:l[0],cols:l[1]}),{width:r,height:a}=t,h=new Float32Array(r*a),f=180/Math.PI;for(let c=0;c<a;c++)for(let t=0;t<r;t++){const e=c*s+t,n=0===c?e:e-s,l=c===a-1?e:e+s,u=i[n]-i[l],p=o[l]-o[n];if(isNaN(u)||isNaN(p))h[c*r+t]=90;else{let e=Math.atan2(p,u)*f;e=(360+e)%360,h[c*r+t]=e}}return h}function R(e,n,l,i,s="nearest"){if(!o(e))return null;"majority"===s&&(e=v(e));const{pixels:r,mask:a,bandMasks:h,pixelType:f}=e,c=e.width,u=e.height,p=t.getPixelArrayConstructor(f),x=r.length,{width:d,height:m}=n;let g=!1;for(let t=0;t<l.length;t+=3)-1===l[t]&&-1===l[t+1]&&-1===l[t+2]&&(g=!0);const{offsets_x:y,offsets_y:w,offsets_xi:k,offsets_yi:M,gridWidth:A}=E({width:c,height:u},n,l,i,"majority"===s?.5:0);let U;const b=(t,e,n,l)=>{const i=t instanceof Float32Array||t instanceof Float64Array?0:.5;for(let o=0;o<m;o++){U=o*A;for(let s=0;s<d;s++){if(y[U]<0||w[U]<0)t[o*d+s]=0;else if(l)t[o*d+s]=e[k[U]+M[U]*c];else{const l=Math.floor(y[U]),r=Math.floor(w[U]),a=Math.ceil(y[U]),h=Math.ceil(w[U]),f=y[U]-l,u=w[U]-r;if(!n||n[l+r*c]&&n[a+r*c]&&n[l+h*c]&&n[a+h*c]){const n=(1-f)*e[l+r*c]+f*e[a+r*c],p=(1-f)*e[l+h*c]+f*e[a+h*c];t[o*d+s]=(1-u)*n+u*p+i}else t[o*d+s]=e[k[U]+M[U]*c]}U++}}},T=[];let C;const B=h?.length===x,S=[];for(let t=0;t<x;t++){if(B){const e=new Uint8Array(d*m);b(e,h[t],h[t],!0),S.push(e)}C=new p(d*m),b(C,r[t],B?h[t]:a,"nearest"===s||"majority"===s),T.push(C)}const P=new t({width:d,height:m,pixelType:f,pixels:T,bandMasks:B?S:void 0});if(null!=a)P.mask=new Uint8Array(d*m),b(P.mask,a,a,!0);else if(g){P.mask=new Uint8Array(d*m);for(let t=0;t<d*m;t++)P.mask[t]=y[t]<0||w[t]<0?0:1}return P.updateStatistics(),P}export{i as MAX_MAP_SIZE_GPU,l as MissingBandAction,n as NoDataInterpretation,R as approximateTransform,P as clip,h as colorize,r as compositeBands,a as createColormapLUT,w as createMaskLUT,y as createRemapLUT,s as extractBands,k as getClipBounds,I as getLocalArithmeticNorthRotations,E as interpolateOffsets,o as isValidPixelBlock,c as lookupBandValues,f as lookupPixels,g as mask,U as mosaic,M as mosaicPixelData,p as remap,u as remapColor,v as resampleByMajority,T as setValidBoundary,W as split};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.28/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import"../../../geometry.js";import{isSome as e}from"../../../core/arrayUtils.js";import t from"../../../core/Error.js";import{getMetersPerUnitForSR as n}from"../../../core/unitUtils.js";import{e as i,f as o,g as r,h as s,j as a}from"../../../chunks/pe.js";import{canProjectWithoutEngine as l,isLoaded as c,load as f,getTransformation as u,project as m}from"../../../geometry/projection.js";import x from"../../../geometry/Extent.js";import h from"../../../geometry/Point.js";import p from"../../../geometry/Polygon.js";import g from"../../../geometry/SpatialReference.js";var y;function d(e,t,n){return!l(e,t,n)}function M(e,n,i){const o=d(e,n,i);if(o&&!c())throw new t("rasterprojectionhelper-project","projection engine is not loaded");return o}!function(e){e[e.None=0]="None",e[e.North=1]="North",e[e.South=2]="South",e[e.Both=3]="Both"}(y||(y={}));const w=(e,t,n,i=0)=>{if(1===n[0])return[0,0];let o=1,r=-1,s=1,a=-1;for(let g=0;g<e.length;g+=2)isNaN(e[g])||(o=o>e[g]?e[g]:o,r=r>e[g]?r:e[g],s=s>e[g+1]?e[g+1]:s,a=a>e[g+1]?a:e[g+1]);const{cols:l,rows:c}=t,f=(r-o)/l/n[0],u=(a-s)/c/n[1],m=2*i;let x=0,h=!1,p=[0,0];for(let g=0;g<l-3;g++){for(let t=0;t<c-3;t++){const n=g*c*2+2*t,i=(e[n]+e[n+4]+e[n+4*c]+e[n+4*c+4])/4,o=(e[n+1]+e[n+5]+e[n+4*c+1]+e[n+4*c+5])/4,r=Math.abs((i-e[n+2*c+2])/f),s=Math.abs((o-e[n+2*c+3])/u);if(r+s>x&&(x=r+s,p=[r,s]),m&&x>m){h=!0;break}}if(h)break}return p},R={3395:20037508.342789244,3410:17334193.943686873,3857:20037508.342788905,3975:17367530.445161372,4087:20037508.342789244,4088:20015108.787169147,6933:17367530.445161372,32662:20037508.342789244,53001:20015086.79602057,53002:10007543.39801029,53003:20015086.79602057,53004:20015086.79602057,53016:14152803.599503474,53017:17333573.624304302,53034:20015086.79602057,53079:20015114.352186374,53080:20015114.352186374,54001:20037508.342789244,54002:10018754.171394624,54003:20037508.342789244,54004:20037508.342789244,54016:14168658.027268292,54017:17367530.44516137,54034:20037508.342789244,54079:20037508.342789244,54080:20037508.342789244,54100:20037508.342789244,54101:20037508.342789244},S=32,P=4,b=P,G=new Map,N=new Map,E=500;async function k(){c()||await f()}function T(e,t,n){M(e.spatialReference,t);return n?u(t,e.spatialReference,e):u(e.spatialReference,t,e)}function C(e,t,i,o=null){const r=e.spatialReference;if(r.equals(t))return e;M(r,t,o);const s=i.center,a=new x({xmin:s.x-e.x/2,xmax:s.x+e.x/2,ymin:s.y-e.y/2,ymax:s.y+e.y/2,spatialReference:r}),l=m(a,t,o),c=K(t);let f;if(null==l||null!=c&&l.width>=c){const i=n(r)/n(t);f={x:e.x*i,y:e.y*i}}else f={x:l.width,y:l.height};return f}function v(e,t=.01){return n(e)?t/n(e):0}function _(e,t,n=null,i=!0){const o=e.spatialReference;if(o.equals(t))return e;M(o,t,n);const r=m(e,t,n);return i&&r?(j([e],[r],o,t),r):r}function j(e,t,n,i){const o=D(n,!0),r=D(i,!0),s=v(n,E),a=v(i,E);if(s&&null!=o&&null!=r)for(let l=0;l<e.length;l++){const n=t[l];if(!n)continue;const{x:i}=e[l],{x:c}=n;c>=r[1]-a&&Math.abs(i-o[0])<s?n.x-=r[1]-r[0]:c<=r[0]+a&&Math.abs(i-o[1])<s&&(n.x+=r[1]-r[0])}}function z(e){const{inSR:t,outSR:n,datumTransformation:i,preferPE:o}=e;if(t.equals(n)){const{points:t}=B(e,null);return t}if(t.isWebMercator&&n.isWGS84||t.isWGS84&&n.isWebMercator)return O(e);if(M(t,n,i)&&o){if(t.isGeographic)return W(e);if(null!=I(t))return W(e)}return L(e)}function L(e){const{points:t}=B(e,null),{inSR:n,outSR:i,datumTransformation:o}=e,r=t.map((e=>new h(e[0],e[1],n))),s=m(r,i,o);return o&&j(r,s,n,i),s.map((e=>e?[e.x,e.y]:[NaN,NaN]))}function W(e){const{inSR:t,outSR:n,datumTransformation:a}=e,l=I(t),{points:c,mask:f}=B(e,l);if(!t.isGeographic){const e=t.wkid?i.coordsys(t.wkid):i.fromString(t.isGeographic?o.PE_TYPE_GEOGCS:o.PE_TYPE_PROJCS,t.wkt);r.projToGeog(e,c.length,c)}if(null!=a&&a.steps.length){let e;const t=179.9955;if(n.isGeographic&&(e=c.map((([e])=>e>t?1:e<-t?-1:0))),a.steps.forEach((e=>{const t=e.wkid?i.geogtran(e.wkid):i.fromString(o.PE_TYPE_GEOGTRAN,e.wkt);s.geogToGeog(t,c.length,c,null,e.isInverse?o.PE_TRANSFORM_2_TO_1:o.PE_TRANSFORM_1_TO_2)})),e)for(let n=0;n<c.length;n++){const i=e[n],o=c[n][0],r=o>t?1:o<-t?-1:0;i&&r&&i!==r&&(c[n][0]=i>0?o+360:o-360)}}if(!n.isGeographic){const e=I(n,!0),t=null!=e&&e.isEnvelope?[e.bbox[1],e.bbox[3]]:[-90,90];F(c,t);const s=n.wkid?i.coordsys(n.wkid):i.fromString(n.isGeographic?o.PE_TYPE_GEOGCS:o.PE_TYPE_PROJCS,n.wkt);r.geogToProj(s,c.length,c)}let u=c;if(f&&c.length!==f.length){u=[];for(let e=0,t=0;e<f.length;e++)f[e]?u.push(c[t++]):u.push([NaN,NaN])}return u}function O(e){const{cols:t,rows:n,xres:i,yres:o,usePixelCenter:r,inSR:s,outSR:a}=e;let{xmin:l,ymax:c}=e;r&&(l+=i/2,c-=o/2);const f=[],u=[],x=Math.max(t,n);for(let g=0;g<x;g++){const e=l+i*Math.min(t,g),r=c-o*Math.min(n,g),x=m(new h({x:e,y:r,spatialReference:s}),a);g<=t&&f.push(x.x),g<=n&&u.push(x.y)}const p=[];for(let m=0;m<t;m++)for(let e=0;e<n;e++)p.push([f[m],u[e]]);return p}function I(e,t=!1){let n=e.wkid||e.wkt;if(!n||e.isGeographic)return null;if(n=String(n),G.has(n)){const e=G.get(n);return t?e?.gcs:e?.pcs}const r=e.wkid?i.coordsys(e.wkid):i.fromString(e.isGeographic?o.PE_TYPE_GEOGCS:o.PE_TYPE_PROJCS,e.wkt),s=A(r,v(e,1e-4)),a=A(r,0,!0);return G.set(n,{pcs:s,gcs:a}),t?a:s}function A(e,t=0,n=!1){const i=a.generate(e),o=n?e.horizonGcsGenerate():e.horizonPcsGenerate();if(!i||!o?.length)return null;let r=!1,s=o.find((e=>1===e.getInclusive()&&1===e.getKind()));if(!s){if(s=o.find((e=>1===e.getInclusive()&&0===e.getKind())),!s)return null;r=!0}const l=n?0:(2===i.getNorthPoleLocation()?1:0)|(2===i.getSouthPoleLocation()?2:0),c=i.isPannableRectangle(),f=s.getCoord();if(r)return{isEnvelope:r,isPannable:c,vertices:f,coef:null,bbox:[f[0][0]-t,f[0][1]-t,f[1][0]+t,f[1][1]+t],poleLocation:l};let u=0;const m=[];let[x,h]=f[0],[p,g]=f[0];for(let a=0,y=f.length;a<y;a++){u++,u===y&&(u=0);const[e,t]=f[a],[n,i]=f[u];if(i===t)m.push([e,n,t,i,2]);else{const o=(n-e)/(i-t||1e-4),r=e-o*t;t<i?m.push([o,r,t,i,0]):m.push([o,r,i,t,1])}x=x<e?x:e,h=h<t?h:t,p=p>e?p:e,g=g>t?g:t}return{isEnvelope:!1,isPannable:c,vertices:f,coef:m,bbox:[x,h,p,g],poleLocation:l}}function B(e,t){const n=[],{cols:i,rows:o,xres:r,yres:s,usePixelCenter:a}=e;let{xmin:l,ymax:c}=e;if(a&&(l+=r/2,c-=s/2),null==t){for(let e=0;e<i;e++)for(let t=0;t<o;t++)n.push([l+r*e,c-s*t]);return{points:n}}const f=new Uint8Array(i*o);if(t.isEnvelope){const{bbox:[e,a,u,m]}=t;for(let x=0,h=0;x<i;x++){const i=l+r*x,p=t.isPannable||i>=e&&i<=u;for(let e=0;e<o;e++,h++){const t=c-s*e;p&&t>=a&&t<=m&&(n.push([i,t]),f[h]=1)}}return{points:n,mask:f}}const u=t.coef,m=[];for(let x=0;x<o;x++){const e=c-s*x,t=[],n=[];for(let o=0;o<u.length;o++){const[i,r,s,a,l]=u[o];if(e===s&&s===a)t.push(i),t.push(r),n.push(2),n.push(2);else if(e>=s&&e<=a){const o=i*e+r;t.push(o),n.push(l)}}let i=t;if(t.length>2){let e=2===n[0]?0:n[0],o=t[0];i=[];for(let r=1;r<n.length;r++)2===n[r]&&r!==n.length-1||(n[r]!==e&&(i.push(0===e?Math.min(o,t[r-1]):Math.max(o,t[r-1])),e=n[r],o=t[r]),r===n.length-1&&i.push(0===n[r]?Math.min(o,t[r]):Math.max(o,t[r])));i.sort(((e,t)=>e-t))}else t[0]>t[1]&&(i=[t[1],t[0]]);m.push(i)}for(let x=0,h=0;x<i;x++){const e=l+r*x;for(let t=0;t<o;t++,h++){const i=c-s*t,o=m[t];if(2===o.length)e>=o[0]&&e<=o[1]&&(n.push([e,i]),f[h]=1);else if(o.length>2){let t=!1;for(let n=0;n<o.length;n+=2)if(e>=o[n]&&e<=o[n+1]){t=!0;break}t&&(n.push([e,i]),f[h]=1)}}}return{points:n,mask:f}}function F(e,t){const[n,i]=t;for(let o=0;o<e.length;o++){const t=e[o][1];(t<n||t>i)&&(e[o]=[NaN,NaN])}}function Y(e){const t=K(e[0].spatialReference);if(e.length<2||null==t)return e[0];const n=v(e[0].spatialReference);if(1===(e=e.filter((e=>e.width>n))).length)return e[0];let{xmin:i,xmax:o,ymin:r,ymax:s}=e[0];for(let a=1;a<e.length;a++){const n=e[a];o=n.xmax+t*a,r=Math.min(r,n.ymin),s=Math.max(s,n.ymax)}return new x({xmin:i,xmax:o,ymin:r,ymax:s,spatialReference:e[0].spatialReference})}function q(t,n,i=null,o=!0){const r=t.spatialReference;if(r.equals(n))return t;const s=Q(t),a=K(r,!0),l=K(n);if(0===s||null==a||null==l){const e=X(t,n,i,o);if(null==a&&null!=l&&Math.abs(e.width-l)<v(n)&&c()){const i=I(r);if(null!=i&&i.poleLocation===y.None&&t.width<(i.bbox[2]-i.bbox[0])/2)return U(t,n)||e}return e}const f=t.clone().normalize();if(1===f.length&&t.xmax<a&&t.xmax-a/2>v(r)){const{xmin:e,xmax:n}=t;for(let i=0;i<=s;i++){const o=0===i?e:-a/2,l=i===s?n-a*i:a/2;f[i]=new x({xmin:o,xmax:l,ymin:t.ymin,ymax:t.ymax,spatialReference:r})}}return Y(f.map((e=>X(e,n,i,o))).filter(e))}function J(e,t,n){if("extent"===e.type){const{xmin:t,ymin:n,xmax:i,ymax:o,spatialReference:r}=e;e=new p({rings:[[[t,o],[i,o],[i,n],[t,n],[t,o]]],spatialReference:r})}return e.spatialReference.equals(t)?e:(M(e.spatialReference,t,n),m(e,t,n))}function U(e,t){const n=K(t);if(null==n)return null;let{xmin:i,ymin:o,xmax:r,ymax:s}=e;const a=e.spatialReference,l=new p({spatialReference:a,rings:[[[i,o],[r,o],[r,s],[i,s],[i,o]]]}),c=m(l,t);if(2!==c.rings.length||!c.rings[0].length||!c.rings[1].length)return null;const{rings:f}=c,u=v(a),h=new x({spatialReference:t});for(let m=0;m<2;m++){i=r=f[m][0][0],o=s=f[m][0][1];for(let e=0;e<f[m].length;e++)i=i>f[m][e][0]?f[m][e][0]:i,r=r<f[m][e][0]?f[m][e][0]:r,o=o>f[m][e][1]?f[m][e][1]:o,s=s<f[m][e][1]?f[m][e][1]:s;if(0===m)h.ymin=o,h.ymax=s,h.xmin=i,h.xmax=r;else if(h.ymin=Math.min(h.ymin,o),h.ymax=Math.max(h.ymax,s),Math.abs(r-n/2)<u)h.xmin=i,h.xmax=h.xmax+n;else{if(!(Math.abs(i+n/2)<u))return null;h.xmax=r+n}}return h}function X(e,t,n=null,i=!0,o=!0){const r=e.spatialReference;if(r.equals(t)||!t)return e;M(r,t,n);const s=m(e,t,n);if(o&&t.isWebMercator&&s&&(s.ymax=Math.min(20037508.342787,s.ymax),s.ymin=Math.max(-20037508.342787,s.ymin),s.ymin>=s.ymax))return null;if(!i||!s)return s;const a=D(r,!0),l=D(t,!0);if(null==a||null==l)return s;const c=v(r,.001),f=v(r,E),u=v(t,.001);if(Math.abs(s.xmin-l[0])<u&&Math.abs(s.xmax-l[1])<u){const i=Math.abs(e.xmin-a[0]),o=Math.abs(a[1]-e.xmax);if(i<c&&o>f){s.xmin=l[0];const i=[];i.push(new h(e.xmax,e.ymin,r)),i.push(new h(e.xmax,(e.ymin+e.ymax)/2,r)),i.push(new h(e.xmax,e.ymax,r));const o=i.map((e=>_(e,t,n))).filter((e=>!isNaN(e?.x))).map((e=>e.x));s.xmax=Math.max.apply(null,o)}if(o<c&&i>f){s.xmax=l[1];const i=[];i.push(new h(e.xmin,e.ymin,r)),i.push(new h(e.xmin,(e.ymin+e.ymax)/2,r)),i.push(new h(e.xmin,e.ymax,r));const o=i.map((e=>_(e,t,n))).filter((e=>!isNaN(e?.x))).map((e=>e.x));s.xmin=Math.min.apply(null,o)}}else{const e=v(t,.001);Math.abs(s.xmin-l[0])<e&&(s.xmin=l[0]),Math.abs(s.xmax-l[1])<e&&(s.xmax=l[1])}return s}function K(e,t=!1){if(!e)return null;const n=t?20037508.342787:20037508.342788905;return e.isWebMercator?2*n:e.wkid&&e.isGeographic?360:2*R[e.wkid]||null}function D(e,t=!1){if(e.isGeographic)return[-180,180];const n=K(e,t);return null!=n?[-n/2,n/2]:null}function H(e,t,n,i){let o=(e-t)/n;return o-Math.floor(o)!=0?o=Math.floor(o):i&&(o-=1),o}function Q(e,t=!1){const n=K(e.spatialReference);if(null==n)return 0;const i=t?0:-(n/2),o=v(e.spatialReference),r=!t&&Math.abs(e.xmax-n/2)<o?n/2:e.xmax,s=!t&&Math.abs(e.xmin+n/2)<o?-n/2:e.xmin;return H(r,i,n,!0)-H(s,i,n,!1)}function V(e){const t=e.storageInfo.origin.x,n=K(e.spatialReference,!0);if(null==n)return{originX:t,halfWorldWidth:null,pyramidsInfo:null};const i=n/2,{nativePixelSize:o,storageInfo:r,extent:s}=e,{maximumPyramidLevel:a,blockWidth:l,pyramidScalingFactor:c}=r;let f=o.x;const u=[],m=null!=e.transform&&"gcs-shift"===e.transform.type,x=t+(m?0:i),h=m?n-t:i-t;for(let p=0;p<=a;p++){const e=(s.xmax-t)/f/l,n=e-Math.floor(e)==0?e:Math.ceil(e),i=h/f/l,o=i-Math.floor(i)==0?i:Math.ceil(i),r=Math.floor(x/f/l),a=Math.round(x/f)%l,m=(l-Math.round(h/f)%l)%l;u.push({resolutionX:f,blockWidth:l,datsetColumnCount:n,worldColumnCountFromOrigin:o,leftMargin:a,rightPadding:m,originColumnOffset:r}),f*=c}return{originX:t,halfWorldWidth:i,pyramidsInfo:u,hasGCSSShiftTransform:m}}function Z(e){if(!e||e.isGeographic)return e;const t=String(e.wkid||e.wkt);let n;if(N.has(t))n=N.get(t);else{n=(e.wkid?i.coordsys(e.wkid):i.fromString(o.PE_TYPE_PROJCS,e.wkt)).getGeogcs().getCode(),N.set(t,n)}return new g({wkid:n})}function $(e){const t=e.isAdaptive&&null==e.spacing;let n=e.spacing||[S,S],i=ee(e),o={cols:i.size[0]+1,rows:i.size[1]+1};const r=i.outofBoundPointCount>0&&i.outofBoundPointCount<i.offsets.length/2;let s=i.outofBoundPointCount===i.offsets.length/2||t&&r?[0,0]:w(i.offsets,o,n,b);const a=(s[0]+s[1])/2,l=e.projectedExtent.spatialReference,c=e.srcBufferExtent.spatialReference;if(t&&(r||a>b)){d(l,c,e.datumTransformation)&&(l.isGeographic||I(l)),n=[P,P],i=ee({...e,spacing:n}),o={cols:i.size[0]+1,rows:i.size[1]+1},s=w(i.offsets,o,n,b)}if(i.error=s,n[0]>1&&(i.coefficients=te(i.offsets,o,r)),e.includeGCSGrid&&!l.isGeographic&&!l.isWebMercator)if(c.isGeographic)i.gcsGrid={offsets:i.offsets,coefficients:i.coefficients,spacing:n};else{const t=I(l);if(null!=t&&!t.isEnvelope){const t=Z(l),s=q(e.projectedExtent,t),{offsets:a}=ee({...e,srcBufferExtent:s,spacing:n}),c=te(a,o,r);i.gcsGrid={offsets:a,coefficients:c,spacing:n}}}return i}function ee(e){const{projectedExtent:t,srcBufferExtent:n,pixelSize:i,datumTransformation:o,rasterTransform:r}=e,s=t.spatialReference,a=n.spatialReference,l=M(s,a),{xmin:c,ymin:f,xmax:u,ymax:m}=t,x=K(a),p=null!=x&&(e.hasWrapAround||"gcs-shift"===r?.type),g=e.spacing||[S,S],y=g[0]*i.x,d=g[1]*i.y,w=1===g[0],R=Math.ceil((u-c)/y-.1/g[0])+(w?0:1),b=Math.ceil((m-f)/d-.1/g[1])+(w?0:1),G=z({cols:R,rows:b,xmin:c,ymax:m,xres:y,yres:d,inSR:s,outSR:a,datumTransformation:o,preferPE:g[0]<=P,usePixelCenter:w}),N=[];let k,T=0;const C=w?-1:NaN,{xmin:_,xmax:j,ymax:L,width:W,height:O}=n,A=v(a,E),B=null!=x&&_>0&&j>x/2;let F=!1;if(l){const e=I(s);F=null!=e&&e.poleLocation>0}for(let M=0;M<R;M++){const e=[];for(let t=0;t<b;t++){let n=G[M*b+t];if(p&&n[0]>j&&n[0]>x/2-A?n[0]-=x:p&&0===M&&n[0]<0&&B&&!r&&(n[0]+=x),!n||isNaN(n[0])||isNaN(n[1]))N.push(C),N.push(C),e.push(null),T++;else{if(r){const e=r.inverseTransform(new h({x:n[0],y:n[1],spatialReference:a}));n=[e.x,e.y]}e.push(n),M>0&&p&&k[t]&&n[0]<k[t][0]&&(n[0]+=x,F&&n[0]>j&&n[0]>x&&(n[0]-=x)),N.push((n[0]-_)/W),N.push((L-n[1])/O)}}k=e}return{offsets:N,error:null,coefficients:null,outofBoundPointCount:T,spacing:g,size:w?[R,b]:[R-1,b-1]}}function te(e,t,n){const{cols:i,rows:o}=t,r=new Float32Array((i-1)*(o-1)*2*6),s=new Float32Array([-0,-1,1,-1,1,-0,1,-0,-0]),a=new Float32Array([-1,1,0,0,-1,1,1,0,0]);for(let l=0;l<i-1;l++){for(let t=0;t<o-1;t++){let n=l*o*2+2*t;const c=e[n],f=e[n+1],u=e[n+2],m=e[n+3];n+=2*o;const x=e[n],h=e[n+1],p=e[n+2],g=e[n+3];let y=0,d=12*(t*(i-1)+l);for(let e=0;e<3;e++)r[d++]=s[y++]*c+s[y++]*u+s[y++]*p;y=0;for(let e=0;e<3;e++)r[d++]=s[y++]*f+s[y++]*m+s[y++]*g;y=0;for(let e=0;e<3;e++)r[d++]=a[y++]*c+a[y++]*x+a[y++]*p;y=0;for(let e=0;e<3;e++)r[d++]=a[y++]*f+a[y++]*h+a[y++]*g}if(n)for(let e=0;e<r.length;e++)isNaN(r[e])&&(r[e]=-1)}return r}function ne(e){const t=e.clone().normalize();return 1===t.length?t[0]:Y(t)}function ie(e,t,i){const{storageInfo:o,pixelSize:r}=t;let s=0,a=!1;const{pyramidResolutions:l}=o,c="mixed"===o.tileInfo.format?.toLowerCase()?Math.max(1,Math.min(3,o.tileInfo.dpi/96)):1,f=(e.x+e.y)/2/c;if(null!=l&&l.length){const e=l.at(-1),o=(e.x+e.y)/2,c=(r.x+r.y)/2;if(f<=c)s=0;else if(f>=o)s=l.length,a=f/o>8;else{let e,t=c;for(let n=1;n<=l.length;n++){if(e=(l[n-1].x+l[n-1].y)/2,f<=e){f===e?s=n:"down"===i?(s=n-1,a=f/t>8):s="up"===i||f-t>e-f||f/t>2?n:n-1;break}t=e}}const u=0===s?r:l[s-1];if(a){Math.min(u.x,u.y)*n(t.spatialReference)>19567&&(a=!1)}return{pyramidLevel:s,pyramidResolution:new h({x:u.x,y:u.y,spatialReference:t.spatialReference}),excessiveReading:a}}const u=Math.log(e.x/r.x)/Math.LN2,m=Math.log(e.y/r.y)/Math.LN2,x=t.storageInfo.maximumPyramidLevel||0;s="down"===i?Math.floor(Math.min(u,m)):"up"===i?Math.ceil(Math.max(u,m)):Math.round((u+m)/2),s<0?s=0:s>x&&(a=s>x+3,s=x);const p=2**s;return{pyramidLevel:s,pyramidResolution:new h({x:p*t.nativePixelSize.x,y:p*t.nativePixelSize.y,spatialReference:t.spatialReference}),excessiveReading:a}}function oe(e,t,i){const o=i?.tileSize??512,r=i?.alignGlobalDatasetWithAGOL??!0,s=!!i?.limitToSrcResolution,{extent:a,spatialReference:l,pixelSize:c}=e,f=C(new h({x:c.x,y:c.y,spatialReference:l}),t,a);if(null==f)return{projectedPixelSize:null,scales:null,srcResolutions:null,isCustomTilingScheme:!1};const u=(f.x+f.y)/2,m=n(t),x=u*m*96*39.37,p=t.isGeographic?256/o*295828763.7958547:256/o*591657527.591555;let g="vector-magdir"===e.dataType||"vector-uv"===e.dataType;const y=q(a,t),d=Math.min(Math.ceil(Math.log(Math.min(e.width,e.height)/32)/Math.LN2),Math.ceil(Math.log(p/2/x)/Math.LN2));if(!g&&r&&(t.isGeographic||t.isWebMercator)&&(g=y.xmin*y.xmax<0,!g&&d<3)){const e=K(t);if(null!=e){const t=2**d*u*o,n=Math.ceil(e/t);g=1===n||2===n&&e/2-y.xmax<t}}let M,w=x;const R=1.001,S=Math.min(2,Math.max(1.414,e.storageInfo?.pyramidScalingFactor||2));if(g){w=p;const e=t.isGeographic?1341104507446289e-21:.29858214164761665,n=e*(96*m*39.37),i=t.isGeographic?4326:3857;M=C(new h({x:e,y:e,spatialReference:{wkid:i}}),l,y),M.x*=w/n,M.y*=w/n}else{M={x:c.x,y:c.y};let e=0;for(;w<p*(R/2)&&e<d;)e++,w*=S,M.x*=S,M.y*=S;Math.max(w,p)/Math.min(w,p)<=R&&(w=p)}const P=[w],b=[{x:M.x,y:M.y}],G=70.5310735,N=Math.min(G,x)/R;for(;w>=N;)w/=S,M.x/=S,M.y/=S,P.push(w),b.push({x:M.x,y:M.y});if(s){const e=.001*c.x;let t=b.findIndex((t=>t.x>=c.x-e&&t.x<=c.x+e));t>-1?(b.length=t+1,P.length=t+1):(t=b.findIndex((t=>t.x<=c.x+e)),t>0&&(b.length=t,P.length=t))}return{projectedPixelSize:f,scales:P,srcResolutions:b,isCustomTilingScheme:!g}}export{oe as computeProjectedScales,S as defaultGridSpacing,b as defaultProjectionToleranceInPixels,T as getDefaultDatumTransformationForDataset,z as getProjectedGridPoints,$ as getProjectionOffsetGrid,V as getRasterDatasetAlignmentInfo,K as getWorldWidth,Q as getWorldWrapCount,k as load,P as minimumGridSpacing,q as projectExtent,_ as projectPoint,J as projectPolygon,C as projectResolution,d as requirePE,ne as snapExtent,ie as snapPyramid};
|
|
5
|
+
import"../../../geometry.js";import{isSome as e}from"../../../core/arrayUtils.js";import t from"../../../core/Error.js";import{getMetersPerUnitForSR as n}from"../../../core/unitUtils.js";import{e as i,f as o,g as r,h as s,j as a}from"../../../chunks/pe.js";import{canProjectWithoutEngine as l,isLoaded as c,load as f,getTransformation as u,project as m}from"../../../geometry/projection.js";import x from"../../../geometry/Extent.js";import h from"../../../geometry/Point.js";import p from"../../../geometry/Polygon.js";import g from"../../../geometry/SpatialReference.js";var y;function d(e,t,n){return!l(e,t,n)}function M(e,n,i){const o=d(e,n,i);if(o&&!c())throw new t("rasterprojectionhelper-project","projection engine is not loaded");return o}!function(e){e[e.None=0]="None",e[e.North=1]="North",e[e.South=2]="South",e[e.Both=3]="Both"}(y||(y={}));const w=(e,t,n,i=0)=>{if(1===n[0])return[0,0];let o=1,r=-1,s=1,a=-1;for(let g=0;g<e.length;g+=2)isNaN(e[g])||(o=o>e[g]?e[g]:o,r=r>e[g]?r:e[g],s=s>e[g+1]?e[g+1]:s,a=a>e[g+1]?a:e[g+1]);const{cols:l,rows:c}=t,f=(r-o)/l/n[0],u=(a-s)/c/n[1],m=2*i;let x=0,h=!1,p=[0,0];for(let g=0;g<l-3;g++){for(let t=0;t<c-3;t++){const n=g*c*2+2*t,i=(e[n]+e[n+4]+e[n+4*c]+e[n+4*c+4])/4,o=(e[n+1]+e[n+5]+e[n+4*c+1]+e[n+4*c+5])/4,r=Math.abs((i-e[n+2*c+2])/f),s=Math.abs((o-e[n+2*c+3])/u);if(r+s>x&&(x=r+s,p=[r,s]),m&&x>m){h=!0;break}}if(h)break}return p},R={3395:20037508.342789244,3410:17334193.943686873,3857:20037508.342788905,3975:17367530.445161372,4087:20037508.342789244,4088:20015108.787169147,6933:17367530.445161372,32662:20037508.342789244,53001:20015086.79602057,53002:10007543.39801029,53003:20015086.79602057,53004:20015086.79602057,53016:14152803.599503474,53017:17333573.624304302,53034:20015086.79602057,53079:20015114.352186374,53080:20015114.352186374,54001:20037508.342789244,54002:10018754.171394624,54003:20037508.342789244,54004:20037508.342789244,54016:14168658.027268292,54017:17367530.44516137,54034:20037508.342789244,54079:20037508.342789244,54080:20037508.342789244,54100:20037508.342789244,54101:20037508.342789244},S=32,P=4,b=P,G=new Map,N=new Map,E=500;async function k(){c()||await f()}function T(e,t,n){M(e.spatialReference,t);return n?u(t,e.spatialReference,e):u(e.spatialReference,t,e)}function v(e,t,i,o=null){const r=e.spatialReference;if(r.equals(t))return e;M(r,t,o);const s=i.center,a=new x({xmin:s.x-e.x/2,xmax:s.x+e.x/2,ymin:s.y-e.y/2,ymax:s.y+e.y/2,spatialReference:r}),l=m(a,t,o),c=K(t);let f;if(null==l||null!=c&&l.width>=c){const i=n(r)/n(t);f={x:e.x*i,y:e.y*i}}else f={x:l.width,y:l.height};return f}function C(e,t=.01){return n(e)?t/n(e):0}function _(e,t,n=null,i=!0){const o=e.spatialReference;if(o.equals(t))return e;M(o,t,n);const r=m(e,t,n);return i&&r?(j([e],[r],o,t),r):r}function j(e,t,n,i){const o=D(n,!0),r=D(i,!0),s=C(n,E),a=C(i,E);if(s&&null!=o&&null!=r)for(let l=0;l<e.length;l++){const n=t[l];if(!n)continue;const{x:i}=e[l],{x:c}=n;c>=r[1]-a&&Math.abs(i-o[0])<s?n.x-=r[1]-r[0]:c<=r[0]+a&&Math.abs(i-o[1])<s&&(n.x+=r[1]-r[0])}}function z(e){const{inSR:t,outSR:n,datumTransformation:i,preferPE:o}=e;if(t.equals(n)){const{points:t}=B(e,null);return t}if(t.isWebMercator&&n.isWGS84||t.isWGS84&&n.isWebMercator)return W(e);if(M(t,n,i)&&o){if(t.isGeographic)return I(e);if(null!=O(t))return I(e)}return L(e)}function L(e){const{points:t}=B(e,null),{inSR:n,outSR:i,datumTransformation:o}=e,r=t.map((e=>new h(e[0],e[1],n))),s=m(r,i,o);return o&&j(r,s,n,i),s.map((e=>e?[e.x,e.y]:[NaN,NaN]))}function I(e){const{inSR:t,outSR:n,datumTransformation:a}=e,l=O(t),{points:c,mask:f}=B(e,l);if(!t.isGeographic){const e=t.wkid?i.coordsys(t.wkid):i.fromString(t.isGeographic?o.PE_TYPE_GEOGCS:o.PE_TYPE_PROJCS,t.wkt);r.projToGeog(e,c.length,c)}if(null!=a&&a.steps.length){let e;const t=179.9955;if(n.isGeographic&&(e=c.map((([e])=>e>t?1:e<-t?-1:0))),a.steps.forEach((e=>{const t=e.wkid?i.geogtran(e.wkid):i.fromString(o.PE_TYPE_GEOGTRAN,e.wkt);s.geogToGeog(t,c.length,c,null,e.isInverse?o.PE_TRANSFORM_2_TO_1:o.PE_TRANSFORM_1_TO_2)})),e)for(let n=0;n<c.length;n++){const i=e[n],o=c[n][0],r=o>t?1:o<-t?-1:0;i&&r&&i!==r&&(c[n][0]=i>0?o+360:o-360)}}if(!n.isGeographic){const e=O(n,!0),t=null!=e&&e.isEnvelope?[e.bbox[1],e.bbox[3]]:[-90,90];F(c,t);const s=n.wkid?i.coordsys(n.wkid):i.fromString(n.isGeographic?o.PE_TYPE_GEOGCS:o.PE_TYPE_PROJCS,n.wkt);r.geogToProj(s,c.length,c)}let u=c;if(f&&c.length!==f.length){u=[];for(let e=0,t=0;e<f.length;e++)f[e]?u.push(c[t++]):u.push([NaN,NaN])}return u}function W(e){const{cols:t,rows:n,xres:i,yres:o,usePixelCenter:r,inSR:s,outSR:a}=e;let{xmin:l,ymax:c}=e;r&&(l+=i/2,c-=o/2);const f=[],u=[],x=Math.max(t,n);for(let g=0;g<x;g++){const e=l+i*Math.min(t,g),r=c-o*Math.min(n,g),x=m(new h({x:e,y:r,spatialReference:s}),a);g<=t&&f.push(x.x),g<=n&&u.push(x.y)}const p=[];for(let m=0;m<t;m++)for(let e=0;e<n;e++)p.push([f[m],u[e]]);return p}function O(e,t=!1){let n=e.wkid||e.wkt;if(!n||e.isGeographic)return null;if(n=String(n),G.has(n)){const e=G.get(n);return t?e?.gcs:e?.pcs}const r=e.wkid?i.coordsys(e.wkid):i.fromString(e.isGeographic?o.PE_TYPE_GEOGCS:o.PE_TYPE_PROJCS,e.wkt),s=A(r,C(e,1e-4)),a=A(r,0,!0);return G.set(n,{pcs:s,gcs:a}),t?a:s}function A(e,t=0,n=!1){const i=a.generate(e),o=n?e.horizonGcsGenerate():e.horizonPcsGenerate();if(!i||!o?.length)return null;let r=!1,s=o.find((e=>1===e.getInclusive()&&1===e.getKind()));if(!s){if(s=o.find((e=>1===e.getInclusive()&&0===e.getKind())),!s)return null;r=!0}const l=n?0:(2===i.getNorthPoleLocation()?1:0)|(2===i.getSouthPoleLocation()?2:0),c=i.isPannableRectangle(),f=s.getCoord();if(r)return{isEnvelope:r,isPannable:c,vertices:f,coef:null,bbox:[f[0][0]-t,f[0][1]-t,f[1][0]+t,f[1][1]+t],poleLocation:l};let u=0;const m=[];let[x,h]=f[0],[p,g]=f[0];for(let a=0,y=f.length;a<y;a++){u++,u===y&&(u=0);const[e,t]=f[a],[n,i]=f[u];if(i===t)m.push([e,n,t,i,2]);else{const o=(n-e)/(i-t||1e-4),r=e-o*t;t<i?m.push([o,r,t,i,0]):m.push([o,r,i,t,1])}x=x<e?x:e,h=h<t?h:t,p=p>e?p:e,g=g>t?g:t}return{isEnvelope:!1,isPannable:c,vertices:f,coef:m,bbox:[x,h,p,g],poleLocation:l}}function B(e,t){const n=[],{cols:i,rows:o,xres:r,yres:s,usePixelCenter:a}=e;let{xmin:l,ymax:c}=e;if(a&&(l+=r/2,c-=s/2),null==t){for(let e=0;e<i;e++)for(let t=0;t<o;t++)n.push([l+r*e,c-s*t]);return{points:n}}const f=new Uint8Array(i*o);if(t.isEnvelope){const{bbox:[e,a,u,m]}=t;for(let x=0,h=0;x<i;x++){const i=l+r*x,p=t.isPannable||i>=e&&i<=u;for(let e=0;e<o;e++,h++){const t=c-s*e;p&&t>=a&&t<=m&&(n.push([i,t]),f[h]=1)}}return{points:n,mask:f}}const u=t.coef,m=[];for(let x=0;x<o;x++){const e=c-s*x,t=[],n=[];for(let o=0;o<u.length;o++){const[i,r,s,a,l]=u[o];if(e===s&&s===a)t.push(i),t.push(r),n.push(2),n.push(2);else if(e>=s&&e<=a){const o=i*e+r;t.push(o),n.push(l)}}let i=t;if(t.length>2){let e=2===n[0]?0:n[0],o=t[0];i=[];for(let r=1;r<n.length;r++)2===n[r]&&r!==n.length-1||(n[r]!==e&&(i.push(0===e?Math.min(o,t[r-1]):Math.max(o,t[r-1])),e=n[r],o=t[r]),r===n.length-1&&i.push(0===n[r]?Math.min(o,t[r]):Math.max(o,t[r])));i.sort(((e,t)=>e-t))}else t[0]>t[1]&&(i=[t[1],t[0]]);m.push(i)}for(let x=0,h=0;x<i;x++){const e=l+r*x;for(let t=0;t<o;t++,h++){const i=c-s*t,o=m[t];if(2===o.length)e>=o[0]&&e<=o[1]&&(n.push([e,i]),f[h]=1);else if(o.length>2){let t=!1;for(let n=0;n<o.length;n+=2)if(e>=o[n]&&e<=o[n+1]){t=!0;break}t&&(n.push([e,i]),f[h]=1)}}}return{points:n,mask:f}}function F(e,t){const[n,i]=t;for(let o=0;o<e.length;o++){const t=e[o][1];(t<n||t>i)&&(e[o]=[NaN,NaN])}}function Y(e,t){const n=K(e[0].spatialReference);if(e.length<2||null==n)return e[0];if(t=t??C(e[0].spatialReference),1===(e=e.filter((e=>e.width>t))).length)return e[0];let{xmin:i,xmax:o,ymin:r,ymax:s}=e[0];for(let a=1;a<e.length;a++){const t=e[a];o=t.xmax+n*a,r=Math.min(r,t.ymin),s=Math.max(s,t.ymax)}return new x({xmin:i,xmax:o,ymin:r,ymax:s,spatialReference:e[0].spatialReference})}function q(t,n,i=null,o=!0){const r=t.spatialReference;if(r.equals(n))return t;const s=Q(t),a=K(r,!0),l=K(n);if(0===s||null==a||null==l){const e=X(t,n,i,o);if(null==a&&null!=l&&Math.abs(e.width-l)<C(n)&&c()){const i=O(r);if(null!=i&&i.poleLocation===y.None&&t.width<(i.bbox[2]-i.bbox[0])/2)return U(t,n)||e}return e}const f=t.clone().normalize();if(1===f.length&&t.xmax<a&&t.xmax-a/2>C(r)){const{xmin:e,xmax:n}=t;for(let i=0;i<=s;i++){const o=0===i?e:-a/2,l=i===s?n-a*i:a/2;f[i]=new x({xmin:o,xmax:l,ymin:t.ymin,ymax:t.ymax,spatialReference:r})}}return Y(f.map((e=>X(e,n,i,o))).filter(e))}function J(e,t,n){if("extent"===e.type){const{xmin:t,ymin:n,xmax:i,ymax:o,spatialReference:r}=e;e=new p({rings:[[[t,o],[i,o],[i,n],[t,n],[t,o]]],spatialReference:r})}return e.spatialReference.equals(t)?e:(M(e.spatialReference,t,n),m(e,t,n))}function U(e,t){const n=K(t);if(null==n)return null;let{xmin:i,ymin:o,xmax:r,ymax:s}=e;const a=e.spatialReference,l=new p({spatialReference:a,rings:[[[i,o],[r,o],[r,s],[i,s],[i,o]]]}),c=m(l,t);if(2!==c.rings.length||!c.rings[0].length||!c.rings[1].length)return null;const{rings:f}=c,u=C(a),h=new x({spatialReference:t});for(let m=0;m<2;m++){i=r=f[m][0][0],o=s=f[m][0][1];for(let e=0;e<f[m].length;e++)i=i>f[m][e][0]?f[m][e][0]:i,r=r<f[m][e][0]?f[m][e][0]:r,o=o>f[m][e][1]?f[m][e][1]:o,s=s<f[m][e][1]?f[m][e][1]:s;if(0===m)h.ymin=o,h.ymax=s,h.xmin=i,h.xmax=r;else if(h.ymin=Math.min(h.ymin,o),h.ymax=Math.max(h.ymax,s),Math.abs(r-n/2)<u)h.xmin=i,h.xmax=h.xmax+n;else{if(!(Math.abs(i+n/2)<u))return null;h.xmax=r+n}}return h}function X(e,t,n=null,i=!0,o=!0){const r=e.spatialReference;if(r.equals(t)||!t)return e;M(r,t,n);const s=m(e,t,n);if(o&&t.isWebMercator&&s&&(s.ymax=Math.min(20037508.342787,s.ymax),s.ymin=Math.max(-20037508.342787,s.ymin),s.ymin>=s.ymax))return null;if(!i||!s)return s;const a=D(r,!0),l=D(t,!0);if(null==a||null==l)return s;const c=C(r,.001),f=C(r,E),u=C(t,.001);if(Math.abs(s.xmin-l[0])<u&&Math.abs(s.xmax-l[1])<u){const i=Math.abs(e.xmin-a[0]),o=Math.abs(a[1]-e.xmax);if(i<c&&o>f){s.xmin=l[0];const i=[];i.push(new h(e.xmax,e.ymin,r)),i.push(new h(e.xmax,(e.ymin+e.ymax)/2,r)),i.push(new h(e.xmax,e.ymax,r));const o=i.map((e=>_(e,t,n))).filter((e=>!isNaN(e?.x))).map((e=>e.x));s.xmax=Math.max.apply(null,o)}if(o<c&&i>f){s.xmax=l[1];const i=[];i.push(new h(e.xmin,e.ymin,r)),i.push(new h(e.xmin,(e.ymin+e.ymax)/2,r)),i.push(new h(e.xmin,e.ymax,r));const o=i.map((e=>_(e,t,n))).filter((e=>!isNaN(e?.x))).map((e=>e.x));s.xmin=Math.min.apply(null,o)}}else{const e=C(t,.001);Math.abs(s.xmin-l[0])<e&&(s.xmin=l[0]),Math.abs(s.xmax-l[1])<e&&(s.xmax=l[1])}return s}function K(e,t=!1){if(!e)return null;const n=t?20037508.342787:20037508.342788905;return e.isWebMercator?2*n:e.wkid&&e.isGeographic?360:2*R[e.wkid]||null}function D(e,t=!1){if(e.isGeographic)return[-180,180];const n=K(e,t);return null!=n?[-n/2,n/2]:null}function H(e,t,n,i){let o=(e-t)/n;return o-Math.floor(o)!=0?o=Math.floor(o):i&&(o-=1),o}function Q(e,t=!1){const n=K(e.spatialReference);if(null==n)return 0;const i=t?0:-(n/2),o=C(e.spatialReference),r=!t&&Math.abs(e.xmax-n/2)<o?n/2:e.xmax,s=!t&&Math.abs(e.xmin+n/2)<o?-n/2:e.xmin;return H(r,i,n,!0)-H(s,i,n,!1)}function V(e){const t=e.storageInfo.origin.x,n=K(e.spatialReference,!0);if(null==n)return{originX:t,halfWorldWidth:null,pyramidsInfo:null};const i=n/2,{nativePixelSize:o,storageInfo:r,extent:s}=e,{maximumPyramidLevel:a,blockWidth:l,pyramidScalingFactor:c}=r;let f=o.x;const u=[],m=null!=e.transform&&"gcs-shift"===e.transform.type,x=t+(m?0:i),h=m?n-t:i-t;for(let p=0;p<=a;p++){const e=(s.xmax-t)/f/l,n=e-Math.floor(e)==0?e:Math.ceil(e),i=h/f/l,o=i-Math.floor(i)==0?i:Math.ceil(i),r=Math.floor(x/f/l),a=Math.round(x/f)%l,m=(l-Math.round(h/f)%l)%l;u.push({resolutionX:f,blockWidth:l,datsetColumnCount:n,worldColumnCountFromOrigin:o,leftMargin:a,rightPadding:m,originColumnOffset:r}),f*=c}return{originX:t,halfWorldWidth:i,pyramidsInfo:u,hasGCSSShiftTransform:m}}function Z(e){if(!e||e.isGeographic)return e;const t=String(e.wkid||e.wkt);let n;if(N.has(t))n=N.get(t);else{n=(e.wkid?i.coordsys(e.wkid):i.fromString(o.PE_TYPE_PROJCS,e.wkt)).getGeogcs().getCode(),N.set(t,n)}return new g({wkid:n})}function $(e){const t=e.isAdaptive&&null==e.spacing;let n=e.spacing||[S,S],i=ee(e),o={cols:i.size[0]+1,rows:i.size[1]+1};const r=i.outofBoundPointCount>0&&i.outofBoundPointCount<i.offsets.length/2;let s=i.outofBoundPointCount===i.offsets.length/2||t&&r?[0,0]:w(i.offsets,o,n,b);const a=(s[0]+s[1])/2,l=e.projectedExtent.spatialReference,c=e.srcBufferExtent.spatialReference;if(t&&(r||a>b)){d(l,c,e.datumTransformation)&&(l.isGeographic||O(l)),n=[P,P],i=ee({...e,spacing:n}),o={cols:i.size[0]+1,rows:i.size[1]+1},s=w(i.offsets,o,n,b)}if(i.error=s,n[0]>1&&(i.coefficients=te(i.offsets,o,r)),e.includeGCSGrid&&!l.isGeographic&&!l.isWebMercator)if(c.isGeographic)i.gcsGrid={offsets:i.offsets,coefficients:i.coefficients,spacing:n};else{const t=O(l);if(null!=t&&!t.isEnvelope){const t=Z(l),s=q(e.projectedExtent,t),{offsets:a}=ee({...e,srcBufferExtent:s,spacing:n}),c=te(a,o,r);i.gcsGrid={offsets:a,coefficients:c,spacing:n}}}return i}function ee(e){const{projectedExtent:t,srcBufferExtent:n,pixelSize:i,datumTransformation:o,rasterTransform:r}=e,s=t.spatialReference,a=n.spatialReference,l=M(s,a),{xmin:c,ymin:f,xmax:u,ymax:m}=t,x=K(a),p=null!=x&&(e.hasWrapAround||"gcs-shift"===r?.type),g=e.spacing||[S,S],y=g[0]*i.x,d=g[1]*i.y,w=1===g[0],R=Math.ceil((u-c)/y-.1/g[0])+(w?0:1),b=Math.ceil((m-f)/d-.1/g[1])+(w?0:1),G=z({cols:R,rows:b,xmin:c,ymax:m,xres:y,yres:d,inSR:s,outSR:a,datumTransformation:o,preferPE:g[0]<=P,usePixelCenter:w}),N=[];let k,T=0;const v=w?-1:NaN,{xmin:_,xmax:j,ymax:L,width:I,height:W}=n,A=C(a,E),B=null!=x&&_>0&&j>x/2;let F=!1;if(l){const e=O(s);F=null!=e&&e.poleLocation>0}for(let M=0;M<R;M++){const e=[];for(let t=0;t<b;t++){let n=G[M*b+t];if(p&&n[0]>j&&n[0]>x/2-A?n[0]-=x:p&&0===M&&n[0]<0&&B&&!r&&(n[0]+=x),!n||isNaN(n[0])||isNaN(n[1]))N.push(v),N.push(v),e.push(null),T++;else{if(r){const e=r.inverseTransform(new h({x:n[0],y:n[1],spatialReference:a}));n=[e.x,e.y]}e.push(n),M>0&&p&&k[t]&&n[0]<k[t][0]&&(n[0]+=x,F&&n[0]>j&&n[0]>x&&(n[0]-=x)),N.push((n[0]-_)/I),N.push((L-n[1])/W)}}k=e}return{offsets:N,error:null,coefficients:null,outofBoundPointCount:T,spacing:g,size:w?[R,b]:[R-1,b-1]}}function te(e,t,n){const{cols:i,rows:o}=t,r=new Float32Array((i-1)*(o-1)*2*6),s=new Float32Array([-0,-1,1,-1,1,-0,1,-0,-0]),a=new Float32Array([-1,1,0,0,-1,1,1,0,0]);for(let l=0;l<i-1;l++){for(let t=0;t<o-1;t++){let n=l*o*2+2*t;const c=e[n],f=e[n+1],u=e[n+2],m=e[n+3];n+=2*o;const x=e[n],h=e[n+1],p=e[n+2],g=e[n+3];let y=0,d=12*(t*(i-1)+l);for(let e=0;e<3;e++)r[d++]=s[y++]*c+s[y++]*u+s[y++]*p;y=0;for(let e=0;e<3;e++)r[d++]=s[y++]*f+s[y++]*m+s[y++]*g;y=0;for(let e=0;e<3;e++)r[d++]=a[y++]*c+a[y++]*x+a[y++]*p;y=0;for(let e=0;e<3;e++)r[d++]=a[y++]*f+a[y++]*h+a[y++]*g}if(n)for(let e=0;e<r.length;e++)isNaN(r[e])&&(r[e]=-1)}return r}function ne(e,t){const n=e.clone().normalize();return 1===n.length?n[0]:Y(n,t)}function ie(e,t,i){const{storageInfo:o,pixelSize:r}=t;let s=0,a=!1;const{pyramidResolutions:l}=o,c="mixed"===o.tileInfo.format?.toLowerCase()?Math.max(1,Math.min(3,o.tileInfo.dpi/96)):1,f=(e.x+e.y)/2/c;if(null!=l&&l.length){const e=l[l.length-1],o=(e.x+e.y)/2,c=(r.x+r.y)/2;if(f<=c)s=0;else if(f>=o)s=l.length,a=f/o>8;else{let e,t=c;for(let n=1;n<=l.length;n++){if(e=(l[n-1].x+l[n-1].y)/2,f<=e){f===e?s=n:"down"===i?(s=n-1,a=f/t>8):s="up"===i||f-t>e-f||f/t>2?n:n-1;break}t=e}}const u=0===s?r:l[s-1];if(a){Math.min(u.x,u.y)*n(t.spatialReference)>19567&&(a=!1)}return{pyramidLevel:s,pyramidResolution:new h({x:u.x,y:u.y,spatialReference:t.spatialReference}),excessiveReading:a}}const u=Math.log(e.x/r.x)/Math.LN2,m=Math.log(e.y/r.y)/Math.LN2,x=t.storageInfo.maximumPyramidLevel||0;s="down"===i?Math.floor(Math.min(u,m)):"up"===i?Math.ceil(Math.max(u,m)):Math.round((u+m)/2),s<0?s=0:s>x&&(a=s>x+3,s=x);const p=2**s;return{pyramidLevel:s,pyramidResolution:new h({x:p*t.nativePixelSize.x,y:p*t.nativePixelSize.y,spatialReference:t.spatialReference}),excessiveReading:a}}function oe(e,t){const{pixelSize:n,extent:i}=e,o=T(i,t,!1);return q(ne(i,(n.x+n.y)/16),t,o)}function re(e,t,i){const o=i?.tileSize??512,r=i?.alignGlobalDatasetWithAGOL??!0,s=!!i?.limitToSrcResolution,{extent:a,spatialReference:l,pixelSize:c}=e,f=v(new h({x:c.x,y:c.y,spatialReference:l}),t,a);if(null==f)return{projectedPixelSize:null,scales:null,srcResolutions:null,isCustomTilingScheme:!1};const u=(f.x+f.y)/2,m=n(t),x=u*m*96*39.37,p=t.isGeographic?256/o*295828763.7958547:256/o*591657527.591555;let g="vector-magdir"===e.dataType||"vector-uv"===e.dataType;const y=oe(e,t),d=Math.min(Math.ceil(Math.log(Math.min(e.width,e.height)/32)/Math.LN2),Math.ceil(Math.log(p/2/x)/Math.LN2));if(!g&&r&&(t.isGeographic||t.isWebMercator)){const n=K(t);if(g=Q(y)>0||null!=n&&y.width>n/4,!g&&null!=n){let t=-1;if(d<3)t=2**d*u*o;else if(e.storageInfo){const{maximumPyramidLevel:n=0,pyramidScalingFactor:i=2}=e.storageInfo;t=i**n*u*o}const i=Math.ceil(n/t);g=1===i||2===i&&n/2-y.xmax<t}}let M,w=x;const R=1.001,S=Math.min(2,Math.max(1.414,e.storageInfo?.pyramidScalingFactor||2));if(g){w=p;const e=t.isGeographic?1341104507446289e-21:.29858214164761665,n=e*(96*m*39.37),i=t.isGeographic?4326:3857;M=v(new h({x:e,y:e,spatialReference:{wkid:i}}),l,y),M.x*=w/n,M.y*=w/n}else{M={x:c.x,y:c.y};let e=0;for(;w<p*(R/2)&&e<d;)e++,w*=S,M.x*=S,M.y*=S;Math.max(w,p)/Math.min(w,p)<=R&&(w=p)}const P=[w],b=[{x:M.x,y:M.y}],G=70.5310735,N=Math.min(G,x)/R;for(;w>=N;)w/=S,M.x/=S,M.y/=S,P.push(w),b.push({x:M.x,y:M.y});if(s){const e=.001*c.x;let t=b.findIndex((t=>t.x>=c.x-e&&t.x<=c.x+e));t>-1?(b.length=t+1,P.length=t+1):(t=b.findIndex((t=>t.x<=c.x+e)),t>0&&(b.length=t,P.length=t))}return{projectedPixelSize:f,scales:P,srcResolutions:b,isCustomTilingScheme:!g}}export{re as computeProjectedScales,S as defaultGridSpacing,b as defaultProjectionToleranceInPixels,T as getDefaultDatumTransformationForDataset,z as getProjectedGridPoints,$ as getProjectionOffsetGrid,V as getRasterDatasetAlignmentInfo,K as getWorldWidth,Q as getWorldWrapCount,k as load,P as minimumGridSpacing,oe as projectDatasetExtent,q as projectExtent,_ as projectPoint,J as projectPolygon,v as projectResolution,d as requirePE,ne as snapExtent,ie as snapPyramid};
|