@arcgis/core 6.0.0-next.14 → 6.0.0-next.16
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/analysis/LineOfSightAnalysis.d.ts +49 -32
- package/analysis/LineOfSightAnalysisObserver.d.ts +19 -3
- package/analysis/LineOfSightAnalysisTarget.d.ts +19 -3
- package/analysis/Viewshed.d.ts +23 -3
- package/analysis/ViewshedAnalysis.d.ts +33 -13
- package/arcade/geometry/operatorsWorkerConnection.js +1 -1
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/00d66e3fba5ab4d2aa3c.js +1 -0
- package/assets/esri/core/workers/chunks/{d994bcf0a65d1c07160f.js → 0320cbd825f9a4222042.js} +1 -1
- package/assets/esri/core/workers/chunks/08fe248e412bb170210d.js +1 -0
- package/assets/esri/core/workers/chunks/{fb444954be74c1962ced.js → 10d80e793019dfb45ca2.js} +1 -1
- package/assets/esri/core/workers/chunks/14d5d219e7fe017f23f0.js +1 -0
- package/assets/esri/core/workers/chunks/164e74d586297946a717.js +1 -0
- package/assets/esri/core/workers/chunks/{1bca39e0e651426bdbb5.js → 1b1d3f6916d2cb751435.js} +1 -1
- package/assets/esri/core/workers/chunks/{ed6e9d7f71bfd2691717.js → 1c77de1e79860f8d2228.js} +1 -1
- package/assets/esri/core/workers/chunks/1e40a26dcce4d1dadc28.js +1 -0
- package/assets/esri/core/workers/chunks/237a1f68a0efbfe5b77c.js +1 -0
- package/assets/esri/core/workers/chunks/23c43f09c4a4749516e1.js +1 -0
- package/assets/esri/core/workers/chunks/{3418877328f4f0830300.js → 24dac4970526a4e0ae63.js} +1 -1
- package/assets/esri/core/workers/chunks/26ceb0ff8d93dbb9b84f.js +1 -0
- package/assets/esri/core/workers/chunks/2acf2952cef69e382a35.js +1 -0
- package/assets/esri/core/workers/chunks/{481589c3eddad6e026ad.js → 369780276b2755361f7d.js} +1 -1
- package/assets/esri/core/workers/chunks/{4df6cb1bee5d0720a43e.js → 36cbd614454581aaf334.js} +1 -1
- package/assets/esri/core/workers/chunks/{1e0d2715d603f48a7e0b.js → 370aad23df597db80d65.js} +1 -1
- package/assets/esri/core/workers/chunks/3baa4a9c52f41bfd6abb.js +1 -0
- package/assets/esri/core/workers/chunks/42d44c7d532df5ee70e9.js +1 -0
- package/assets/esri/core/workers/chunks/42e985a576d7aaeed0cf.js +1 -0
- package/assets/esri/core/workers/chunks/{6400446b7615b97c3521.js → 45f826554499c38968c6.js} +1 -1
- package/assets/esri/core/workers/chunks/48cc58890fddbcf69cef.js +1 -0
- package/assets/esri/core/workers/chunks/494bd434fee9032e1d02.js +1 -0
- package/assets/esri/core/workers/chunks/{33e4ff228a8c81b99022.js → 4abd3753cd9b80e4d937.js} +1 -1
- package/assets/esri/core/workers/chunks/4bbe1f28f5f16a6bef05.js +1 -0
- package/assets/esri/core/workers/chunks/4c389472b8cdb0c55154.js +1 -0
- package/assets/esri/core/workers/chunks/4e4f747de424941a0bfa.js +1 -0
- package/assets/esri/core/workers/chunks/5529831dd891382c79df.js +1 -0
- package/assets/esri/core/workers/chunks/5736feefa261589b6273.js +1 -0
- package/assets/esri/core/workers/chunks/576248e9ae2654569420.js +1 -0
- package/assets/esri/core/workers/chunks/5acb422fe3cf693d9d4f.js +1 -0
- package/assets/esri/core/workers/chunks/{aeaaff7a4b1a99540f52.js → 5cb26bbaa08114aec5ce.js} +1 -1
- package/assets/esri/core/workers/chunks/661c6324529dd17b297e.js +1 -0
- package/assets/esri/core/workers/chunks/68dd1fd2025c7125ead1.js +1 -0
- package/assets/esri/core/workers/chunks/{89e76de5ae3328d821a4.js → 69f6d5997b8ff1326e39.js} +1 -1
- package/assets/esri/core/workers/chunks/6a8dd8b18b0b825b0c1b.js +1 -0
- package/assets/esri/core/workers/chunks/{a40b6d8b5c73e06e14d4.js → 6c255c029d67423e4dac.js} +1 -1
- package/assets/esri/core/workers/chunks/7446d0dfebf93e86c098.js +1 -0
- package/assets/esri/core/workers/chunks/{688f2dbf784e66082308.js → 74c866e0b66e61751861.js} +1 -1
- package/assets/esri/core/workers/chunks/{3ffda5bf0b91700dc308.js → 78643f116677950ea29a.js} +1 -1
- package/assets/esri/core/workers/chunks/{916b363c342b61ba5461.js → 787c1a8bda7d745633f2.js} +1 -1
- package/assets/esri/core/workers/chunks/7b5f3c79e0605c32b267.js +1 -0
- package/assets/esri/core/workers/chunks/7bbfe9ff352afc566367.js +1 -0
- package/assets/esri/core/workers/chunks/{ac5a6603f7fa78d3e4c8.js → 7e8611cb709f105946f5.js} +1 -1
- package/assets/esri/core/workers/chunks/{05cd33d41d91f8d09633.js → 7fb7493f483cd9878bfa.js} +1 -1
- package/assets/esri/core/workers/chunks/{acfa03c65ba3ca6c5685.js → 8715661a838361d4211a.js} +1 -1
- package/assets/esri/core/workers/chunks/{601e1d020b8115497944.js → 8a485130781b49dbf608.js} +1 -1
- package/assets/esri/core/workers/chunks/{0ccab50877b24f862d6e.js → 8ac2098ecdc40ad41055.js} +1 -1
- package/assets/esri/core/workers/chunks/{a655ebdb4bf0660615a2.js → 8b4e9fd88c0c313416d4.js} +1 -1
- package/assets/esri/core/workers/chunks/{4e544de61f07ca660236.js → 8c12269d26f5a4c753cb.js} +1 -1
- package/assets/esri/core/workers/chunks/8e19629899a5becf8e19.js +1 -0
- package/assets/esri/core/workers/chunks/91dd65cf877c8f2e01a7.js +1 -0
- package/assets/esri/core/workers/chunks/{46b4fb6a7fe4877b0efc.js → 94baa354e50c03b82b25.js} +2 -2
- package/assets/esri/core/workers/chunks/950d4578dc450467404c.js +1 -0
- package/assets/esri/core/workers/chunks/{68be3fb88ca61f82fb90.js → 95dbbddac6581b9d671f.js} +1 -1
- package/assets/esri/core/workers/chunks/98be2f621801e230aa01.js +1 -0
- package/assets/esri/core/workers/chunks/9b051745d24d1f43480b.js +1 -0
- package/assets/esri/core/workers/chunks/9d61740ef8bdcc162be1.js +1 -0
- package/assets/esri/core/workers/chunks/{eb04e1717a1002cda3ab.js → 9f06ec95bdf0d0b52b41.js} +1 -1
- package/assets/esri/core/workers/chunks/{fafb92ca2c5e4b0b2c23.js → a09d2e1e2540921e4717.js} +1 -1
- package/assets/esri/core/workers/chunks/{3b3e519f15ed52c83f0c.js → a49fe94933b65b4b64f8.js} +1 -1
- package/assets/esri/core/workers/chunks/{1819c45655c836b9a8d7.js → a4d3944700f1cc240176.js} +1 -1
- package/assets/esri/core/workers/chunks/{90bdf86f553e2742d67c.js → a7bd5ba4d7d97411fd33.js} +1 -1
- package/assets/esri/core/workers/chunks/{900181f68449d8f82eeb.js → aa1ac7954e4f0fefe15b.js} +1 -1
- package/assets/esri/core/workers/chunks/ac24b4370dc7194a3107.js +1 -0
- package/assets/esri/core/workers/chunks/{b8337492e2b753aefac4.js → ace41659a5ca0e5abfc3.js} +1 -1
- package/assets/esri/core/workers/chunks/{3c0ed15b544df6fb0903.js → b48952e1fb4cb7360dd0.js} +1 -1
- package/assets/esri/core/workers/chunks/b5e7475cc5fbf31289d3.js +1 -0
- package/assets/esri/core/workers/chunks/{f3da30d7300b92bd8bb0.js → befa32b9e7b3fbdd431e.js} +1 -1
- package/assets/esri/core/workers/chunks/{0f617980c7dd9ad0444f.js → bf35927979fc5e7e0478.js} +1 -1
- package/assets/esri/core/workers/chunks/c4ddac23bd649d24f3f2.js +1 -0
- package/assets/esri/core/workers/chunks/{4e6f40cbdb8c508e6df1.js → c5a9e77977e867a75ff2.js} +1 -1
- package/assets/esri/core/workers/chunks/{25f19fc929f25ddd628c.js → c79934cd6883307203f8.js} +1 -1
- package/assets/esri/core/workers/chunks/cddc3e285f763ccf33c2.js +1 -0
- package/assets/esri/core/workers/chunks/d08ff41e2a9bcd58b64a.js +1 -0
- package/assets/esri/core/workers/chunks/d311ff96a5a2791d8cfc.js +1 -0
- package/assets/esri/core/workers/chunks/d62afb71f4ece4283994.js +1 -0
- package/assets/esri/core/workers/chunks/dc1761cba0454fda3cf9.js +1 -0
- package/assets/esri/core/workers/chunks/{4ac1d3e49e242e373a92.js → e0650b1408197d3ac862.js} +1 -1
- package/assets/esri/core/workers/chunks/{3ff6d1ed3c0f1285f3e7.js → e0d9dc97985561320bd4.js} +1 -1
- package/assets/esri/core/workers/chunks/eaddffcc7004101fc230.js +1 -0
- package/assets/esri/core/workers/chunks/eb2652ec48faa78de3c5.js +1 -0
- package/assets/esri/core/workers/chunks/eca44e53bcee9b08d70a.js +1 -0
- package/assets/esri/core/workers/chunks/f00458654c7c34c369ef.js +1 -0
- package/assets/esri/core/workers/chunks/f3cd610084e3f4d8656b.js +1 -0
- package/assets/esri/core/workers/chunks/f47fe4433b05fca5c3ad.js +1 -0
- package/assets/esri/core/workers/chunks/f7bfa3d33b05b250ce33.js +1 -0
- package/assets/esri/core/workers/chunks/f91bc1cb1014e05be763.js +1 -0
- package/assets/esri/core/workers/chunks/{aadfe34a99c9ec7a0e11.js → f9c5aa0bbf23e780fecc.js} +1 -1
- package/assets/esri/core/workers/chunks/f9ff27cfcf0538ac5e26.js +1 -0
- package/assets/esri/core/workers/chunks/{19676b2c5f8b0a5ee680.js → facd1ff23203fed67686.js} +1 -1
- package/assets/esri/core/workers/chunks/{40a584cb952e94326e9e.js → fcb86d24fc7e0666b564.js} +1 -1
- package/assets/esri/libs/pdfjs/wasm/openjpeg_nowasm_fallback.js +1 -0
- package/chunks/Distance2DCalculator-DjIp2uQi.js +1 -1
- package/chunks/Envelope.js +1 -1
- package/chunks/MultiPathImpl.js +1 -1
- package/chunks/OperatorGeodeticArea.js +1 -1
- package/chunks/OperatorShapePreservingLength.js +1 -1
- package/chunks/OperatorShapePreservingProject.js +1 -1
- package/chunks/UnitFactory.js +1 -1
- package/chunks/basis_encoder.js +1 -1
- package/chunks/basis_transcoder.js +1 -1
- package/chunks/index.js +1 -1
- package/chunks/lclayout.js +1 -1
- package/config.d.ts +2 -0
- package/config.js +1 -1
- package/core/ObjectPool.js +1 -1
- package/core/PooledArray.js +1 -1
- package/core/accessorSupport/DefaultsStore.js +1 -1
- package/core/accessorSupport/MultiOriginStore.js +1 -1
- package/core/accessorSupport/Store.js +1 -1
- package/core/accessorSupport/decorators/reader.js +1 -1
- package/core/accessorSupport/decorators/writer.js +1 -1
- package/core/accessorSupport/tracking/SimpleTrackingTarget.js +1 -1
- package/core/workers/WorkerOwner.js +1 -1
- package/core/workers/workerFactory.js +1 -1
- package/core/workers/workers.js +2 -2
- package/core/workers.d.ts +9 -0
- package/form/elements/inputs/DynamicChoiceInput.d.ts +4 -2
- package/geometry/Mesh.js +1 -1
- package/geometry/operators/gx/operatorAlphaShape.js +1 -1
- package/geometry/operators/gx/operatorOffset.js +1 -1
- package/geometry/operators/gx/operatorPolygonSlicer.js +1 -1
- package/geometry/operators/support/jsonConverter.js +1 -1
- package/geometry/support/buffer/BufferPool.js +1 -1
- package/geometry/support/coordsUtils.js +1 -1
- package/geometry/support/curves/bezierCurveUtils.js +1 -1
- package/geometry/support/curves/ellipticArc7Utils.js +1 -1
- package/geometry/support/meshUtils/merge.js +1 -1
- package/geometry/support/meshUtils/rotate.js +1 -1
- package/geometry/support/meshUtils.d.ts +5 -6
- package/geometry/support/polygonExtentClipping.js +1 -1
- package/identity/Credential.js +1 -1
- package/interfaces.d.ts +18 -9
- package/kernel.js +1 -1
- package/layers/AnnotationFeatureLayer.d.ts +2 -2
- package/layers/AnnotationFeatureLayer.js +1 -1
- package/layers/CatalogLayer.d.ts +2 -2
- package/layers/CatalogLayer.js +1 -1
- package/layers/DimensionFeatureLayer.d.ts +2 -2
- package/layers/DimensionFeatureLayer.js +1 -1
- package/layers/FeatureLayer.d.ts +4 -4
- package/layers/FeatureLayer.js +1 -1
- package/layers/GeospatialPDFLayer.d.ts +154 -4
- package/layers/ImageryTileLayer.js +1 -1
- package/layers/Layer.d.ts +2 -0
- package/layers/LineOfSightLayer.d.ts +10 -8
- package/layers/SceneLayer.js +1 -1
- package/layers/SubtypeGroupLayer.d.ts +2 -2
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/ViewshedLayer.d.ts +1 -1
- package/layers/VoxelLayer.js +1 -1
- package/layers/WMSLayer.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFFrame.js +1 -1
- package/layers/geospatialPDF/GeospatialPDFLayerWorker.js +9 -9
- package/layers/geospatialPDF/GeospatialPDFWorkerClient.js +1 -1
- package/layers/geospatialPDF/LGIDictMapFrame.js +1 -1
- package/layers/geospatialPDF/ViewportMeasureFrame.js +1 -1
- package/layers/geospatialPDF/geospatialPDFParserUtils.js +1 -1
- package/layers/graphics/controllers/FeatureTileController3D.js +1 -1
- package/layers/graphics/controllers/I3SOnDemandController.js +1 -1
- package/layers/graphics/data/QueryEngineResult.js +1 -1
- package/layers/graphics/sources/connections/WebSocketConnection.js +1 -1
- package/layers/graphics/sources/parquet/FileProvider.js +1 -1
- package/layers/graphics/sources/support/ParquetSourceWorker.js +1 -1
- package/layers/mixins/{FeatureLayerReload.d.ts → ReloadableLayer.d.ts} +5 -3
- package/layers/mixins/ReloadableLayer.js +2 -0
- package/layers/raster/datasets/BaseRaster.js +1 -1
- package/layers/raster/datasets/GeospatialPDFRaster.js +1 -1
- package/layers/raster/datasets/ImageAuxRaster.js +2 -2
- package/layers/raster/datasets/ImageServerRaster.js +1 -1
- package/layers/raster/datasets/InMemoryRaster.js +1 -1
- package/layers/raster/datasets/MRFRaster.js +1 -1
- package/layers/raster/datasets/TIFFRaster.js +1 -1
- package/layers/raster/datasets/WCSRaster.js +1 -1
- package/layers/raster/formats/ImageCanvasDecoder.js +1 -1
- package/layers/raster/formats/RasterCodec.js +1 -1
- package/layers/raster/formats/TiffDecoder.js +1 -1
- package/layers/raster/formats/Zlib.js +1 -1
- package/layers/raster/functions/stretchUtils.js +1 -1
- package/layers/raster/functions/vectorFieldUtils.js +1 -1
- package/layers/support/FieldsIndex.js +1 -1
- package/layers/support/LabelClass.d.ts +3 -2
- package/layers/support/PortalItemData.d.ts +31 -8
- package/layers/support/RasterWorker.js +1 -1
- package/layers/support/featureReductionProperties.js +1 -1
- package/layers/support/kmlUtils.js +1 -1
- package/layers/support/types.d.ts +4 -1
- package/layers/video/VideoController.js +10 -10
- package/libs/maquette/projection.js +1 -1
- package/networks/UtilityNetworkTraceAnalysis.js +1 -1
- package/package.json +5 -5
- package/popup/FeatureModel.js +1 -1
- package/popup/FeaturesModel.js +1 -1
- package/portal/Portal.js +1 -1
- package/request/process.js +1 -1
- package/request/types.d.ts +7 -0
- package/rest/knowledgeGraph/ObjectValue.js +1 -1
- package/rest/knowledgeGraphService.js +1 -1
- package/rest/networks/trace.js +1 -1
- package/rest/query/executeQuery.js +1 -1
- package/smartMapping/raster/renderers/shadedRelief.js +1 -1
- package/smartMapping/renderers/univariateColorSize.js +1 -1
- package/smartMapping/statistics/support/statsWorker.js +1 -1
- package/smartMapping/statistics/support/utils.js +1 -1
- package/smartMapping/support/clusterUtils.js +1 -1
- package/statistics/utils.js +1 -1
- package/symbols/cim/CIMCursor.js +1 -1
- package/symbols/cim/CIMSymbolDrawHelper.js +1 -1
- package/symbols/cim/cimAnalyzer.js +1 -1
- package/symbols/support/ElevationInfo.d.ts +4 -3
- package/undoredo/support/Services.js +1 -1
- package/views/2d/engine/vectorTiles/buckets/SymbolBucket.js +2 -2
- package/views/2d/engine/webgl/shaderGraph/techniques/labels/LabelMeshWriter.js +1 -1
- package/views/2d/grid/GridView2D.js +1 -1
- package/views/2d/layers/FeatureLikeLayerView2D.js +1 -1
- package/views/2d/layers/features/sources/strategies/FeatureHybridTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/FeaturePagedTileLoadStrategy.js +1 -1
- package/views/2d/layers/features/sources/strategies/FeatureSnapshotLoadStrategy.js +1 -1
- package/views/2d/viewpointUtils.js +1 -1
- package/views/3d/analysis/AreaMeasurement/support/MeasurementData.js +1 -1
- package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightController.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightItemTool.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightPlacementController.js +1 -1
- package/views/3d/analysis/LineOfSight/{LineOfSightRootPlugin.js → LineOfSightPlacementRootPlugin.js} +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/LineOfSight/types.d.ts +14 -3
- package/views/3d/analysis/LineOfSightAnalysisView3D.d.ts +39 -13
- package/views/3d/analysis/Viewshed/ViewshedEditTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedSubTool.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedTool.js +1 -1
- package/views/3d/analysis/Viewshed/types.d.ts +7 -0
- package/views/3d/analysis/ViewshedAnalysisView3D.d.ts +43 -15
- package/views/3d/input/handlers/KeyboardNavigation.js +1 -1
- package/views/3d/interactive/editingTools/ManipulatedObject3DGraphic.js +1 -1
- package/views/3d/interactive/editingTools/draw/DrawGraphicTool3D.js +1 -1
- package/views/3d/interactive/editingTools/reshape/ReshapeOperation.js +1 -1
- package/views/3d/interactive/editingTools/transform/ExtentTransformTool.js +1 -1
- package/views/3d/interactive/editingTools/transform/ScaleRotateTransform.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/layers/graphics/Graphics3DCore.js +1 -1
- package/views/3d/layers/graphics/Graphics3DElevationAlignment.js +1 -1
- package/views/3d/layers/graphics/Graphics3DGraphic.js +1 -1
- package/views/3d/layers/graphics/Graphics3DIconSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/Graphics3DPathSymbolLayer.js +1 -1
- package/views/3d/layers/graphics/SpatialIndex2D.js +1 -1
- package/views/3d/layers/i3s/I3SNode.js +1 -1
- package/views/3d/layers/i3s/I3SUtil.js +1 -1
- package/views/3d/layers/i3s/I3SViewportQueries.js +1 -1
- package/views/3d/layers/i3s/LayerElevationProvider.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3D.js +1 -1
- package/views/3d/layers/support/FeatureTileFetcher3DDebugger.js +1 -1
- package/views/3d/layers/support/ImageHighlightHelper3D.js +1 -1
- package/views/3d/layers/support/StageLayerElevationProvider.js +1 -1
- package/views/3d/state/helpers/SceneIntersectionHelper.js +1 -1
- package/views/3d/support/MemoryController.js +1 -1
- package/views/3d/support/elevationUpdateExtentUtils.js +1 -1
- package/views/3d/support/elevationUpdateUtils.js +1 -1
- package/views/3d/support/pointsOfInterest/Focus.js +1 -1
- package/views/3d/support/sphereExtentUtils.js +2 -0
- package/views/3d/terrain/OverlayFramebufferObject.js +1 -1
- package/views/3d/terrain/OverlayRenderer.js +1 -1
- package/views/3d/terrain/PatchRenderData.js +1 -1
- package/views/3d/terrain/TerrainData.js +1 -1
- package/views/3d/terrain/terrainUtils.js +1 -1
- package/views/3d/webgl-engine/effects/RenderPluginManager.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccluded.js +1 -1
- package/views/3d/webgl-engine/lib/BindParameters.js +1 -1
- package/views/3d/webgl-engine/lib/ManagedTexture.js +1 -1
- package/views/3d/webgl-engine/lib/PathBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/PathCapBuilder.js +1 -1
- package/views/3d/webgl-engine/lib/PathEvaluator.js +1 -1
- package/views/3d/webgl-engine/lib/PathExtruder.js +1 -1
- package/views/3d/webgl-engine/lib/PathProfile.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/pathGeometryUtils.js +1 -1
- package/views/3d/webgl-engine/materials/internal/MaterialUtil.js +1 -1
- package/views/3d/webgl-engine/materials/renderers/PerBufferData.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/ToolViewManager.js +1 -1
- package/views/draw/DrawOperation.js +1 -1
- package/views/draw/support/InteractiveHandle.js +1 -1
- package/views/draw/support/Reshape.js +1 -1
- package/views/draw/support/createUtils.js +1 -1
- package/views/draw/support/editingSessionUtils.js +1 -1
- package/views/draw/support/managers/InteractiveHandleManager.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/SetAllVertexPositions.js +1 -1
- package/views/interactive/editGeometry/operations/UndoGroup.js +1 -1
- package/views/interactive/options/TooltipOptions.d.ts +2 -0
- package/views/interactive/sketch/SketchTooltipOptions.d.ts +2 -0
- package/views/interactive/sketch/constraintUtils.js +1 -1
- package/views/interactive/snapping/SnappingDragPipelineStep.js +1 -1
- package/views/interactive/tooltip/components/TooltipEditableField.js +1 -1
- package/views/layers/LayerView.js +1 -1
- package/views/layers/LineOfSightLayerView.d.ts +35 -13
- package/views/layers/SketchLayerView.d.ts +1 -0
- package/views/layers/ViewshedLayerView.d.ts +36 -12
- package/views/webgl/Program.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/widgets/BasemapToggle/BasemapToggleViewModel.js +1 -1
- package/widgets/BatchAttributeForm/inputs/support/DynamicChoiceController.js +1 -1
- package/widgets/BatchAttributeForm.js +1 -1
- package/widgets/Directions.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.d.ts +10 -1
- package/widgets/Editor/legacy/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor.d.ts +10 -1
- package/widgets/ElevationProfile/support/chartUtils.js +1 -1
- package/widgets/FeatureTable/FeatureTableViewModel.js +1 -1
- package/widgets/FeatureTable/support/FeatureStore.js +1 -1
- package/widgets/FeatureTable/support/GroupColumnTemplate.js +1 -1
- package/widgets/FeatureTable/support/TableTemplate.js +1 -1
- package/widgets/HistogramRangeSlider.d.ts +2 -2
- package/widgets/HistogramRangeSlider.js +1 -1
- package/widgets/Legend.d.ts +1 -0
- package/widgets/Print.js +1 -1
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.d.ts +5 -2
- package/widgets/ScaleRangeSlider/ScaleRangeSliderViewModel.js +1 -1
- package/widgets/ScaleRangeSlider.js +1 -1
- package/widgets/Slice.js +1 -1
- package/widgets/UtilityNetworkTraceAnalysis/UtilityNetworkTraceAnalysisViewModel.js +1 -1
- package/widgets/ValuePicker/ValuePickerBaseComponent.d.ts +5 -1
- package/widgets/ValuePicker/ValuePickerCollection.d.ts +2 -0
- package/widgets/ValuePicker/ValuePickerCombobox.d.ts +7 -1
- package/widgets/ValuePicker/ValuePickerLabel.d.ts +7 -1
- package/widgets/ValuePicker/ValuePickerSlider.d.ts +2 -0
- package/widgets/ValuePicker/ValuePickerSliderVisibleElements.d.ts +5 -1
- package/widgets/ValuePicker/ValuePickerVisibleElements.d.ts +5 -1
- package/widgets/ValuePicker/types.d.ts +2 -0
- package/widgets/support/SelectionList/SelectionListViewModel.js +1 -1
- package/widgets/support/SelectionList.js +1 -1
- package/widgets/support/componentsUtils.js +1 -1
- package/assets/esri/core/workers/chunks/024b44c0c8876627f904.js +0 -1
- package/assets/esri/core/workers/chunks/02c5d027bdaee67869cf.js +0 -1
- package/assets/esri/core/workers/chunks/03261b9451e293a0fac8.js +0 -1
- package/assets/esri/core/workers/chunks/037a8cc19debbaaa4e10.js +0 -1
- package/assets/esri/core/workers/chunks/0c8c01097847617261b9.js +0 -1
- package/assets/esri/core/workers/chunks/0d931c7579b6409a696d.js +0 -1
- package/assets/esri/core/workers/chunks/12c154342fff876f2f1e.js +0 -1
- package/assets/esri/core/workers/chunks/1c65ab9ed611c322ce27.js +0 -1
- package/assets/esri/core/workers/chunks/1e11d2e97d17685b878a.js +0 -1
- package/assets/esri/core/workers/chunks/1f339247b68b061ab0a4.js +0 -1
- package/assets/esri/core/workers/chunks/21ddb26526bcb2b122c3.js +0 -1
- package/assets/esri/core/workers/chunks/22e8c0aad2fe75943865.js +0 -1
- package/assets/esri/core/workers/chunks/2eae542fe7f0f6576ac1.js +0 -1
- package/assets/esri/core/workers/chunks/408e81c8f1eff8a7b379.js +0 -1
- package/assets/esri/core/workers/chunks/444e5f214abce3d607cd.js +0 -1
- package/assets/esri/core/workers/chunks/46a7da93a63663878583.js +0 -1
- package/assets/esri/core/workers/chunks/4a1e23e021bac37a88ab.js +0 -1
- package/assets/esri/core/workers/chunks/4c4117e28ea358a32088.js +0 -1
- package/assets/esri/core/workers/chunks/54b18559280a7d2a8d93.js +0 -1
- package/assets/esri/core/workers/chunks/59b216b60464611742d4.js +0 -1
- package/assets/esri/core/workers/chunks/5bfea0c55aca826de536.js +0 -1
- package/assets/esri/core/workers/chunks/62ac588f7dd1d24d0c9d.js +0 -1
- package/assets/esri/core/workers/chunks/62c8c9ad09e0166207fd.js +0 -1
- package/assets/esri/core/workers/chunks/62d6e101e9bd9557a410.js +0 -1
- package/assets/esri/core/workers/chunks/6558488ea96620439f34.js +0 -1
- package/assets/esri/core/workers/chunks/665e31c494d2af505acc.js +0 -1
- package/assets/esri/core/workers/chunks/6f4e6022a52de0c54aab.js +0 -1
- package/assets/esri/core/workers/chunks/7267b17de212207142c9.js +0 -1
- package/assets/esri/core/workers/chunks/7ef182e24cad50815b4e.js +0 -1
- package/assets/esri/core/workers/chunks/8293600f94553afc8c38.js +0 -1
- package/assets/esri/core/workers/chunks/8431ca60ad33d594e323.js +0 -1
- package/assets/esri/core/workers/chunks/876f7633c15f1e31078d.js +0 -1
- package/assets/esri/core/workers/chunks/8ca9648eacb894283513.js +0 -1
- package/assets/esri/core/workers/chunks/91ebb2ccab1889eb7e81.js +0 -1
- package/assets/esri/core/workers/chunks/9ce91a909eccc4dfe388.js +0 -1
- package/assets/esri/core/workers/chunks/9e1a3b6a08c96dcefdde.js +0 -1
- package/assets/esri/core/workers/chunks/9e3e442a9874ed23a043.js +0 -1
- package/assets/esri/core/workers/chunks/ad76f7ab2f3e6d5a5b3c.js +0 -1
- package/assets/esri/core/workers/chunks/aff32980d91dab07dfb7.js +0 -1
- package/assets/esri/core/workers/chunks/bbf993dba74850bbf9d7.js +0 -1
- package/assets/esri/core/workers/chunks/d8f1cefcad02d7353d4b.js +0 -1
- package/assets/esri/core/workers/chunks/d938987344bce83cc660.js +0 -1
- package/assets/esri/core/workers/chunks/ddf0671976648f621269.js +0 -1
- package/assets/esri/core/workers/chunks/de02f60258e6985ef676.js +0 -1
- package/assets/esri/core/workers/chunks/e10b57aefcc89671116e.js +0 -1
- package/assets/esri/core/workers/chunks/e65dfa19f030ec298437.js +0 -1
- package/assets/esri/core/workers/chunks/f122c18af10e56f9ec2b.js +0 -1
- package/assets/esri/core/workers/chunks/f92364afaefbac7e8f77.js +0 -1
- package/assets/esri/core/workers/chunks/fd9663952d5a94f3a83f.js +0 -1
- package/assets/esri/core/workers/chunks/fe9879ecd69ac4329291.js +0 -1
- package/layers/mixins/FeatureLayerReload.js +0 -2
- /package/views/3d/analysis/LineOfSight/{lineOfSightPlacementUtils.js → placementUtils.js} +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{toConst as n}from"../../../../core/compilerUtils.js";import r from"../../../../core/Error.js";import i from"../../../../core/Handles.js";import has from"../../../../core/has.js";import a from"../../../../core/Logger.js";import{onAbortOrThrow as o,throwIfAborted as s}from"../../../../core/promiseUtils.js";import{QueueProcessor as c}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import{getMetersPerUnitForSR as u}from"../../../../core/units.js";import d from"../../../../geometry/SpatialReference.js";import{set as f,create as p,expandWithAABB as m,expandWithRect as ee,negativeInfinity as h}from"../../../../geometry/support/aaBoundingBox.js";import{copy as te,negativeInfinity as g,create as ne,expandWithRect as re}from"../../../../geometry/support/aaBoundingRect.js";import{isWebMercator as _,isWGS84 as v}from"../../../../geometry/support/spatialReferenceUtils.js";import{normalizeColumnPath as y,readParquetFileAttribute as b}from"../../../parquet.js";import{convertToGeometry as x}from"../../featureConversionUtils.js";import{getFieldNamesFromStatistics as S}from"../../data/attributeSupport.js";import{getQueryResultExtent as C,getQueryBoundingRects as w,QueryEngine as T}from"../../data/QueryEngine.js";import{queryCapabilities as ie}from"../../data/QueryEngineCapabilities.js";import{QueryEngineResult as E}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as D}from"../../data/queryUtils.js";import{createFileProvider as O}from"../parquet/createFileProvider.js";import{readFieldStatistic as k}from"../parquet/ParquetFileStatistics.js";import{createDrawingInfo as ae}from"./clientSideDefaults.js";import{getParquetFileId as oe,getParquetRowId as se,getParquetObjectId as ce}from"./parquetIdUtils.js";import A from"../../../support/Field.js";import j from"../../../support/FieldsIndex.js";import{isNumericField as M}from"../../../support/fieldUtils.js";import{fromParquetGeometryEncodingJSON as N}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as P,fromParquetJSONGeometryType as F,toParquetJSONGeometryType as I}from"../../../support/parquetUtils.js";import{loadParquetModule as L}from"../../../../libs/librust-parquet/loadParquetModule.js";import{utc as R}from"../../../../time/constants.js";import{FeatureStoreQueryAdapter as z}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as B}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as V}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as H}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as U}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const W=new z,G=`__OBJECTID`,K=8e3;class le{constructor(e,t){this._files=e,this._createFileStream=t,this._fileIndex=0,this._streamIndex=0,this._streams=[],this._pending=new Set,this._resolvedCount=0}async next(e){for(await this._fill(e);this._pending.size>0;){s(e),await this._fill(e);let t=await ue(this._pending);if(this._pending.delete(t.read),this._resolvedCount++,t.chunk!=null)return t.chunk}return null}async _fill(e){for(this._removeDone();this._pending.size<8;){let t=this._getOrCreateNextStream(e);if(t==null)return;this._pending.add(t.read(e))}}_getOrCreateNextStream(e){let t=this._resolvedCount>=8?8:2;if(this._fileIndex<this._files.length&&this._streams.length<t){let t=this._files[this._fileIndex++],n=new de(t.id,this._createFileStream(t,e));return this._streams.push(n),n}return this._getNextStream()}_getNextStream(){let e=this._streams.length;for(let t=0;t<e;t++){let n=(this._streamIndex+t)%e,r=this._streams[n];if(r.canRead)return this._streamIndex=(n+1)%e,r}return null}_removeDone(){let e=this._streamIndex;for(let t=this._streams.length-1;t>=0;t--)this._streams[t].done&&(this._streams.splice(t,1),t<e&&e--);this._streamIndex=this._streams.length>0?e%this._streams.length:0}}function ue(e){return Promise.race(Array.from(e,async e=>({read:e,chunk:await e})))}class de{constructor(e,t){this._fileId=e,this._stream=t,this._readCount=0,this._reachedEnd=!1}get canRead(){return!this._reachedEnd}get done(){return this._reachedEnd&&this._readCount===0}async read(e){this._readCount++;try{let t=await(await this._stream).next(e);return t==null?(this._reachedEnd=!0,null):{fileId:this._fileId,chunk:t}}finally{this._readCount--}}}class fe{constructor(){this._hasZ=!1,this._hasM=!1,this._queue=new c({concurrency:4,process:(e,t)=>this._executeQuery(e,t)}),this._streams=new Map,this._streamIdCounter=0,this._indexMap={},this._handles=new i}async load(e){let t=e.spatialReference?d.fromJSON(e.spatialReference):void 0;if(t&&!t.isWGS84&&!t.isWebMercator)throw new r(`parquet:unsupported-projection`,`Only WGS84 and Web Mercator are supported`);this._customParameters=e.customParameters,this._loadParameters=e,await this._updateProvider(O(e.provider,null,()=>this._customParameters));let n=await this._provider.getMetadata(),i=await P(n,{fields:e.fields?.map(e=>A.fromJSON(e)),geometryEncoding:e.geometryEncoding?N(e.geometryEncoding):null,geometryType:e.geometryType?F(e.geometryType):null,displayOptimization:e.displayOptimization,spatialReference:t});if(this._hasZ=!!n?.hasZ,this._hasM=!!n?.hasM,!i.fields)throw new r(`parquet:unsupported`,`Fields must be defined`);let o;if(i.spatialReference&&i.geometryType){if(!i.spatialReference)throw new r(`parquet:unsupported`,`SpatialReference must be defined`);if(!i.spatialReference.isGeographic&&!i.spatialReference.isWebMercator)throw new r(`parquet:unsupported-projection`,`Only WGS84 and Web Mercator are supported`);i.spatialReference.isGeographic&&!i.spatialReference.isWGS84&&(a.getLogger(`parquet:unsupported-projection`).warn(`Found a geographic projection that is not WGS84. Handling as WGS84.`,{spatialReference:i.spatialReference}),i.spatialReference=d.WGS84),o={geometry:i.geometryEncoding?{geometryType:I(i.geometryType),spatialReference:i.spatialReference.toJSON(),encoding:i.geometryEncoding.toJSON()}:null,displayOptimization:i.displayOptimization}}this.setCustomParameters(e.customParameters),this._displayOptimization=i.displayOptimization,await this._provider.updateGeometryInfo(o),this._capabilities=$(await this._getFileStatistics(),this._hasZ,this._hasM);let s=await this._provider.getFiles();if(!s.length)return{layerDefinition:{},capabilities:$(null,this._hasZ,this._hasM)};let c=await s[0].file;i.file=c;let{fields:l}=i;if(l==null)throw new r(`parquet-layer:missing-metadata`,`Unable to create parquet source: cannot infer fields`,l);l.push(new A({name:G,type:`oid`,alias:G}));for(let e of l){let t=c.getColumnId(e.name);t!=null&&(this._indexMap[e.name]=t)}let u=j.fromLayerJSON({fields:l.map(e=>e.toJSON()),dateFieldsTimeReference:{timeZoneIANA:`UTC`}});this._fieldsIndex=u;let f=I(i.geometryType??`point`);return this._metadata=H.createFeature({fieldsIndex:u.toJSON(),geometryType:f,hasZ:this._hasZ,hasM:this._hasM,featureIdInfo:{type:`object-id`,fieldName:G},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:i.spatialReference,outSpatialReference:null,attributeSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:R}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:f,featureIdInfo:{type:`object-id`,fieldName:G},hasM:this._hasM,hasZ:this._hasZ,spatialReference:i.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},this._fullExtent=n?.extent?n.extent:await this._tryDeriveParquetFullExtent(i),{capabilities:this._capabilities,layerDefinition:{fields:i.fields?.map(e=>e.toJSON()),drawingInfo:ae(f),extent:this._fullExtent??void 0,geometryType:f,hasZ:this._hasZ,hasM:this._hasM,geometryEncoding:i.geometryEncoding?.toJSON(),displayOptimization:i.displayOptimization}}}destroy(){this._provider.destroy(),this._queue.destroy();for(let{handle:e}of this._streams.values())e.remove();this._streams.clear(),this._indexMap={},this._handles.removeAll()}async reload(e){this.destroy(),await this.load(e)}set remoteClient(e){this._source=e.createInvokeProxy(``)}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async updateFileProvider(e){this._loadParameters={...this._loadParameters,provider:e};let t=O(e,this._provider.getGeometryInfo(),()=>this._customParameters);await this._updateProvider(t)}async getDiagnosticsSnapshot(){let e=await this._provider.getFiles();return{files:await Promise.all(e.map(e=>e.getDiagnosticsSnapshot()))}}async getColumnIndex(e){return(await this._getFileInfoById(e.fileId)).getColumnIndex(e.rowGroupIndex,e.columnIndex)}async getOffsetIndex(e){return(await this._getFileInfoById(e.fileId)).getOffsetIndex(e.rowGroupIndex,e.columnIndex)}async queryFeatures(e,t){let n=await D(e,null,this._queryEngineParams.spatialReference);return this._validateQuery(n),we(n)||(n.resultRecordCount=n.resultRecordCount?Math.min(n.resultRecordCount,K):K,n.resultOffset=n.resultOffset??0),n.outStatistics?this._queryStatistics(n,t):(n.returnDistinctValues&&(n.returnGeometry=void 0),(await this._enqueueQuery(n,t)).createQueryResponse())}async queryFeatureCount(e,t){let n=await D(e,null,this._queryEngineParams.spatialReference);return this._validateQuery(n),!q(n)&&!n.returnDistinctValues&&!n.groupByFieldsForStatistics?.length&&!n.outStatistics?.length?this._getFeatureCount():(n.returnDistinctValues||(n.outFields=void 0),n.returnGeometry=void 0,(await this._enqueueQuery(n,t)).createQueryResponseForCount())}async queryObjectIds(e,t){let n=await D(e,null,this._queryEngineParams.spatialReference);return this._validateQuery(n),q(n)?(n.resultRecordCount=n.resultRecordCount?Math.min(n.resultRecordCount,8e3):8e3,n.resultOffset=n.resultOffset??0,n.returnGeometry=void 0,n.outFields=void 0,n.returnDistinctValues=void 0,(await this._enqueueQuery(n,t)).items.map(e=>e.getObjectId())):Array.from({length:await this._getFeatureCount()},(e,t)=>t)}async queryAttributeBins(e,t={}){throw new r(`parquet:unsupported`,`queryAttributeBins not supported.`)}async queryExtent(e,t){let r=await D(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!q(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};let i=n(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;let a=f(p(),h),o=p(),s=await this._enqueueQuery(r,t),c=0;for(let e of s.items)e.getBounds(o)&&(m(a,o),c+=1);let l=C(a,i,r.outSR?n(r.outSR):i.toJSON(),i,!1);return{count:c,extent:l}}async queryStream(e,t){if(!t.signal)throw Error(`InternalError: AbortSignal must be passed`);let n=await this._getCandidateFiles(e),r=new le(n,async(t,n)=>{let r=await t.file,i=await this._createParquetDisplayQuery(r,t.id,e);return r.executeQuery(i,K,n)}),i=this._streamIdCounter++,a=o(t.signal,e=>{let t=this._streams.get(i);t!=null&&(t.handle.remove(),this._streams.delete(i))});return this._streams.set(i,{stream:r,handle:a}),i}async getStreamNext(e,t){if(!t.signal)throw Error(`InternalError: AbortSignal must be passed`);let n=this._streams.get(e);if(!n)return{result:null};let r=await n.stream.next(t.signal);if(r==null)return n.handle.remove(),this._streams.delete(e),{result:null};let i=r.chunk.serialize().buffer,a={fileId:r.fileId,buffer:i};return i instanceof ArrayBuffer?{result:a,transferList:[i]}:{result:a}}async getStreamNextFeatures(e,t){let{result:n}=await this.getStreamNext(e,t);if(n==null)return null;let r=(await L()).ParquetChunk.deserialize(new Uint8Array(n.buffer)),i=new U(this._metadata,this._indexMap,r,n.fileId),a=[];for(;i.next();){let e=x(i.readGeometryWorldSpace(),i.geometryType,i.hasZ,i.hasM),t=i.readAttributes();a.push({attributes:t,geometry:e})}return{features:a}}async createPatch(e,t,n,r,i){if(!i.signal)throw Error(`InternalError: AbortSignal must be passed`);return(await(await(await this._getFileInfoById(e)).file).createChunkPatch(t,n,r,i.signal)).serialize().buffer}async _updateProvider(e){let t=this._provider;this._handles.removeAll(),this._provider=e,this._handles.add([e.events.on(`rangeRead`,e=>{this._source.onRangeRead(e)}),e.events.on(`sourceChanged`,async()=>{await this.reload(this._loadParameters),await this._source.onSourceChange()})]),await t?.destroy()}async _getCandidateFiles(e){let t=await this._provider.getFiles(),n=await this._getSpatialFilePruning(e);if(n==null)return t;let r=t.filter(e=>this._mayIncludeFileForSpatialPruning(e,n));return n.type===`xz`?Ce(r,n):r}async _queryStatistics(e,t){let n=await D({...e},null,this._queryEngineParams.spatialReference);if(n.returnGeometry=void 0,ve(n,this._fieldsIndex)){let e=await this._getStatisticsFromFiles(n);if(e)return e}return(await this._enqueueQuery(n,t)).createQueryResponse()}async _getStatisticsFromFiles(e){let t=await this._provider.getFiles(),n={},r=[];for(let i of e.outStatistics??[]){let e=xe(i,t);if(!e.available)return null;n[i.outStatisticFieldName]=e.value,r.push(be(i,this._fieldsIndex))}return{fields:r,features:[{attributes:n}]}}async _getSpatialFilePruning(e){if(e.type!==`tile`&&(e.type!==`arcade`||e.extent==null))return null;let t=this._displayOptimization?.index;if(t==null)return null;let n=e.outSpatialReference.wkid;if(t.wkid==null||n==null)return null;let r=t.wkid,i=await L();switch(t.type){case`xz`:return{type:`xz`,fieldName:y(t.code),intersects:(a,o)=>i.queryIntersectsXZStatistics(t.fullExtent,e.extent,n,r,t.maxLevel,a,o)};case`z`:return{type:`xy`,xFieldName:y(t.xColumn),yFieldName:y(t.yColumn),intersects:(t,a,o,s)=>i.queryIntersectsXYStatistics(e.extent,n,r,t,a,o,s)}}}_mayIncludeFileForSpatialPruning(e,t){switch(t.type){case`xz`:{let n=Z(e,t);return n?.type===`null-only`?!1:n?.type!==`bounds`||t.intersects(n.minValue,n.maxValue)}case`xy`:{let n=e.statistics.statistics.get(t.xFieldName),r=e.statistics.statistics.get(t.yFieldName);return n?.type===`null-only`||r?.type===`null-only`?!1:n?.type!==`bounds`||r?.type!==`bounds`||t.intersects(n.minValue,n.maxValue,r.minValue,r.maxValue)}}}async _tryDeriveParquetFullExtent(n){if(!n.spatialReference)return null;if(this._fullExtent==null&&n.geometryEncoding?.type===`location`){let r=await this._provider.getFiles(),{xField:i,yField:a}=n.geometryEncoding,o=f(p(),h),s=!1;for(let n of r){let r=await n.file;for(let n of r.rowGroups()){let r={stack:[],error:void 0,hasError:!1};try{let t=e(r,n.columnDescriptorForAttribute(i),!1),c=e(r,n.columnDescriptorForAttribute(a),!1),l=k(t),u=k(c);if(l?.type===`bounds`&&u?.type===`bounds`){let e=[l.minValue,u.minValue,l.maxValue,u.maxValue];ee(o,e),s=!0}n.free()}catch(e){r.error=e,r.hasError=!0}finally{t(r)}}}return s?{xmin:o[0],ymin:o[1],xmax:o[3],ymax:o[4],spatialReference:n.spatialReference?.toJSON()}:null}return null}async _getFileInfoById(e){let t=await this._provider.getFiles();for(let n of t)if(n.id===e)return n;throw Error(`InternalError: File ${e} does not exist`)}async _getFileStatistics(){return{featureCount:await this._getFeatureCount(),byteLength:await this._getByteLength()}}async _getFile(e){return(await this._getFileInfoById(e)).file}async _createParquetQuery(e,t,n,r,i){let a=(await L()).Query.new();n!=null&&a.setPreFilterStart(n),r!=null&&a.setPreFilterCount(r),i!=null&&a.setPostFilterCount(i);let o=await this._getRequiredFields(e);a.setOutFields(o),(e.geometry||e.returnGeometry)&&a.setReturnGeometry(!0),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM);let s=this._tryGetGeneralizedGeometryResolution(e);s!=null&&a.setSourceResolution(s);let c=e.geometry?.spatialReference??this._queryEngineParams.spatialReference,l=c.wkid;if(e.geometry&&(_(c)||v(c))){let t=te(ne(),g);for(let n of w(e.geometry))re(t,n);a.setOutSpatialReference(l),a.setExtent({xmin:t[0],ymin:t[1],xmax:t[2],ymax:t[3]})}if(e.where){let{id:n,file:r}=t;await this._setWhereClause(a,await r,n,e.where)}return a}async _createParquetDisplayQuery(e,t,n){let r=(await L()).Query.new();if(n.type===`tile`){r.setExtent(n.extent),r.setQuantizationTransform(n.transform);let e=this._sourceResolution(n.resolution,n.outSpatialReference);e!=null&&r.setSourceResolution(e)}else n.type===`arcade`&&n.extent!=null&&r.setExtent(n.extent);return r.setOutFields(n.outFields.filter(e=>this._indexMap[e]!=null)),r.setOutSpatialReference(n.outSpatialReference.wkid),r.setReturnGeometry(n.returnGeometry),r.setReturnZ(n.returnZ),r.setReturnM(n.returnM),n.where&&await this._setWhereClause(r,e,t,n.where),r}async _getFeatureCount(){return(await this._provider.getFiles()).map(e=>e.statistics.rowCount).reduce((e,t)=>e+t,0)}async _getByteLength(){return(await this._provider.getFiles()).map(e=>e.statistics.byteSize).reduce((e,t)=>e+t,0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new r(`parquet:unsupported`,`Statistics queries are not supported`,{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new r(`parquet:unsupported`,`Queries using orderBy are not supported`,{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new r(`parquet:unsupported`,`Queries using returnDistinctValues are not supported`,{query:e})}async _setWhereClause(e,t,n,i){let a=this._indexMap,o=this._fieldsIndex,s={getAttribute(e,r){let i=a[r];if(i==null){if(o.get(r)?.name===`__OBJECTID`){let t=e.row+e.rowGroupStart;return ce(n,t)}return null}let s=o.get(r);return b(t,e.rowGroup,e.row,i,s.type)}},c=await l(i,this._fieldsIndex);if(!c.isStandardized)throw new r(`sql-parse-error`,`expression is not standardized`);let u=(e,t,n)=>c.testFeatureCompiled({rowGroup:e,row:t,rowGroupStart:n},s,null),d=c.fieldNames.map(e=>o.get(e)).filter(e=>e&&this._indexMap[e?.name]!=null);e.setWhere(i),e.setWhereEvaluator(u),e.setWhereFields(d.map(e=>e.name))}async*_streamFeatures(e,t,n,r,i){let a=await this._provider.getFiles(),o=0;for(let s of a){let a=o,c=o+s.statistics.rowCount;if(o+=s.statistics.rowCount,t!=null&&t>=c)continue;let l=t==null?null:Math.max(t-a,0),u=n;if(n!=null){let e=t??0,r=e+n;u=Math.max(Math.min(r,c)-Math.max(e,a),0)}if(u===0)continue;let d=await this._createParquetQuery(e,s,l,u,r),f=await(await s.file).executeQuery(d,K),p=async()=>{let e=await f.next(i);if(!e)return null;let t=new U(this._metadata,this._indexMap,e,s.id);return X([new B(t,null,0,!1)],this._queryEngineParams)},m=await p();for(;m!=null;)yield m,m=await p()}}async _queryFeaturesWithQueryEnginePagination(e,t){let n=[],r=this._streamFeatures(e,null,null,null,t),i=await r.next();for(;!i.done;){let a=await i.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(let e of a)n.push(e);i=await r.next()}return n}async _queryFeaturesWithUpfrontPagination(e,t){let n=e.resultOffset??0,r=e.resultRecordCount??K,i,a,o;ge(e)?_e(e)||(o=n+r):(n&&=(i=n,0),a=e.resultRecordCount);let s=[],c=this._streamFeatures(e,i,a,o,t),l=await c.next();for(;!l.done&&r>0;){let i=await l.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(let e of i)if(n>0)n--;else if(s.push(e),--r<=0)return s;l=await c.next()}return s}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){if(e.objectIds?.length){let n=new Map;for(let t of e.objectIds){let e=oe(t),r=se(t),i=n.get(e);i||(i=[],n.set(e,i)),i.push(r)}let r=[];for(let[i,a]of n.entries()){let n=await this._executeFileIdQuery(e,i,a,t);for(let e of n)r.push(e)}return new E(r,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:W,featureIdInfo:this._queryEngineParams.featureIdInfo})}if(e.where===`1=1`&&(e.where=null),e.resultOffset??=0,e.resultRecordCount??=await this._getFeatureCount(),e.resultRecordCount>2e7&&!(this._displayOptimization&&e.geometry))throw new r(`parquet:cannot-execute-query`,`Unable to execute query, dataset is too large.`);let n=!!e.orderByFields?.length||!!e.outStatistics?.length||!!e.returnDistinctValues,i=n?await this._queryFeaturesWithQueryEnginePagination(e,t):await this._queryFeaturesWithUpfrontPagination(e,t);return n||(e.resultOffset=0),new E(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:W,featureIdInfo:this._queryEngineParams.featureIdInfo})}async _executeFileIdQuery(e,t,n,r){let i=await this._getRequiredFields(e),a=(await L()).Query.new();a.setOutFields(i),a.setReturnGeometry(!!e.returnGeometry),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM),a.setIds(new Uint32Array(n));let o=await(await this._getFile(t)).executeQuery(a,K,r),s=await o.next(r),c=0,l=[];for(;s!=null;){let e=new U(this._metadata,this._indexMap,s,t),n=new B(e,null,c++,!1);l.push(n),s=await o.next(r)}return X(l,this._queryEngineParams).executeQueryForOpaqueFeatures(e,r)}async _getRequiredFields(e){let t=new Set;if(e.outStatistics)for(let n of S(this._fieldsIndex,e.outStatistics,e.groupByFieldsForStatistics))t.add(n);else if(e.outFields)for(let n of e.outFields)t.add(n);return(t.has(`*`)?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>this._indexMap[e]!=null)}_tryGetGeneralizedGeometryResolution(e){if(!this._displayOptimization)return null;let t=e.outSR??this._queryEngineParams.spatialReference;if(!_(t)&&!v(t))return null;let n=e.quantizationParameters?.tolerance??e.maxAllowableOffset;return n?this._sourceResolution(n,t):null}_sourceResolution(e,t){let n=this._queryEngineParams.spatialReference,r=u(t)/u(n)*e;return!Number.isFinite(r)||r<=0?null:r}}function pe(e){switch(e){case`fullText`:case`having`:case`timeExtent`:case`historicMoment`:case`aggregateIds`:case`uniqueIds`:case`gdbVersion`:case`objectIds`:case`where`:case`geometry`:case`resultOffset`:case`resultRecordCount`:return!0;default:return!1}}function me(e){switch(e){case`fullText`:case`having`:case`timeExtent`:case`historicMoment`:case`aggregateIds`:case`uniqueIds`:case`gdbVersion`:case`objectIds`:case`where`:case`geometry`:return!0;default:return!1}}function he(e){switch(e){case`fullText`:case`having`:case`timeExtent`:return!0;case`historicMoment`:case`aggregateIds`:case`uniqueIds`:case`gdbVersion`:return!1;case`objectIds`:case`where`:case`resultOffset`:case`geometry`:case`resultRecordCount`:return!1}return!1}function q(e){for(let t in e){let n=t;if(pe(n)&&e[n]!==null)return!0}return!1}function ge(e){for(let t in e){let n=t;if(me(n)&&e[n]!==null)return!0}return!1}function _e(e){for(let t in e){let n=t;if(he(n)&&e[n]!==null)return!0}return!1}function ve(e,t){return!!e.outStatistics?.length&&!q(e)&&!e.groupByFieldsForStatistics?.length&&!e.orderByFields?.length&&!e.returnDistinctValues&&!e.returnAggIds&&e.outStatistics.every(e=>ye(e,t))}function ye(e,t){switch(e.statisticType){case`count`:return e.onStatisticField===`1`||t.get(e.onStatisticField)!=null;case`min`:case`max`:{let n=t.get(e.onStatisticField);return n!=null&&M(n)}default:return!1}}function be(e,t){let n=e.statisticType===`exceedslimit`?null:t.get(e.onStatisticField),r=(e.statisticType===`min`||e.statisticType===`max`)&&n?.type===`esriFieldTypeDate`?n.type:`esriFieldTypeDouble`;return{name:e.outStatisticFieldName,alias:e.outStatisticFieldName,type:r}}function xe(e,t){switch(e.statisticType){case`count`:return J(e,t);case`min`:return Y(e,t,Math.min);case`max`:return Y(e,t,Math.max);default:return{available:!1,value:null}}}function J(e,t){if(e.statisticType!==`count`)return{available:!1,value:null};if(e.onStatisticField===`1`)return{available:!0,value:t.reduce((e,t)=>e+t.statistics.rowCount,0)};let n=0;for(let r of t){let t=r.statistics.statistics.get(e.onStatisticField);if(t==null||t.nullCount==null)return{available:!1,value:null};n+=r.statistics.rowCount-t.nullCount}return{available:!0,value:n}}function Y(e,t,n){if(e.statisticType!==`min`&&e.statisticType!==`max`)return{available:!1,value:null};let r=null,i=e.statisticType===`min`?`minValue`:`maxValue`;for(let a of t){let t=a.statistics.statistics.get(e.onStatisticField);if(t==null)return{available:!1,value:null};switch(t.type){case`null-only`:continue;case`unknown`:return{available:!1,value:null};case`bounds`:{let e=Se(t[i]);if(e==null)return{available:!1,value:null};r=r==null?e:n(r,e);break}}}return{available:!0,value:r}}function Se(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function X(e,t){let n=new V;for(let t of e)n.insert(t);return new T({...t,featureStore:n})}function Z(e,t){return e.statistics.statistics.get(t.fieldName)??null}function Ce(e,t){return e.slice().sort((e,n)=>{let r=Q(e,t),i=Q(n,t);return r===i?0:r<i?-1:1})}function Q(e,t){let n=Z(e,t);return n?.type===`bounds`?n.maxValue-n.minValue:1/0}function $(e,t,n){let r=e?.featureCount,i=!1;return r!=null&&r<has(`parquetlayer-full-query-feature-count`)&&(i=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:n,supportsTrueCurve:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{...ie,maxRecordCount:K,supportsOrderBy:i,supportsDistinct:!0,supportsStatistics:!0,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1}},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function we(e){return!!e.objectIds?.length||!!e.outStatistics||!!e.orderByFields?.length||!!e.returnDistinctValues}export{fe as default};
|
|
2
|
+
import{__addDisposableResource as e,__disposeResources as t}from"tslib";import{toConst as n}from"../../../../core/compilerUtils.js";import r from"../../../../core/Error.js";import i from"../../../../core/Handles.js";import has from"../../../../core/has.js";import a from"../../../../core/Logger.js";import{onAbortOrThrow as o,throwIfAborted as s}from"../../../../core/promiseUtils.js";import{QueueProcessor as c}from"../../../../core/QueueProcessor.js";import{parseWhereClause as l}from"../../../../core/sql.js";import{getMetersPerUnitForSR as u}from"../../../../core/units.js";import d from"../../../../geometry/SpatialReference.js";import{set as f,create as p,expandWithAABB as m,expandWithRect as ee,negativeInfinity as h}from"../../../../geometry/support/aaBoundingBox.js";import{copy as te,create as g,expandWithRect as ne,negativeInfinity as re}from"../../../../geometry/support/aaBoundingRect.js";import{isWebMercator as _,isWGS84 as v}from"../../../../geometry/support/spatialReferenceUtils.js";import{normalizeColumnPath as y,readParquetFileAttribute as b}from"../../../parquet.js";import{convertToGeometry as x}from"../../featureConversionUtils.js";import{getFieldNamesFromStatistics as S}from"../../data/attributeSupport.js";import{getQueryResultExtent as C,getQueryBoundingRects as w,QueryEngine as T}from"../../data/QueryEngine.js";import{queryCapabilities as ie}from"../../data/QueryEngineCapabilities.js";import{QueryEngineResult as E}from"../../data/QueryEngineResult.js";import{normalizeQueryLike as D}from"../../data/queryUtils.js";import{createFileProvider as O}from"../parquet/createFileProvider.js";import{readFieldStatistic as k}from"../parquet/ParquetFileStatistics.js";import{createDrawingInfo as ae}from"./clientSideDefaults.js";import{getParquetFileId as oe,getParquetRowId as se,getParquetObjectId as ce}from"./parquetIdUtils.js";import A from"../../../support/Field.js";import j from"../../../support/FieldsIndex.js";import{isNumericField as M}from"../../../support/fieldUtils.js";import{fromParquetGeometryEncodingJSON as N}from"../../../support/parquetEncodingUtils.js";import{completeParquetLayerInfo as P,fromParquetJSONGeometryType as F,toParquetJSONGeometryType as I}from"../../../support/parquetUtils.js";import{loadParquetModule as L}from"../../../../libs/librust-parquet/loadParquetModule.js";import{utc as R}from"../../../../time/constants.js";import{FeatureStoreQueryAdapter as z}from"../../../../views/2d/layers/features/FeatureStoreQueryAdapter.js";import{FeatureSnapshotSourceChunk as B}from"../../../../views/2d/layers/features/sources/strategies/chunks/FeatureSnapshotSourceChunk.js";import{FeatureSourceChunkStore as V}from"../../../../views/2d/layers/features/sources/strategies/chunks/SourceChunkStore.js";import{FeatureMetadata as H}from"../../../../views/2d/layers/features/support/FeatureMetadata.js";import{FeatureSetReaderParquet as U}from"../../../../views/2d/layers/features/support/FeatureSetReaderParquet.js";const W=new z,G=`__OBJECTID`,K=8e3;class le{constructor(e,t){this._files=e,this._createFileStream=t,this._fileIndex=0,this._streamIndex=0,this._streams=[],this._pending=new Set,this._resolvedCount=0}async next(e){for(await this._fill(e);this._pending.size>0;){s(e),await this._fill(e);let t=await ue(this._pending);if(this._pending.delete(t.read),this._resolvedCount++,t.chunk!=null)return t.chunk}return null}async _fill(e){for(this._removeDone();this._pending.size<8;){let t=this._getOrCreateNextStream(e);if(t==null)return;this._pending.add(t.read(e))}}_getOrCreateNextStream(e){let t=this._resolvedCount>=8?8:2;if(this._fileIndex<this._files.length&&this._streams.length<t){let t=this._files[this._fileIndex++],n=new de(t.id,this._createFileStream(t,e));return this._streams.push(n),n}return this._getNextStream()}_getNextStream(){let e=this._streams.length;for(let t=0;t<e;t++){let n=(this._streamIndex+t)%e,r=this._streams[n];if(r.canRead)return this._streamIndex=(n+1)%e,r}return null}_removeDone(){let e=this._streamIndex;for(let t=this._streams.length-1;t>=0;t--)this._streams[t].done&&(this._streams.splice(t,1),t<e&&e--);this._streamIndex=this._streams.length>0?e%this._streams.length:0}}function ue(e){return Promise.race(Array.from(e,async e=>({read:e,chunk:await e})))}class de{constructor(e,t){this._fileId=e,this._stream=t,this._readCount=0,this._reachedEnd=!1}get canRead(){return!this._reachedEnd}get done(){return this._reachedEnd&&this._readCount===0}async read(e){this._readCount++;try{let t=await(await this._stream).next(e);return t==null?(this._reachedEnd=!0,null):{fileId:this._fileId,chunk:t}}finally{this._readCount--}}}class fe{constructor(){this._hasZ=!1,this._hasM=!1,this._queue=new c({concurrency:4,process:(e,t)=>this._executeQuery(e,t)}),this._streams=new Map,this._streamIdCounter=0,this._indexMap={},this._handles=new i}async load(e){let t=e.spatialReference?d.fromJSON(e.spatialReference):void 0;if(t&&!t.isWGS84&&!t.isWebMercator)throw new r(`parquet:unsupported-projection`,`Only WGS84 and Web Mercator are supported`);this._customParameters=e.customParameters,this._loadParameters=e,await this._updateProvider(O(e.provider,null,()=>this._customParameters));let n=await this._provider.getMetadata(),i=await P(n,{fields:e.fields?.map(e=>A.fromJSON(e)),geometryEncoding:e.geometryEncoding?N(e.geometryEncoding):null,geometryType:e.geometryType?F(e.geometryType):null,displayOptimization:e.displayOptimization,spatialReference:t});if(this._hasZ=!!n?.hasZ,this._hasM=!!n?.hasM,!i.fields)throw new r(`parquet:unsupported`,`Fields must be defined`);let o;if(i.spatialReference&&i.geometryType){if(!i.spatialReference)throw new r(`parquet:unsupported`,`SpatialReference must be defined`);if(!i.spatialReference.isGeographic&&!i.spatialReference.isWebMercator)throw new r(`parquet:unsupported-projection`,`Only WGS84 and Web Mercator are supported`);i.spatialReference.isGeographic&&!i.spatialReference.isWGS84&&(a.getLogger(`parquet:unsupported-projection`).warn(`Found a geographic projection that is not WGS84. Handling as WGS84.`,{spatialReference:i.spatialReference}),i.spatialReference=d.WGS84),o={geometry:i.geometryEncoding?{geometryType:I(i.geometryType),spatialReference:i.spatialReference.toJSON(),encoding:i.geometryEncoding.toJSON()}:null,displayOptimization:i.displayOptimization}}this.setCustomParameters(e.customParameters),this._displayOptimization=i.displayOptimization,await this._provider.updateGeometryInfo(o),this._capabilities=$(await this._getFileStatistics(),this._hasZ,this._hasM);let s=await this._provider.getFiles();if(!s.length)return{layerDefinition:{},capabilities:$(null,this._hasZ,this._hasM)};let c=await s[0].file;i.file=c;let{fields:l}=i;if(l==null)throw new r(`parquet-layer:missing-metadata`,`Unable to create parquet source: cannot infer fields`,l);l.push(new A({name:G,type:`oid`,alias:G}));for(let e of l){let t=c.getColumnId(e.name);t!=null&&(this._indexMap[e.name]=t)}let u=j.fromLayerJSON({fields:l.map(e=>e.toJSON()),dateFieldsTimeReference:{timeZoneIANA:`UTC`}});this._fieldsIndex=u;let f=I(i.geometryType??`point`);return this._metadata=H.createFeature({fieldsIndex:u.toJSON(),geometryType:f,hasZ:this._hasZ,hasM:this._hasM,featureIdInfo:{type:`object-id`,fieldName:G},subtypes:null,subtypeField:null,types:null,typeIdField:null,globalIdField:null,spatialReference:i.spatialReference,outSpatialReference:null,attributeSpatialReference:null,timeInfo:null,timeReferenceUnknownClient:null,dateFieldsTimeZone:R}),this._queryEngineParams={fieldsIndex:this._metadata.fieldsIndex,geometryType:f,featureIdInfo:{type:`object-id`,fieldName:G},hasM:this._hasM,hasZ:this._hasZ,spatialReference:i.spatialReference?.toJSON()??{wkid:4326},aggregateAdapter:null,timeInfo:null,definitionExpression:null},this._fullExtent=n?.extent?n.extent:await this._tryDeriveParquetFullExtent(i),{capabilities:this._capabilities,layerDefinition:{fields:i.fields?.map(e=>e.toJSON()),drawingInfo:ae(f),extent:this._fullExtent??void 0,geometryType:f,hasZ:this._hasZ,hasM:this._hasM,geometryEncoding:i.geometryEncoding?.toJSON(),displayOptimization:i.displayOptimization}}}destroy(){this._provider.destroy(),this._queue.destroy();for(let{handle:e}of this._streams.values())e.remove();this._streams.clear(),this._indexMap={},this._handles.removeAll()}async reload(e){this.destroy(),await this.load(e)}set remoteClient(e){this._source=e.createInvokeProxy(``)}setCustomParameters(e){this._customParameters=e}getIndexMap(){return this._indexMap}async updateFileProvider(e){this._loadParameters={...this._loadParameters,provider:e};let t=O(e,this._provider.getGeometryInfo(),()=>this._customParameters);await this._updateProvider(t)}async getDiagnosticsSnapshot(){let e=await this._provider.getFiles();return{files:await Promise.all(e.map(e=>e.getDiagnosticsSnapshot()))}}async getColumnIndex(e){return(await this._getFileInfoById(e.fileId)).getColumnIndex(e.rowGroupIndex,e.columnIndex)}async getOffsetIndex(e){return(await this._getFileInfoById(e.fileId)).getOffsetIndex(e.rowGroupIndex,e.columnIndex)}async queryFeatures(e,t){let n=await D(e,null,this._queryEngineParams.spatialReference);return this._validateQuery(n),we(n)||(n.resultRecordCount=n.resultRecordCount?Math.min(n.resultRecordCount,K):K,n.resultOffset=n.resultOffset??0),n.outStatistics?this._queryStatistics(n,t):(n.returnDistinctValues&&(n.returnGeometry=void 0),(await this._enqueueQuery(n,t)).createQueryResponse())}async queryFeatureCount(e,t){let n=await D(e,null,this._queryEngineParams.spatialReference);return this._validateQuery(n),!q(n)&&!n.returnDistinctValues&&!n.groupByFieldsForStatistics?.length&&!n.outStatistics?.length?this._getFeatureCount():(n.returnDistinctValues||(n.outFields=void 0),n.returnGeometry=void 0,(await this._enqueueQuery(n,t)).createQueryResponseForCount())}async queryObjectIds(e,t){let n=await D(e,null,this._queryEngineParams.spatialReference);return this._validateQuery(n),q(n)?(n.resultRecordCount=n.resultRecordCount?Math.min(n.resultRecordCount,8e3):8e3,n.resultOffset=n.resultOffset??0,n.returnGeometry=void 0,n.outFields=void 0,n.returnDistinctValues=void 0,(await this._enqueueQuery(n,t)).items.map(e=>e.getObjectId())):Array.from({length:await this._getFeatureCount()},(e,t)=>t)}async queryAttributeBins(e,t={}){throw new r(`parquet:unsupported`,`queryAttributeBins not supported.`)}async queryExtent(e,t){let r=await D(e,null,this._queryEngineParams.spatialReference);if(this._validateQuery(r),this._fullExtent&&!q(r))return{count:await this._getFeatureCount(),extent:this._fullExtent};let i=n(this._metadata.spatialReference);r.returnGeometry=!0,r.outFields=void 0;let a=f(p(),h),o=p(),s=await this._enqueueQuery(r,t),c=0;for(let e of s.items)e.getBounds(o)&&(m(a,o),c+=1);let l=C(a,i,r.outSR?n(r.outSR):i.toJSON(),i,!1);return{count:c,extent:l}}async queryStream(e,t){if(!t.signal)throw Error(`InternalError: AbortSignal must be passed`);let n=await this._getCandidateFiles(e),r=new le(n,async(t,n)=>{let r=await t.file,i=await this._createParquetDisplayQuery(r,t.id,e);return r.executeQuery(i,K,n)}),i=this._streamIdCounter++,a=o(t.signal,e=>{let t=this._streams.get(i);t!=null&&(t.handle.remove(),this._streams.delete(i))});return this._streams.set(i,{stream:r,handle:a}),i}async getStreamNext(e,t){if(!t.signal)throw Error(`InternalError: AbortSignal must be passed`);let n=this._streams.get(e);if(!n)return{result:null};let r=await n.stream.next(t.signal);if(r==null)return n.handle.remove(),this._streams.delete(e),{result:null};let i=r.chunk.serialize().buffer,a={fileId:r.fileId,buffer:i};return i instanceof ArrayBuffer?{result:a,transferList:[i]}:{result:a}}async getStreamNextFeatures(e,t){let{result:n}=await this.getStreamNext(e,t);if(n==null)return null;let r=(await L()).ParquetChunk.deserialize(new Uint8Array(n.buffer)),i=new U(this._metadata,this._indexMap,r,n.fileId),a=[];for(;i.next();){let e=x(i.readGeometryWorldSpace(),i.geometryType,i.hasZ,i.hasM),t=i.readAttributes();a.push({attributes:t,geometry:e})}return{features:a}}async createPatch(e,t,n,r,i){if(!i.signal)throw Error(`InternalError: AbortSignal must be passed`);return(await(await(await this._getFileInfoById(e)).file).createChunkPatch(t,n,r,i.signal)).serialize().buffer}async _updateProvider(e){let t=this._provider;this._handles.removeAll(),this._provider=e,this._handles.add([e.events.on(`rangeRead`,e=>{this._source.onRangeRead(e)}),e.events.on(`sourceChanged`,async()=>{await this.reload(this._loadParameters),await this._source.onSourceChange()})]),await t?.destroy()}async _getCandidateFiles(e){let t=await this._provider.getFiles(),n=await this._getSpatialFilePruning(e);if(n==null)return t;let r=t.filter(e=>this._mayIncludeFileForSpatialPruning(e,n));return n.type===`xz`?Ce(r,n):r}async _queryStatistics(e,t){let n=await D({...e},null,this._queryEngineParams.spatialReference);if(n.returnGeometry=void 0,ve(n,this._fieldsIndex)){let e=await this._getStatisticsFromFiles(n);if(e)return e}return(await this._enqueueQuery(n,t)).createQueryResponse()}async _getStatisticsFromFiles(e){let t=await this._provider.getFiles(),n={},r=[];for(let i of e.outStatistics??[]){let e=xe(i,t);if(!e.available)return null;n[i.outStatisticFieldName]=e.value,r.push(be(i,this._fieldsIndex))}return{fields:r,features:[{attributes:n}]}}async _getSpatialFilePruning(e){if(e.type!==`tile`&&(e.type!==`arcade`||e.extent==null))return null;let t=this._displayOptimization?.index;if(t==null)return null;let n=e.outSpatialReference.wkid;if(t.wkid==null||n==null)return null;let r=t.wkid,i=await L();switch(t.type){case`xz`:return{type:`xz`,fieldName:y(t.code),intersects:(a,o)=>i.queryIntersectsXZStatistics(t.fullExtent,e.extent,n,r,t.maxLevel,a,o)};case`z`:return{type:`xy`,xFieldName:y(t.xColumn),yFieldName:y(t.yColumn),intersects:(t,a,o,s)=>i.queryIntersectsXYStatistics(e.extent,n,r,t,a,o,s)}}}_mayIncludeFileForSpatialPruning(e,t){switch(t.type){case`xz`:{let n=Z(e,t);return n?.type===`null-only`?!1:n?.type!==`bounds`||t.intersects(n.minValue,n.maxValue)}case`xy`:{let n=e.statistics.statistics.get(t.xFieldName),r=e.statistics.statistics.get(t.yFieldName);return n?.type===`null-only`||r?.type===`null-only`?!1:n?.type!==`bounds`||r?.type!==`bounds`||t.intersects(n.minValue,n.maxValue,r.minValue,r.maxValue)}}}async _tryDeriveParquetFullExtent(n){if(!n.spatialReference)return null;if(this._fullExtent==null&&n.geometryEncoding?.type===`location`){let r=await this._provider.getFiles(),{xField:i,yField:a}=n.geometryEncoding,o=f(p(),h),s=!1;for(let n of r){let r=await n.file;for(let n of r.rowGroups()){let r={stack:[],error:void 0,hasError:!1};try{let t=e(r,n.columnDescriptorForAttribute(i),!1),c=e(r,n.columnDescriptorForAttribute(a),!1),l=k(t),u=k(c);if(l?.type===`bounds`&&u?.type===`bounds`){let e=[l.minValue,u.minValue,l.maxValue,u.maxValue];ee(o,e),s=!0}n.free()}catch(e){r.error=e,r.hasError=!0}finally{t(r)}}}return s?{xmin:o[0],ymin:o[1],xmax:o[3],ymax:o[4],spatialReference:n.spatialReference?.toJSON()}:null}return null}async _getFileInfoById(e){let t=await this._provider.getFiles();for(let n of t)if(n.id===e)return n;throw Error(`InternalError: File ${e} does not exist`)}async _getFileStatistics(){return{featureCount:await this._getFeatureCount(),byteLength:await this._getByteLength()}}async _getFile(e){return(await this._getFileInfoById(e)).file}async _createParquetQuery(e,t,n,r,i){let a=(await L()).Query.new();n!=null&&a.setPreFilterStart(n),r!=null&&a.setPreFilterCount(r),i!=null&&a.setPostFilterCount(i);let o=await this._getRequiredFields(e);a.setOutFields(o),(e.geometry||e.returnGeometry)&&a.setReturnGeometry(!0),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM);let s=this._tryGetGeneralizedGeometryResolution(e);s!=null&&a.setSourceResolution(s);let c=e.geometry?.spatialReference??this._queryEngineParams.spatialReference,l=c.wkid;if(e.geometry&&(_(c)||v(c))){let t=te(g(),re);for(let n of w(e.geometry))ne(t,n);a.setOutSpatialReference(l),a.setExtent({xmin:t[0],ymin:t[1],xmax:t[2],ymax:t[3]})}if(e.where){let{id:n,file:r}=t;await this._setWhereClause(a,await r,n,e.where)}return a}async _createParquetDisplayQuery(e,t,n){let r=(await L()).Query.new();if(n.type===`tile`){r.setExtent(n.extent),r.setQuantizationTransform(n.transform);let e=this._sourceResolution(n.resolution,n.outSpatialReference);e!=null&&r.setSourceResolution(e)}else n.type===`arcade`&&n.extent!=null&&r.setExtent(n.extent);return r.setOutFields(n.outFields.filter(e=>this._indexMap[e]!=null)),r.setOutSpatialReference(n.outSpatialReference.wkid),r.setReturnGeometry(n.returnGeometry),r.setReturnZ(n.returnZ),r.setReturnM(n.returnM),n.where&&await this._setWhereClause(r,e,t,n.where),r}async _getFeatureCount(){return(await this._provider.getFiles()).map(e=>e.statistics.rowCount).reduce((e,t)=>e+t,0)}async _getByteLength(){return(await this._provider.getFiles()).map(e=>e.statistics.byteSize).reduce((e,t)=>e+t,0)}_validateQuery(e){if(!this._capabilities.query.supportsStatistics&&e.outStatistics)throw new r(`parquet:unsupported`,`Statistics queries are not supported`,{query:e});if(!this._capabilities.query.supportsOrderBy&&e.orderByFields?.length)throw new r(`parquet:unsupported`,`Queries using orderBy are not supported`,{query:e});if(!this._capabilities.query.supportsDistinct&&e.returnDistinctValues)throw new r(`parquet:unsupported`,`Queries using returnDistinctValues are not supported`,{query:e})}async _setWhereClause(e,t,n,i){let a=this._indexMap,o=this._fieldsIndex,s={getAttribute(e,r){let i=a[r];if(i==null){if(o.get(r)?.name===`__OBJECTID`){let t=e.row+e.rowGroupStart;return ce(n,t)}return null}let s=o.get(r);return b(t,e.rowGroup,e.row,i,s.type)}},c=await l(i,this._fieldsIndex);if(!c.isStandardized)throw new r(`sql-parse-error`,`expression is not standardized`);let u=(e,t,n)=>c.testFeatureCompiled({rowGroup:e,row:t,rowGroupStart:n},s,null),d=c.fieldNames.map(e=>o.get(e)).filter(e=>e&&this._indexMap[e?.name]!=null);e.setWhere(i),e.setWhereEvaluator(u),e.setWhereFields(d.map(e=>e.name))}async*_streamFeatures(e,t,n,r,i){let a=await this._provider.getFiles(),o=0;for(let s of a){let a=o,c=o+s.statistics.rowCount;if(o+=s.statistics.rowCount,t!=null&&t>=c)continue;let l=t==null?null:Math.max(t-a,0),u=n;if(n!=null){let e=t??0,r=e+n;u=Math.max(Math.min(r,c)-Math.max(e,a),0)}if(u===0)continue;let d=await this._createParquetQuery(e,s,l,u,r),f=await(await s.file).executeQuery(d,K),p=async()=>{let e=await f.next(i);if(!e)return null;let t=new U(this._metadata,this._indexMap,e,s.id);return X([new B(t,null,0,!1)],this._queryEngineParams)},m=await p();for(;m!=null;)yield m,m=await p()}}async _queryFeaturesWithQueryEnginePagination(e,t){let n=[],r=this._streamFeatures(e,null,null,null,t),i=await r.next();for(;!i.done;){let a=await i.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(let e of a)n.push(e);i=await r.next()}return n}async _queryFeaturesWithUpfrontPagination(e,t){let n=e.resultOffset??0,r=e.resultRecordCount??K,i,a,o;ge(e)?_e(e)||(o=n+r):(n&&=(i=n,0),a=e.resultRecordCount);let s=[],c=this._streamFeatures(e,i,a,o,t),l=await c.next();for(;!l.done&&r>0;){let i=await l.value.executeQueryForOpaqueFeatures({...e,where:void 0},t);for(let e of i)if(n>0)n--;else if(s.push(e),--r<=0)return s;l=await c.next()}return s}_enqueueQuery(e,t){return this._queue.push(e,t)}async _executeQuery(e,t){if(e.objectIds?.length){let n=new Map;for(let t of e.objectIds){let e=oe(t),r=se(t),i=n.get(e);i||(i=[],n.set(e,i)),i.push(r)}let r=[];for(let[i,a]of n.entries()){let n=await this._executeFileIdQuery(e,i,a,t);for(let e of n)r.push(e)}return new E(r,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:W,featureIdInfo:this._queryEngineParams.featureIdInfo})}if(e.where===`1=1`&&(e.where=null),e.resultOffset??=0,e.resultRecordCount??=await this._getFeatureCount(),e.resultRecordCount>2e7&&!(this._displayOptimization&&e.geometry))throw new r(`parquet:cannot-execute-query`,`Unable to execute query, dataset is too large.`);let n=!!e.orderByFields?.length||!!e.outStatistics?.length||!!e.returnDistinctValues,i=n?await this._queryFeaturesWithQueryEnginePagination(e,t):await this._queryFeaturesWithUpfrontPagination(e,t);return n||(e.resultOffset=0),new E(i,e,{fieldsIndex:this._fieldsIndex,geometryType:this._metadata.geometryType,spatialReference:this._queryEngineParams.spatialReference,hasM:this._hasM,hasZ:this._hasZ,featureAdapter:W,featureIdInfo:this._queryEngineParams.featureIdInfo})}async _executeFileIdQuery(e,t,n,r){let i=await this._getRequiredFields(e),a=(await L()).Query.new();a.setOutFields(i),a.setReturnGeometry(!!e.returnGeometry),a.setReturnZ(!!e.returnZ),a.setReturnM(!!e.returnM),a.setIds(new Uint32Array(n));let o=await(await this._getFile(t)).executeQuery(a,K,r),s=await o.next(r),c=0,l=[];for(;s!=null;){let e=new U(this._metadata,this._indexMap,s,t),n=new B(e,null,c++,!1);l.push(n),s=await o.next(r)}return X(l,this._queryEngineParams).executeQueryForOpaqueFeatures(e,r)}async _getRequiredFields(e){let t=new Set;if(e.outStatistics)for(let n of S(this._fieldsIndex,e.outStatistics,e.groupByFieldsForStatistics))t.add(n);else if(e.outFields)for(let n of e.outFields)t.add(n);return(t.has(`*`)?this._fieldsIndex.fields.map(e=>e.name):Array.from(t)).filter(e=>this._indexMap[e]!=null)}_tryGetGeneralizedGeometryResolution(e){if(!this._displayOptimization)return null;let t=e.outSR??this._queryEngineParams.spatialReference;if(!_(t)&&!v(t))return null;let n=e.quantizationParameters?.tolerance??e.maxAllowableOffset;return n?this._sourceResolution(n,t):null}_sourceResolution(e,t){let n=this._queryEngineParams.spatialReference,r=u(t)/u(n)*e;return!Number.isFinite(r)||r<=0?null:r}}function pe(e){switch(e){case`fullText`:case`having`:case`timeExtent`:case`historicMoment`:case`aggregateIds`:case`uniqueIds`:case`gdbVersion`:case`objectIds`:case`where`:case`geometry`:case`resultOffset`:case`resultRecordCount`:return!0;default:return!1}}function me(e){switch(e){case`fullText`:case`having`:case`timeExtent`:case`historicMoment`:case`aggregateIds`:case`uniqueIds`:case`gdbVersion`:case`objectIds`:case`where`:case`geometry`:return!0;default:return!1}}function he(e){switch(e){case`fullText`:case`having`:case`timeExtent`:return!0;case`historicMoment`:case`aggregateIds`:case`uniqueIds`:case`gdbVersion`:return!1;case`objectIds`:case`where`:case`resultOffset`:case`geometry`:case`resultRecordCount`:return!1}return!1}function q(e){for(let t in e){let n=t;if(pe(n)&&e[n]!==null)return!0}return!1}function ge(e){for(let t in e){let n=t;if(me(n)&&e[n]!==null)return!0}return!1}function _e(e){for(let t in e){let n=t;if(he(n)&&e[n]!==null)return!0}return!1}function ve(e,t){return!!e.outStatistics?.length&&!q(e)&&!e.groupByFieldsForStatistics?.length&&!e.orderByFields?.length&&!e.returnDistinctValues&&!e.returnAggIds&&e.outStatistics.every(e=>ye(e,t))}function ye(e,t){switch(e.statisticType){case`count`:return e.onStatisticField===`1`||t.get(e.onStatisticField)!=null;case`min`:case`max`:{let n=t.get(e.onStatisticField);return n!=null&&M(n)}default:return!1}}function be(e,t){let n=e.statisticType===`exceedslimit`?null:t.get(e.onStatisticField),r=(e.statisticType===`min`||e.statisticType===`max`)&&n?.type===`esriFieldTypeDate`?n.type:`esriFieldTypeDouble`;return{name:e.outStatisticFieldName,alias:e.outStatisticFieldName,type:r}}function xe(e,t){switch(e.statisticType){case`count`:return J(e,t);case`min`:return Y(e,t,Math.min);case`max`:return Y(e,t,Math.max);default:return{available:!1,value:null}}}function J(e,t){if(e.statisticType!==`count`)return{available:!1,value:null};if(e.onStatisticField===`1`)return{available:!0,value:t.reduce((e,t)=>e+t.statistics.rowCount,0)};let n=0;for(let r of t){let t=r.statistics.statistics.get(e.onStatisticField);if(t==null||t.nullCount==null)return{available:!1,value:null};n+=r.statistics.rowCount-t.nullCount}return{available:!0,value:n}}function Y(e,t,n){if(e.statisticType!==`min`&&e.statisticType!==`max`)return{available:!1,value:null};let r=null,i=e.statisticType===`min`?`minValue`:`maxValue`;for(let a of t){let t=a.statistics.statistics.get(e.onStatisticField);if(t==null)return{available:!1,value:null};switch(t.type){case`null-only`:continue;case`unknown`:return{available:!1,value:null};case`bounds`:{let e=Se(t[i]);if(e==null)return{available:!1,value:null};r=r==null?e:n(r,e);break}}}return{available:!0,value:r}}function Se(e){return typeof e==`number`&&Number.isFinite(e)?e:null}function X(e,t){let n=new V;for(let t of e)n.insert(t);return new T({...t,featureStore:n})}function Z(e,t){return e.statistics.statistics.get(t.fieldName)??null}function Ce(e,t){return e.slice().sort((e,n)=>{let r=Q(e,t),i=Q(n,t);return r===i?0:r<i?-1:1})}function Q(e,t){let n=Z(e,t);return n?.type===`bounds`?n.maxValue-n.minValue:1/0}function $(e,t,n){let r=e?.featureCount,i=!1;return r!=null&&r<has(`parquetlayer-full-query-feature-count`)&&(i=!0),{analytics:{supportsCacheHint:!1},attachment:null,data:{isVersioned:!1,isBranchVersioned:!1,supportedCurveTypes:[],supportsAttachment:!1,supportsM:n,supportsTrueCurve:!1,supportsZ:t},metadata:{supportsAdvancedFieldProperties:!1},operations:{supportsCalculate:!1,supportsTruncate:!1,supportsValidateSql:!1,supportsAdd:!1,supportsDelete:!1,supportsEditing:!1,supportsChangeTracking:!1,supportsQuery:!0,supportsQueryBins:!1,supportsQueryPivot:!1,supportsQueryAnalytics:!1,supportsQueryAttachments:!1,supportsQueryTopFeatures:!1,supportsResizeAttachments:!1,supportsSync:!1,supportsUpdate:!1,supportsExceedsLimitStatistics:!1,supportsAsyncConvert3D:!1},query:{...ie,maxRecordCount:K,supportsOrderBy:i,supportsDistinct:!0,supportsStatistics:!0,supportsSpatialAggregationStatistics:!1,supportedSpatialAggregationStatistics:{envelope:!1,centroid:!1,convexHull:!1}},queryAttributeBins:{supportsDate:!1,supportsFixedInterval:!1,supportsAutoInterval:!1,supportsFixedBoundaries:!1,supportsStackBy:!1,supportsSplitBy:!1,supportsSnapToData:!1,supportsReturnFullIntervalBin:!1,supportsFirstDayOfWeek:!1,supportsNormalization:!1},queryRelated:{supportsCount:!1,supportsOrderBy:!1,supportsPagination:!1,supportsCacheHint:!1},queryTopFeatures:{supportsCacheHint:!1},editing:{supportsDeleteByAnonymous:!1,supportsDeleteByOthers:!1,supportsGeometryUpdate:!1,supportsGlobalId:!1,supportsTrueCurveUpdate:!1,supportsTrueCurveUpdateByTrueCurveClientsOnly:!0,supportsReturnServiceEditsInSourceSpatialReference:!1,supportsRollbackOnFailure:!1,supportsUpdateByAnonymous:!1,supportsUpdateByOthers:!1,supportsUploadWithItemId:!1,supportsUpdateWithoutM:!1,supportsAsyncApplyEdits:!1,zDefault:void 0}}}function we(e){return!!e.objectIds?.length||!!e.outStatistics||!!e.orderByFields?.length||!!e.returnDistinctValues}export{fe as default};
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* ReloadableLayer is a mixin that adds support for reloading layer's schema and properties.
|
|
3
3
|
*
|
|
4
4
|
* @since 5.2
|
|
5
5
|
*/
|
|
6
|
-
export abstract class
|
|
6
|
+
export abstract class ReloadableLayer {
|
|
7
7
|
constructor(...args: any[]);
|
|
8
8
|
/**
|
|
9
|
-
* Indicates if the layer is in the process of reloading its properties and schema after a call to
|
|
9
|
+
* Indicates if the layer is in the process of reloading its properties and schema after a call to [reload()](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ReloadableLayer/#reload).
|
|
10
10
|
*
|
|
11
11
|
* @since 5.2
|
|
12
|
+
* @see [reload()](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ReloadableLayer/#reload)
|
|
12
13
|
*/
|
|
13
14
|
get reloading(): boolean;
|
|
14
15
|
/**
|
|
@@ -21,6 +22,7 @@ export abstract class FeatureLayerReload {
|
|
|
21
22
|
* @returns `true` when the layer is successfully updated with data from the portal item or service;
|
|
22
23
|
* `false` when the layer is not updated, not loaded, or does not reference a service.
|
|
23
24
|
* @since 5.2
|
|
25
|
+
* @see [reloading](https://developers.arcgis.com/javascript/latest/references/core/layers/mixins/ReloadableLayer/#reloading)
|
|
24
26
|
*/
|
|
25
27
|
reload(): Promise<boolean>;
|
|
26
28
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
+
import{__decorate as e}from"tslib";import{abortHandle as t}from"../../core/handleUtils.js";import{debounce as n,throwIfAbortError as r}from"../../core/promiseUtils.js";import{property as i,subclass as a}from"../../core/accessorSupport/decorators.js";import{getOwningPortalUrl as o}from"../support/layerUtils.js";import s from"../../portal/Portal.js";import c from"../../portal/PortalItem.js";const l=`reload`,u=u=>{let d=u,f=class extends d{constructor(...e){super(...e),this._loadTimestamp=0,this._pendingReloadCount=0,this._serviceItemModified=null,this._debounceReload=n(async()=>{if(this.destroyed||!this.loaded||!this.canReload())return!1;let e=new AbortController;this.addHandles(t(e),l);try{let t=null,n;if(this.portalItem?.id&&this.portalItem.id===this.serviceItemId)n=await this.reloadFromPortal({supportedTypes:this.supportedPortalItemTypes},{signal:e.signal});else{let r=await this._shouldReloadFromServiceItem(e.signal);n=r.updated,t=r.modified}return n&&await this.reloadFromService(e.signal),e.signal.throwIfAborted(),t!=null&&(this._serviceItemModified=t),n}finally{this.removeHandles(l)}}),this.when().then(()=>{this._loadTimestamp=Date.now()},()=>{})}get reloading(){return this._pendingReloadCount>0}reload(){return this.destroyed||!this.loaded||!this.canReload()?Promise.resolve(!1):(this._pendingReloadCount++,this._debounceReload().finally(()=>{this._pendingReloadCount--}))}canReload(){return this.url!=null}async _shouldReloadFromServiceItem(e){let{serviceItemId:t,url:n}=this;if(!t||!n)return{modified:null,updated:!0};try{let r=await o(n,{signal:e});if(!r)return{modified:null,updated:!0};let i=new s({url:r}),a=new c({apiKey:this.apiKey,id:t,portal:i});await a.load({signal:e});let l=a.modified?.getTime();if(l==null)return{modified:null,updated:!0};let u=this._serviceItemModified;return{modified:l,updated:u==null?l>this._loadTimestamp:u<l}}catch(e){return r(e),{modified:null,updated:!0}}}};return e([i({clonable:!1})],f.prototype,`_pendingReloadCount`,void 0),e([i({readOnly:!0})],f.prototype,`reloading`,null),f=e([a(`esri.layers.mixins.ReloadableLayer`)],f),f};export{u as ReloadableLayer};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../request.js";import n from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import i from"../../../core/Logger.js";import{debounce as a,onAbort as o}from"../../../core/promiseUtils.js";import{QueueProcessor as s}from"../../../core/QueueProcessor.js";import{property as c,subclass as l}from"../../../core/accessorSupport/decorators.js";import{ensureClass as u}from"../../../core/accessorSupport/ensureType.js";import d from"../../../geometry/Extent.js";import f from"../../../geometry/Point.js";import p from"../../../geometry/SpatialReference.js";import{isFunctionRaster as m,getPixelSpaceCoverage as h}from"./datasetUtils.js";import{isMultiSliceOrRangeDefinition as g,getSliceIndex as _,createSlices as v,getSliceIds as y}from"./multidimensionalUtils.js";import{clearRegisteredIds as b,getRasterId as x,getBlock as S,putBlock as C,deleteBlock as w,decreaseRefCount as T}from"./RawBlockCache.js";import{convertNoDataToMask as E}from"../formats/pixelRangeUtils.js";import{decode as D}from"../formats/RasterCodec.js";import{convertPixelSize as O}from"../functions/clipUtils.js";import{mosaic as k,approximateTransform as A,getLocalArithmeticNorthRotations as j,compositeBands as M}from"../functions/pixelUtils.js";import{getWorldWidth as N,load as P,projectPoint as F,snapPyramid as I,shiftExtent as L,getWorldWrapCount as R,projectExtent as z,getProjectionOffsetGrid as B,getRasterDatasetAlignmentInfo as V,projectResolution as H}from"../functions/rasterProjectionHelper.js";import{convertToLocalDirections as U,uvComponentToVector as W}from"../functions/vectorFieldUtils.js";import{sanitizeUrl as G}from"../../support/arcgisLayerUrl.js";import{url as K}from"../../support/commonProperties.js";import q from"../../support/DimensionalDefinition.js";import J from"../../support/LOD.js";import Y from"../../support/RasterStorageInfo.js";import X from"../../support/TileInfo.js";let Z=0,Q=class extends r{constructor(){super(...arguments),this._tileFetchQueue=new s({concurrency:32,process:(e,t)=>this.fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:`closest`},this.rawBlockRegistryIds=[],this.refresh=a(async e=>{await this._openPromise;let t=await this._refresh(e);return t.dataChanged&&b(this.rasterId,this.rawBlockRegistryIds),t})}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:`closest`,tileInfo:X.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){let{rasterInfo:e}=this,t=N(e.spatialReference);return t!=null&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){let{transform:e}=this.rasterInfo;return e==null||e.type===`gcs-shift`}set rasterJobHandler(e){this._set(`rasterJobHandler`,e),m(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||`rasterId-${Z++}`}set url(e){this._set(`url`,G(e,i.getLogger(this)))}async open(e){return this._openPromise??=P().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,r,i={}){let a=i.tileInfo||this.rasterInfo.storageInfo.tileInfo,o=this.getTileExtentFromTileInfo(e,t,r,a);if(!o)throw new n(`imagery-tile:out-of-bounds`,`Level for fetch tile out of range`);return i={noClip:!0,...i},this.fetchPixels(o,a.size[0],a.size[1],i)}async identify(e,t={}){e=u(f,e).clone().normalize();let{multidimensionalDefinition:n,timeExtent:r}=t,{rasterInfo:i}=this,{hasMultidimensionalTranspose:a,multidimensionalInfo:o}=i,{transposedVariableName:s}=t,c=o!=null&&a&&(r!=null||g(n));c&&!s&&(s=n!=null&&n.length>0?n[0].variableName??void 0:o.variables[0].name,t={...t,transposedVariableName:s}),t=this._getRequestOptionsWithSliceId(t);let{spatialReference:l,extent:p}=i,{datumTransformation:h}=t,_=F(e,l,h);if(!p.intersects(_))return{location:_,value:null};if(i.transform!=null){let e=i.transform.inverseTransform(_);if(!i.nativeExtent.intersects(e))return{location:e,value:null};_=e}let v=s!=null&&o!=null&&i.hasMultidimensionalTranspose;if(m(this)){let e=this.primaryRasters.rasters[0];if(v)return e.identify(_,t);let{pixelSize:r}=i,a=r.x*3/2,o=r.y*3/2,s=new d({xmin:_.x-a,xmax:_.x+a,ymin:_.y-o,ymax:_.y+o,spatialReference:l}),c={interpolation:`nearest`,multidimensionalDefinition:n,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:u}=await e.fetchPixels(s,3,3,c),{pixelBlock:f}=await this.fetchPixels(s,3,3,c);if(u==null)return{location:_,value:null};let p=!u.mask||u.mask[4]?u.pixels.map(e=>e[4]):null,m;return f!=null&&(m=!f.mask||f.mask[4]?f.pixels.map(e=>e[4]):void 0),{location:_,value:p,processedValue:m,pyramidLevel:0}}let y=0;if(!v){let{srcResolution:n}=t;if(n)n.spatialReference&&(n=O(new f(n),l)),y=I(n,i,this.ioConfig.sampling).pyramidLevel;else if(y=await this.computeBestPyramidLevelForLocation(e,t),y==null)return{location:_,value:null}}let b=this.identifyPixelLocation(_,y,null,v);if(b===null)return{location:_,value:null};let{row:x,col:S,rowOffset:C,colOffset:w,blockWidth:T}=b,E=await this._fetchRawTile(y,x,S,t);if(!E?.pixels?.length)return{location:_,value:null};let D=C*T+w;return this._processIdentifyResult(E,{srcLocation:_,position:D,pyramidLevel:y,useTransposedTile:!!v,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,n,r={}){e=L(e),r=this._getRequestOptionsWithSliceId(r);let{_hasNoneOrGCSShiftTransform:i}=this;if(r.requestRawData&&i)return this._fetchPixels(e,t,n,r);let a=N(e.spatialReference),o=R(e);if(a==null||o===0||o===1&&this._isGlobalWrappableSource&&i)return this._fetchPixels(e,t,n,r);if(o>=3)return{extent:e,pixelBlock:null};let s=[],{xmin:c,xmax:l}=e,u=Math.round(a/(l-c)*t),f=u-Math.round((a/2-c)/(l-c)*t),p=0,m=[];for(let i=0;i<=o;i++){let h=i===0?c:-a/2,g=i===o?l-a*i:a/2,_=new d({xmin:h,xmax:g,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),v=i===0?u-f:i===o?t-p:u;p+=v,m.push(v);let y=r.disableWrapAround&&i>0?null:this._fetchPixels(_,v,n,r);s.push(y)}let h=(await Promise.all(s)).map(e=>e?.pixelBlock),g=null,_={width:t,height:n};g=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:h,srcMosaicSize:_,destDimension:null,coefs:null,sampleSpacing:null,interpolation:`nearest`,alignmentInfo:null,blockWidths:m},r)).pixelBlock:k(h,_,{blockWidths:m});let v=z(e,this.rasterInfo.spatialReference,r.datumTransformation);return{extent:e,srcExtent:v,pixelBlock:g}}async fetchRawPixels(e,t,n,r={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};let i=await this._fetchRawTiles(e,t,n,r),{nativeExtent:a,nativePixelSize:o,storageInfo:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,f=new d({xmin:a.xmin+l*t.x,xmax:a.xmin+l*(t.x+n.width-1),ymin:a.ymax-u*(t.y+n.height-1),ymax:a.ymax-u*t.y,spatialReference:a.spatialReference});if(!i)return{extent:f,srcExtent:f,pixelBlock:null};let{pixelBlocks:p,mosaicSize:m}=i;if(p.length===1&&p[0]!=null&&p[0].width===n.width&&p[0].height===n.height)return{extent:f,srcExtent:f,pixelBlock:i.pixelBlocks[0]};let h=e>0?s.pyramidBlockWidth:s.blockWidth,g=e>0?s.pyramidBlockHeight:s.blockHeight,_={x:t.x%h,y:t.y%g},v;return v=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:m,destDimension:n,clipOffset:_,clipSize:n,coefs:null,sampleSpacing:null,interpolation:r.interpolation,alignmentInfo:null,blockWidths:null},r)).pixelBlock:k(p,m,{clipOffset:_,clipSize:n}),{extent:f,srcExtent:f,pixelBlock:v}}fetchRawTile(e,t,r,i){throw new n(`BaseRaster:read-not-implemented`,`fetchRawTile() is not implemented`)}computeExtent(e){return z(this.rasterInfo.extent,e)}decodePixelBlock(e,t){return this.rasterJobHandler?this.rasterJobHandler.decode({data:e,options:t}):D(e,t)}async request(e,n,r=0){let{customFetchParameters:i}=this.ioConfig,{range:a,query:o,headers:s}=n;r=r??n.retryCount??this.ioConfig.retryCount;let c=a?{Range:`bytes=${a.from}-${a.to}`}:null;try{return await t(e,{...n,query:{...o,...i},headers:{...s,...c}})}catch(t){if(r>0)return r--,this.request(e,n,r);throw t}}getSliceIndex(e){let{multidimensionalInfo:t}=this.rasterInfo;return t==null||e==null||e.length===0?null:_(e,t)}getTileExtentFromTileInfo(e,t,n,r){let i=r.lodAt(e);return i?this.getTileExtent({x:i.resolution,y:i.resolution},t,n,r.origin,r.spatialReference,r.size):null}updateTileInfo(){let{storageInfo:e,spatialReference:t,extent:n,pixelSize:r}=this.rasterInfo,{pyramidResolutions:i}=e;if(!e.tileInfo){let a=[],o=e.maximumPyramidLevel||0,s=(r.x+r.y)/2,c=1/.0254*96*s;for(let e=0;e<=o&&(a.unshift(new J({level:o-e,resolution:s,scale:c})),e!==o);e++)if(i){let t=(i[e].x+i[e].y)/2;c*=t/s,s=t}else s*=2,c*=2;let l=new f({x:n.xmin,y:n.ymax,spatialReference:t});e.tileInfo=new X({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:a}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,n=512,r){let{width:i,height:a,nativeExtent:o,pixelSize:s,spatialReference:c}=e,l=new f({x:o.xmin,y:o.ymax,spatialReference:c});r??=Math.max(0,Math.round(Math.log(Math.max(i,a))/Math.LN2-8));let u=this.computeBlockBoundary(o,512,512,{x:o.xmin,y:o.ymax},[s],r);e.storageInfo=new Y({blockWidth:t,blockHeight:n,pyramidBlockWidth:t,pyramidBlockHeight:n,origin:l,firstPyramidLevel:1,maximumPyramidLevel:r,blockBoundary:u})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,n,r,i,a=0,o=2){if(i.length===1&&a>0){i=[...i];let{x:e,y:t}=i[0];for(let n=0;n<a;n++)e*=o,t*=o,i.push({x:e,y:t})}let s=[],{x:c,y:l}=r;for(let r=0;r<i.length;r++){let{x:a,y:o}=i[r];s.push({minCol:Math.floor((e.xmin-c+.1*a)/t/a),maxCol:Math.floor((e.xmax-c-.1*a)/t/a),minRow:Math.floor((l-e.ymax+.1*o)/n/o),maxRow:Math.floor((l-e.ymin-.1*o)/n/o)})}return s}getPyramidPixelSize(e){let{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:n,pyramidScalingFactor:r}=this.rasterInfo.storageInfo;if(e===0)return t;if(n!=null&&n.length)return n[e-1];let i=r**e;return{x:t.x*i,y:t.y*i}}identifyPixelLocation(e,t,n,r){let{spatialReference:i,nativeExtent:a,storageInfo:o}=this.rasterInfo,{maximumPyramidLevel:s,origin:c,transposeInfo:l}=o,u=r&&l!=null?l.tileSize[0]:o.blockWidth,d=r&&l!=null?l.tileSize[1]:o.blockHeight,f=F(e,i,n);if(!a.intersects(f)||t<0||t>s)return null;let{x:p,y:m}=this.getPyramidPixelSize(t),h=(c.y-f.y)/m/d,g=(f.x-c.x)/p/u,_=Math.min(d-1,Math.floor((h-Math.floor(h))*d)),v=Math.min(u-1,Math.floor((g-Math.floor(g))*u));return{pyramidLevel:t,row:Math.floor(h),col:Math.floor(g),rowOffset:_,colOffset:v,blockWidth:u,srcLocation:f}}getTileExtent(e,t,n,r,i,a){let[o,s]=a,c=r.x+n*o*e.x,l=c+o*e.x,u=r.y-t*s*e.y,f=u-s*e.y;return new d({xmin:c,xmax:l,ymin:f,ymax:u,spatialReference:i})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,n){let r=this.rasterInfo.storageInfo.blockBoundary[e];return!r||r.maxRow<t||r.maxCol<n||r.minRow>t||r.minCol>n}updateImageSpaceRasterInfo(e){let{pixelSize:t}=e,{width:n,height:r}=e,i=p.WebMercator;e.spatialReference=i,e.extent=e.nativeExtent=new d({xmin:-.5,ymax:.5,xmax:n-.5,ymin:.5-r,spatialReference:i}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new f({x:1,y:1,spatialReference:i});let{extent:a,storageInfo:o}=e;if(o){o.origin=new f({x:a.xmin,y:a.ymax,spatialReference:i});let{pyramidResolutions:n,tileInfo:r}=o;if(n&&n.forEach(e=>{e.x/=t.x,e.y/=t.y}),r){r.origin=o.origin;let t=(e.nativePixelSize.x+e.nativePixelSize.y)/2;r.lods.forEach((e,n)=>{e.resolution=t*2**n,e.scale=96*e.resolution/.0254})}}}async _refresh(e){return{dataChanged:!0}}async _fetchPixels(e,t,n,r={}){let i=R(e);if(i>=2)return{extent:e,pixelBlock:null};let a=this._getSourceDataInfo(e,t,n,r),{pyramidLevel:o,srcResolution:s,srcWidth:c,srcHeight:l,ul:u}=a,{srcExtent:d}=a;if(c===0||l===0)return{extent:e,srcExtent:d,pixelBlock:null};let{rasterInfo:p}=this,m=p.transform,h=m?.type===`gcs-shift`,g=N(e.spatialReference)!=null;(h||!g)&&(i=R(d,h));let _=await this._fetchRawTiles(o,u,{width:c,height:l,wrapCount:i},r);if(!_)return{extent:e,srcExtent:d,pixelBlock:null};d=_.extent;let v=p.storageInfo,y=o>0?v.pyramidBlockWidth:v.blockWidth,b=o>0?v.pyramidBlockHeight:v.blockHeight,{x,y:S}=p.pixelSize;if(o>0){let{pyramidResolutions:e,pyramidScalingFactor:t}=v;if(e!=null&&e[o-1])({x,y:S}=e[o-1]);else{let e=t**o;x*=e,S*=e}}let C=p.spatialReference,w=new f({x,y:S,spatialReference:C}),T=y===c&&b===l&&u.x%y===0&&u.y%b===0,E=new f({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/n,spatialReference:e.spatialReference}),D=!e.spatialReference.equals(C),O=C.isGeographic?1e-9:1e-4,{datumTransformation:M}=r;if(!D&&T&&_.pixelBlocks.length===1&&y===t&&b===n&&$(s,E,O))return{extent:e,srcExtent:d,srcTilePixelSize:w,pixelBlock:_.pixelBlocks[0]};let F=g&&N(d.spatialReference)!=null&&this._hasNoneOrGCSShiftTransform,I=r.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith(`vector`);I&&!this.rasterJobHandler&&await P();let L=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:d,pixelSize:E.toJSON(),datumTransformation:M,rasterTransform:m,hasWrapAround:i>0||F,isAdaptive:this.ioConfig.optimizeProjectionAccuracy!==!1,includeGCSGrid:I},r):B({projectedExtent:e,srcBufferExtent:d,pixelSize:E,datumTransformation:M,rasterTransform:m,hasWrapAround:i>0||F,isAdaptive:!1,includeGCSGrid:I}),z,V=!r.requestRawData,H={rows:L.spacing[0],cols:L.spacing[1]},W=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(o,d.xmin):void 0,{pixelBlocks:G,mosaicSize:K,isPartiallyFilled:q}=_,J=null;if(this.rasterJobHandler){let e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:G,srcMosaicSize:K,destDimension:V?{width:t,height:n}:null,coefs:V?L.coefficients:null,sampleSpacing:V?H:null,projectDirections:I,gcsGrid:I?L.gcsGrid:null,isUV:this.rasterInfo.dataType===`vector-uv`,interpolation:r.interpolation,alignmentInfo:W,blockWidths:null},r);({pixelBlock:z,localNorthDirections:J}=e)}else{let e=k(G,K,{alignmentInfo:W});z=V?A(e,{width:t,height:n},L.coefficients,H,r.interpolation):e,I&&L.gcsGrid&&(J=j({width:t,height:n},L.gcsGrid),z=U(z,this.rasterInfo.dataType,J))}return r.requestRawData||I?{extent:e,srcExtent:d,srcTilePixelSize:w,pixelBlock:z,transformGrid:L,localNorthDirections:J,isPartiallyFilled:q}:{extent:e,srcExtent:e,srcTilePixelSize:w,pixelBlock:z}}async _fetchRawTiles(e,t,n,r){let{origin:i,blockBoundary:a}=this.rasterInfo.storageInfo,{blockWidth:o,blockHeight:s}=this.getBlockWidthHeight(e),{x:c,y:l}=t,{width:u,height:f,wrapCount:p}=n,m=this._getRasterTileAlignmentInfo(e,0);r.buffer&&(c-=r.buffer.cols,l-=r.buffer.rows,u+=r.buffer.cols*2,f+=r.buffer.rows*2);let h=0,g=0,_=0;p&&m!=null&&({worldColumnCountFromOrigin:g,originColumnOffset:_,rightPadding:h}=m,g*m.blockWidth-h>=c+u&&(h=0));let v=Math.floor(c/o),y=Math.floor(l/s),b=Math.floor((c+u+h-1)/o),x=Math.floor((l+f+h-1)/s),S=a[e];if(!S)return null;let{minRow:C,minCol:w,maxCol:T,maxRow:E}=S;if(p===0&&(x<C||b<w||y>E||v>T))return null;let D=[],O=!1,k=this.ioConfig.allowPartialFill==null?r.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=y;t<=x;t++)for(let n=v;n<=b;n++){let i=n;if(!r.disableWrapAround&&p&&m!=null&&g<=n&&(i=n-g-_),t>=C&&i>=w&&E>=t&&T>=i){let n=this._fetchRawTile(e,t,i,r);k?D.push(new Promise(e=>{n.then(t=>e(t)).catch(()=>{O=!0,e(null)})})):D.push(n)}else D.push(Promise.resolve(null))}if(D.length===0)return null;let A=await Promise.all(D),j={height:(x-y+1)*s,width:(b-v+1)*o},{spatialReference:M}=this.rasterInfo,{x:N,y:P}=this.getPyramidPixelSize(e);return{extent:new d({xmin:i.x+v*o*N,xmax:i.x+(b+1)*o*N,ymin:i.y-(x+1)*s*P,ymax:i.y-y*s*P,spatialReference:M}),pixelBlocks:A,mosaicSize:j,isPartiallyFilled:O}}_fetchRawTile(e,t,n,r){let{storageInfo:i}=this.rasterInfo,a=i.transposeInfo!=null&&!!r.transposedVariableName;if(!a){let r=i.blockBoundary[e];if(!r)return Promise.resolve(null);let{minRow:a,minCol:o,maxCol:s,maxRow:c}=r;if(t<a||n<o||t>c||n>s)return Promise.resolve(null)}let s=a?r.transposeVariableName:r.sliceId,c=i.isBsqTile?r.bandIds:null,l=x(this.rasterId,s,c),u=`${e}/${t}/${n}`,d=S(l,r.registryId,u);if(d==null){let a=new AbortController,o=r.bandIds?.slice();if(o?.length&&i.isBsqTile){let i=new Set(o),s=[],c=Array.from(i);for(let i of c)s.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:n,options:{...r,bandIds:[i]}},{signal:a.signal}));d=Promise.all(s).then(e=>{if(e.some(e=>e==null))return null;if(c.length!==o.length){let t=[];for(let n of o){let r=e[c.indexOf(n)];t.includes(r)&&(r=r.clone()),t.push(r)}e=t}return this.rasterJobHandler?this.rasterJobHandler.compositeBands({pixelBlocks:e},{signal:a.signal,transferPixelsToWorker:!0}):M(e)})}else d=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:n,options:r},{signal:a.signal});C(l,r.registryId,u,d,a),d.catch(()=>w(l,r.registryId,u))}return r.signal&&o(r,()=>{T(l,r.registryId,u)}),d}_computeMagDirValues(e){let{bandCount:t,dataType:n}=this.rasterInfo;if(!(t===2&&n===`vector-magdir`||n===`vector-uv`)||e?.length!==2||!e[0]?.length)return null;let r=e[0].length;if(n===`vector-magdir`){let t=e[1].map(e=>(e+360)%360);return[e[0],t]}let[i,a]=e,o=[],s=[];for(let e=0;e<r;e++){let[t,n]=W([i[e],a[e]]);o.push(t),s.push(n)}return[o,s]}_getRasterTileAlignmentInfo(e,t){return this._rasterTileAlignmentInfo??=V(this.rasterInfo),this._rasterTileAlignmentInfo.pyramidsInfo==null?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,n,r={}){let i={datumTransformation:r.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};r.srcResolution&&(i.srcResolution=r.srcResolution,this._updateSourceDataInfo(e,i));let a=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:o,srcHeight:s,pyramidLevel:c}=i,l=o/t,u=s/n,d=c<a&&l*u>=16,p=c===a&&this._requireTooManySrcTiles(o,s,t,n);if(d||p||o===0||s===0){let o=new f({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/n,spatialReference:e.spatialReference}),s=H(o,this.rasterInfo.spatialReference,e,i.datumTransformation),p=!s||r.srcResolution&&s.x+s.y<r.srcResolution.x+r.srcResolution.y;if(d&&r.srcResolution&&p){let e=Math.round(Math.log(Math.max(l,u))/Math.LN2)-1;if(a-c+3>=e){let t=2**e;s={x:r.srcResolution.x*t,y:r.srcResolution.y*t}}}s&&(i.srcResolution=s,this._updateSourceDataInfo(e,i))}return this._requireTooManySrcTiles(i.srcWidth,i.srcHeight,t,n)&&(i.srcWidth=0,i.srcHeight=0),i}_requireTooManySrcTiles(e,t,n,r){let{tileInfo:i}=this.rasterInfo.storageInfo,a=Math.ceil(e/i.size[0])*Math.ceil(t/i.size[1]),o=e/n,s=t/r;return a>=256*Math.max(1,(n+r)/1024)||o>8||s>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;let{rasterInfo:n}=this,r=n.spatialReference,{srcResolution:i,datumTransformation:a}=t,{pyramidLevel:o,pyramidResolution:s,excessiveReading:c}=I(i,n,this.ioConfig.sampling);if(c)return;let l=t.srcExtent||z(e,r,a);if(l==null)return;let u=n.transform;u&&(l=u.inverseTransform(l)),t.srcExtent=l;let{origin:d}=n.storageInfo,{width:f,height:p,ul:m}=h(l,d,s,o);t.pyramidLevel=o,t.pyramidResolution=s,t.srcWidth=f,t.srcHeight=p,t.ul=m}_getRequestOptionsWithSliceId(e){return this.rasterInfo.multidimensionalInfo!=null&&e.sliceId==null&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){let{srcLocation:n,position:r,pyramidLevel:i,useTransposedTile:a}=t,o=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[r])return{location:n,value:null};let{multidimensionalInfo:s}=this.rasterInfo;if(s==null||!a){let t=e.pixels.map(e=>e[r]),a={location:n,value:t,pyramidLevel:i},o=this._computeMagDirValues(t.map(e=>[e]));return o?.length&&(a.magdirValue=o.map(e=>e[0])),a}let c=e.pixels.map(e=>e.slice(r*o,r*o+o)),l=this._computeMagDirValues(c),{requestSomeSlices:u,identifyOptions:d}=t,f=v(s,d.transposedVariableName);if(u){let e=y(f,d.multidimensionalDefinition,d.timeExtent);c=c.map(t=>e.map(e=>t[e])),l=l?.map(t=>e.map(e=>t[e])),f=e.map(e=>f[e])}let p=e.noDataValues||this.rasterInfo.noDataValue,m={pixels:c,pixelType:e.pixelType},h;return p!=null&&(E(m,p),h=m.mask),{location:n,value:null,dataSeries:f.map((e,t)=>{let n={value:h?.[t]===0?null:c.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new q({...e,isSlice:!0}))};return l?.length&&(n.magdirValue=[l[0][t],l[1][t]]),n}),pyramidLevel:i}}};e([c()],Q.prototype,`_rasterTileAlignmentInfo`,void 0),e([c()],Q.prototype,`_tileFetchQueue`,void 0),e([c({readOnly:!0})],Q.prototype,`_isGlobalWrappableSource`,null),e([c({readOnly:!0})],Q.prototype,`_hasNoneOrGCSShiftTransform`,null),e([c()],Q.prototype,`_openPromise`,void 0),e([c()],Q.prototype,`rasterJobHandler`,null),e([c({readOnly:!0})],Q.prototype,`rasterId`,null),e([c(K)],Q.prototype,`url`,null),e([c({type:String,json:{write:!0}})],Q.prototype,`datasetName`,void 0),e([c({type:String,json:{write:!0}})],Q.prototype,`datasetFormat`,void 0),e([c()],Q.prototype,`hasUniqueSourceStorageInfo`,void 0),e([c()],Q.prototype,`rasterInfo`,void 0),e([c()],Q.prototype,`ioConfig`,void 0),e([c()],Q.prototype,`sourceJSON`,void 0),e([c()],Q.prototype,`rawBlockRegistryIds`,void 0),Q=e([l(`esri.layers.raster.datasets.BaseRaster`)],Q);function $(e,t,n){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}export{Q as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../request.js";import n from"../../../core/Error.js";import{JSONSupport as r}from"../../../core/JSONSupport.js";import i from"../../../core/Logger.js";import{debounce as a,onAbort as o}from"../../../core/promiseUtils.js";import{QueueProcessor as s}from"../../../core/QueueProcessor.js";import{property as c,subclass as l}from"../../../core/accessorSupport/decorators.js";import{ensureClass as u}from"../../../core/accessorSupport/ensureType.js";import d from"../../../geometry/Extent.js";import f from"../../../geometry/Point.js";import p from"../../../geometry/SpatialReference.js";import{isFunctionRaster as m,getPixelSpaceCoverage as h}from"./datasetUtils.js";import{isMultiSliceOrRangeDefinition as g,getSliceIndex as _,createSlices as v,getSliceIds as y}from"./multidimensionalUtils.js";import{clearRegisteredIds as b,getRasterId as x,getBlock as S,putBlock as C,deleteBlock as w,decreaseRefCount as T}from"./RawBlockCache.js";import{convertNoDataToMask as E}from"../formats/pixelRangeUtils.js";import{decode as D}from"../formats/RasterCodec.js";import{convertPixelSize as O}from"../functions/clipUtils.js";import{mosaic as k,approximateTransform as A,getLocalArithmeticNorthRotations as j,compositeBands as M}from"../functions/pixelUtils.js";import{getWorldWidth as N,load as P,projectPoint as F,snapPyramid as I,shiftExtent as L,getWorldWrapCount as R,projectExtent as z,getProjectionOffsetGrid as B,getRasterDatasetAlignmentInfo as V,projectResolution as H}from"../functions/rasterProjectionHelper.js";import{convertToLocalDirections as U,uvComponentToVector as W}from"../functions/vectorFieldUtils.js";import{sanitizeUrl as G}from"../../support/arcgisLayerUrl.js";import{url as K}from"../../support/commonProperties.js";import q from"../../support/DimensionalDefinition.js";import J from"../../support/LOD.js";import Y from"../../support/RasterStorageInfo.js";import X from"../../support/TileInfo.js";let Z=0,Q=class extends r{constructor(){super(...arguments),this._tileFetchQueue=new s({concurrency:32,process:(e,t)=>this.fetchRawTile(e.pyramidLevel,e.row,e.col,{...e.options,signal:t})}),this.datasetName=null,this.datasetFormat=null,this.hasUniqueSourceStorageInfo=!0,this.rasterInfo=null,this.ioConfig={sampling:`closest`},this.rawBlockRegistryIds=[],this.refresh=a(async e=>{await this._openPromise;let t=await this._refresh(e);return t.dataChanged&&b(this.rasterId,this.rawBlockRegistryIds),t})}normalizeCtorArgs(e){return e?.ioConfig&&(e={...e,ioConfig:{resolution:null,bandIds:null,sampling:`closest`,tileInfo:X.create(),...e.ioConfig}}),e}get _isGlobalWrappableSource(){let{rasterInfo:e}=this,t=N(e.spatialReference);return t!=null&&e.extent.width>=t/2}get _hasNoneOrGCSShiftTransform(){let{transform:e}=this.rasterInfo;return e==null||e.type===`gcs-shift`}set rasterJobHandler(e){this._set(`rasterJobHandler`,e),m(this)&&this.primaryRasters?.rasters?.forEach(t=>t.rasterJobHandler=e)}get rasterId(){return this.url||`rasterId-${Z++}`}set url(e){this._set(`url`,G(e,i.getLogger(this)))}async open(e){return this._openPromise??=P().then(()=>this._open(e)),this._openPromise}async fetchTile(e,t,r,i={}){let a=i.tileInfo||this.rasterInfo.storageInfo.tileInfo,o=this.getTileExtentFromTileInfo(e,t,r,a);if(!o)throw new n(`imagery-tile:out-of-bounds`,`Level for fetch tile out of range`);return i={noClip:!0,...i},this.fetchPixels(o,a.size[0],a.size[1],i)}async identify(e,t={}){e=u(f,e).clone().normalize();let{multidimensionalDefinition:n,timeExtent:r}=t,{rasterInfo:i}=this,{hasMultidimensionalTranspose:a,multidimensionalInfo:o}=i,{transposedVariableName:s}=t,c=o!=null&&a&&(r!=null||g(n));c&&!s&&(s=n!=null&&n.length>0?n[0].variableName??void 0:o.variables[0].name,t={...t,transposedVariableName:s}),t=this._getRequestOptionsWithSliceId(t);let{spatialReference:l,extent:p}=i,{datumTransformation:h}=t,_=F(e,l,h);if(!p.intersects(_))return{location:_,value:null};if(i.transform!=null){let e=i.transform.inverseTransform(_);if(!i.nativeExtent.intersects(e))return{location:e,value:null};_=e}let v=s!=null&&o!=null&&i.hasMultidimensionalTranspose;if(m(this)){let e=this.primaryRasters.rasters[0];if(v)return e.identify(_,t);let{pixelSize:r}=i,a=r.x*3/2,o=r.y*3/2,s=new d({xmin:_.x-a,xmax:_.x+a,ymin:_.y-o,ymax:_.y+o,spatialReference:l}),c={interpolation:`nearest`,multidimensionalDefinition:n,sliceId:t.sliceId,bandIds:t.bandIds},{pixelBlock:u}=await e.fetchPixels(s,3,3,c),{pixelBlock:f}=await this.fetchPixels(s,3,3,c);if(u==null)return{location:_,value:null};let p=!u.mask||u.mask[4]?u.pixels.map(e=>e[4]):null,m;return f!=null&&(m=!f.mask||f.mask[4]?f.pixels.map(e=>e[4]):void 0),{location:_,value:p,processedValue:m,pyramidLevel:0}}let y=0;if(!v){let{srcResolution:n}=t;if(n)n.spatialReference&&(n=O(new f(n),l)),y=I(n,i,this.ioConfig.sampling).pyramidLevel;else if(y=await this.computeBestPyramidLevelForLocation(e,t),y==null)return{location:_,value:null}}let b=this.identifyPixelLocation(_,y,null,v);if(b===null)return{location:_,value:null};let{row:x,col:S,rowOffset:C,colOffset:w,blockWidth:T}=b,E=await this._fetchRawTile(y,x,S,t);if(!E?.pixels?.length)return{location:_,value:null};let D=C*T+w;return this._processIdentifyResult(E,{srcLocation:_,position:D,pyramidLevel:y,useTransposedTile:!!v,requestSomeSlices:c,identifyOptions:t})}async fetchPixels(e,t,n,r={}){e=L(e),r=this._getRequestOptionsWithSliceId(r);let{_hasNoneOrGCSShiftTransform:i}=this;if(r.requestRawData&&i)return this._fetchPixels(e,t,n,r);let a=N(e.spatialReference),o=R(e);if(a==null||o===0||o===1&&this._isGlobalWrappableSource&&i)return this._fetchPixels(e,t,n,r);if(o>=3)return{extent:e,pixelBlock:null};let s=[],{xmin:c,xmax:l}=e,u=Math.round(a/(l-c)*t),f=u-Math.round((a/2-c)/(l-c)*t),p=0,m=[];for(let i=0;i<=o;i++){let h=i===0?c:-a/2,g=i===o?l-a*i:a/2,_=new d({xmin:h,xmax:g,ymin:e.ymin,ymax:e.ymax,spatialReference:e.spatialReference}),v=i===0?u-f:i===o?t-p:u;p+=v,m.push(v);let y=r.disableWrapAround&&i>0?null:this._fetchPixels(_,v,n,r);s.push(y)}let h=(await Promise.all(s)).map(e=>e?.pixelBlock),g=null,_={width:t,height:n};g=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:h,srcMosaicSize:_,destDimension:null,coefs:null,sampleSpacing:null,interpolation:`nearest`,alignmentInfo:null,blockWidths:m},r)).pixelBlock:k(h,_,{blockWidths:m});let v=z(e,this.rasterInfo.spatialReference,r.datumTransformation);return{extent:e,srcExtent:v,pixelBlock:g}}async fetchRawPixels(e,t,n,r={}){t={x:Math.floor(t.x),y:Math.floor(t.y)};let i=await this._fetchRawTiles(e,t,n,r),{nativeExtent:a,nativePixelSize:o,storageInfo:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,f=new d({xmin:a.xmin+l*t.x,xmax:a.xmin+l*(t.x+n.width-1),ymin:a.ymax-u*(t.y+n.height-1),ymax:a.ymax-u*t.y,spatialReference:a.spatialReference});if(!i)return{extent:f,srcExtent:f,pixelBlock:null};let{pixelBlocks:p,mosaicSize:m}=i;if(p.length===1&&p[0]!=null&&p[0].width===n.width&&p[0].height===n.height)return{extent:f,srcExtent:f,pixelBlock:i.pixelBlocks[0]};let h=e>0?s.pyramidBlockWidth:s.blockWidth,g=e>0?s.pyramidBlockHeight:s.blockHeight,_={x:t.x%h,y:t.y%g},v;return v=this.rasterJobHandler?(await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:p,srcMosaicSize:m,destDimension:n,clipOffset:_,clipSize:n,coefs:null,sampleSpacing:null,interpolation:r.interpolation,alignmentInfo:null,blockWidths:null},r)).pixelBlock:k(p,m,{clipOffset:_,clipSize:n}),{extent:f,srcExtent:f,pixelBlock:v}}fetchRawTile(e,t,r,i){throw new n(`BaseRaster:read-not-implemented`,`fetchRawTile() is not implemented`)}computeExtent(e){return z(this.rasterInfo.extent,e)}decodePixelBlock(e,t,n){return this.rasterJobHandler?this.rasterJobHandler.decode({data:e,options:t},n):D(e,t,n)}async request(e,n,r=0){let{customFetchParameters:i}=this.ioConfig,{range:a,query:o,headers:s}=n;r=r??n.retryCount??this.ioConfig.retryCount;let c=a?{Range:`bytes=${a.from}-${a.to}`}:null;try{return await t(e,{...n,query:{...o,...i},headers:{...s,...c}})}catch(t){if(r>0)return r--,this.request(e,n,r);throw t}}getSliceIndex(e){let{multidimensionalInfo:t}=this.rasterInfo;return t==null||e==null||e.length===0?null:_(e,t)}getTileExtentFromTileInfo(e,t,n,r){let i=r.lodAt(e);return i?this.getTileExtent({x:i.resolution,y:i.resolution},t,n,r.origin,r.spatialReference,r.size):null}updateTileInfo(){let{storageInfo:e,spatialReference:t,extent:n,pixelSize:r}=this.rasterInfo,{pyramidResolutions:i}=e;if(!e.tileInfo){let a=[],o=e.maximumPyramidLevel||0,s=(r.x+r.y)/2,c=1/.0254*96*s;for(let e=0;e<=o&&(a.unshift(new J({level:o-e,resolution:s,scale:c})),e!==o);e++)if(i){let t=(i[e].x+i[e].y)/2;c*=t/s,s=t}else s*=2,c*=2;let l=new f({x:n.xmin,y:n.ymax,spatialReference:t});e.tileInfo=new X({origin:l,size:[e.blockWidth,e.blockHeight],spatialReference:t,lods:a}),e.isVirtualTileInfo=!0}}createRemoteDatasetStorageInfo(e,t=512,n=512,r){let{width:i,height:a,nativeExtent:o,pixelSize:s,spatialReference:c}=e,l=new f({x:o.xmin,y:o.ymax,spatialReference:c});r??=Math.max(0,Math.round(Math.log(Math.max(i,a))/Math.LN2-8));let u=this.computeBlockBoundary(o,t,n,{x:o.xmin,y:o.ymax},[s],r);e.storageInfo=new Y({blockWidth:t,blockHeight:n,pyramidBlockWidth:t,pyramidBlockHeight:n,origin:l,firstPyramidLevel:1,maximumPyramidLevel:r,blockBoundary:u})}async computeBestPyramidLevelForLocation(e,t={}){return 0}computeBlockBoundary(e,t,n,r,i,a=0,o=2){if(i.length===1&&a>0){i=[...i];let{x:e,y:t}=i[0];for(let n=0;n<a;n++)e*=o,t*=o,i.push({x:e,y:t})}let s=[],{x:c,y:l}=r;for(let r=0;r<i.length;r++){let{x:a,y:o}=i[r];s.push({minCol:Math.floor((e.xmin-c+.1*a)/t/a),maxCol:Math.floor((e.xmax-c-.1*a)/t/a),minRow:Math.floor((l-e.ymax+.1*o)/n/o),maxRow:Math.floor((l-e.ymin-.1*o)/n/o)})}return s}getPyramidPixelSize(e){let{nativePixelSize:t}=this.rasterInfo,{pyramidResolutions:n,pyramidScalingFactor:r}=this.rasterInfo.storageInfo;if(e===0)return t;if(n!=null&&n.length)return n[e-1];let i=r**e;return{x:t.x*i,y:t.y*i}}identifyPixelLocation(e,t,n,r){let{spatialReference:i,nativeExtent:a,storageInfo:o}=this.rasterInfo,{maximumPyramidLevel:s,origin:c,transposeInfo:l}=o,u=r&&l!=null?l.tileSize[0]:o.blockWidth,d=r&&l!=null?l.tileSize[1]:o.blockHeight,f=F(e,i,n);if(!a.intersects(f)||t<0||t>s)return null;let{x:p,y:m}=this.getPyramidPixelSize(t),h=(c.y-f.y)/m/d,g=(f.x-c.x)/p/u,_=Math.min(d-1,Math.floor((h-Math.floor(h))*d)),v=Math.min(u-1,Math.floor((g-Math.floor(g))*u));return{pyramidLevel:t,row:Math.floor(h),col:Math.floor(g),rowOffset:_,colOffset:v,blockWidth:u,srcLocation:f}}getTileExtent(e,t,n,r,i,a){let[o,s]=a,c=r.x+n*o*e.x,l=c+o*e.x,u=r.y-t*s*e.y,f=u-s*e.y;return new d({xmin:c,xmax:l,ymin:f,ymax:u,spatialReference:i})}getBlockWidthHeight(e){return{blockWidth:e>0?this.rasterInfo.storageInfo.pyramidBlockWidth:this.rasterInfo.storageInfo.blockWidth,blockHeight:e>0?this.rasterInfo.storageInfo.pyramidBlockHeight:this.rasterInfo.storageInfo.blockHeight}}isBlockOutside(e,t,n){let r=this.rasterInfo.storageInfo.blockBoundary[e];return!r||r.maxRow<t||r.maxCol<n||r.minRow>t||r.minCol>n}updateImageSpaceRasterInfo(e){let{pixelSize:t}=e,{width:n,height:r}=e,i=p.WebMercator;e.spatialReference=i,e.extent=e.nativeExtent=new d({xmin:-.5,ymax:.5,xmax:n-.5,ymin:.5-r,spatialReference:i}),e.isPseudoSpatialReference=!0,e.transform=null,e.pixelSize=new f({x:1,y:1,spatialReference:i});let{extent:a,storageInfo:o}=e;if(o){o.origin=new f({x:a.xmin,y:a.ymax,spatialReference:i});let{pyramidResolutions:n,tileInfo:r}=o;if(n&&n.forEach(e=>{e.x/=t.x,e.y/=t.y}),r){r.origin=o.origin;let t=(e.nativePixelSize.x+e.nativePixelSize.y)/2;r.lods.forEach((e,n)=>{e.resolution=t*2**n,e.scale=96*e.resolution/.0254})}}}async _refresh(e){return{dataChanged:!0}}async _fetchPixels(e,t,n,r={}){let i=R(e);if(i>=2)return{extent:e,pixelBlock:null};let a=this._getSourceDataInfo(e,t,n,r),{pyramidLevel:o,srcResolution:s,srcWidth:c,srcHeight:l,ul:u}=a,{srcExtent:d}=a;if(c===0||l===0)return{extent:e,srcExtent:d,pixelBlock:null};let{rasterInfo:p}=this,m=p.transform,h=m?.type===`gcs-shift`,g=N(e.spatialReference)!=null;(h||!g)&&(i=R(d,h));let _=await this._fetchRawTiles(o,u,{width:c,height:l,wrapCount:i},r);if(!_)return{extent:e,srcExtent:d,pixelBlock:null};d=_.extent;let v=p.storageInfo,y=o>0?v.pyramidBlockWidth:v.blockWidth,b=o>0?v.pyramidBlockHeight:v.blockHeight,{x,y:S}=p.pixelSize;if(o>0){let{pyramidResolutions:e,pyramidScalingFactor:t}=v;if(e!=null&&e[o-1])({x,y:S}=e[o-1]);else{let e=t**o;x*=e,S*=e}}let C=p.spatialReference,w=new f({x,y:S,spatialReference:C}),T=y===c&&b===l&&u.x%y===0&&u.y%b===0,E=new f({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/n,spatialReference:e.spatialReference}),D=!e.spatialReference.equals(C),O=C.isGeographic?1e-9:1e-4,{datumTransformation:M}=r;if(!D&&T&&_.pixelBlocks.length===1&&y===t&&b===n&&$(s,E,O))return{extent:e,srcExtent:d,srcTilePixelSize:w,pixelBlock:_.pixelBlocks[0]};let F=g&&N(d.spatialReference)!=null&&this._hasNoneOrGCSShiftTransform,I=r.requestProjectedLocalDirections&&this.rasterInfo.dataType.startsWith(`vector`);I&&!this.rasterJobHandler&&await P();let L=this.rasterJobHandler?await this.rasterJobHandler.getProjectionOffsetGrid({projectedExtent:e,srcBufferExtent:d,pixelSize:E.toJSON(),datumTransformation:M,rasterTransform:m,hasWrapAround:i>0||F,isAdaptive:this.ioConfig.optimizeProjectionAccuracy!==!1,includeGCSGrid:I},r):B({projectedExtent:e,srcBufferExtent:d,pixelSize:E,datumTransformation:M,rasterTransform:m,hasWrapAround:i>0||F,isAdaptive:!1,includeGCSGrid:I}),z,V=!r.requestRawData,H={rows:L.spacing[0],cols:L.spacing[1]},W=this._hasNoneOrGCSShiftTransform?this._getRasterTileAlignmentInfo(o,d.xmin):void 0,{pixelBlocks:G,mosaicSize:K,isPartiallyFilled:q}=_,J=null;if(this.rasterJobHandler){let e=await this.rasterJobHandler.mosaicAndTransform({srcPixelBlocks:G,srcMosaicSize:K,destDimension:V?{width:t,height:n}:null,coefs:V?L.coefficients:null,sampleSpacing:V?H:null,projectDirections:I,gcsGrid:I?L.gcsGrid:null,isUV:this.rasterInfo.dataType===`vector-uv`,interpolation:r.interpolation,alignmentInfo:W,blockWidths:null},r);({pixelBlock:z,localNorthDirections:J}=e)}else{let e=k(G,K,{alignmentInfo:W});z=V?A(e,{width:t,height:n},L.coefficients,H,r.interpolation):e,I&&L.gcsGrid&&(J=j({width:t,height:n},L.gcsGrid),z=U(z,this.rasterInfo.dataType,J))}return r.requestRawData||I?{extent:e,srcExtent:d,srcTilePixelSize:w,pixelBlock:z,transformGrid:L,localNorthDirections:J,isPartiallyFilled:q}:{extent:e,srcExtent:e,srcTilePixelSize:w,pixelBlock:z}}async _fetchRawTiles(e,t,n,r){let{origin:i,blockBoundary:a}=this.rasterInfo.storageInfo,{blockWidth:o,blockHeight:s}=this.getBlockWidthHeight(e),{x:c,y:l}=t,{width:u,height:f,wrapCount:p}=n,m=this._getRasterTileAlignmentInfo(e,0);r.buffer&&(c-=r.buffer.cols,l-=r.buffer.rows,u+=r.buffer.cols*2,f+=r.buffer.rows*2);let h=0,g=0,_=0;p&&m!=null&&({worldColumnCountFromOrigin:g,originColumnOffset:_,rightPadding:h}=m,g*m.blockWidth-h>=c+u&&(h=0));let v=Math.floor(c/o),y=Math.floor(l/s),b=Math.floor((c+u+h-1)/o),x=Math.floor((l+f+h-1)/s),S=a[e];if(!S)return null;let{minRow:C,minCol:w,maxCol:T,maxRow:E}=S;if(p===0&&(x<C||b<w||y>E||v>T))return null;let D=[],O=!1,k=this.ioConfig.allowPartialFill==null?r.allowPartialFill:this.ioConfig.allowPartialFill;for(let t=y;t<=x;t++)for(let n=v;n<=b;n++){let i=n;if(!r.disableWrapAround&&p&&m!=null&&g<=n&&(i=n-g-_),t>=C&&i>=w&&E>=t&&T>=i){let n=this._fetchRawTile(e,t,i,r);k?D.push(new Promise(e=>{n.then(t=>e(t)).catch(()=>{O=!0,e(null)})})):D.push(n)}else D.push(Promise.resolve(null))}if(D.length===0)return null;let A=await Promise.all(D),j={height:(x-y+1)*s,width:(b-v+1)*o},{spatialReference:M}=this.rasterInfo,{x:N,y:P}=this.getPyramidPixelSize(e);return{extent:new d({xmin:i.x+v*o*N,xmax:i.x+(b+1)*o*N,ymin:i.y-(x+1)*s*P,ymax:i.y-y*s*P,spatialReference:M}),pixelBlocks:A,mosaicSize:j,isPartiallyFilled:O}}_fetchRawTile(e,t,n,r){let{storageInfo:i}=this.rasterInfo,a=i.transposeInfo!=null&&!!r.transposedVariableName;if(!a){let r=i.blockBoundary[e];if(!r)return Promise.resolve(null);let{minRow:a,minCol:o,maxCol:s,maxRow:c}=r;if(t<a||n<o||t>c||n>s)return Promise.resolve(null)}let s=a?r.transposeVariableName:r.sliceId,c=i.isBsqTile?r.bandIds:null,l=x(this.rasterId,s,c),u=`${e}/${t}/${n}`,d=S(l,r.registryId,u);if(d==null){let a=new AbortController,o=r.bandIds?.slice();if(o?.length&&i.isBsqTile){let i=new Set(o),s=[],c=Array.from(i);for(let i of c)s.push(this._tileFetchQueue.push({pyramidLevel:e,row:t,col:n,options:{...r,bandIds:[i]}},{signal:a.signal}));d=Promise.all(s).then(e=>{if(e.some(e=>e==null))return null;if(c.length!==o.length){let t=[];for(let n of o){let r=e[c.indexOf(n)];t.includes(r)&&(r=r.clone()),t.push(r)}e=t}return this.rasterJobHandler?this.rasterJobHandler.compositeBands({pixelBlocks:e},{signal:a.signal,transferPixelsToWorker:!0}):M(e)})}else d=this._tileFetchQueue.push({pyramidLevel:e,row:t,col:n,options:r},{signal:a.signal});C(l,r.registryId,u,d,a),d.catch(()=>w(l,r.registryId,u))}return r.signal&&o(r,()=>{T(l,r.registryId,u)}),d}_computeMagDirValues(e){let{bandCount:t,dataType:n}=this.rasterInfo;if(!(t===2&&n===`vector-magdir`||n===`vector-uv`)||e?.length!==2||!e[0]?.length)return null;let r=e[0].length;if(n===`vector-magdir`){let t=e[1].map(e=>(e+360)%360);return[e[0],t]}let[i,a]=e,o=[],s=[];for(let e=0;e<r;e++){let[t,n]=W([i[e],a[e]]);o.push(t),s.push(n)}return[o,s]}_getRasterTileAlignmentInfo(e,t){return this._rasterTileAlignmentInfo??=V(this.rasterInfo),this._rasterTileAlignmentInfo.pyramidsInfo==null?null:{startX:t,halfWorldWidth:this._rasterTileAlignmentInfo.halfWorldWidth,hasGCSSShiftTransform:this._rasterTileAlignmentInfo.hasGCSSShiftTransform,...this._rasterTileAlignmentInfo.pyramidsInfo[e]}}_getSourceDataInfo(e,t,n,r={}){let i={datumTransformation:r.datumTransformation,pyramidLevel:0,pyramidResolution:null,srcExtent:null,srcHeight:0,srcResolution:null,srcWidth:0,ul:{x:0,y:0}};r.srcResolution&&(i.srcResolution=r.srcResolution,this._updateSourceDataInfo(e,i));let a=this.rasterInfo.storageInfo.maximumPyramidLevel||0,{srcWidth:o,srcHeight:s,pyramidLevel:c}=i,l=o/t,u=s/n,d=c<a&&l*u>=16,p=c===a&&this._requireTooManySrcTiles(o,s,t,n);if(d||p||o===0||s===0){let o=new f({x:(e.xmax-e.xmin)/t,y:(e.ymax-e.ymin)/n,spatialReference:e.spatialReference}),s=H(o,this.rasterInfo.spatialReference,e,i.datumTransformation),p=!s||r.srcResolution&&s.x+s.y<r.srcResolution.x+r.srcResolution.y;if(d&&r.srcResolution&&p){let e=Math.round(Math.log(Math.max(l,u))/Math.LN2)-1;if(a-c+3>=e){let t=2**e;s={x:r.srcResolution.x*t,y:r.srcResolution.y*t}}}s&&(i.srcResolution=s,this._updateSourceDataInfo(e,i))}return this._requireTooManySrcTiles(i.srcWidth,i.srcHeight,t,n)&&(i.srcWidth=0,i.srcHeight=0),i}_requireTooManySrcTiles(e,t,n,r){let{tileInfo:i}=this.rasterInfo.storageInfo,a=Math.ceil(e/i.size[0])*Math.ceil(t/i.size[1]),o=e/n,s=t/r;return a>=256*Math.max(1,(n+r)/1024)||o>8||s>8}_updateSourceDataInfo(e,t){t.srcWidth=0,t.srcHeight=0;let{rasterInfo:n}=this,r=n.spatialReference,{srcResolution:i,datumTransformation:a}=t,{pyramidLevel:o,pyramidResolution:s,excessiveReading:c}=I(i,n,this.ioConfig.sampling);if(c)return;let l=t.srcExtent||z(e,r,a);if(l==null)return;let u=n.transform;u&&(l=u.inverseTransform(l)),t.srcExtent=l;let{origin:d}=n.storageInfo,{width:f,height:p,ul:m}=h(l,d,s,o);t.pyramidLevel=o,t.pyramidResolution=s,t.srcWidth=f,t.srcHeight=p,t.ul=m}_getRequestOptionsWithSliceId(e){return this.rasterInfo.multidimensionalInfo!=null&&e.sliceId==null&&(e={...e,sliceId:this.getSliceIndex(e.multidimensionalDefinition)}),e}_processIdentifyResult(e,t){let{srcLocation:n,position:r,pyramidLevel:i,useTransposedTile:a}=t,o=e.pixels[0].length/e.width/e.height;if(e.mask&&!e.mask[r])return{location:n,value:null};let{multidimensionalInfo:s}=this.rasterInfo;if(s==null||!a){let t=e.pixels.map(e=>e[r]),a={location:n,value:t,pyramidLevel:i},o=this._computeMagDirValues(t.map(e=>[e]));return o?.length&&(a.magdirValue=o.map(e=>e[0])),a}let c=e.pixels.map(e=>e.slice(r*o,r*o+o)),l=this._computeMagDirValues(c),{requestSomeSlices:u,identifyOptions:d}=t,f=v(s,d.transposedVariableName);if(u){let e=y(f,d.multidimensionalDefinition,d.timeExtent);c=c.map(t=>e.map(e=>t[e])),l=l?.map(t=>e.map(e=>t[e])),f=e.map(e=>f[e])}let p=e.noDataValues||this.rasterInfo.noDataValue,m={pixels:c,pixelType:e.pixelType},h;return p!=null&&(E(m,p),h=m.mask),{location:n,value:null,dataSeries:f.map((e,t)=>{let n={value:h?.[t]===0?null:c.map(e=>e[t]),multidimensionalDefinition:e.multidimensionalDefinition.map(e=>new q({...e,isSlice:!0}))};return l?.length&&(n.magdirValue=[l[0][t],l[1][t]]),n}),pyramidLevel:i}}};e([c()],Q.prototype,`_rasterTileAlignmentInfo`,void 0),e([c()],Q.prototype,`_tileFetchQueue`,void 0),e([c({readOnly:!0})],Q.prototype,`_isGlobalWrappableSource`,null),e([c({readOnly:!0})],Q.prototype,`_hasNoneOrGCSShiftTransform`,null),e([c()],Q.prototype,`_openPromise`,void 0),e([c()],Q.prototype,`rasterJobHandler`,null),e([c({readOnly:!0})],Q.prototype,`rasterId`,null),e([c(K)],Q.prototype,`url`,null),e([c({type:String,json:{write:!0}})],Q.prototype,`datasetName`,void 0),e([c({type:String,json:{write:!0}})],Q.prototype,`datasetFormat`,void 0),e([c()],Q.prototype,`hasUniqueSourceStorageInfo`,void 0),e([c()],Q.prototype,`rasterInfo`,void 0),e([c()],Q.prototype,`ioConfig`,void 0),e([c()],Q.prototype,`sourceJSON`,void 0),e([c()],Q.prototype,`rawBlockRegistryIds`,void 0),Q=e([l(`esri.layers.raster.datasets.BaseRaster`)],Q);function $(e,t,n){return Math.abs(e.x-t.x)<n&&Math.abs(e.y-t.y)<n}export{Q as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Point.js";import{GeospatialPDFWorkerClient as a}from"../../geospatialPDF/GeospatialPDFWorkerClient.js";import o from"./BaseRaster.js";import s from"../../support/PixelBlock.js";import c from"../../support/RasterInfo.js";let l=class extends o{constructor(){super(...arguments),this._workerClient=new a,this._extent=null,this._ctm=null,this._neatlineRing=[],this._width=0,this._height=0,this._tileSize=512,this.datasetFormat=`PDF`,this.frame=null,this.neatlineExtent=null,this.page=1,this.tileType=`Raster`}destroy(){this._workerClient.destroy(),this.neatlineExtent=null,this._extent=null,this._ctm=null,this._neatlineRing=[]}async fetchRawTile(e,t,n,r={}){let i=this._extent,a=this._ctm,o=this.getTileExtentPDF(e,t,n);return o.intersects(i)?d(await this._workerClient.render(o,this._tileSize,this._tileSize,a,this._neatlineRing,r)):null}async _open(e){if(!this.url)throw new t(`geospatial-pdf-raster:open`,`GeospatialPDFRaster requires a url.`);let n=await this._workerClient.loadPDF({url:this.url,page:this.page},e);this.frame=n.frame;let r=this.frame.outerExtentMediabox;if(!r)throw new t(`geospatial-pdf-raster:open`,`Failed to compute Geospatial PDF extent.`);this.neatlineExtent=n.
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Point.js";import{GeospatialPDFWorkerClient as a}from"../../geospatialPDF/GeospatialPDFWorkerClient.js";import o from"./BaseRaster.js";import s from"../../support/PixelBlock.js";import c from"../../support/RasterInfo.js";let l=class extends o{constructor(){super(...arguments),this._workerClient=new a,this._extent=null,this._ctm=null,this._neatlineRing=[],this._width=0,this._height=0,this._tileSize=512,this.datasetFormat=`PDF`,this.frame=null,this.neatlineExtent=null,this.page=1,this.tileType=`Raster`}destroy(){this._workerClient.destroy(),this.neatlineExtent=null,this._extent=null,this._ctm=null,this._neatlineRing=[]}async fetchRawTile(e,t,n,r={}){let i=this._extent,a=this._ctm,o=this.getTileExtentPDF(e,t,n);return o.intersects(i)?d(await this._workerClient.render(o,this._tileSize,this._tileSize,a,this._neatlineRing,r)):null}async _open(e){if(!this.url)throw new t(`geospatial-pdf-raster:open`,`GeospatialPDFRaster requires a url.`);let n=await this._workerClient.loadPDF({url:this.url,page:this.page},e);this.frame=n.frame;let r=this.frame.outerExtentMediabox;if(!r)throw new t(`geospatial-pdf-raster:open`,`Failed to compute Geospatial PDF extent.`);this.neatlineExtent=n.neatlineExtent,this._extent=r,this._ctm=this.frame.ctm,this._neatlineRing=this.frame.sourceMediaBoxPolygon.rings[0];let i=f(this.frame.ctm,this._extent);this._width=i[0],this._height=i[1];let a={x:r.width/this._width,y:r.height/this._height},o=new c({width:this._width,height:this._height,pixelType:`u8`,extent:r,pixelSize:a,spatialReference:r.spatialReference,bandCount:3,keyProperties:{DataType:`Processed`}});this.createRemoteDatasetStorageInfo(o,this._tileSize,this._tileSize),this._set(`rasterInfo`,o),this.updateTileInfo()}getTileExtentPDF(e,t,n){let r=this._extent,a=2**e,o=r.width/this._width*a,s=r.height/this._height*a,c=new i({x:r.xmin,y:r.ymax});return this.getTileExtent({x:o,y:s},t,n,c,r.spatialReference,[512,512])}};e([n({type:String,json:{write:!0}})],l.prototype,`datasetFormat`,void 0),e([n({constructOnly:!0})],l.prototype,`page`,void 0),e([n({readOnly:!0})],l.prototype,`tileType`,void 0),l=e([r(`esri.layers.raster.datasets.GeospatialPDFRaster`)],l);const u=l;function d(e){return new s({width:e.width,height:e.height,pixelType:`u8`,pixels:[e.red,e.green,e.blue],mask:e.mask})}function f(e,n){let[r,i,a,o]=e,s=r*o-i*a;if(!Number.isFinite(s)||s===0)throw new t(`geospatial-pdf-raster:open`,`Failed to derive raster dimensions from an invalid PDF CTM.`);let c=10*Math.hypot(o,i)/Math.abs(s),l=10*Math.hypot(a,r)/Math.abs(s),u=Math.max(1,Math.ceil(n.width*c)),d=Math.max(1,Math.ceil(n.height*l));if(!Number.isFinite(u)||!Number.isFinite(d))throw new t(`geospatial-pdf-raster:open`,`PDF CTM produced invalid raster dimensions.`);return[u,d]}export{u as default};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{
|
|
3
|
-
`).slice(0,6).map(e=>Number(e)):null;f.transform=e?.length===6?new
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{throwIfAborted as n,eachAlways as r,createAbortError as i}from"../../../core/promiseUtils.js";import{property as a,subclass as o}from"../../../core/accessorSupport/decorators.js";import s from"../../../geometry/Extent.js";import c from"../../../geometry/SpatialReference.js";import l from"./BaseRaster.js";import u from"./InMemoryRaster.js";import{parsePAMInfo as d}from"./pamParser.js";import{parseHeader as f}from"../formats/JpgPlus.js";import{getFormat as p}from"../formats/RasterCodec.js";import{estimateStatisticsFromHistograms as m}from"../functions/stretchUtils.js";import h from"../transforms/PolynomialTransform.js";const g=`image-aux-raster:open`,_=`The data is not a supported format.`;let v=class extends l{set rasterJobHandler(e){this._set(`rasterJobHandler`,e),this._inMemoryRaster&&(this._inMemoryRaster.rasterJobHandler=e)}async fetchRawTile(e,t,n,r={}){return this._inMemoryRaster?.fetchRawTile(e,t,n,r)}async _open(e){let{data:n,format:r}=await this._fetchData(e),i,{tileGeneration:a}=this.ioConfig,o=a===`immediate`||r!==`jpg`;if(o){let a=await this._decodeFullImage(n,r,e);if(!a)throw new t(g,`The data cannot be decoded.`);i=await this._createRasterSource(a,e)}else{let r=f(n);if(!r)throw new t(g,_);i=await this._createRasterSource(r,e),i.encodedData=n}let{rasterJobHandler:s,ioConfig:c}=this,l=new u({preGenerateTiles:o,rasterJobHandler:s,source:i,ioConfig:{...c,sampling:`closest`,skipStatistics:!0}});await l.open(e),this._set(`rasterInfo`,l.rasterInfo),this._inMemoryRaster=l}async _createRasterSource(e,t){let{spatialReference:n,statistics:r,histograms:i,transform:a}=await this._fetchAuxiliaryData(t),o=!n;o&&(n=new c({wkid:3857})),i?.length&&r==null&&(r=m(i));let{width:l,height:u}=e,d=new s({xmin:-.5,ymin:.5-u,xmax:l-.5,ymax:.5,spatialReference:n}),f=a?a.forwardTransform(d):d,p=!0;if(a){let e=a.forwardCoefficients;p=e&&e[1]===0&&e[2]===0,p&&(a=null,d=f)}let h=[];return`pixels`in e&&h.push(e),{name:this.datasetName,pixelBlocks:h,imageInfo:{width:l,height:u,pixelType:`u8`,bandCount:3},extent:f,nativeExtent:d,transform:a,statistics:r,histograms:i,isPseudoSpatialReference:o,keyProperties:{DataType:`Processed`}}}async _fetchData(e){let{data:n}=await this.request(this.url,{responseType:`array-buffer`,signal:e?.signal}),r=p(n);if(r===`jpg`||r===`png`||r===`gif`||r===`bmp`)this._set(`datasetFormat`,r.toUpperCase());else throw new t(g,_);return{data:n,format:r}}async _decodeFullImage(e,t,r){try{return await this.decodePixelBlock(e,{format:t,canvasUsage:`canvas-only`,cloneSource:!0,skipStatistics:!0},r)}catch{return n(r?.signal),this.decodePixelBlock(e,{format:t,canvasUsage:`no-canvas`,skipStatistics:!0},r)}}async _fetchAuxiliaryData(e){let t=e?.signal,{skipExtensions:n=[],skipMapInfo:a}=this.ioConfig,o=a||n.includes(`aux.xml`)?null:this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:t}),s=this.datasetFormat,c=s===`JPG`?`jgw`:s===`PNG`?`pgw`:s===`BMP`?`bpw`:null,l=a||c==null||n.includes(c)?null:this.request(this.url.slice(0,this.url.lastIndexOf(`.`))+`.`+c,{responseType:`text`,signal:t}),u=await r([o,l]);if(t?.aborted)throw i();let f=d(u[0].value?.data);if(!f.transform){let e=u[1].value?u[1].value.data.split(`
|
|
3
|
+
`).slice(0,6).map(e=>Number(e)):null;f.transform=e?.length===6?new h({forwardCoefficients:[e[4],e[5],e[0],-e[1],e[2],-e[3]]}):null}return f}};e([a({type:String,json:{write:!0}})],v.prototype,`datasetFormat`,void 0),e([a()],v.prototype,`rasterJobHandler`,null),v=e([o(`esri.layers.raster.datasets.ImageAuxRaster`)],v);const y=v;export{y as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as n}from"../../../core/maybe.js";import{urlToObject as r}from"../../../core/urlUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/Point.js";import c from"../../../geometry/SpatialReference.js";import l from"./BaseRaster.js";import{setValidBoundary as u}from"../functions/pixelUtils.js";import d from"../transforms/GCSShiftTransform.js";import f from"../../support/RasterInfo.js";import p from"../../support/RasterStorageInfo.js";import m from"../../support/TileInfo.js";import{TilemapCache as h}from"../../support/TilemapCache.js";import{patchServiceInfo as g,fetchServiceRasterInfo as _}from"../../../rest/imageService/fetchRasterInfo.js";let v=class extends l{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat=`RasterTileServer`,this.tileType=null}async fetchRawTile(e,t,n,r={}){let{storageInfo:i,extent:a}=this.rasterInfo,{transposeInfo:o}=i,s=o!=null&&!!r.transposedVariableName;if(this._slices&&!s&&r.sliceId==null)return null;let c=s?0:i.maximumPyramidLevel-e+this._levelOffset,l=`${this.url}/tile/${c}/${t}/${n}`,d={...this._slices?s?{variable:r.transposedVariableName}:{sliceId:r.sliceId||0}:null,...r.refreshParameters},f,p;if(i.isBsqTile){let e=(r.bandIds?.length?r.bandIds:[0,1,2]).map(e=>this.request(l,{query:{...d,bandId:e},responseType:`array-buffer`,signal:r.signal})),t=await Promise.all(e),n=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),i=new Uint8Array(n);p=[];let a=0;for(let{data:e}of t)p.push(a),i.set(new Uint8Array(e),a),a+=e.byteLength;f=i.buffer}else f=(await this.request(l,{query:d,responseType:`array-buffer`,signal:r.signal})).data;if(!f)return null;let{tileInfo:m}=i,h=s?o.tileSize:m.size,g=/^(mixed|jp)/i.test(m.format),_=await this.decodePixelBlock(f,{width:h[0],height:h[1],planes:p?.length,offsets:p,pixelType:null,isPoint:this.tileType===`Elevation`,returnInterleaved:s,noDataValue:this.rasterInfo.noDataValue,applyJpegMask:g});if(_==null)return null;let v=i.blockBoundary[e];if(i.compression!==`jpg`||n>v.minCol&&n<v.maxCol&&t>v.minRow&&t<v.maxRow)return _;let{origin:y,blockWidth:b,blockHeight:x}=i,{x:S,y:C}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-y.x)/S)%b,T=Math.round((a.xmax-y.x)/S)%b||b,E=Math.round((y.y-a.ymax)/C)%x,D=Math.round((y.y-a.ymin)/C)%x||x,O=n===v.minCol?w:0,k=t===v.minRow?E:0,A=n===v.maxCol?T:b,j=t===v.maxRow?D:x;return u(_,{x:O,y:k},{width:A-O,height:j-k}),_}getSliceIndex(e){if(!this._slices||e==null||e.length===0)return null;let t=e;for(let e=0;e<this._slices.length;e++){let n=this._slices[e].multidimensionalDefinition;if(n.length===t.length&&!n.some(e=>{let n=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);return!n||(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(n.values[0])?`${n.values[0][0]}-${n.values[0][1]}`:n.values[0])}))return e}return null}async fetchVariableStatisticsHistograms(e,t){let n=this.request(this.url+`/statistics`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.statistics),r=this.request(this.url+`/histograms`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.histograms),i=await Promise.all([n,r]);return i[0]&&i[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),i[1]?.[0]?.counts?.length||(i[1]=null),{statistics:i[0]||null,histograms:i[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let n=this.identifyPixelLocation(e,0,t.datumTransformation);if(n===null)return null;let r=0,{maximumPyramidLevel:i}=this.rasterInfo.storageInfo,a=i-r+this._levelOffset,o=n.srcLocation;for(;a>=0;){try{if(await this._tilemapCache.fetchAvailability(a,n.row,n.col,t)===`available`)break}catch{}if(a--,r++,n=this.identifyPixelLocation(o,r,t.datumTransformation),n===null)return null}return a===-1||n==null?null:r}async _open(e){let i=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:`json`},signal:i});a.ssl&&(this.url=this.url.replace(/^http:/i,`https:`));let o=a.data;if(this.sourceJSON=o,!o)throw new t(`imageserverraster:open`,`cannot initialize tiled image service, missing service info`);if(!o.tileInfo)throw new t(`imageserverraster:open`,`use ImageryLayer to open non-tiled image services`);this._fixScaleInServiceInfo();let s=[`jpg`,`jpeg`,`png`,`png8`,`png24`,`png32`,`mixed`];this.tileType=o.cacheType,this.tileType??=s.includes(o.tileInfo.format.toLowerCase())?`Map`:o.tileInfo.format.toLowerCase()===`lerc`?`Elevation`:`Raster`,this.datasetName=o.name?.slice(o.name.indexOf(`/`)+1)??``;let c=this.rasterInfo??await this._fetchRasterInfo({signal:i});if(c==null)throw new t(`image-server-raster:open`,`cannot initialize image service`);g(c,o);let l=this.tileType===`Map`?y(o.tileInfo,o):m.fromJSON(o.tileInfo);n(l);let[u,d]=this._computeMinMaxLOD(c,l),{extent:f,pixelSize:_}=c,v=Math.min(_.x,_.y)*.001;(_.x!==_.y||Math.abs(u.resolution-_.x)>v)&&(_.x=_.y=u.resolution,c.width=Math.ceil((f.xmax-f.xmin)/_.x-.1),c.height=Math.ceil((f.ymax-f.ymin)/_.y-.1));let x=u.level-d.level,[S,C]=l.size,w=[],T=[],{lods:E}=l;E.forEach((e,t)=>{e.level>=d.level&&e.level<=u.level&&w.push({x:e.resolution,y:e.resolution}),t<E.length-1&&T.push(Math.round(10*e.resolution/E[t+1].resolution)/10)}),w.sort((e,t)=>e.x-t.x);let D=this.computeBlockBoundary(f,S,C,l.origin,w,x),O=w.length>1?w.slice(1):null,k;o.transposeInfo&&(k={tileSize:[o.transposeInfo.rows,o.transposeInfo.cols],packetSize:c.keyProperties?._yxs.PacketSize??0});let A=T.length<=1||T.length>=3&&T.slice(0,-1).every(e=>e===T[0])?T[0]??2:Math.round(10/(d.resolution/u.resolution)**(-1/x))/10,j=!!o.bsq&&this.tileType===`Raster`;if(c.storageInfo=new p({blockWidth:l.size[0],blockHeight:l.size[1],pyramidBlockWidth:l.size[0],pyramidBlockHeight:l.size[1],pyramidResolutions:O,pyramidScalingFactor:A,compression:l.format,origin:l.origin,firstPyramidLevel:1,maximumPyramidLevel:x,tileInfo:l,isBsqTile:j,transposeInfo:k,blockBoundary:D}),b(c),this._set(`rasterInfo`,c),o.capabilities.toLowerCase().includes(`tilemap`)){let e={tileInfo:c.storageInfo.tileInfo,parsedUrl:r(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){let t=this.sourceJSON;if(this.tileType===`Map`){let e=t.fullExtent||t.extent,n=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),r=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),i=c.fromJSON(t.spatialReference||e.spatialReference),a=new s({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:i});return new f({width:n,height:r,bandCount:3,extent:o.fromJSON(e),spatialReference:i,pixelSize:a,pixelType:`u8`,statistics:null,keyProperties:{DataType:`processed`}})}let n={...e,query:{...this.ioConfig.customFetchParameters,f:`json`}},r=_(this.url,this.sourceJSON,n),i=t.hasMultidimensions?this.request(`${this.url}/slices`,n).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([r,i]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){let{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){let{pixelSize:n}=e,r=.5/e.width*n.x,{lods:i}=t,a=t.lodAt(Math.max.apply(null,i.map(e=>e.level))),o=t.lodAt(Math.min.apply(null,i.map(e=>e.level))),{tileType:s}=this;if(s===`Map`)return this._levelOffset=i[0].level,[a,o];if(s===`Raster`)return[i.find(e=>e.resolution===n.x)??a,o];let{minScale:c,maxScale:l}=this.sourceJSON,u=a;l>0&&(u=i.find(e=>Math.abs(e.scale-l)<r),u||=i.filter(e=>e.scale>l).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a);let d=o;return c>0&&(d=i.find(e=>Math.abs(e.scale-c)<r)??o,this._levelOffset=d.level-o.level),[u,d]}};e([i({type:String,json:{write:!0}})],v.prototype,`datasetFormat`,void 0),e([i()],v.prototype,`tileType`,void 0),v=e([a(`esri.layers.raster.datasets.ImageServerRaster`)],v);function y(e,t){if(!e)return null;let{minScale:n,maxScale:r,minLOD:i,maxLOD:a}=t;if(i!=null&&a!=null)return m.fromJSON({...e,lods:e.lods.filter(({level:e})=>e!=null&&e>=i&&e<=a)});if(n!==0&&r!==0){let t=e=>Math.round(e*1e4)/1e4,i=n?t(n):1/0,a=r?t(r):-1/0;return m.fromJSON({...e,lods:e.lods.filter(e=>{let n=t(e.scale);return n<=i&&n>=a})})}return m.fromJSON(e)}function b(e){let{extent:t,spatialReference:n}=e;t.xmin>-1&&t.xmax>181&&n?.wkid&&n.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}const x=v;export{x as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{assertIsSome as n}from"../../../core/maybe.js";import{urlToObject as r}from"../../../core/urlUtils.js";import{property as i,subclass as a}from"../../../core/accessorSupport/decorators.js";import o from"../../../geometry/Extent.js";import s from"../../../geometry/Point.js";import c from"../../../geometry/SpatialReference.js";import l from"./BaseRaster.js";import{setValidBoundary as u}from"../functions/pixelUtils.js";import d from"../transforms/GCSShiftTransform.js";import f from"../../support/RasterInfo.js";import p from"../../support/RasterStorageInfo.js";import m from"../../support/TileInfo.js";import{TilemapCache as h}from"../../support/TilemapCache.js";import{patchServiceInfo as g,fetchServiceRasterInfo as _}from"../../../rest/imageService/fetchRasterInfo.js";let v=class extends l{constructor(){super(...arguments),this._levelOffset=0,this._tilemapCache=null,this._slices=null,this.datasetFormat=`RasterTileServer`,this.tileType=null}async fetchRawTile(e,t,n,r={}){let{storageInfo:i,extent:a}=this.rasterInfo,{transposeInfo:o}=i,s=o!=null&&!!r.transposedVariableName;if(this._slices&&!s&&r.sliceId==null)return null;let c=s?0:i.maximumPyramidLevel-e+this._levelOffset,l=`${this.url}/tile/${c}/${t}/${n}`,d={...this._slices?s?{variable:r.transposedVariableName}:{sliceId:r.sliceId||0}:null,...r.refreshParameters},f,p;if(i.isBsqTile){let e=(r.bandIds?.length?r.bandIds:[0,1,2]).map(e=>this.request(l,{query:{...d,bandId:e},responseType:`array-buffer`,signal:r.signal})),t=await Promise.all(e),n=t.map(e=>e.data.byteLength).reduce((e,t)=>e+t),i=new Uint8Array(n);p=[];let a=0;for(let{data:e}of t)p.push(a),i.set(new Uint8Array(e),a),a+=e.byteLength;f=i.buffer}else f=(await this.request(l,{query:d,responseType:`array-buffer`,signal:r.signal})).data;if(!f)return null;let{tileInfo:m}=i,h=s?o.tileSize:m.size,g=/^(mixed|jp)/i.test(m.format),_=await this.decodePixelBlock(f,{width:h[0],height:h[1],planes:p?.length,offsets:p,pixelType:null,isPoint:this.tileType===`Elevation`,returnInterleaved:s,noDataValue:this.rasterInfo.noDataValue,applyJpegMask:g},{signal:r.signal});if(_==null)return null;let v=i.blockBoundary[e];if(i.compression!==`jpg`||n>v.minCol&&n<v.maxCol&&t>v.minRow&&t<v.maxRow)return _;let{origin:y,blockWidth:b,blockHeight:x}=i,{x:S,y:C}=this.getPyramidPixelSize(e),w=Math.round((a.xmin-y.x)/S)%b,T=Math.round((a.xmax-y.x)/S)%b||b,E=Math.round((y.y-a.ymax)/C)%x,D=Math.round((y.y-a.ymin)/C)%x||x,O=n===v.minCol?w:0,k=t===v.minRow?E:0,A=n===v.maxCol?T:b,j=t===v.maxRow?D:x;return u(_,{x:O,y:k},{width:A-O,height:j-k}),_}getSliceIndex(e){if(!this._slices||e==null||e.length===0)return null;let t=e;for(let e=0;e<this._slices.length;e++){let n=this._slices[e].multidimensionalDefinition;if(n.length===t.length&&!n.some(e=>{let n=t.find(t=>e.variableName===t.variableName&&t.dimensionName===e.dimensionName);return!n||(Array.isArray(e.values[0])?`${e.values[0][0]}-${e.values[0][1]}`:e.values[0])!==(Array.isArray(n.values[0])?`${n.values[0][0]}-${n.values[0][1]}`:n.values[0])}))return e}return null}async fetchVariableStatisticsHistograms(e,t){let n=this.request(this.url+`/statistics`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.statistics),r=this.request(this.url+`/histograms`,{query:{variable:e,f:`json`},signal:t}).then(e=>e.data?.histograms),i=await Promise.all([n,r]);return i[0]&&i[0].forEach(e=>{e.avg=e.mean,e.stddev=e.standardDeviation}),i[1]?.[0]?.counts?.length||(i[1]=null),{statistics:i[0]||null,histograms:i[1]||null}}async computeBestPyramidLevelForLocation(e,t={}){if(!this._tilemapCache)return 0;let n=this.identifyPixelLocation(e,0,t.datumTransformation);if(n===null)return null;let r=0,{maximumPyramidLevel:i}=this.rasterInfo.storageInfo,a=i-r+this._levelOffset,o=n.srcLocation;for(;a>=0;){try{if(await this._tilemapCache.fetchAvailability(a,n.row,n.col,t)===`available`)break}catch{}if(a--,r++,n=this.identifyPixelLocation(o,r,t.datumTransformation),n===null)return null}return a===-1||n==null?null:r}async _open(e){let i=e?.signal,a=this.sourceJSON?{data:this.sourceJSON}:await this.request(this.url,{query:{f:`json`},signal:i});a.ssl&&(this.url=this.url.replace(/^http:/i,`https:`));let o=a.data;if(this.sourceJSON=o,!o)throw new t(`imageserverraster:open`,`cannot initialize tiled image service, missing service info`);if(!o.tileInfo)throw new t(`imageserverraster:open`,`use ImageryLayer to open non-tiled image services`);this._fixScaleInServiceInfo();let s=[`jpg`,`jpeg`,`png`,`png8`,`png24`,`png32`,`mixed`];this.tileType=o.cacheType,this.tileType??=s.includes(o.tileInfo.format.toLowerCase())?`Map`:o.tileInfo.format.toLowerCase()===`lerc`?`Elevation`:`Raster`,this.datasetName=o.name?.slice(o.name.indexOf(`/`)+1)??``;let c=this.rasterInfo??await this._fetchRasterInfo({signal:i});if(c==null)throw new t(`image-server-raster:open`,`cannot initialize image service`);g(c,o);let l=this.tileType===`Map`?y(o.tileInfo,o):m.fromJSON(o.tileInfo);n(l);let[u,d]=this._computeMinMaxLOD(c,l),{extent:f,pixelSize:_}=c,v=Math.min(_.x,_.y)*.001;(_.x!==_.y||Math.abs(u.resolution-_.x)>v)&&(_.x=_.y=u.resolution,c.width=Math.ceil((f.xmax-f.xmin)/_.x-.1),c.height=Math.ceil((f.ymax-f.ymin)/_.y-.1));let x=u.level-d.level,[S,C]=l.size,w=[],T=[],{lods:E}=l;E.forEach((e,t)=>{e.level>=d.level&&e.level<=u.level&&w.push({x:e.resolution,y:e.resolution}),t<E.length-1&&T.push(Math.round(10*e.resolution/E[t+1].resolution)/10)}),w.sort((e,t)=>e.x-t.x);let D=this.computeBlockBoundary(f,S,C,l.origin,w,x),O=w.length>1?w.slice(1):null,k;o.transposeInfo&&(k={tileSize:[o.transposeInfo.rows,o.transposeInfo.cols],packetSize:c.keyProperties?._yxs.PacketSize??0});let A=T.length<=1||T.length>=3&&T.slice(0,-1).every(e=>e===T[0])?T[0]??2:Math.round(10/(d.resolution/u.resolution)**(-1/x))/10,j=!!o.bsq&&this.tileType===`Raster`;if(c.storageInfo=new p({blockWidth:l.size[0],blockHeight:l.size[1],pyramidBlockWidth:l.size[0],pyramidBlockHeight:l.size[1],pyramidResolutions:O,pyramidScalingFactor:A,compression:l.format,origin:l.origin,firstPyramidLevel:1,maximumPyramidLevel:x,tileInfo:l,isBsqTile:j,transposeInfo:k,blockBoundary:D}),b(c),this._set(`rasterInfo`,c),o.capabilities.toLowerCase().includes(`tilemap`)){let e={tileInfo:c.storageInfo.tileInfo,parsedUrl:r(this.url),url:this.url,tileServers:[]};this._tilemapCache=new h({layer:e})}}async _fetchRasterInfo(e){let t=this.sourceJSON;if(this.tileType===`Map`){let e=t.fullExtent||t.extent,n=Math.ceil((e.xmax-e.xmin)/t.pixelSizeX-.1),r=Math.ceil((e.ymax-e.ymin)/t.pixelSizeY-.1),i=c.fromJSON(t.spatialReference||e.spatialReference),a=new s({x:t.pixelSizeX,y:t.pixelSizeY,spatialReference:i});return new f({width:n,height:r,bandCount:3,extent:o.fromJSON(e),spatialReference:i,pixelSize:a,pixelType:`u8`,statistics:null,keyProperties:{DataType:`processed`}})}let n={...e,query:{...this.ioConfig.customFetchParameters,f:`json`}},r=_(this.url,this.sourceJSON,n),i=t.hasMultidimensions?this.request(`${this.url}/slices`,n).then(e=>e.data?.slices).catch(()=>null):null,a=await Promise.all([r,i]);return this._slices=a[1],a[0]}_fixScaleInServiceInfo(){let{sourceJSON:e}=this;e.minScale&&e.minScale<0&&(e.minScale=0),e.maxScale&&e.maxScale<0&&(e.maxScale=0)}_computeMinMaxLOD(e,t){let{pixelSize:n}=e,r=.5/e.width*n.x,{lods:i}=t,a=t.lodAt(Math.max.apply(null,i.map(e=>e.level))),o=t.lodAt(Math.min.apply(null,i.map(e=>e.level))),{tileType:s}=this;if(s===`Map`)return this._levelOffset=i[0].level,[a,o];if(s===`Raster`)return[i.find(e=>e.resolution===n.x)??a,o];let{minScale:c,maxScale:l}=this.sourceJSON,u=a;l>0&&(u=i.find(e=>Math.abs(e.scale-l)<r),u||=i.filter(e=>e.scale>l).sort((e,t)=>e.scale>t.scale?1:-1)[0]??a);let d=o;return c>0&&(d=i.find(e=>Math.abs(e.scale-c)<r)??o,this._levelOffset=d.level-o.level),[u,d]}};e([i({type:String,json:{write:!0}})],v.prototype,`datasetFormat`,void 0),e([i()],v.prototype,`tileType`,void 0),v=e([a(`esri.layers.raster.datasets.ImageServerRaster`)],v);function y(e,t){if(!e)return null;let{minScale:n,maxScale:r,minLOD:i,maxLOD:a}=t;if(i!=null&&a!=null)return m.fromJSON({...e,lods:e.lods.filter(({level:e})=>e!=null&&e>=i&&e<=a)});if(n!==0&&r!==0){let t=e=>Math.round(e*1e4)/1e4,i=n?t(n):1/0,a=r?t(r):-1/0;return m.fromJSON({...e,lods:e.lods.filter(e=>{let n=t(e.scale);return n<=i&&n>=a})})}return m.fromJSON(e)}function b(e){let{extent:t,spatialReference:n}=e;t.xmin>-1&&t.xmax>181&&n?.wkid&&n.isGeographic&&(e.nativeExtent=e.extent,e.transform=new d,e.extent=e.transform.forwardTransform(t))}const x=v;export{x as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{eachAlways as n}from"../../../core/promiseUtils.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/SpatialReference.js";import s from"./BaseRaster.js";import{getSliceIndex as c}from"./multidimensionalUtils.js";import{clipTile as l,split as u}from"../functions/pixelUtils.js";import{estimateStatisticsHistograms as d,computeStatisticsHistograms as f}from"../functions/stretchUtils.js";import p from"../../support/DimensionalDefinition.js";import m from"../../support/RasterInfo.js";let h=class extends s{constructor(){super(...arguments),this.datasetFormat=`MEMORY`,this.preGenerateTiles=!0,this.source=null}get url(){return``}fetchRawTile(e,t,n,r={}){if(!this.
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{eachAlways as n}from"../../../core/promiseUtils.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/SpatialReference.js";import s from"./BaseRaster.js";import{getSliceIndex as c}from"./multidimensionalUtils.js";import{clipTile as l,split as u}from"../functions/pixelUtils.js";import{estimateStatisticsHistograms as d,computeStatisticsHistograms as f}from"../functions/stretchUtils.js";import p from"../../support/DimensionalDefinition.js";import m from"../../support/RasterInfo.js";let h=class extends s{constructor(){super(...arguments),this._pixelBlockTiles=new Map,this.datasetFormat=`MEMORY`,this.preGenerateTiles=!0,this.source=null}get url(){return``}async fetchRawTile(e,t,n,r={}){let i=`${e}/${t}/${n}`,a=this._pixelBlockTiles.get(i);if(a)return a;if(!this.source)return null;let{rasterInfo:o}=this,[s,c]=o.storageInfo.tileInfo.size,{sliceId:u}=r,{encodedData:d}=this.source;if(d){let a=await this.decodePixelBlock(d,{tileSize:[s,c],tileIndex:[e,t,n],canvasUsage:`canvas-only`,cloneSource:!0,skipStatistics:!0},{signal:r.signal});return a&&this._pixelBlockTiles.set(i,a),a}let{pixelBlocks:f}=this.source,p=u==null?f[0]:f[u];if(p==null)return null;let m={pixelBlock:p,useBilinear:o.dataType!==`thematic`,tileSize:{width:s,height:c},level:e,row:t,col:n};return this.rasterJobHandler?this.rasterJobHandler.clipTile(m,r):l(m)}async _open(e){if(!this.source)throw new t(`in-memory-raster:open`,`source is required to open an in memory raster`);let n=this.source;this.datasetName=n.name;let{pixelBlocks:r,attributeTable:i,statistics:s,histograms:c,nativeExtent:l,transform:u,colormap:d}=n,f=r[0],{width:p,height:h,pixelType:g}=f??n.imageInfo,_=n.extent??new a({xmin:-.5,ymin:.5,xmax:p-.5,ymax:h-.5,spatialReference:new o({wkid:3857})}),v=n.isPseudoSpatialReference??!n.extent,y={x:_.width/p,y:_.height/h},b={...n.keyProperties};n.dataType&&(b.DataType=n.dataType),n.bandInfos&&(b.BandProperties=n.bandInfos.map(e=>e.toJSON())),i&&(b.DataType=`Thematic`);let x=new m({width:p,height:h,pixelType:g,extent:_,nativeExtent:l,attributeTable:i,colormap:d,transform:u,pixelSize:y,spatialReference:_.spatialReference,bandCount:f?.pixels.length??n.imageInfo.bandCount,keyProperties:b,multidimensionalInfo:n.multidimensionalInfo,statistics:s,isPseudoSpatialReference:v,histograms:c});this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(x),this.createRemoteDatasetStorageInfo(x,512,512),this._set(`rasterInfo`,x),this.updateTileInfo(),x.multidimensionalInfo?await this._buildMDimStats(r,x.multidimensionalInfo):this.preGenerateTiles&&f&&(await this._buildInMemoryRaster(f,{width:512,height:512},e),this.source=null)}async _buildInMemoryRaster(e,r,i){let{rasterInfo:a}=this,o=a.storageInfo.maximumPyramidLevel??0,s=a.dataType!==`thematic`,c=this.rasterJobHandler?this.rasterJobHandler.split({pixelBlock:e,tileSize:r,maximumPyramidLevel:o,useBilinear:s},i):Promise.resolve(u(e,r,o,s)),l=a.statistics!=null,f=a.histograms!=null,p=this.ioConfig.skipStatistics||l?Promise.resolve({statistics:null,histograms:null}):this.rasterJobHandler?this.rasterJobHandler.estimateStatisticsHistograms({pixelBlock:e},i):Promise.resolve(d(e)),m=await n([c,p]);if(!m[0].value)throw new t(`in-memory-raster:open`,`failed to build in memory raster`);this._pixelBlockTiles=m[0].value,l||(a.statistics=m[1].value?.statistics),f||(a.histograms=m[1].value?.histograms)}async _buildMDimStats(e,t,n){for(let r=0;r<t.variables.length;r++){let i=t.variables[r];if(i.statistics)continue;let a=i.dimensions.map(e=>new p({variableName:i.name,dimensionName:e.name,values:[e.values?.[0]??e.extent?.[0]],isSlice:!0})),o=c(a,t),s=o==null?null:e[o];if(s==null)continue;let l=this.rasterJobHandler?await this.rasterJobHandler.computeStatisticsHistograms({pixelBlock:s},n):f(s);i.statistics=l.statistics,i.histograms||=l.histograms}}};e([r({type:String,json:{write:!0}})],h.prototype,`datasetFormat`,void 0),e([r({constructOnly:!0})],h.prototype,`preGenerateTiles`,void 0),e([r()],h.prototype,`source`,void 0),e([r()],h.prototype,`url`,null),h=e([i(`esri.layers.raster.datasets.InMemoryRaster`)],h);const g=h;export{g as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Extent.js";import a from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import s from"./BaseRaster.js";import{parseSpatialReference as c,parsePAMInfo as l}from"./pamParser.js";import{getElement as u,getElementValue as d}from"./xmlUtilities.js";import{isPlatformLittleEndian as f}from"../formats/utils.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../../support/PixelBlock.js";import h from"../../support/RasterInfo.js";import g from"../../support/RasterStorageInfo.js";const _=new Map([[`byte`,`u8`],[`signedbyte`,`s8`],[`int8`,`s8`],[`uint8`,`u8`],[`int16`,`s16`],[`uint16`,`u16`],[`int32`,`s32`],[`uint32`,`u32`],[`float32`,`f32`],[`float64`,`f64`],[`double64`,`f64`]]),v=new Map;v.set(`none`,{blobExtension:`.til`,isOneSegment:!0,decoderFormat:`bip`}),v.set(`lerc`,{blobExtension:`.lrc`,isOneSegment:!1,decoderFormat:`lerc`}),v.set(`deflate`,{blobExtension:`.pzp`,isOneSegment:!0,decoderFormat:`deflate`}),v.set(`jpeg`,{blobExtension:`.pjg`,isOneSegment:!0,decoderFormat:`jpg`}),v.set(`qb3`,{blobExtension:`.pq3`,isOneSegment:!0,decoderFormat:`qb3`});let y=class extends s{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this._isBsq=!1,this.datasetFormat=`MRF`}async fetchRawTile(e,t,n,r={}){let{blockWidth:i,blockHeight:a,blockBoundary:o}=this.rasterInfo.storageInfo,s=o[e];if(!s||s.maxRow<t||s.maxCol<n||s.minRow>t||s.minCol>n)return null;let{bandCount:c,pixelType:l}=this.rasterInfo,{ranges:u,actualTileWidth:d,actualTileHeight:f}=this._getTileLocation(e,t,n);if(!u||u.length===0)return null;if(u.some(e=>e.from>e.to)){let e=new Uint8Array(i*a);return new m({width:i,height:a,pixels:void 0,mask:e,validPixelCount:0})}let{bandIds:p}=this.ioConfig,h=this._getBandSegmentCount(),g=[],_=0;for(_=0;_<h;_++)(!p||p.includes(_))&&g.push(this.request(this._files.data,{range:{from:u[_].from,to:u[_].to},responseType:`array-buffer`,signal:r.signal}));let y=await Promise.all(g),b=y.map(e=>e.data.byteLength).reduce((e,t)=>e+t),x=new Uint8Array(b),S=[],C=0;for(_=0;_<h;_++)S.push(C),x.set(new Uint8Array(y[_].data),C),C+=y[_].data.byteLength;let w=v.get(this.rasterInfo.storageInfo.compression).decoderFormat,T=w===`jpg`&&c===4&&S.length===1,E=await this.decodePixelBlock(x.buffer,{width:i,height:a,format:w,planes:p?.length||c,offsets:S,pixelType:l,canvasUsage:T?`no-canvas`:void 0,decodeJpegAsRgb:!1}
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import{property as n,subclass as r}from"../../../core/accessorSupport/decorators.js";import i from"../../../geometry/Extent.js";import a from"../../../geometry/Point.js";import o from"../../../geometry/SpatialReference.js";import s from"./BaseRaster.js";import{parseSpatialReference as c,parsePAMInfo as l}from"./pamParser.js";import{getElement as u,getElementValue as d}from"./xmlUtilities.js";import{isPlatformLittleEndian as f}from"../formats/utils.js";import{estimateStatisticsFromHistograms as p}from"../functions/stretchUtils.js";import m from"../../support/PixelBlock.js";import h from"../../support/RasterInfo.js";import g from"../../support/RasterStorageInfo.js";const _=new Map([[`byte`,`u8`],[`signedbyte`,`s8`],[`int8`,`s8`],[`uint8`,`u8`],[`int16`,`s16`],[`uint16`,`u16`],[`int32`,`s32`],[`uint32`,`u32`],[`float32`,`f32`],[`float64`,`f64`],[`double64`,`f64`]]),v=new Map;v.set(`none`,{blobExtension:`.til`,isOneSegment:!0,decoderFormat:`bip`}),v.set(`lerc`,{blobExtension:`.lrc`,isOneSegment:!1,decoderFormat:`lerc`}),v.set(`deflate`,{blobExtension:`.pzp`,isOneSegment:!0,decoderFormat:`deflate`}),v.set(`jpeg`,{blobExtension:`.pjg`,isOneSegment:!0,decoderFormat:`jpg`}),v.set(`qb3`,{blobExtension:`.pq3`,isOneSegment:!0,decoderFormat:`qb3`});let y=class extends s{constructor(){super(...arguments),this._files=null,this._storageIndex=null,this._isBsq=!1,this.datasetFormat=`MRF`}async fetchRawTile(e,t,n,r={}){let{blockWidth:i,blockHeight:a,blockBoundary:o}=this.rasterInfo.storageInfo,s=o[e];if(!s||s.maxRow<t||s.maxCol<n||s.minRow>t||s.minCol>n)return null;let{bandCount:c,pixelType:l}=this.rasterInfo,{ranges:u,actualTileWidth:d,actualTileHeight:f}=this._getTileLocation(e,t,n);if(!u||u.length===0)return null;if(u.some(e=>e.from>e.to)){let e=new Uint8Array(i*a);return new m({width:i,height:a,pixels:void 0,mask:e,validPixelCount:0})}let{bandIds:p}=this.ioConfig,h=this._getBandSegmentCount(),g=[],_=0;for(_=0;_<h;_++)(!p||p.includes(_))&&g.push(this.request(this._files.data,{range:{from:u[_].from,to:u[_].to},responseType:`array-buffer`,signal:r.signal}));let y=await Promise.all(g),b=y.map(e=>e.data.byteLength).reduce((e,t)=>e+t),x=new Uint8Array(b),S=[],C=0;for(_=0;_<h;_++)S.push(C),x.set(new Uint8Array(y[_].data),C),C+=y[_].data.byteLength;let w=v.get(this.rasterInfo.storageInfo.compression).decoderFormat,T=w===`jpg`&&c===4&&S.length===1,E=await this.decodePixelBlock(x.buffer,{width:i,height:a,format:w,planes:p?.length||c,offsets:S,pixelType:l,canvasUsage:T?`no-canvas`:void 0,decodeJpegAsRgb:!1},{signal:r.signal});if(E==null)return null;let{noDataValue:D}=this.rasterInfo;if(D!=null&&w!==`lerc`&&!E.mask&&(D=D[0],D!=null)){let e=E.width*E.height,t=new Uint8Array(e);if(Math.abs(D)>1e24)for(_=0;_<e;_++)Math.abs((E.pixels[0][_]-D)/D)>1e-6&&(t[_]=1);else for(_=0;_<e;_++)E.pixels[0][_]!==D&&(t[_]=1);E.mask=t}let O=0,k=0;if(d!==i||f!==a){let e=E.mask;if(e)for(_=0;_<a;_++)if(k=_*i,_<f)for(O=d;O<i;O++)e[k+O]=0;else for(O=0;O<i;O++)e[k+O]=0;else for(e=new Uint8Array(i*a),E.mask=e,_=0;_<f;_++)for(k=_*i,O=0;O<d;O++)e[k+O]=1}return E}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1);let t=e?e.signal:null,n=await this.request(this.url,{responseType:`xml`,signal:t}),{rasterInfo:r,files:i}=this._parseHeader(n.data),{skipMapInfo:a,skipExtensions:o=[]}=this.ioConfig;if(!o.includes(`aux.xml`)&&!a){let t=await this._fetchAuxiliaryData(e);t!=null&&(r.statistics=t.statistics??r.statistics,r.histograms=t.histograms,t.histograms&&r.statistics==null&&(r.statistics=p(t.histograms)))}a&&this.updateImageSpaceRasterInfo(r),this._set(`rasterInfo`,r),this._files=i;let s=await this.request(i.index,{responseType:`array-buffer`,signal:t});this._storageIndex=b(s.data);let{blockWidth:c,blockHeight:l}=this.rasterInfo.storageInfo,u=this.rasterInfo.storageInfo.pyramidScalingFactor,{width:d,height:f}=this.rasterInfo,m=[],h=this._getBandSegmentCount(),g=0,_=-1;for(;g<this._storageIndex.length;){_++;let e=Math.ceil(d/c/u**_)-1,t=Math.ceil(f/l/u**_)-1;g+=(e+1)*(t+1)*h*4,m.push({maxRow:t,maxCol:e,minCol:0,minRow:0})}this.rasterInfo.storageInfo.blockBoundary=m,_>0&&(this.rasterInfo.storageInfo.firstPyramidLevel=1,this.rasterInfo.storageInfo.maximumPyramidLevel=_),this.updateTileInfo()}_getBandSegmentCount(){return this._isBsq?this.rasterInfo.bandCount:1}_getTileLocation(e,t,n){let{blockWidth:r,blockHeight:i,pyramidScalingFactor:a}=this.rasterInfo.storageInfo,{width:o,height:s}=this.rasterInfo,c=this._getBandSegmentCount(),l,u,d,f=0,p=0;for(d=0;d<e;d++)p=a**d,l=Math.ceil(o/r/p),u=Math.ceil(s/i/p),f+=l*u;p=a**e,l=Math.ceil(o/r/p),u=Math.ceil(s/i/p),f+=t*l+n,f*=c*4;let m=this._storageIndex.subarray(f,f+4*c),h=0,g=0,_=[];for(let e=0;e<c;e++)h=m[e*4]*2**32+m[e*4+1],g=h+m[e*4+2]*2**32+m[e*4+3]-1,_.push({from:h,to:g});return{ranges:_,actualTileWidth:n<l-1?r:Math.ceil(o/p)-r*(l-1),actualTileHeight:t<u-1?i:Math.ceil(s/p)-i*(u-1)}}_parseHeader(e){let n=u(e,`MRF_META/Raster`);if(!n)throw new t(`mrf:open`,`not a valid MRF format`);let r=u(n,`Size`),s=parseInt(r.getAttribute(`x`),10),l=parseInt(r.getAttribute(`y`),10),f=parseInt(r.getAttribute(`c`),10),p=(d(n,`Compression`)||`none`).toLowerCase();if(!v.has(p))throw new t(`mrf:open`,`currently does not support compression `+p);let m=d(n,`DataType`)||`UInt8`,y=_.get(m.toLowerCase());if(y==null)throw new t(`mrf:open`,`currently does not support pixel type `+m);let b=u(n,`PageSize`),x=parseInt(b.getAttribute(`x`),10),S=parseInt(b.getAttribute(`y`),10),C=b.getAttribute(`c`),w=C?C===String(f):v.get(p).isOneSegment;this._isBsq=!w;let T=u(n,`DataValues`),E;if(T){let e=T.getAttribute(`NoData`);e!=null&&(E=e.trim().split(` `).map(e=>parseFloat(e)))}if(u(e,`MRF_META/CachedSource`))throw new t(`mrf:open`,`currently does not support MRF referencing other data files`);let D=u(e,`MRF_META/GeoTags`),O=u(D,`BoundingBox`),k=!1,A;if(O!=null){let e=parseFloat(O.getAttribute(`minx`)),t=parseFloat(O.getAttribute(`miny`)),n=parseFloat(O.getAttribute(`maxx`)),r=parseFloat(O.getAttribute(`maxy`)),a=d(D,`Projection`)||``,s=o.WGS84;if(a!==`LOCAL_CS[]`){if(a.toLowerCase().startsWith(`epsg:`)){let e=Number(a.slice(5));!isNaN(e)&&e!==0&&(s=new o({wkid:e}))}else s=c(a)??o.WGS84}else k=!0,s=new o({wkid:3857});A=new i(e,t,n,r),A.spatialReference=s}else k=!0,A=new i({xmin:-.5,ymin:.5-l,xmax:s-.5,ymax:.5,spatialReference:new o({wkid:3857})});let j=u(e,`MRF_META/Rsets`),M=parseInt(j?.getAttribute(`scale`)||`2`,10),N=A.spatialReference,P=new g({origin:new a({x:A.xmin,y:A.ymax,spatialReference:N}),blockWidth:x,blockHeight:S,pyramidBlockWidth:x,pyramidBlockHeight:S,compression:p,pyramidScalingFactor:M}),F=new a({x:A.width/s,y:A.height/l,spatialReference:N}),I=new h({width:s,height:l,extent:A,isPseudoSpatialReference:k,spatialReference:N,bandCount:f,pixelType:y,pixelSize:F,noDataValue:E,storageInfo:P}),L=this._getAuxFullPath(d(n,`DataFile`)),R=this._getAuxFullPath(d(n,`IndexFile`));return{rasterInfo:I,files:{mrf:this.url,index:R||this.url.replace(`.mrf`,`.idx`),data:L||this.url.replace(`.mrf`,v.get(p).blobExtension)}}}_getAuxFullPath(e){return!e||e.includes(`\\`)?null:e.includes(`/`)?e.startsWith(new URL(this.url).origin)?e:null:`${this.url.slice(0,this.url.lastIndexOf(`/`))}/${e}`}async _fetchAuxiliaryData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return l(t)}catch{return null}}};e([n()],y.prototype,`_files`,void 0),e([n()],y.prototype,`_storageIndex`,void 0),e([n()],y.prototype,`_isBsq`,void 0),e([n({type:String,json:{write:!0}})],y.prototype,`datasetFormat`,void 0),y=e([r(`esri.layers.raster.datasets.MRFRaster`)],y);function b(e){if(e.byteLength%16>0)throw Error(`invalid array buffer must be multiples of 16`);let t;if(f){let n=new Uint8Array(e),r=new ArrayBuffer(e.byteLength),i=new Uint8Array(r);for(let t=0;t<e.byteLength/4;t++)for(let e=0;e<4;e++)i[t*4+e]=n[t*4+3-e];t=new Uint32Array(r)}else t=new Uint32Array(e);return t}const x=y;export{x as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/Point.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{parse as l}from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as d}from"./pamParser.js";import{parseSignature as f,getPyramidIFDs as p,getMaskIFDs as m,parseIFD as h,parseGeoKeyDirectory as g,parseXMP as _,parseFieldValues as v,isBSQConfig as y,getTagNumericValues as b,getTagFirstNumericValue as x,getImageInfo as S}from"../formats/tiffParser.js";import{tiffTags as C,ifdTags as w}from"../formats/tiffTag.js";import{estimateStatisticsFromHistograms as T}from"../functions/stretchUtils.js";import E from"../transforms/PolynomialTransform.js";import D from"../../support/RasterInfo.js";import O from"../../support/RasterStorageInfo.js";import k from"../../../rest/support/FeatureSet.js";const A=`none-tiled tiff is not optimized for access, convert to COG and retry.`;let j=class extends c{constructor(){super(...arguments),this._bufferSize=1048576,this._chunkSize=10*1024**2,this._fileSize=-1,this._headerChunks=[],this.datasetFormat=`TIFF`,this.headerInfo=null}async fetchRawTile(e,t,n,r={}){if(!this.headerInfo?.isSupported||this.isBlockOutside(e,t,n))return null;let i=await this._fetchRawTiffTile(e,t,n,!1,r);if(i!=null&&this.headerInfo.hasMaskBand){let a=await this._fetchRawTiffTile(e,t,n,!0,r);a!=null&&a.pixels[0]instanceof Uint8Array&&(i.mask=a.pixels[0])}return i}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1,this.url.lastIndexOf(`.`)),await this._readHeader(e?.signal),await this._fetchAllAuxData(),this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(this.rasterInfo),this.updateTileInfo()}async _readHeader(e){try{let n=await this._fetchHeaderData(0,this._bufferSize,e);if(!n)throw new t(`tiffraster:open`,`failed to open url `+this.url);let{littleEndian:r,firstIFDPos:i,isBigTiff:a}=f(n),o=[],s={fileChunk:n,posIFD:i,fileOffset:0};await this._readIFDs(o,s,r,a?8:4,e);let{imageInfo:c,rasterInfo:l}=M(o),u=p(o),d=m(o);this.headerInfo={littleEndian:r,isBigTiff:a,ifds:o,pyramidIFDs:u,maskIFDs:d,...c},this._set(`rasterInfo`,l),this._validateHeader()}finally{this._headerChunks.length=0}}_validateHeader(){let e=this.headerInfo;if(!e.isSupported)throw new t(`tiffraster:open`,`this tiff is not supported: `+e.message);if(!e.tileWidth||!e.tileHeight)throw new t(`tiffraster:open`,A);this.rasterInfo.isPseudoSpatialReference&&n.getLogger(this).warn(`The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.`);let r=e.ifds[0],i=r.get(`PREDICTOR`)?.values?.[0];if(r.get(`SAMPLEFORMAT`)?.values?.[0]===3&&i===2)throw new t(`tiffraster:open`,`unsupported horizontal difference encoding. Predictor=3 is supported for floating point data`)}async _fetchHeaderData(e,n,r){let i=this._getCachedHeaderData(e,n);if(i)return i;let a=Math.floor(e/this._bufferSize)*this._bufferSize,o=a+Math.max(1,Math.ceil((n-a)/this._bufferSize))*this._bufferSize,s=this._getMissingHeaderRanges(a,o).map(async e=>{let{from:t,to:n}=e,i=await this._fetchOffsets(t,n,r),a=this._fileSize;return{chunk:i,fileOffset:t,isEOF:a>0?t+i.byteLength>=a:i.byteLength<n-t+1}}),c=await Promise.all(s);this._headerChunks.push(...c),this._headerChunks.sort((e,t)=>e.fileOffset-t.fileOffset);let l=this._getCachedHeaderData(e,n);if(!l)throw new t(`tiffraster:open`,`failed to fetch byte range ${e}-${n} from ${this.url}`);return l}_getCachedHeaderData(e,t){let n=[],r=e;for(let{chunk:i,fileOffset:a,isEOF:o}of this._headerChunks){if(a+i.byteLength-1<r)continue;if(a>r)return null;let s=r-a,c=Math.min(t-a+1,i.byteLength);if(n.push({chunk:i,start:s,end:c}),r=a+c,r>t||o&&c===i.byteLength){let t=new Uint8Array(r-e),i=0;for(let e of n){let n=new Uint8Array(e.chunk,e.start,e.end-e.start);t.set(n,i),i+=n.byteLength}return t.buffer}}return null}_getMissingHeaderRanges(e,t){let n=[],r=(e,t)=>{let r=Math.floor(e/this._bufferSize)*this._bufferSize,i=Math.ceil(t/this._bufferSize)*this._bufferSize;n.push({from:r,to:i})},i=e;for(let{chunk:e,fileOffset:a,isEOF:o}of this._headerChunks){let s=a+e.byteLength-1;if(!(s<i)&&(a>i&&r(i,Math.min(a-1,t)),i=Math.max(i,s+1),i>t||o))return n}return i<=t&&r(i,t),n}async _validateOrFetchHeaderBuffer(e,n){let{fileChunk:r,fileOffset:i,posIFD:a}=e;if(a+8>=r.byteLength||a<0){if(i=a+i,i<0)throw new t(`tiffraster:open`,`invalid IFD position ${i}. failed to open url ${this.url}`);r=await this._fetchHeaderData(i,i+this._bufferSize/2,n),a=0}return{fileChunk:r,fileOffset:i,posIFD:a}}async _readIFDs(e,n,r,i=4,a){if(!n.posIFD)return null;n=await this._validateOrFetchHeaderBuffer(n,a);let o=await this._readIFD(n,r,C,i,a);if(!o?.ifd)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(e.push(o.ifd),!o.nextIFD)return null;n.posIFD=o.nextIFD-n.fileOffset,await this._readIFDs(e,n,r,i,a)}async _readIFD(e,n,r=C,i=4,a){let{fileChunk:o,posIFD:s,fileOffset:c}=e;if(!e.fileChunk)return null;let l=h(o,n,s,c,r,i);if(l.success){let{ifd:e}=l;if(!e)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(!this.ioConfig.loadFullMetadata&&r===C&&(!e.has(`TILEWIDTH`)||!e.has(`TILELENGTH`)))throw new t(`tiffraster:open`,A);let i=[];e.forEach(e=>{e.values||i.push(e)}),i.length>0&&await this._fillOffsets(i,n,l.nextIFD,a),g(e),_(e);for(let[t,r]of w){let i=e.get(t),l=i?.data!=null&&Array.from(i.data.values()).some(e=>e.values==null&&e.offlineOffsetSize!=null);if(i&&(!i.data||l)){s=i.valueOffset-c;let e=await this._validateOrFetchHeaderBuffer({fileChunk:o,posIFD:s,fileOffset:c},a);i.data=(await this._readIFD(e,n,r,4,a))?.ifd}}return l}return l.requiredBufferSize?(o=await this._fetchHeaderData(c,c+s+l.requiredBufferSize+8,a),o.byteLength<s+l.requiredBufferSize?null:(e.fileChunk=o,e.fileOffset=c,this._readIFD(e,n,r,i,a))):null}async _fillOffsets(e,t,n,r){let i=e.filter(e=>e.offlineOffsetSize!=null);if(i.length===0)return;let a=i.map(e=>e.offlineOffsetSize),o=Math.min.apply(null,a.map(e=>e[0])),s=Math.max.apply(null,a.map(e=>e[0]+e[1])),c=a.length===1||s-o<=this._bufferSize;if(!c&&a.length>1&&(a.sort((e,t)=>e[0]-t[0]),c=a.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,a[0][0])===s),c){let e=Math.max(s,o+this._bufferSize/4),n=await this._fetchHeaderData(o,e,r);i.forEach(e=>v(n,t,e,o));return}let l=i.map(async e=>{let n=e.offlineOffsetSize,i=await this._fetchHeaderData(n[0],n[1]+n[0],r);v(i,t,e,n[0])});await Promise.all(l)}async _fetchOffsets(e,t,n){let r=[],i=this._chunkSize;this._fileSize>0&&(t=Math.min(t,this._fileSize-1));let a=Math.ceil((t-e+1)/i),o=e;for(let e=0;e<a;e++)r.push(this.request(this.url,{range:{from:o,to:e===a-1?t:o+i-1},responseType:`array-buffer`,signal:n})),o+=i;let s=await Promise.all(r);if(this._fileSize===-1&&s[0].httpStatus===206){let e=s[0].getHeader?.(`Content-Range`),t=Number(e?.split(`/`)[1]);Number.isFinite(t)&&(this._fileSize=t)}if(s.length===1)return s[0].data;let c=s.reduce((e,t)=>e+t.data.byteLength,0),l=new Uint8Array(c),u=0;for(let e of s)l.set(new Uint8Array(e.data),u),u+=e.data.byteLength;return l.buffer}async _fetchRawTiffTile(e,t,n,r,i={}){let a=this._getTileLocation(e,t,n,r);if(!a)return null;let{ranges:o,actualTileWidth:s,actualTileHeight:c,ifd:l}=a,u=o.map(e=>this.request(this.url,{range:e,responseType:`array-buffer`,signal:i.signal})),d=await Promise.all(u),f=d.map(e=>e.data.byteLength).reduce((e,t)=>e+t),p=d.length===1?d[0].data:new ArrayBuffer(f),m=[0],h=[0];if(d.length>1){let e=new Uint8Array(p);for(let t=0,n=0;t<d.length;t++){let r=d[t].data;e.set(new Uint8Array(r),n),m[t]=n,n+=r.byteLength,h[t]=r.byteLength}}let{blockWidth:g,blockHeight:_}=this.getBlockWidthHeight(e),v=await this.decodePixelBlock(p,{format:`tiff`,customOptions:{headerInfo:this.headerInfo,ifd:l,offsets:m,sizes:h},width:g,height:_,planes:null,pixelType:null});if(v==null)return null;if(s!==g||c!==_){let e=v.mask;if(e)for(let t=0;t<_;t++){let n=t*g;if(t<c)for(let t=s;t<g;t++)e[n+t]=0;else for(let t=0;t<g;t++)e[n+t]=0}else{e=new Uint8Array(g*_),v.mask=e;for(let t=0;t<c;t++){let n=t*g;for(let t=0;t<s;t++)e[n+t]=1}}}return v}_getTileLocation(e,t,n,r=!1){let{firstPyramidLevel:i,blockBoundary:a}=this.rasterInfo.storageInfo,o=e===0?0:e-(i-1),{headerInfo:s}=this;if(!s)return null;let c=r?s.maskIFDs[o]:o===0?s.ifds[0]:s.pyramidIFDs[o-1];if(!c)return null;let l=y(c,s),u=b(c,`TILEOFFSETS`),d=b(c,`TILEBYTECOUNTS`);if(!u?.length||!d?.length)return null;let{minRow:f,minCol:p,maxRow:m,maxCol:h}=a[o];if(t>m||n>h||t<f||n<p)return null;let g=x(c,`IMAGEWIDTH`),_=x(c,`IMAGELENGTH`),v=x(c,`TILEWIDTH`),S=x(c,`TILELENGTH`),C=[];if(l){let{bandCount:e}=this.rasterInfo;for(let r=0;r<e;r++){let e=r*(m+1)*(h+1)+t*(h+1)+n;C[r]={from:u[e],to:u[e]+d[e]-1}}}else{let e=t*(h+1)+n;C.push({from:u[e],to:u[e]+d[e]-1})}for(let e=0;e<C.length;e++)if(C[e].from==null||!C[e].to||C[e].to<0)return null;return{ranges:C,ifd:c,actualTileWidth:n===h&&g%v||v,actualTileHeight:t===m&&_%S||S}}async _fetchAllAuxData(e){if(this.ioConfig.skipMapInfo)return;let{rasterInfo:t}=this,{skipExtensions:n=[]}=this.ioConfig,r=n.includes(`aux.xml`)?Promise.resolve(null):this._fetchAuxiliaryMetaData(e),i=!n.includes(`vat.dbf`)&&t.bandCount===1&&t.pixelType===`u8`?this._fetchAuxiliaryTable(e):Promise.resolve(null),[a,o]=await Promise.all([r,i]);a!=null&&N(a,t),o!=null&&(t.attributeTable=o,t.keyProperties.DataType=`thematic`)}async _fetchAuxiliaryMetaData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{let{data:t}=await this.request(this.url+`.vat.dbf`,{responseType:`array-buffer`,signal:e?.signal}),n=l(t);return n?.recordSet?k.fromJSON(n.recordSet):null}catch{return null}}};e([r()],j.prototype,`_bufferSize`,void 0),e([r()],j.prototype,`_chunkSize`,void 0),e([r()],j.prototype,`_fileSize`,void 0),e([r()],j.prototype,`_headerChunks`,void 0),e([r({type:String,json:{write:!0}})],j.prototype,`datasetFormat`,void 0),e([r()],j.prototype,`headerInfo`,void 0),j=e([i(`esri.layers.raster.datasets.TIFFRaster`)],j);function M(e){let t=S(e),{width:n,height:r,tileWidth:i,tileHeight:c,planes:l,pixelType:u,compression:f,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidBlockWidth:h,pyramidBlockHeight:g,pyramidResolutions:_,tileBoundary:v,affine:y,metadata:b,colormap:x}=t,C=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid,w=d(C),T=!!t.isPseudoGeographic;w??=(T=!0,new s({wkid:3857}));let k=new a({...t.extent,spatialReference:w}),A=k?new o({x:k.xmin,y:k.ymax,spatialReference:w}):new o({x:0,y:0}),j=new O({blockWidth:i,blockHeight:c,pyramidBlockWidth:h,pyramidBlockHeight:g,compression:f,origin:A,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidResolutions:_,blockBoundary:v}),M=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:w}),N=b?{BandProperties:b.bandProperties,DataType:b.dataType}:{},P=new D({width:n,height:r,bandCount:l,pixelType:u,pixelSize:M,storageInfo:j,spatialReference:w,isPseudoSpatialReference:T,keyProperties:N,extent:k,colormap:x,statistics:b?b.statistics:null});if(y?.length&&(P.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:n-.5,ymax:.5,spatialReference:w}),P.transform=new E({polynomialOrder:1,forwardCoefficients:[y[2]+y[0]/2,y[5]-y[3]/2,y[0],y[3],-y[1],-y[4]]}),P.extent=P.transform.forwardTransform(P.nativeExtent),P.pixelSize=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:w}),j.origin.x=-.5,j.origin.y=.5),_){let{x:e,y:t}=P.pixelSize;_.forEach(n=>{n.x*=e,n.y*=t})}return{imageInfo:t,rasterInfo:P}}function N(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&t.statistics==null&&(t.statistics=T(e.histograms)),e.transform&&t.transform==null){t.transform=e.transform,t.nativeExtent=t.extent;let n=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new o({x:(n.xmax-n.xmin)/t.width,y:(n.ymax-n.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=n}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}const P=j;export{P as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import"../../../core/has.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import o from"../../../geometry/Point.js";import s from"../../../geometry/SpatialReference.js";import c from"./BaseRaster.js";import{parse as l}from"./DBFParser.js";import{parsePAMInfo as u,parseSpatialReference as d}from"./pamParser.js";import{parseSignature as f,getPyramidIFDs as p,getMaskIFDs as m,parseIFD as h,parseGeoKeyDirectory as g,parseXMP as _,parseFieldValues as v,isBSQConfig as y,getTagNumericValues as b,getTagFirstNumericValue as x,getImageInfo as S}from"../formats/tiffParser.js";import{tiffTags as C,ifdTags as w}from"../formats/tiffTag.js";import{estimateStatisticsFromHistograms as T}from"../functions/stretchUtils.js";import E from"../transforms/PolynomialTransform.js";import D from"../../support/RasterInfo.js";import O from"../../support/RasterStorageInfo.js";import k from"../../../rest/support/FeatureSet.js";const A=`none-tiled tiff is not optimized for access, convert to COG and retry.`;let j=class extends c{constructor(){super(...arguments),this._bufferSize=1048576,this._chunkSize=10*1024**2,this._fileSize=-1,this._headerChunks=[],this.datasetFormat=`TIFF`,this.headerInfo=null}async fetchRawTile(e,t,n,r={}){if(!this.headerInfo?.isSupported||this.isBlockOutside(e,t,n))return null;let i=await this._fetchRawTiffTile(e,t,n,!1,r);if(i!=null&&this.headerInfo.hasMaskBand){let a=await this._fetchRawTiffTile(e,t,n,!0,r);a!=null&&a.pixels[0]instanceof Uint8Array&&(i.mask=a.pixels[0])}return i}async _open(e){this.datasetName=this.url.slice(this.url.lastIndexOf(`/`)+1,this.url.lastIndexOf(`.`)),await this._readHeader(e?.signal),await this._fetchAllAuxData(),this.ioConfig.skipMapInfo&&this.updateImageSpaceRasterInfo(this.rasterInfo),this.updateTileInfo()}async _readHeader(e){try{let n=await this._fetchHeaderData(0,this._bufferSize,e);if(!n)throw new t(`tiffraster:open`,`failed to open url `+this.url);let{littleEndian:r,firstIFDPos:i,isBigTiff:a}=f(n),o=[],s={fileChunk:n,posIFD:i,fileOffset:0};await this._readIFDs(o,s,r,a?8:4,e);let{imageInfo:c,rasterInfo:l}=M(o),u=p(o),d=m(o);this.headerInfo={littleEndian:r,isBigTiff:a,ifds:o,pyramidIFDs:u,maskIFDs:d,...c},this._set(`rasterInfo`,l),this._validateHeader()}finally{this._headerChunks.length=0}}_validateHeader(){let e=this.headerInfo;if(!e.isSupported)throw new t(`tiffraster:open`,`this tiff is not supported: `+e.message);if(!e.tileWidth||!e.tileHeight)throw new t(`tiffraster:open`,A);this.rasterInfo.isPseudoSpatialReference&&n.getLogger(this).warn(`The spatial reference for this tiff is unsupported. Only EPSG spatial reference codes and Esri WKTs are supported.`);let r=e.ifds[0],i=r.get(`PREDICTOR`)?.values?.[0];if(r.get(`SAMPLEFORMAT`)?.values?.[0]===3&&i===2)throw new t(`tiffraster:open`,`unsupported horizontal difference encoding. Predictor=3 is supported for floating point data`)}async _fetchHeaderData(e,n,r){let i=this._getCachedHeaderData(e,n);if(i)return i;let a=Math.floor(e/this._bufferSize)*this._bufferSize,o=a+Math.max(1,Math.ceil((n-a)/this._bufferSize))*this._bufferSize,s=this._getMissingHeaderRanges(a,o).map(async e=>{let{from:t,to:n}=e,i=await this._fetchOffsets(t,n,r),a=this._fileSize;return{chunk:i,fileOffset:t,isEOF:a>0?t+i.byteLength>=a:i.byteLength<n-t+1}}),c=await Promise.all(s);this._headerChunks.push(...c),this._headerChunks.sort((e,t)=>e.fileOffset-t.fileOffset);let l=this._getCachedHeaderData(e,n);if(!l)throw new t(`tiffraster:open`,`failed to fetch byte range ${e}-${n} from ${this.url}`);return l}_getCachedHeaderData(e,t){let n=[],r=e;for(let{chunk:i,fileOffset:a,isEOF:o}of this._headerChunks){if(a+i.byteLength-1<r)continue;if(a>r)return null;let s=r-a,c=Math.min(t-a+1,i.byteLength);if(n.push({chunk:i,start:s,end:c}),r=a+c,r>t||o&&c===i.byteLength){let t=new Uint8Array(r-e),i=0;for(let e of n){let n=new Uint8Array(e.chunk,e.start,e.end-e.start);t.set(n,i),i+=n.byteLength}return t.buffer}}return null}_getMissingHeaderRanges(e,t){let n=[],r=(e,t)=>{let r=Math.floor(e/this._bufferSize)*this._bufferSize,i=Math.ceil(t/this._bufferSize)*this._bufferSize;n.push({from:r,to:i})},i=e;for(let{chunk:e,fileOffset:a,isEOF:o}of this._headerChunks){let s=a+e.byteLength-1;if(!(s<i)&&(a>i&&r(i,Math.min(a-1,t)),i=Math.max(i,s+1),i>t||o))return n}return i<=t&&r(i,t),n}async _validateOrFetchHeaderBuffer(e,n){let{fileChunk:r,fileOffset:i,posIFD:a}=e;if(a+8>=r.byteLength||a<0){if(i=a+i,i<0)throw new t(`tiffraster:open`,`invalid IFD position ${i}. failed to open url ${this.url}`);r=await this._fetchHeaderData(i,i+this._bufferSize/2,n),a=0}return{fileChunk:r,fileOffset:i,posIFD:a}}async _readIFDs(e,n,r,i=4,a){if(!n.posIFD)return null;n=await this._validateOrFetchHeaderBuffer(n,a);let o=await this._readIFD(n,r,C,i,a);if(!o?.ifd)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(e.push(o.ifd),!o.nextIFD)return null;n.posIFD=o.nextIFD-n.fileOffset,await this._readIFDs(e,n,r,i,a)}async _readIFD(e,n,r=C,i=4,a){let{fileChunk:o,posIFD:s,fileOffset:c}=e;if(!e.fileChunk)return null;let l=h(o,n,s,c,r,i);if(l.success){let{ifd:e}=l;if(!e)throw new t(`tiffraster:open`,`cannot parse tiff header. failed to open url `+this.url);if(!this.ioConfig.loadFullMetadata&&r===C&&(!e.has(`TILEWIDTH`)||!e.has(`TILELENGTH`)))throw new t(`tiffraster:open`,A);let i=[];e.forEach(e=>{e.values||i.push(e)}),i.length>0&&await this._fillOffsets(i,n,l.nextIFD,a),g(e),_(e);for(let[t,r]of w){let i=e.get(t),l=i?.data!=null&&Array.from(i.data.values()).some(e=>e.values==null&&e.offlineOffsetSize!=null);if(i&&(!i.data||l)){s=i.valueOffset-c;let e=await this._validateOrFetchHeaderBuffer({fileChunk:o,posIFD:s,fileOffset:c},a);i.data=(await this._readIFD(e,n,r,4,a))?.ifd}}return l}return l.requiredBufferSize?(o=await this._fetchHeaderData(c,c+s+l.requiredBufferSize+8,a),o.byteLength<s+l.requiredBufferSize?null:(e.fileChunk=o,e.fileOffset=c,this._readIFD(e,n,r,i,a))):null}async _fillOffsets(e,t,n,r){let i=e.filter(e=>e.offlineOffsetSize!=null);if(i.length===0)return;let a=i.map(e=>e.offlineOffsetSize),o=Math.min.apply(null,a.map(e=>e[0])),s=Math.max.apply(null,a.map(e=>e[0]+e[1])),c=a.length===1||s-o<=this._bufferSize;if(!c&&a.length>1&&(a.sort((e,t)=>e[0]-t[0]),c=a.reduce((e,t)=>e===t[0]?t[0]+t[1]:0,a[0][0])===s),c){let e=Math.max(s,o+this._bufferSize/4),n=await this._fetchHeaderData(o,e,r);i.forEach(e=>v(n,t,e,o));return}let l=i.map(async e=>{let n=e.offlineOffsetSize,i=await this._fetchHeaderData(n[0],n[1]+n[0],r);v(i,t,e,n[0])});await Promise.all(l)}async _fetchOffsets(e,t,n){let r=[],i=this._chunkSize;this._fileSize>0&&(t=Math.min(t,this._fileSize-1));let a=Math.ceil((t-e+1)/i),o=e;for(let e=0;e<a;e++)r.push(this.request(this.url,{range:{from:o,to:e===a-1?t:o+i-1},responseType:`array-buffer`,signal:n})),o+=i;let s=await Promise.all(r);if(this._fileSize===-1&&s[0].httpStatus===206){let e=s[0].getHeader?.(`Content-Range`),t=Number(e?.split(`/`)[1]);Number.isFinite(t)&&(this._fileSize=t)}if(s.length===1)return s[0].data;let c=s.reduce((e,t)=>e+t.data.byteLength,0),l=new Uint8Array(c),u=0;for(let e of s)l.set(new Uint8Array(e.data),u),u+=e.data.byteLength;return l.buffer}async _fetchRawTiffTile(e,t,n,r,i={}){let a=this._getTileLocation(e,t,n,r);if(!a)return null;let{ranges:o,actualTileWidth:s,actualTileHeight:c,ifd:l}=a,u=o.map(e=>this.request(this.url,{range:e,responseType:`array-buffer`,signal:i.signal})),d=await Promise.all(u),f=d.map(e=>e.data.byteLength).reduce((e,t)=>e+t),p=d.length===1?d[0].data:new ArrayBuffer(f),m=[0],h=[0];if(d.length>1){let e=new Uint8Array(p);for(let t=0,n=0;t<d.length;t++){let r=d[t].data;e.set(new Uint8Array(r),n),m[t]=n,n+=r.byteLength,h[t]=r.byteLength}}let{blockWidth:g,blockHeight:_}=this.getBlockWidthHeight(e),v=await this.decodePixelBlock(p,{format:`tiff`,customOptions:{headerInfo:this.headerInfo,ifd:l,offsets:m,sizes:h},width:g,height:_,planes:null,pixelType:null},{signal:i.signal});if(v==null)return null;if(s!==g||c!==_){let e=v.mask;if(e)for(let t=0;t<_;t++){let n=t*g;if(t<c)for(let t=s;t<g;t++)e[n+t]=0;else for(let t=0;t<g;t++)e[n+t]=0}else{e=new Uint8Array(g*_),v.mask=e;for(let t=0;t<c;t++){let n=t*g;for(let t=0;t<s;t++)e[n+t]=1}}}return v}_getTileLocation(e,t,n,r=!1){let{firstPyramidLevel:i,blockBoundary:a}=this.rasterInfo.storageInfo,o=e===0?0:e-(i-1),{headerInfo:s}=this;if(!s)return null;let c=r?s.maskIFDs[o]:o===0?s.ifds[0]:s.pyramidIFDs[o-1];if(!c)return null;let l=y(c,s),u=b(c,`TILEOFFSETS`),d=b(c,`TILEBYTECOUNTS`);if(!u?.length||!d?.length)return null;let{minRow:f,minCol:p,maxRow:m,maxCol:h}=a[o];if(t>m||n>h||t<f||n<p)return null;let g=x(c,`IMAGEWIDTH`),_=x(c,`IMAGELENGTH`),v=x(c,`TILEWIDTH`),S=x(c,`TILELENGTH`),C=[];if(l){let{bandCount:e}=this.rasterInfo;for(let r=0;r<e;r++){let e=r*(m+1)*(h+1)+t*(h+1)+n;C[r]={from:u[e],to:u[e]+d[e]-1}}}else{let e=t*(h+1)+n;C.push({from:u[e],to:u[e]+d[e]-1})}for(let e=0;e<C.length;e++)if(C[e].from==null||!C[e].to||C[e].to<0)return null;return{ranges:C,ifd:c,actualTileWidth:n===h&&g%v||v,actualTileHeight:t===m&&_%S||S}}async _fetchAllAuxData(e){if(this.ioConfig.skipMapInfo)return;let{rasterInfo:t}=this,{skipExtensions:n=[]}=this.ioConfig,r=n.includes(`aux.xml`)?Promise.resolve(null):this._fetchAuxiliaryMetaData(e),i=!n.includes(`vat.dbf`)&&t.bandCount===1&&t.pixelType===`u8`?this._fetchAuxiliaryTable(e):Promise.resolve(null),[a,o]=await Promise.all([r,i]);a!=null&&N(a,t),o!=null&&(t.attributeTable=o,t.keyProperties.DataType=`thematic`)}async _fetchAuxiliaryMetaData(e){try{let{data:t}=await this.request(this.url+`.aux.xml`,{responseType:`xml`,signal:e?.signal});return u(t)}catch{return null}}async _fetchAuxiliaryTable(e){try{let{data:t}=await this.request(this.url+`.vat.dbf`,{responseType:`array-buffer`,signal:e?.signal}),n=l(t);return n?.recordSet?k.fromJSON(n.recordSet):null}catch{return null}}};e([r()],j.prototype,`_bufferSize`,void 0),e([r()],j.prototype,`_chunkSize`,void 0),e([r()],j.prototype,`_fileSize`,void 0),e([r()],j.prototype,`_headerChunks`,void 0),e([r({type:String,json:{write:!0}})],j.prototype,`datasetFormat`,void 0),e([r()],j.prototype,`headerInfo`,void 0),j=e([i(`esri.layers.raster.datasets.TIFFRaster`)],j);function M(e){let t=S(e),{width:n,height:r,tileWidth:i,tileHeight:c,planes:l,pixelType:u,compression:f,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidBlockWidth:h,pyramidBlockHeight:g,pyramidResolutions:_,tileBoundary:v,affine:y,metadata:b,colormap:x}=t,C=t.extent.spatialReference?.wkt||t.extent.spatialReference?.wkid,w=d(C),T=!!t.isPseudoGeographic;w??=(T=!0,new s({wkid:3857}));let k=new a({...t.extent,spatialReference:w}),A=k?new o({x:k.xmin,y:k.ymax,spatialReference:w}):new o({x:0,y:0}),j=new O({blockWidth:i,blockHeight:c,pyramidBlockWidth:h,pyramidBlockHeight:g,compression:f,origin:A,firstPyramidLevel:p,maximumPyramidLevel:m,pyramidResolutions:_,blockBoundary:v}),M=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:w}),N=b?{BandProperties:b.bandProperties,DataType:b.dataType}:{},P=new D({width:n,height:r,bandCount:l,pixelType:u,pixelSize:M,storageInfo:j,spatialReference:w,isPseudoSpatialReference:T,keyProperties:N,extent:k,colormap:x,statistics:b?b.statistics:null});if(y?.length&&(P.nativeExtent=new a({xmin:-.5,ymin:.5-r,xmax:n-.5,ymax:.5,spatialReference:w}),P.transform=new E({polynomialOrder:1,forwardCoefficients:[y[2]+y[0]/2,y[5]-y[3]/2,y[0],y[3],-y[1],-y[4]]}),P.extent=P.transform.forwardTransform(P.nativeExtent),P.pixelSize=new o({x:(k.xmax-k.xmin)/n,y:(k.ymax-k.ymin)/r,spatialReference:w}),j.origin.x=-.5,j.origin.y=.5),_){let{x:e,y:t}=P.pixelSize;_.forEach(n=>{n.x*=e,n.y*=t})}return{imageInfo:t,rasterInfo:P}}function N(e,t){if(t.statistics=e.statistics??t.statistics,t.histograms=e.histograms,e.histograms&&t.statistics==null&&(t.statistics=T(e.histograms)),e.transform&&t.transform==null){t.transform=e.transform,t.nativeExtent=t.extent;let n=t.transform.forwardTransform(t.nativeExtent);t.pixelSize=new o({x:(n.xmax-n.xmin)/t.width,y:(n.ymax-n.ymin)/t.height,spatialReference:t.spatialReference}),t.extent=n}t.isPseudoSpatialReference&&e.spatialReference&&(t.spatialReference=e.spatialReference,t.extent.spatialReference=t.nativeExtent.spatialReference=t.storageInfo.origin.spatialReference=t.spatialReference)}const P=j;export{P as default};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/* COPYRIGHT Esri - https://js.arcgis.com/6.0/LICENSE.txt */
|
|
2
|
-
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import{getCapabilities as s,describeCoverage as c}from"../../ogc/wcsUtils.js";import l from"./BaseRaster.js";import{convertOleDateTimeToEpoch as u}from"./multidimensionalUtils.js";import{parse as d}from"./multipartParser.js";import{standardizeInterpolations as f}from"./wcsCoverageParser.js";import{getFormat as p}from"../formats/RasterCodec.js";import{clip as m}from"../functions/pixelUtils.js";import h from"../../support/DimensionalDefinition.js";const g=[`nearest neighbor`,`bilinear`,`bicubic`],_=[`nearest`,`linear`,`cubic`],v=`response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode`,y=new Set([`1.0.0`,`1.1.0`,`1.1.1`,`1.1.2`,`2.0.1`]);let b=class extends l{constructor(){super(...arguments),this.datasetFormat=`WCSServer`,this.tileType=`Raster`}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,r,i,a={}){if(this.isBlockOutside(e,r,i))return null;let{nativePixelSize:o,spatialReference:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:p}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:u},r,i,p,s,[d,f]),g=this.rasterInfo.extent,_=h.xmax>g.xmax,v=h.ymin<g.ymin,y=_||v,b=h,x=d,S=f;if(y&&(b=h.clone().intersection(g),b!=null&&(_&&(x=Math.floor((b.xmax-b.xmin)/l),b.xmax=b.xmin+l*x),v&&(S=Math.floor((b.ymax-b.ymin)/u),b.ymin=b.ymax-u*S))),b==null||x<=1||S<=1)return null;let C=await this._getCoverage(b,x,S,c,a);if(!C)return null;let{coverageDescription:w}=this.coverageInfo,{noDataValue:T,multidimensionalInfo:E}=this.rasterInfo,{multidimensionalDefinition:D}=a,O;if(E!=null&&D!=null&&D.length){let e=D[0].variableName;w.version===`2.0`?O=w.rangeType[0].find(t=>t.name===e)?.nilValue:w.version===`1.1`&&(O=w.range.find(t=>t.identifier===e)?.nullValues)}let k=O??T,A=await this.decodePixelBlock(C,{width:x,height:S,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(k)?k[0]:k,matchAllNoData:!0});if(A==null)return null;if(A&&(A.width!==x||A.height!==S)){let e=`The tiff coverage response has unexpected width: ${A.width}, height: ${A.height}, expecting width: ${x}, height: ${S}`;throw n.getLogger(this).error(`wcsraster-fetch`,e),new t(`wcsraster-fetch`,e)}return y?m(A,{x:0,y:0},{width:f,height:f}):A}async _open(e){let{customFetchParameters:n}=this.ioConfig,r=e?.signal,i=await s(this.url,{version:n?.version??this.version,customParameters:n,signal:r});if(this.capabilities=i,!this.version){let e=i.version.slice(0,3);e===`2.0`||e===`1.1`||e===`1.0`?this.version=i.version:(e=i.supportedVersions.find(e=>e===`2.0.1`)||i.supportedVersions.find(e=>e.startsWith(`2.0`))||i.supportedVersions.find(e=>e.startsWith(`1.1`))||i.supportedVersions.find(e=>e.startsWith(`1.0`))||`1.0.0`,this.version=e)}let{version:a}=this;if(!y.has(a))throw new t(`wcsraster-open`,`unsupported WCS version ${a}`);let{gridCoverages:o}=i;if(!o.length)throw new t(`wcsraster-open`,`cannot find rectified grid coverages`);this.coverageId??=o[0].id;let{coverageId:l}=this,u=o.find(e=>e.id===l);if(u==null)throw new t(`wcsraster-open`,`the coverageId ${l} does not exist in capabilities`);let d=await c(this.url,{coverageIds:[l],version:a,customParameters:n,signal:r});if(this.coverageInfo=d[0],a.startsWith(`2.0`)){let{coverageInfo:e}=this;e.lonLatEnvelope=u.lonLatEnvelope,e.supportedInterpolations=f(i.supportedInterpolations),this._patchDimensionValues201(l,r)}this.datasetName=this.coverageInfo.title;let{rasterInfo:p}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(p,512,512),this._set(`rasterInfo`,p),p.spatialReference==null)throw new t(`wcsraster-open`,`coverage without spatial reference is not supported: ${l}`);let{pixelType:m,bandCount:h}=await this._getPixelTypeAndBandCount(r);p.pixelType=m,p.bandCount===1&&h>1&&(p.bandCount=h),this.updateTileInfo()}async _patchDimensionValues201(e,t){let{coverageInfo:n}=this,r=n.rasterInfo.multidimensionalInfo?.variables,i=y.has(`1.1.2`)?`1.1.2`:y.has(`1.1.1`)?`1.1.1`:y.has(`1.1.0`)?`1.1.0`:null,{customFetchParameters:a}=this.ioConfig;if(r&&i)try{let n=this.url.includes(`/ImageServer/`),o=e.length>8&&e.startsWith(`Coverage`)&&n?e.slice(8):e,s=(await c(this.url,{coverageIds:[o??e],version:i,customParameters:a,signal:t}).catch(()=>{if(o)return c(this.url,{coverageIds:[e],version:i,customParameters:a,signal:t})}))?.[0].rasterInfo.multidimensionalInfo?.variables;if(s)for(let e of r){let t=s.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let r=e.dimensions.length-1;r>=0;r--){let i=e.dimensions[r],a=t.dimensions.find(({name:e})=>e===i.name);a?a.values&&a.extent?.join(`,`)===i.extent?.join(`,`)&&(e.dimensions[r]={...i,values:a.values}):n&&e.dimensions.splice(r,1)}}}catch{}}async _getPixelTypeAndBandCount(e){let{pixelSize:r,extent:i,multidimensionalInfo:o}=this.rasterInfo,s=i.center,c=new a({xmin:s.x-r.x,xmax:s.x+r.x,ymin:s.y-r.y,ymax:s.y+r.y,spatialReference:i.spatialReference}),l=[];if(o!=null){let e=o.variables[0];l=[],e.dimensions.forEach(t=>{l.push(new h({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}let{coverageDescription:u}=this.coverageInfo,d={interpolation:`nearest`,multidimensionalDefinition:l,signal:e},{version:f}=u,{ioConfig:p}=this,m=f===`2.0`&&p.allowAnyMediaType==null||f===`1.1`&&p.use2GridOffsets==null,g;try{g=await this._getCoverage(c,2,2,1,d,!0)}catch(e){if(!m)throw e;if(f===`1.1`){if(e.details?.isResolutionMismatch)p.use2GridOffsets=!0;else throw e}}if(!g&&m&&(f===`2.0`&&(p.allowAnyMediaType=!0),g=await this._getCoverage(c,2,2,1,d),g&&n.getLogger(this).warn(`wcsraster:getcoverage`,v)),!g)throw new t(`wcsraster-open`,`unable to determine pixel type`);let _=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null});if(_==null)throw new t(`wcsraster-open`,`unable to determine pixel type`);return{pixelType:_.pixelType,bandCount:_.getPlaneCount()??0}}async _getCoverage(e,r,i,a,o,s=!1){let{coverageDescription:c}=this.coverageInfo,{version:l}=c,u=l===`2.0`?this._getCoverage201Parameters(e,r,i,a,o,c):l===`1.1`?this._getCoverage110Parameters(e,r,i,o,c):this._getCoverage100Parameters(e,r,i,o),f=l===`2.0`?await this.request(this._constructWCS201Url(u),{signal:o.signal,responseType:`array-buffer`}):await this.request(this.url,{query:u,signal:o.signal,responseType:`array-buffer`});if(l===`1.0`)return f.data;if(l===`2.0`&&this.ioConfig.allowAnyMediaType!==!1&&p(f.data)===`tiff`)return s&&(this.ioConfig.allowAnyMediaType=!0,n.getLogger(this).warn(`wcsraster:getcoverage`,v)),f.data;let m=d(f);if(m.isMultipart&&m.data){let e=m.data.find(e=>e.isValidImage);return s&&e?.contentTransferEncoding===`base64`&&n.getLogger(this).warn(`wcsraster:getcoverage`,`response is base64 encoded which may impact layer display performance`),e?.contentData}let h=new Uint8Array(f.data,0,Math.min(f.data.byteLength,2e3)),g=String.fromCharCode.apply(null,h).toLowerCase().includes(`exception`),_=g&&String.fromCharCode.apply(null,h).includes(`A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided`);throw g?new t(`wcsraster:getcoverage`,`server returns an exception`,{isResolutionMismatch:_}):new t(`wcsraster:getcoverage`,`response is not a supported multipart mediaType with inline tiff`)}_getInterpolationIndex(e){return!e||!this.coverageInfo.supportedInterpolations?.includes(e)||e===`nearest`?0:e===`bilinear`?1:e===`cubic`?2:0}_getCoverage100Parameters(e,t,n,r){let i=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,a=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`GEOTIFF`,{bandIds:s,interpolation:c}=r,l=this._getInterpolationIndex(c),u=s?s.map(e=>this.coverageInfo.bandNames[e]):null,d=g[l],{multidimensionalDefinition:f}=r,p;if(f!=null&&this.rasterInfo.multidimensionalInfo!=null){let e=f.find(e=>e.dimensionName===`StdTime`)?.values;e&&e.length>0&&(Array.isArray(e[0])&&(e=e[0]),p=e.map(e=>x(e)).join(`,`))}return{service:`WCS`,request:`GetCoverage`,version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${a}`,bbox:i,width:t,height:n,time:p,interpolation:d,band:u?.join(`,`)}}_getCoverage110Parameters(e,t,n,r,i){let{multidimensionalDefinition:a,bandIds:s,interpolation:c}=r,l=e.spatialReference.wkid,u=`urn:ogc:def:crs:EPSG::${l}`,d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,f=this._getInterpolationIndex(c),p=_[f],m=c==null||this.coverageInfo.supportedInterpolations?.indexOf(c)===0,h=i.domain.spatialDomain,g=h.origin.x<=h.envelope.xmin&&h.origin.y<=h.envelope.ymin,v=e.width/t,y=e.height/n*(g?1:-1),b=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],S=h.useEPSGAxis&&o(l),C=S?`${b[1]},${b[0]}`:`${b[0]},${b[1]}`,w=this.ioConfig.use2GridOffsets,T=S?w?`${y},${v}`:`${y},0,0,${v}`:w?`${v},${y}`:`${v},0,0,${y}`,E=v/2,D=e.xmin+E,O=e.xmax-E,k=Math.abs(y)/2,A=e.ymin+k,j=e.ymax-k,M=S?`${A},${D},${j},${O},${u}`:`${D},${A},${O},${j},${u}`,N=i.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes(`band`))),P=N&&p&&s?m?`${N.identifier}[${N.axis[0].identifier}[${s.join(`,`)}]]`:`${N.identifier}:${p}[${N.axis[0].identifier}[${s.join(`,`)}]]`:null,F;if(a!=null&&a.length)for(let e=0;e<a.length;e++){let t=a[e].values,n=a[e].dimensionName?.toLowerCase(),r=a[e].variableName?.toLowerCase(),o=i.range.find(e=>e.identifier.toLowerCase()===r);if(t.length>0){if(Array.isArray(t[0])&&(t=t[0]),n===`stdtime`)F=t.map(e=>x(e)).join(`,`);else if(o){let e=o.axis.find(e=>e.identifier.toLowerCase()===n);e&&(P=m?o.identifier+`[`+e.identifier+`[`+t.join(`,`)+`]]`:o.identifier+`:`+p+`[`+e.identifier+`[`+t.join(`,`)+`]]`)}}e===a.length-1&&o&&!P&&(P=m?o.identifier:o.identifier+`:`+p)}return{service:`WCS`,request:`GetCoverage`,version:this.version,identifier:this.coverageId,format:d,crs:`EPSG:${l}`,boundingbox:M,gridCS:`urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS`,gridType:`urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs`,gridOrigin:C,gridOffsets:T,gridBaseCRS:u,timeSequence:F,rangeSubset:P}}_getCoverage201Parameters(e,t,n,r,i,a){let{multidimensionalDefinition:o,interpolation:s}=i,c=this._getInterpolationIndex(s),l=null,{supportedInterpolations:u}=this.capabilities;if(u?.length)switch(c){case 0:l=u.find(e=>e.toLowerCase().includes(`nearest`));break;case 1:l=u.find(e=>e.toLowerCase().includes(`linear`));break;case 2:l=u.find(e=>e.toLowerCase().includes(`cubic`)||e.toLowerCase().includes(`quadratic`))}let d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,{bandNames:f}=this.coverageInfo,{boundedBy:p,domainSet:m,rangeType:h}=a,g=+!p.isEastFirst,_=1-g,{axisLabels:v}=p,y=v[g],b=v[_],S=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=S,w=[];w.push(`${y}(${e.xmin},${e.xmax})`),w.push(`${b}(${e.ymin},${e.ymax})`);let T=[];if(v.length>2)for(let e=2;e<v.length;e++){let t=m.origin[e];if(v[e].toLowerCase().includes(`time`)){let n=t.toString();p.uomLabels?.[e].toLowerCase().includes(`ole`)&&(T.push(v[e]),n=x(t,!0)),w.push(v[e]+`,http://www.opengis.net(`+n+`)`)}else w.push(v[e]+`,http://www.opengis.net(`+t+`)`)}let E=null;if(o!=null&&o.length){let e=[];h.forEach(t=>t.forEach(t=>e.push(t.name)));let t=[];for(let n=0;n<o.length;n++){let r=v.find(e=>e===o[n].dimensionName),i=e.find(e=>e===o[n].variableName);if(t.includes(i)||t.push(i),r){let e=o[n].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t=``;t=r.toLowerCase().includes(`time`)?e.map(e=>x(e)).join(`,`):e.join(`,`);let n=w.findIndex(e=>e.startsWith(r+`,http://www.opengis.net`));n===-1&&w.push(r+`,http://www.opengis.net(`+t+`)`),n!==-1&&!w[n].includes(`(`+t+`)`)&&w.splice(n,1,r+`,http://www.opengis.net(`+t+`)`)}}}t.length&&(E=t.join(`,`))}else f?.length>=2&&(E=(i.bandIds?i.bandIds.map(e=>f[e]):f).join(`,`));let D=w.join(`&subset=`),O=!a.domainSet.hasSameAxisLabelsAsBoundedBy&&this.ioConfig.allowScaleFactor!==!1,k=O?null:`${y}(${t}),${b}(${n})`,A=O?1/r:null;return{service:`WCS`,request:`GetCoverage`,version:this.version,coverageId:this.coverageId,rangesubset:E,interpolation:l,scaleSize:k,scaleFactor:A,subset:D,format:d,mediaType:this.ioConfig.allowAnyMediaType?null:`multipart/related`,outputcrs:S,subsettingcrs:C}}_constructWCS201Url(e){let t={...this.ioConfig.customFetchParameters,...e},n=[];return Object.keys(t).forEach(e=>{let r=t[e];r!=null&&(e===`subset`?typeof r==`string`&&r.split(`&subset=`).forEach(e=>{e&&n.push(`subset=${encodeURIComponent(e)}`)}):n.push(`${e}=${encodeURIComponent(r)}`))}),`${encodeURI(this.url)}?${n.join(`&`)}`}};e([r({type:String,json:{write:!0}})],b.prototype,`datasetFormat`,void 0),e([r({readOnly:!0})],b.prototype,`tileType`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`version`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`coverageId`,void 0),e([r({readOnly:!0})],b.prototype,`rasterId`,null),b=e([i(`esri.layers.raster.datasets.WCSRaster`)],b);function x(e,t=!1){return(t?new Date(u(e)):new Date(e)).toISOString()}export{b as default};
|
|
2
|
+
import{__decorate as e}from"tslib";import t from"../../../core/Error.js";import n from"../../../core/Logger.js";import{property as r,subclass as i}from"../../../core/accessorSupport/decorators.js";import a from"../../../geometry/Extent.js";import{isAxesOrderReversedForWkid as o}from"../../ogc/crsUtils.js";import{getCapabilities as s,describeCoverage as c}from"../../ogc/wcsUtils.js";import l from"./BaseRaster.js";import{convertOleDateTimeToEpoch as u}from"./multidimensionalUtils.js";import{parse as d}from"./multipartParser.js";import{standardizeInterpolations as f}from"./wcsCoverageParser.js";import{getFormat as p}from"../formats/RasterCodec.js";import{clip as m}from"../functions/pixelUtils.js";import h from"../../support/DimensionalDefinition.js";const g=[`nearest neighbor`,`bilinear`,`bicubic`],_=[`nearest`,`linear`,`cubic`],v=`response is not a supported multipart/related mediaType with inline tiff, switching to compatibility mode`,y=new Set([`1.0.0`,`1.1.0`,`1.1.1`,`1.1.2`,`2.0.1`]);let b=class extends l{constructor(){super(...arguments),this.datasetFormat=`WCSServer`,this.tileType=`Raster`}get rasterId(){return`${this.url}-${this.coverageId}-${this.version}`}async fetchRawTile(e,r,i,a={}){if(this.isBlockOutside(e,r,i))return null;let{nativePixelSize:o,spatialReference:s}=this.rasterInfo,c=2**e,l=o.x*c,u=o.y*c,{blockWidth:d,blockHeight:f}=this.getBlockWidthHeight(e),{origin:p}=this.rasterInfo.storageInfo.tileInfo,h=this.getTileExtent({x:l,y:u},r,i,p,s,[d,f]),g=this.rasterInfo.extent,_=h.xmax>g.xmax,v=h.ymin<g.ymin,y=_||v,b=h,x=d,S=f;if(y&&(b=h.clone().intersection(g),b!=null&&(_&&(x=Math.floor((b.xmax-b.xmin)/l),b.xmax=b.xmin+l*x),v&&(S=Math.floor((b.ymax-b.ymin)/u),b.ymin=b.ymax-u*S))),b==null||x<=1||S<=1)return null;let C=await this._getCoverage(b,x,S,c,a);if(!C)return null;let{coverageDescription:w}=this.coverageInfo,{noDataValue:T,multidimensionalInfo:E}=this.rasterInfo,{multidimensionalDefinition:D}=a,O;if(E!=null&&D!=null&&D.length){let e=D[0].variableName;w.version===`2.0`?O=w.rangeType[0].find(t=>t.name===e)?.nilValue:w.version===`1.1`&&(O=w.range.find(t=>t.identifier===e)?.nullValues)}let k=O??T,A=await this.decodePixelBlock(C,{width:x,height:S,planes:null,pixelType:null,tiffNoDataValue:Array.isArray(k)?k[0]:k,matchAllNoData:!0},{signal:a.signal});if(A==null)return null;if(A&&(A.width!==x||A.height!==S)){let e=`The tiff coverage response has unexpected width: ${A.width}, height: ${A.height}, expecting width: ${x}, height: ${S}`;throw n.getLogger(this).error(`wcsraster-fetch`,e),new t(`wcsraster-fetch`,e)}return y?m(A,{x:0,y:0},{width:f,height:f}):A}async _open(e){let{customFetchParameters:n}=this.ioConfig,r=e?.signal,i=await s(this.url,{version:n?.version??this.version,customParameters:n,signal:r});if(this.capabilities=i,!this.version){let e=i.version.slice(0,3);e===`2.0`||e===`1.1`||e===`1.0`?this.version=i.version:(e=i.supportedVersions.find(e=>e===`2.0.1`)||i.supportedVersions.find(e=>e.startsWith(`2.0`))||i.supportedVersions.find(e=>e.startsWith(`1.1`))||i.supportedVersions.find(e=>e.startsWith(`1.0`))||`1.0.0`,this.version=e)}let{version:a}=this;if(!y.has(a))throw new t(`wcsraster-open`,`unsupported WCS version ${a}`);let{gridCoverages:o}=i;if(!o.length)throw new t(`wcsraster-open`,`cannot find rectified grid coverages`);this.coverageId??=o[0].id;let{coverageId:l}=this,u=o.find(e=>e.id===l);if(u==null)throw new t(`wcsraster-open`,`the coverageId ${l} does not exist in capabilities`);let d=await c(this.url,{coverageIds:[l],version:a,customParameters:n,signal:r});if(this.coverageInfo=d[0],a.startsWith(`2.0`)){let{coverageInfo:e}=this;e.lonLatEnvelope=u.lonLatEnvelope,e.supportedInterpolations=f(i.supportedInterpolations),this._patchDimensionValues201(l,r)}this.datasetName=this.coverageInfo.title;let{rasterInfo:p}=this.coverageInfo;if(this.createRemoteDatasetStorageInfo(p,512,512),this._set(`rasterInfo`,p),p.spatialReference==null)throw new t(`wcsraster-open`,`coverage without spatial reference is not supported: ${l}`);let{pixelType:m,bandCount:h}=await this._getPixelTypeAndBandCount(r);p.pixelType=m,p.bandCount===1&&h>1&&(p.bandCount=h),this.updateTileInfo()}async _patchDimensionValues201(e,t){let{coverageInfo:n}=this,r=n.rasterInfo.multidimensionalInfo?.variables,i=y.has(`1.1.2`)?`1.1.2`:y.has(`1.1.1`)?`1.1.1`:y.has(`1.1.0`)?`1.1.0`:null,{customFetchParameters:a}=this.ioConfig;if(r&&i)try{let n=this.url.includes(`/ImageServer/`),o=e.length>8&&e.startsWith(`Coverage`)&&n?e.slice(8):e,s=(await c(this.url,{coverageIds:[o??e],version:i,customParameters:a,signal:t}).catch(()=>{if(o)return c(this.url,{coverageIds:[e],version:i,customParameters:a,signal:t})}))?.[0].rasterInfo.multidimensionalInfo?.variables;if(s)for(let e of r){let t=s.find(({name:t})=>t===e.name);if(t?.dimensions?.length)for(let r=e.dimensions.length-1;r>=0;r--){let i=e.dimensions[r],a=t.dimensions.find(({name:e})=>e===i.name);a?a.values&&a.extent?.join(`,`)===i.extent?.join(`,`)&&(e.dimensions[r]={...i,values:a.values}):n&&e.dimensions.splice(r,1)}}}catch{}}async _getPixelTypeAndBandCount(e){let{pixelSize:r,extent:i,multidimensionalInfo:o}=this.rasterInfo,s=i.center,c=new a({xmin:s.x-r.x,xmax:s.x+r.x,ymin:s.y-r.y,ymax:s.y+r.y,spatialReference:i.spatialReference}),l=[];if(o!=null){let e=o.variables[0];l=[],e.dimensions.forEach(t=>{l.push(new h({variableName:e.name,dimensionName:t.name,values:t.hasRegularIntervals?t.extent?.[0]:t.values?.[0],isSlice:!0}))})}let{coverageDescription:u}=this.coverageInfo,d={interpolation:`nearest`,multidimensionalDefinition:l,signal:e},{version:f}=u,{ioConfig:p}=this,m=f===`2.0`&&p.allowAnyMediaType==null||f===`1.1`&&p.use2GridOffsets==null,g;try{g=await this._getCoverage(c,2,2,1,d,!0)}catch(e){if(!m)throw e;if(f===`1.1`){if(e.details?.isResolutionMismatch)p.use2GridOffsets=!0;else throw e}}if(!g&&m&&(f===`2.0`&&(p.allowAnyMediaType=!0),g=await this._getCoverage(c,2,2,1,d),g&&n.getLogger(this).warn(`wcsraster:getcoverage`,v)),!g)throw new t(`wcsraster-open`,`unable to determine pixel type`);let _=await this.decodePixelBlock(g,{width:2,height:2,planes:null,pixelType:null},{signal:d.signal});if(_==null)throw new t(`wcsraster-open`,`unable to determine pixel type`);return{pixelType:_.pixelType,bandCount:_.getPlaneCount()??0}}async _getCoverage(e,r,i,a,o,s=!1){let{coverageDescription:c}=this.coverageInfo,{version:l}=c,u=l===`2.0`?this._getCoverage201Parameters(e,r,i,a,o,c):l===`1.1`?this._getCoverage110Parameters(e,r,i,o,c):this._getCoverage100Parameters(e,r,i,o),f=l===`2.0`?await this.request(this._constructWCS201Url(u),{signal:o.signal,responseType:`array-buffer`}):await this.request(this.url,{query:u,signal:o.signal,responseType:`array-buffer`});if(l===`1.0`)return f.data;if(l===`2.0`&&this.ioConfig.allowAnyMediaType!==!1&&p(f.data)===`tiff`)return s&&(this.ioConfig.allowAnyMediaType=!0,n.getLogger(this).warn(`wcsraster:getcoverage`,v)),f.data;let m=d(f);if(m.isMultipart&&m.data){let e=m.data.find(e=>e.isValidImage);return s&&e?.contentTransferEncoding===`base64`&&n.getLogger(this).warn(`wcsraster:getcoverage`,`response is base64 encoded which may impact layer display performance`),e?.contentData}let h=new Uint8Array(f.data,0,Math.min(f.data.byteLength,2e3)),g=String.fromCharCode.apply(null,h).toLowerCase().includes(`exception`),_=g&&String.fromCharCode.apply(null,h).includes(`A non-zero RESX/RESY or WIDTH/HEIGHT is required but neither was provided`);throw g?new t(`wcsraster:getcoverage`,`server returns an exception`,{isResolutionMismatch:_}):new t(`wcsraster:getcoverage`,`response is not a supported multipart mediaType with inline tiff`)}_getInterpolationIndex(e){return!e||!this.coverageInfo.supportedInterpolations?.includes(e)||e===`nearest`?0:e===`bilinear`?1:e===`cubic`?2:0}_getCoverage100Parameters(e,t,n,r){let i=`${e.xmin},${e.ymin},${e.xmax},${e.ymax}`,a=e.spatialReference.wkid,o=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`GEOTIFF`,{bandIds:s,interpolation:c}=r,l=this._getInterpolationIndex(c),u=s?s.map(e=>this.coverageInfo.bandNames[e]):null,d=g[l],{multidimensionalDefinition:f}=r,p;if(f!=null&&this.rasterInfo.multidimensionalInfo!=null){let e=f.find(e=>e.dimensionName===`StdTime`)?.values;e&&e.length>0&&(Array.isArray(e[0])&&(e=e[0]),p=e.map(e=>x(e)).join(`,`))}return{service:`WCS`,request:`GetCoverage`,version:this.version,coverage:this.coverageId,format:o,crs:`EPSG:${a}`,bbox:i,width:t,height:n,time:p,interpolation:d,band:u?.join(`,`)}}_getCoverage110Parameters(e,t,n,r,i){let{multidimensionalDefinition:a,bandIds:s,interpolation:c}=r,l=e.spatialReference.wkid,u=`urn:ogc:def:crs:EPSG::${l}`,d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,f=this._getInterpolationIndex(c),p=_[f],m=c==null||this.coverageInfo.supportedInterpolations?.indexOf(c)===0,h=i.domain.spatialDomain,g=h.origin.x<=h.envelope.xmin&&h.origin.y<=h.envelope.ymin,v=e.width/t,y=e.height/n*(g?1:-1),b=g?[e.xmin,e.ymin]:[e.xmin,e.ymax],S=h.useEPSGAxis&&o(l),C=S?`${b[1]},${b[0]}`:`${b[0]},${b[1]}`,w=this.ioConfig.use2GridOffsets,T=S?w?`${y},${v}`:`${y},0,0,${v}`:w?`${v},${y}`:`${v},0,0,${y}`,E=v/2,D=e.xmin+E,O=e.xmax-E,k=Math.abs(y)/2,A=e.ymin+k,j=e.ymax-k,M=S?`${A},${D},${j},${O},${u}`:`${D},${A},${O},${j},${u}`,N=i.range.find(e=>e.axis.some(e=>e.identifier.toLowerCase().includes(`band`))),P=N&&p&&s?m?`${N.identifier}[${N.axis[0].identifier}[${s.join(`,`)}]]`:`${N.identifier}:${p}[${N.axis[0].identifier}[${s.join(`,`)}]]`:null,F;if(a!=null&&a.length)for(let e=0;e<a.length;e++){let t=a[e].values,n=a[e].dimensionName?.toLowerCase(),r=a[e].variableName?.toLowerCase(),o=i.range.find(e=>e.identifier.toLowerCase()===r);if(t.length>0){if(Array.isArray(t[0])&&(t=t[0]),n===`stdtime`)F=t.map(e=>x(e)).join(`,`);else if(o){let e=o.axis.find(e=>e.identifier.toLowerCase()===n);e&&(P=m?o.identifier+`[`+e.identifier+`[`+t.join(`,`)+`]]`:o.identifier+`:`+p+`[`+e.identifier+`[`+t.join(`,`)+`]]`)}}e===a.length-1&&o&&!P&&(P=m?o.identifier:o.identifier+`:`+p)}return{service:`WCS`,request:`GetCoverage`,version:this.version,identifier:this.coverageId,format:d,crs:`EPSG:${l}`,boundingbox:M,gridCS:`urn:ogc:def:cs:OGC:0.0:Grid2dSquareCS`,gridType:`urn:ogc:def:method:WCS:1.1:2dGridIn2dCrs`,gridOrigin:C,gridOffsets:T,gridBaseCRS:u,timeSequence:F,rangeSubset:P}}_getCoverage201Parameters(e,t,n,r,i,a){let{multidimensionalDefinition:o,interpolation:s}=i,c=this._getInterpolationIndex(s),l=null,{supportedInterpolations:u}=this.capabilities;if(u?.length)switch(c){case 0:l=u.find(e=>e.toLowerCase().includes(`nearest`));break;case 1:l=u.find(e=>e.toLowerCase().includes(`linear`));break;case 2:l=u.find(e=>e.toLowerCase().includes(`cubic`)||e.toLowerCase().includes(`quadratic`))}let d=(this.coverageInfo.supportedFormats||[]).find(e=>e.toLowerCase().includes(`tiff`))||`image/tiff`,{bandNames:f}=this.coverageInfo,{boundedBy:p,domainSet:m,rangeType:h}=a,g=+!p.isEastFirst,_=1-g,{axisLabels:v}=p,y=v[g],b=v[_],S=`http://www.opengis.net/def/crs/EPSG/0/${e.spatialReference.wkid}`,C=S,w=[];w.push(`${y}(${e.xmin},${e.xmax})`),w.push(`${b}(${e.ymin},${e.ymax})`);let T=[];if(v.length>2)for(let e=2;e<v.length;e++){let t=m.origin[e];if(v[e].toLowerCase().includes(`time`)){let n=t.toString();p.uomLabels?.[e].toLowerCase().includes(`ole`)&&(T.push(v[e]),n=x(t,!0)),w.push(v[e]+`,http://www.opengis.net(`+n+`)`)}else w.push(v[e]+`,http://www.opengis.net(`+t+`)`)}let E=null;if(o!=null&&o.length){let e=[];h.forEach(t=>t.forEach(t=>e.push(t.name)));let t=[];for(let n=0;n<o.length;n++){let r=v.find(e=>e===o[n].dimensionName),i=e.find(e=>e===o[n].variableName);if(t.includes(i)||t.push(i),r){let e=o[n].values;if(e.length>0){Array.isArray(e[0])&&(e=e[0]);let t=``;t=r.toLowerCase().includes(`time`)?e.map(e=>x(e)).join(`,`):e.join(`,`);let n=w.findIndex(e=>e.startsWith(r+`,http://www.opengis.net`));n===-1&&w.push(r+`,http://www.opengis.net(`+t+`)`),n!==-1&&!w[n].includes(`(`+t+`)`)&&w.splice(n,1,r+`,http://www.opengis.net(`+t+`)`)}}}t.length&&(E=t.join(`,`))}else f?.length>=2&&(E=(i.bandIds?i.bandIds.map(e=>f[e]):f).join(`,`));let D=w.join(`&subset=`),O=!a.domainSet.hasSameAxisLabelsAsBoundedBy&&this.ioConfig.allowScaleFactor!==!1,k=O?null:`${y}(${t}),${b}(${n})`,A=O?1/r:null;return{service:`WCS`,request:`GetCoverage`,version:this.version,coverageId:this.coverageId,rangesubset:E,interpolation:l,scaleSize:k,scaleFactor:A,subset:D,format:d,mediaType:this.ioConfig.allowAnyMediaType?null:`multipart/related`,outputcrs:S,subsettingcrs:C}}_constructWCS201Url(e){let t={...this.ioConfig.customFetchParameters,...e},n=[];return Object.keys(t).forEach(e=>{let r=t[e];r!=null&&(e===`subset`?typeof r==`string`&&r.split(`&subset=`).forEach(e=>{e&&n.push(`subset=${encodeURIComponent(e)}`)}):n.push(`${e}=${encodeURIComponent(r)}`))}),`${encodeURI(this.url)}?${n.join(`&`)}`}};e([r({type:String,json:{write:!0}})],b.prototype,`datasetFormat`,void 0),e([r({readOnly:!0})],b.prototype,`tileType`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`version`,void 0),e([r({type:String,json:{write:!0}})],b.prototype,`coverageId`,void 0),e([r({readOnly:!0})],b.prototype,`rasterId`,null),b=e([i(`esri.layers.raster.datasets.WCSRaster`)],b);function x(e,t=!1){return(t?new Date(u(e)):new Date(e)).toISOString()}export{b as default};
|