@arcgis/core 4.33.0-next.20250423 → 4.33.0-next.20250425
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/Graphic.js +1 -1
- package/WebScene.js +1 -1
- package/analysis/Analysis.d.ts +4 -0
- package/analysis/Analysis.js +1 -1
- package/analysis/SliceAnalysis.js +1 -1
- package/analysis/SlicePlane.js +1 -1
- package/analysis/support/AnalysisOriginWebScene.d.ts +4 -0
- package/analysis/support/AnalysisOriginWebScene.js +5 -0
- package/analysis/support/SliceAnalysisExcludedLayer.js +5 -0
- package/assets/esri/core/workers/RemoteClient.js +1 -1
- package/assets/esri/core/workers/chunks/{d4d011eea16a89a5aad9.js → 0219c3f9408d3fa3c9a0.js} +1 -1
- package/assets/esri/core/workers/chunks/070839cb71c8e764b8d7.js +1 -0
- package/assets/esri/core/workers/chunks/19084a293694c5a00cae.js +1 -0
- package/assets/esri/core/workers/chunks/{8ba7d44eff348004f084.js → 1a6d2d090b643a87408a.js} +1 -1
- package/assets/esri/core/workers/chunks/1b8cc83aa1179245b2dc.js +1 -0
- package/assets/esri/core/workers/chunks/{5e5225623977e61fd0ef.js → 213adc87c843d627c5d6.js} +1 -1
- package/assets/esri/core/workers/chunks/{fa8a3c75f9b41d31559b.js → 265f69d153b7b6f07e42.js} +1 -1
- package/assets/esri/core/workers/chunks/{769b66cca8347f0f84db.js → 279bbd61b32577693a4a.js} +1 -1
- package/assets/esri/core/workers/chunks/290b065b377f9d2ee058.js +1 -0
- package/assets/esri/core/workers/chunks/29d3245261a7223124ed.js +1 -0
- package/assets/esri/core/workers/chunks/2bed8a5ed9ae3760fa2f.js +1 -0
- package/assets/esri/core/workers/chunks/2e3019ce49e972a815ca.js +1 -0
- package/assets/esri/core/workers/chunks/335b539893569e3d7b82.js +1 -0
- package/assets/esri/core/workers/chunks/38f5e6a202ce292edd9f.js +1 -0
- package/assets/esri/core/workers/chunks/415903f481392c72870f.js +1 -0
- package/assets/esri/core/workers/chunks/4351b3e54b309935faed.js +1 -0
- package/assets/esri/core/workers/chunks/4da99f058cca83937e9b.js +1 -0
- package/assets/esri/core/workers/chunks/5acdd49c5f1a49fdc6e7.js +1 -0
- package/assets/esri/core/workers/chunks/60f7cd05e88701f43d3f.js +1 -0
- package/assets/esri/core/workers/chunks/{26e0a0a13060cd3e4291.js → 626ba3a7dee952308566.js} +1 -1
- package/assets/esri/core/workers/chunks/7cd32b10ed0e18e44ef2.js +1 -0
- package/assets/esri/core/workers/chunks/9661ee8569ee208e6237.js +1 -0
- package/assets/esri/core/workers/chunks/968f2f841c011095a6d2.js +1 -0
- package/assets/esri/core/workers/chunks/974742af7beb000c4b4a.js +1 -0
- package/assets/esri/core/workers/chunks/{e27fa1e84f16b7f19a90.js → 9850ff14bd9c7da81c65.js} +1 -1
- package/assets/esri/core/workers/chunks/a0c51c4c30a5f749dfc6.js +1 -0
- package/assets/esri/core/workers/chunks/a2676f3f135ad5fdf872.js +1 -0
- package/assets/esri/core/workers/chunks/a8430e1e2142f1ce9b92.js +1 -0
- package/assets/esri/core/workers/chunks/{fdcbd28f38bc485ac5e3.js → ab6ecd8eeec5ff761b34.js} +1 -1
- package/assets/esri/core/workers/chunks/b53300b46646cfad2526.js +319 -0
- package/assets/esri/core/workers/chunks/bf543bdec3da0fe278fb.js +1 -0
- package/assets/esri/core/workers/chunks/{5bdd5ae2d2f23ef6b331.js → c87e2a63b96e0da77dfe.js} +1 -1
- package/assets/esri/core/workers/chunks/cc4dd739c4c7e3ccea3f.js +1 -0
- package/assets/esri/core/workers/chunks/d3a74087e076a3ae76ca.js +1 -0
- package/assets/esri/core/workers/chunks/{7c42281188b874ffcdad.js → db5913824d5e5a2a8365.js} +1 -1
- package/assets/esri/core/workers/chunks/{48a1bb1e171dd06a7c6e.js → dd94585508f49863dc15.js} +1 -1
- package/assets/esri/core/workers/chunks/{9408a72968cbd985dd24.js → f2cef954b58c6604642c.js} +34 -34
- package/assets/esri/core/workers/chunks/f52e597dca4b32a81881.js +1 -0
- package/assets/esri/libs/lyr3d/lyr3DMain.wasm +0 -0
- package/assets/esri/libs/lyr3d/lyr3DWorker.wasm +0 -0
- package/chunks/BloomBlur.glsl.js +7 -7
- package/chunks/BloomComposition.glsl.js +24 -25
- package/chunks/ShadowCastAccumulate.glsl.js +13 -9
- package/chunks/ShadowCastVisualize.glsl.js +24 -9
- package/chunks/cameraUtilsSpherical.js +1 -1
- package/chunks/lyr3DMain.js +1 -1
- package/chunks/lyr3DWorker.js +1 -1
- package/chunks/sphere.js +1 -1
- package/core/Collection.js +1 -1
- package/core/JSONSupport.js +1 -1
- package/core/SetUtils.js +1 -1
- package/{views/webgl/GLObjectType.js → core/support/jsonUtils.js} +1 -1
- package/core/urlUtils.js +1 -1
- package/geometry/Mesh.js +1 -1
- package/geometry/support/normalizeUtilsSync.js +1 -1
- package/geometry/support/sphere.js +1 -1
- package/interfaces.d.ts +544 -116
- package/layers/DimensionLayer.js +1 -1
- package/layers/IntegratedMesh3DTilesLayer.js +1 -1
- package/layers/Lyr3DWasmPerSceneView.js +1 -1
- package/layers/ParquetLayer.js +1 -1
- package/layers/RouteLayer.js +1 -1
- package/layers/SubtypeGroupLayer.js +1 -1
- package/layers/ViewshedLayer.js +1 -1
- package/layers/graphics/data/QueryEngine.js +1 -1
- package/layers/mixins/ImageryTileMixin.js +1 -1
- package/layers/orientedImagery/transformations/imageToWorld.js +1 -1
- package/layers/orientedImagery/transformations/utils.js +1 -1
- package/layers/support/FieldsIndex.js +1 -1
- package/layers/support/ParquetEncodingLocation.d.ts +4 -0
- package/layers/support/ParquetEncodingLocation.js +1 -1
- package/layers/support/ParquetEncodingWkb.d.ts +4 -0
- package/layers/support/ParquetEncodingWkb.js +1 -1
- package/layers/support/RasterStorageInfo.js +1 -1
- package/layers/support/VideoElement.js +1 -1
- package/layers/support/layerUtils.js +1 -1
- package/layers/support/parquetUtils.d.ts +3 -0
- package/layers/support/parquetUtils.js +1 -1
- package/layers/support/rasterDatasets/BaseRaster.js +1 -1
- package/layers/support/rasterDatasets/FunctionRaster.js +1 -1
- package/layers/support/rasterDatasets/ImageServerRaster.js +1 -1
- package/layers/support/rasterDatasets/RawBlockCache.js +1 -1
- package/layers/support/rasterDatasets/TIFFRaster.js +1 -1
- package/layers/support/rasterFormats/TiffDecoder.js +1 -1
- package/layers/support/rasterFormats/pixelRangeUtils.js +1 -1
- package/layers/support/rasterFormats/{TiffTags.js → tiffTag.js} +1 -1
- package/layers/support/rasterFunctions/BandArithmeticFunction.js +1 -1
- package/layers/support/rasterFunctions/BaseRasterFunction.js +1 -1
- package/layers/support/rasterFunctions/ExtractBandFunction.js +1 -1
- package/layers/support/rasterFunctions/NDVIFunction.js +1 -1
- package/layers/support/rasterFunctions/RemapFunction.js +1 -1
- package/layers/support/rasterFunctions/rasterFunctionHelper.js +1 -1
- package/layers/support/videoUtils.js +5 -0
- package/package.json +2 -2
- package/portal/schemas/definitions.js +1 -1
- package/portal/schemas/integratedMesh3DTilesLayerItem.js +1 -1
- package/renderers/UniqueValueRenderer.js +1 -1
- package/renderers/support/colorRampUtils.js +1 -1
- package/support/revision.js +1 -1
- package/symbols/IconSymbol3DLayer.js +1 -1
- package/symbols/cim/effects/EffectTaperedPolygon.js +1 -1
- package/views/2d/engine/webgl/meshing/Mesh.js +1 -1
- package/views/2d/engine/webgl/shaderGraph/typed/TypedShaderProgram.js +1 -1
- package/views/2d/engine/webgl/textureUtils.js +1 -1
- package/views/2d/layers/ImageryTileLayerView2D.js +1 -1
- package/views/2d/layers/MediaLayerView2D.js +1 -1
- package/views/2d/layers/TileLayerView2D.js +1 -1
- package/views/2d/layers/imagery/BaseImageryTileSubView2D.js +1 -1
- package/views/2d/layers/imagery/ImageryTileView2D.js +1 -1
- package/views/2d/layers/support/DebugOverlay.js +1 -1
- package/views/2d/layers/support/MediaLayerInteraction.js +1 -1
- package/views/3d/analysis/DirectLineMeasurementAnalysisView3D.js +1 -1
- package/views/3d/analysis/LineOfSight/LineOfSightTool.js +1 -1
- package/views/3d/analysis/LineOfSightAnalysisView3D.js +1 -1
- package/views/3d/analysis/Slice/SliceTool.js +1 -1
- package/views/3d/analysis/Slice/SliceVisualization.js +1 -1
- package/views/3d/analysis/SliceAnalysisView3D.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedAnalysisVisualization.js +1 -1
- package/views/3d/analysis/Viewshed/ViewshedVisualization.js +1 -1
- package/views/3d/analysis/ViewshedAnalysisView3D.js +1 -1
- package/views/3d/camera/constraintUtils/distance.js +1 -1
- package/views/3d/camera/intersectionUtils.js +1 -1
- package/views/3d/environment/ChapmanAtmosphere.js +1 -1
- package/views/3d/environment/atmosphereUtils.js +1 -1
- package/views/3d/interactive/measurementTools/directLineMeasurement3D/DirectLineMeasurement3DTool.js +1 -1
- package/views/3d/interactive/visualElements/DrapedVisualElementResources.js +1 -1
- package/views/3d/interactive/visualElements/EngineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ExtendedLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LabelVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LaserlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/LineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/MarkerVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementAreaVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/MeasurementArrowVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/OutlineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ParallelLineVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/PointVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/RightAngleQuadVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/SlicePlaneVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VerticesVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/ViewshedShapeVisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VisualElement.js +1 -1
- package/views/3d/interactive/visualElements/VisualElementResources.js +1 -1
- package/views/3d/layers/I3SMeshView3D.js +1 -1
- package/views/3d/layers/IntegratedMesh3DTilesLayerView3D.js +1 -1
- package/views/3d/layers/Lyr3DWorker.js +1 -1
- package/views/3d/layers/graphics/Deconflictor.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipeline.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorker.js +1 -1
- package/views/3d/layers/graphics/pipeline/Feature3DPipelineWorkerHandle.js +1 -1
- package/views/3d/layers/graphics/pipeline/PipelineCommand.js +1 -1
- package/views/3d/layers/graphics/pipeline/Tile3DManager.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/FeaturePipelineRenderManager.js +1 -1
- package/views/3d/layers/graphics/pipeline/rendering/RenderCommandContext.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/Factory.js +5 -0
- package/views/3d/layers/graphics/pipeline/symbolization/SimpleFeatureRenderer.js +5 -0
- package/views/3d/layers/graphics/pipeline/symbolization/TestObjectSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/TestSymbol.js +1 -1
- package/views/3d/layers/graphics/pipeline/symbolization/UniqueValueFeatureRenderer.js +1 -1
- package/views/3d/layers/i3s/I3SMeshViewFilter.js +1 -1
- package/views/3d/layers/support/MediaLayerInteraction.js +1 -1
- package/views/3d/state/ConstraintsManager.js +1 -1
- package/views/3d/state/NearFarHeuristic.js +1 -1
- package/views/3d/state/ViewState.js +1 -1
- package/views/3d/state/ViewStateManager.js +1 -1
- package/views/3d/state/utils/navigationUtils.js +1 -1
- package/views/3d/support/cameraUtilsSpherical.js +1 -1
- package/views/3d/support/geometryUtils/sphere.js +1 -1
- package/views/3d/terrain/OverlayRenderTargets.js +1 -1
- package/views/3d/webgl/ManagedDepthTexture.js +1 -1
- package/views/3d/webgl/ManagedFBO.js +1 -1
- package/views/3d/webgl-engine/core/FBOCache.js +1 -1
- package/views/3d/webgl-engine/core/FBOCacheFormats.js +5 -0
- package/views/3d/webgl-engine/core/shaderLibrary/Laserline.glsl.js +12 -20
- package/views/3d/webgl-engine/core/shaderLibrary/output/Emissions.glsl.js +1 -1
- package/views/3d/webgl-engine/core/shaderLibrary/util/BlendColorsPremultiplied.glsl.js +5 -0
- package/views/3d/webgl-engine/effects/bloom/BloomRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/debug/RenderNodeVisualizerNode.js +1 -1
- package/views/3d/webgl-engine/effects/focusArea/FocusAreaMaskNode.js +1 -1
- package/views/3d/webgl-engine/effects/geometry/RenderOccludedRenderNode.js +1 -1
- package/views/3d/webgl-engine/effects/haze/Haze.js +1 -1
- package/views/3d/webgl-engine/effects/highlight/Highlight.js +1 -1
- package/views/3d/webgl-engine/effects/laserlines/LaserLineRenderer.js +1 -1
- package/views/3d/webgl-engine/effects/smaa/SMAA.js +1 -1
- package/views/3d/webgl-engine/effects/ssao/SSAO.js +1 -1
- package/views/3d/webgl-engine/lib/DepthRange.js +1 -1
- package/views/3d/webgl-engine/lib/MainFramebuffer.js +1 -1
- package/views/3d/webgl-engine/lib/Renderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowAccumulator.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowCastRenderer.js +1 -1
- package/views/3d/webgl-engine/lib/ShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/Texture.js +1 -1
- package/views/3d/webgl-engine/lib/Viewshed.js +1 -1
- package/views/3d/webgl-engine/lib/ViewshedShadowMap.js +1 -1
- package/views/3d/webgl-engine/lib/depthRangeUtils.js +1 -1
- package/views/3d/webgl-engine/parts/RenderView.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastAccumulate.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastAccumulateTechniqueConfiguration.js +5 -0
- package/views/3d/webgl-engine/shaders/ShadowCastVisualize.glsl.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechnique.js +1 -1
- package/views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js +1 -1
- package/views/PopupView.js +1 -1
- package/views/SceneView.js +1 -1
- package/views/SelectionManager.js +1 -1
- package/views/VideoView.js +1 -1
- package/views/analysis/analysisViewUtils.js +1 -1
- package/views/input/InputManager.js +1 -1
- package/views/input/ViewEvents.js +1 -1
- package/views/support/selectionUtils.js +1 -1
- package/views/webgl/FBOAttachmentType.js +5 -0
- package/views/webgl/FramebufferObject.js +1 -1
- package/views/webgl/Renderbuffer.js +1 -1
- package/views/webgl/RenderbufferDescriptor.js +1 -1
- package/views/webgl/Texture.js +1 -1
- package/views/webgl/TextureDescriptor.js +1 -1
- package/views/webgl/textureUtils.js +1 -1
- package/webscene/InitialViewProperties.js +1 -1
- package/webscene/Presentation.js +1 -1
- package/webscene/Slide.js +1 -1
- package/webscene/SlideLegendInfo.js +1 -1
- package/webscene/background/ColorBackground.js +1 -1
- package/webscene/spec-certification/api.js +1 -1
- package/webscene/spec-certification/compare.js +1 -1
- package/webscene/spec-certification/index.js +1 -1
- package/webscene/spec-certification/spec.js +1 -1
- package/webscene/spec-certification/utils.js +1 -1
- package/webscene/support/Description.js +1 -1
- package/webscene/support/SlideElements.js +1 -1
- package/webscene/support/SlideEnvironment.js +1 -1
- package/webscene/support/SlideGround.js +1 -1
- package/webscene/support/SlideVisibleLayer.js +1 -1
- package/webscene/support/Title.js +1 -1
- package/webscene/support/analysisUtils.js +5 -0
- package/widgets/BatchAttributeForm/expressions/ExpressionsManager.js +1 -1
- package/widgets/DirectLineMeasurement3D/DirectLineMeasurement3DViewModel.js +1 -1
- package/widgets/Editor/CreateFeaturesWorkflow.js +1 -1
- package/widgets/Editor/EditorViewModel.js +1 -1
- package/widgets/Editor/UpdateWorkflow.js +1 -1
- package/widgets/Editor/support/SketchController.js +5 -0
- package/widgets/Editor/workflowUtils.js +1 -1
- package/widgets/ElevationProfile/ElevationProfileInteraction.js +1 -1
- package/widgets/Feature/FeatureUtilityNetworkAssociationList.js +1 -1
- package/widgets/FeatureForm/FeatureFormUtilityNetworkAssociations/FeatureFormUtilityNetworkAssociationList.js +1 -1
- package/widgets/FeatureForm/FeatureFormViewModel.js +1 -1
- package/widgets/FeatureForm/UtilityNetworkAssociationAddAssociationViewModel.js +1 -1
- package/widgets/FeatureTable/support/tableUtils.js +1 -1
- package/widgets/FeatureTable.js +1 -1
- package/widgets/LayerList/LayerListItem.js +1 -1
- package/widgets/OrientedImageryViewer/OrientedImageryViewerViewModel.js +1 -1
- package/widgets/OrientedImageryViewer/components/ImageViewerViewModel.js +1 -1
- package/widgets/PanoramicViewer/PanoramicViewerViewModel.js +1 -1
- package/widgets/ShadowCast/ShadowCastViewModel.js +1 -1
- package/widgets/ShadowCast/ThresholdOptions.js +1 -1
- package/widgets/Sketch/SketchViewModel.js +1 -1
- package/widgets/VideoPlayer.js +1 -1
- package/widgets/Widget.js +1 -1
- package/widgets/support/AnalysisViewModel.js +1 -1
- package/widgets/support/SelectionList.js +1 -1
- package/widgets/support/SnappingControls.js +1 -1
- package/assets/esri/core/workers/chunks/184d7c8ea818bec5c462.js +0 -1
- package/assets/esri/core/workers/chunks/22f604726529ee6f8c25.js +0 -1
- package/assets/esri/core/workers/chunks/244d2196bac5ef279436.js +0 -1
- package/assets/esri/core/workers/chunks/26fcbe053194bd78fcc3.js +0 -1
- package/assets/esri/core/workers/chunks/32f2e0c88046b39916cc.js +0 -1
- package/assets/esri/core/workers/chunks/388a763da712ca71ccf4.js +0 -1
- package/assets/esri/core/workers/chunks/4f8782b3b6ad414409e8.js +0 -1
- package/assets/esri/core/workers/chunks/5ffc3ca6c6a4d32e1282.js +0 -1
- package/assets/esri/core/workers/chunks/642a595353a86f3717e3.js +0 -1
- package/assets/esri/core/workers/chunks/8dd26b12c625d20196ed.js +0 -319
- package/assets/esri/core/workers/chunks/931275cfa2c55eb0f504.js +0 -1
- package/assets/esri/core/workers/chunks/93e9dfd1ba8f393c6c47.js +0 -1
- package/assets/esri/core/workers/chunks/95379fdd6917c8a84c71.js +0 -1
- package/assets/esri/core/workers/chunks/9b21dc4659922cc577cb.js +0 -1
- package/assets/esri/core/workers/chunks/a197c86d42cc9ce21924.js +0 -1
- package/assets/esri/core/workers/chunks/a276980c06d5d311a37e.js +0 -1
- package/assets/esri/core/workers/chunks/b42ecc7c3eb2fd8d1308.js +0 -1
- package/assets/esri/core/workers/chunks/ccc50f28f217e50cc2c3.js +0 -1
- package/assets/esri/core/workers/chunks/d04efa51da9b4eb3a8a7.js +0 -1
- package/assets/esri/core/workers/chunks/d81bebbb6fe000200d35.js +0 -1
- package/assets/esri/core/workers/chunks/dd8e72d6784a8ebc115d.js +0 -1
- package/assets/esri/core/workers/chunks/e9fba86036b8fe700a41.js +0 -1
- package/assets/esri/core/workers/chunks/ed3d1d0465f4a4d8df4a.js +0 -1
- package/views/webgl/formats.js +0 -5
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as a,equals as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import c from"../../core/JSONSupport.js";import{equalsShallow as h}from"../../core/lang.js";import u from"../../core/Logger.js";import{clamp as p}from"../../core/mathUtils.js";import{abortMaybe as m,destroyMaybe as d}from"../../core/maybe.js";import g from"../../core/Promise.js";import{isAbortError as y,throwIfAborted as f,waitTick as v}from"../../core/promiseUtils.js";import w from"../../core/ReactiveMap.js";import{on as b,watch as F,syncAndInitial as _,initial as P}from"../../core/reactiveUtils.js";import{sqlAnd as I}from"../../core/sql.js";import{getMetersPerUnitForSR as M}from"../../core/unitUtils.js";import{property as S}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as C}from"../../core/accessorSupport/decorators/subclass.js";import{distance as k}from"../../core/libs/gl-matrix-2/math/vec2.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import R from"../../geometry/Multipoint.js";import G from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import L from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import j from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as z}from"../../geometry/support/webMercatorUtils.js";import B from"../../layers/GraphicsLayer.js";import{searchImages as H}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as D}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as T,computePolygonForInspection as U,resizePolygon as N,checkIfPolygonContainsSelectedPoint as W}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as q,isElevationSource as $}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as J,imageToWorldPanoramic as Z}from"../../layers/orientedImagery/transformations/imageToWorld.js";import K from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as X,convertPixelToHeadingPitch as Y,getImageToWorldProperties as ee,getUpdateElevationProps as te,isElevationSampler as ae,getImageToWorldPanoramicProperties as ie,pointToArray as re,transformGraphicCoordinatesToPixel as se,getWorldToImageProperties as oe,convertHeadingPitchToSphereVertex as ne,or as le}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ce,worldToImage as he}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ue}from"../../layers/support/floorFilterUtils.js";import pe from"../../symbols/SimpleLineSymbol.js";import me from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ye from"../PanoramicViewer.js";import{invalidCameraHeading as fe,sectorsInOrder as ve,sectorsRadii as we}from"./constants.js";import{configureSketchTool as be,extractFieldsFromDataCaptureLayer as Fe,isValidDataCaptureLayer as _e,constructGraphicFromImageGeometry as Pe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Ie,getImageSourceFromAttachment as Me}from"./galleryUtils.js";import{formatPixels as Se,heightMeasurementPanoramic as Ce,heightMeasurement2D as ke,calculateHeightAccuracyPanoramic as Ve,calculateHeightAccuracy as Ae,pixelAreaMeasurement2D as Re,pixelAreaMeasurementPanoramic as Ge,pixelDistanceMeasurement2D as Oe,pixelDistanceMeasurementPanoramic as Le,generateCombinations as xe,getRootOfSumOfSquaredErrors as je,generateCombinationsPanoramic as Ee,calculateLocationAccuracyFromDeviations as ze,calculateReferenceImagePointPanoramic as Be,calculateAnglePano as He,calculateTempImagePoint as De,calculateAngle as Te,getModeCorrectedPoint as Ue,calculateCorrectedPixel as Ne,calculateHeightFromTemporaryDistance as We}from"./imageMeasurementUtils.js";import{crossSymbol as qe,crossSymbol3D as $e,measurementPolygonSymbol as Je,polylineSymbolPanoramic as Ze,measurementPolylineSymbol as Ke,sourcePointSymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,locationSymbol as et,locationSymbol3D as tt,activeSourcePointSymbol as at}from"./symbols.js";import{isNoAttachmentError as it,getContentType as rt,isTifOrMrf as st,filterOILLayerView as ot,isSceneView as nt,isGraphic as lt,calculateSegment as ct,calculateDirection as ht}from"./utils.js";import ut from"./components/ImageViewer.js";const pt={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},mt=new Set(["JPG","JPEG"]),dt=/\.(\w+)$/,gt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let yt=class extends(l.EventedMixin(g)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(o){y(o)||(this.loadImageError(o),u.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new w,this.pixelCoordinates=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.draw=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new ut,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new B({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new ye,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return f(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.toggleImageAttributes=()=>{m(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,l=new t({geometry:n,attributes:o.toJSON(),layer:r});f(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(pt.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ge.WIDGET),pt.click)},this._createImageClickHandle=()=>{this.removeHandles(pt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const l=b((()=>a),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return le(!t,e.spatialReference.equals(t))?e:x(e,t)}));f(a),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,pt.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(pt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const l=b((()=>a),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});f(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),f(a)),this.groundCoordinates=r;const n=await this.calculateLocationAccuracy(e,r,t,a);f(a),n&&(this.groundCoordinatesAccuracy=n)}))}));this.addHandles(l,pt.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:h,cameraOrientation:p,location:m}=r,d=(l??0)+(o??0),g=m.spatialReference.isWGS84&&4!==p?.type?z(m):new G(m);let v=s;if(Ie(s))try{v=await Me(a,h,e)}catch(w){if(y(w))return;return it(w)?(u.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${h}`)):(u.getLogger(this).error(w,{[a.objectIdField]:h,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${h}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:i,cameraLocation:g}),f(e),await this.transformAndPlotSelectedLocation(e)}catch(w){y(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(dt)?.[1]:e.datasetFormat;if(!c)try{c=await rt(o,{...t.options})}catch(h){y(h)||u.getLogger(this).error("#getContentType()",h)}switch(c??="UNKNOWN FORMAT",a){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(mt.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=i??0;"number"==typeof n?l=n-l:s&&e&&(l=await X(s,e)-l),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");f(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");f(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,a)=>{if(await v(a),!e)return;const i=new G({...c.isSerializable(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:qe}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new G(n,j.WebMercator),symbol:$e}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([F((()=>this.view),(()=>{this.load()}),_),F((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),P),F((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),P),F((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),_),F((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),_),F((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),_),F((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),_),F((()=>this.currentBestFeature),(async(e,t)=>{m(this._featureChangedTask),this._featureChangedTask=r((async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}]))),await this._featureChangedTask.promise}),{sync:!0}),F((()=>this.mode),(e=>{switch(this.removeHandles(pt.interactionHandles),e){case"default":this.addHandles(F((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(m(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{..._,equals:(e,t)=>i(e,t,h)}),pt.interactionHandles);break;case"panoramic":this.addHandles(F((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:a,vfov:i,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&a&&!t.includes("loading")?[i,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;m(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e})}))}),{..._,equals:(e,t)=>i(e,t,h)}),pt.interactionHandles)}}),_),F((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)}),_),F((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=m(this._updateFootprintTask),this._clickTask=m(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=d(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._crossSymbol=d(this._crossSymbol),this._referencePointOnGround=d(this._referencePointOnGround),this._referencePointOnImage=d(this._referencePointOnImage),this._locationPointOnImage=d(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(u.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",p(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",p(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return st(t)||Ie(t)}get imageLoaded(){return o(u.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(ot(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ue(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?ve.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",p(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return st(r)||Ie(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null})).filter(a)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new B({elevationInfo:{mode:"absolute-height"}});case"default":return new B;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=i?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(l,n[0],n[1]),u=e.at(0),p=e.at(-1);if(!(h&&u&&p&&c&&o))return;const m=[p,u],d=Se(m,!1),g="panoramic"===t?await Ce(m,h,c,i,!0,!1):await ke(m,h,c,!0,a);if(!g)return;const y="panoramic"===t?await Ve(c,d,h,g,i,!0):await Ae(c,d,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const i="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(a),i?"default"===t?await Re(e,i,!0):await Ge(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:r}=this;if(e.length<2||!i||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return f(a),s?"default"===t?await Oe([e.at(0),e.at(-1)],s,!0):await Le([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s}=this,o=i?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;const l=await this.getMeasurementProperties();if(f(a),!l)return null;const c="area"===t?await Re(e,l,!0):await Oe([e.at(0),e.at(-1)],l,!0);f(a);const{updateElevationProps:h,...u}=l,p=xe(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async i=>{const r="area"===t?await Re(e,i,!0):await Oe([e.at(0),e.at(-1)],i,!0);if(f(a),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),d=await Promise.all(m);f(a);const g=d.filter((e=>null!==e));return 0===g.length?null:je(g)}async calculateLocationAccuracy(e,t,a="default",i){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,l=o?.every((e=>0===e))||!o?.length;if(!s||l)return null;const c="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(f(i),!c)return null;const{updateElevationProps:h,...u}=c,p="default"===a?xe(u,o):Ee(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async r=>{const{updateElevationProps:s,...o}=r;let l="default"===a?await J(e,o,s):await Z(e,o,s);return f(i),n&&!l.spatialReference.equals(n)&&(l=await x(l,n),f(i)),l&&t?[Math.abs(l.x-t.x),Math.abs(l.y-t.y),l.z&&t.z?Math.abs(l.z-t.z):0]:null})),d=await Promise.all(m);if(f(i),!d?.length)return null;const g=d.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[y,v,w]=ze(g);return{x:y,y:v,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s,mode:o}=this,n=i?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(f(a),!c)return null;const h="area"===t?await Ge(e,c,!0):await Le([e.at(0),e.at(-1)],c,!0);f(a);const{updateElevationProps:u,...p}=c,m=Ee(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async i=>{const r="area"===t?await Ge(e,i,!0):await Le([e.at(0),e.at(-1)],i,!0);if(f(a),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(d);f(a);const y=g.filter((e=>null!==e));return 0===y.length?null:je(y)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:i,activeViewer:r}=this,s=r?.imageSize;if(!i||!r||!s?.length||"none"===t)return;const{attributes:o}=i,[n]=Se([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await Be(n,l,i,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=He(n,e),r=k([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await De(n,l,a);if(!c)return;const h=Te(n,c),u=k([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null)}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw gt();be(i,e,a),await a.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw gt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw gt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw gt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw gt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw gt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw gt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t){const a=[],i=[],r=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=M(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,q(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=T(o);if(n=c.clone(),o.isInspection&&(n=U(o)),s&&(n=N(n,s)),W(n,t)){r.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,u=t.clone();u.z=n,u.imageID=s,this.pointSources.push(u),l!==fe&&(a.push(c),h&&i.push(h))}})),{features:r,polygons:a,frustums:i}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ee(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ie(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ve[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t];i?.length&&this._updateCurrentBestFeature(i.at(a))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=Ue(e.vertices.at(-1),r,o);if(i.length<1||!n||!a||!t||"none"===r)return;const l=Ne(i[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=We(this.heightMeasurementPixels,a);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=Ue(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!y(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?z(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){u.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;f(e),this.sketch=new a({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(f(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Je(o),this.sketch.polylineSymbol="panoramic"===s?Ze:Ke(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[e],spatialReference:a});else{const i=new L({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Ke(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=Y(i,a[0],a[1]),{heading:n,pitch:l}=Y(r,a[0],a[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[c],spatialReference:e});else{const a=new L({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:Ze}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=T(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${i.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n=Qe.clone();return n.outline=new pe({color:[0,0,0],width:1}),new t({attributes:a,symbol:n,geometry:s})})));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,h=r?.imageSize;if(!h||!o||"none"===n||l.includes("loading")||!c)return;const{polygon:p}=T(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Fe(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:p,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(m.map((async a=>{const r=a.symbol?.clone()??e.renderer?.getSymbol(a)?.clone(),{attributes:s,geometry:l}=a,c=l,{imageGeometryField:p,oiObjectIdField:m}=this;if(p&&m&&_e(e,p,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Pe(s,p,e,i,h,n,r)}catch(g){u.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:a,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const a=await this.getPixels(c,{feature:o,imageSize:h,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:a,visible:e.visible&&i})}case"polygon":{const{rings:a,spatialReference:l}=c,u=a.map((e=>e.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}case"polyline":{const{paths:a,spatialReference:l}=c,u=a.map((e=>e.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))))),p=await Promise.all(u.map((async e=>this.getPixels(e,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new L({paths:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}case"multipoint":{const{points:a,spatialReference:l}=c,u=a.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))),p=await this.getPixels(u,{feature:o,imageSize:h,mode:n}).then((e=>e.map(re)));return new t({attributes:s,layer:e,symbol:r,geometry:new R({points:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}}return null})))).filter(a));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:a,mode:i}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new G({x:e.x-.5,y:.5-e.y,spatialReference:j.WebMercator});const[t,r]=a,{heading:s,pitch:o}=Y(e,t,r),n=ne(s,o);return new G(n,j.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await x(u,j.WebMercator));const p=await te(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ae(p.elevationSample)&&(a.elevationSample=p.elevationSample),"default"===i){const t=ee(o,r[0],r[1]);m=await J(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=ie(o,r[0],r[1]);m=await Z(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}return Array.isArray(e)?m:m[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new G({...e.toJSON()}),symbol:Xe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=c.isSerializable(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new G(n,j.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=m(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(a&&(l[e.objectIdField]=a),i&&e.globalIdField&&(l[e.globalIdField]=i),t.success.push(n)),t}),{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:i,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!i||"none"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:a}=t;if(!a)return;const n=a.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(a):a;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(se(s,m,o),{feature:i,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map((async e=>this.getMapPoint(e.map((([e,t,a])=>se(s,{x:e,y:t,z:a},o))),{feature:i,imageSize:o,mode:s}))));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(re)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,a])=>se(s,{x:e,y:t,z:a},o))),{feature:i,imageSize:o,mode:s}))));return t.geometry=new L({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(re)))}),t}}}))),c=l.filter(a);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let a=0;const i=l.map((e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:i}}))}async searchBestImage(e,t){try{const a=await H(e,t);a&&await this._processFeatureResponse(a,e.point,{signal:t?.signal})}catch(a){y(a)||(this.setMessage("imageLoadError","error",a.message),u.getLogger(this).error("error occurred while finding best image",a))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);f(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=d(this.sketchAdapter),this.sketch=d(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const a=this.overlayedMapFeatures.get(e);a&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:a}=e;let i=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);i=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!i&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,a);if(o)return f(a),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(y(a))return;this.setMessage("imageLoadError","error"),u.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:a,features:i,invalidCameraHeading:r}=this;if(!e||!t||!a||!i||r)return void(this._sectorData=null);this._sectorData={};for(const c of ve)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:a,featureIndex:r}=e,s=t/l*we[2],o=ct(t,l),n=ht(a);if(!this._sectorData)return;const c=we[3]+s*Math.sin(a*Math.PI/180),h=we[3]+s*Math.cos(a*Math.PI/180);let u;const p=i.at(r),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)u=-90;else{const e=c-we[3],t=h-we[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),u=i}const g=""===o?n:`${o}_${n}`;m&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=d?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:a,featureIndex:r,x:c,y:h,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}_plotLocationPointOnDefaultImage(e){const a=c.isSerializable(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._locationPointOnImage=new t({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:et}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new G(n,j.WebMercator),symbol:tt}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}async _processFeatureResponse(e,t,a){const{features:i}=e;if(!i?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t);if(!r.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new O({spatialReference:s[0].spatialReference});for(const a of s)e=await A(e,a);const t=[];for(const{geometry:a}of r)e.contains(a)||t.push([a.x,a.y]);if(t.sort(((e,t)=>+E([e,t]))),e.addRing(t),this.footprintExtent=de(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(l){y(l)||u.getLogger(this).error(l)}}if((n||r[0].attributes.elevationSource)&&this.footprintExtent){const e=r[0].attributes.elevationSource;$(e)&&!n&&(n=await Q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const a=await te((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[i,...s]=await K([t,...r.map((e=>e.attributes.geometry.clone()))],a);r[0].elevationSample=n??a.elevationSample,t.elevation=i.z,r.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}r[0].elevationSample&&r.forEach((e=>{e.elevationSample=r[0].elevationSample})),this._suitabilities=D({features:r,selectedPoint:t,camera:nt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),c=I("1=1",I(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:M(l.spatialReference),u={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,a)}_resetCursor(){const{activeViewer:e}=this;e&&(e.imageRenderer.cursor=this._previousCursor)}_setMeasurementCursor(){const{activeViewer:e}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),f(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Qe,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-we[3],i=e.y-we[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=d(this._referencePointOnImage))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=d(this._locationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=d(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,e),f(e),await this.plotSelectedPointOnImage(s,e)}catch(o){y(o)||u.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t){const{footprintExtent:a}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!a)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await te(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const p=Array.isArray(e)?e:[e];let m,d=await Promise.all(p.map((e=>new Promise((t=>{if(!e.hasZ)return t(K(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await x(h,j.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,t)))),f(t),"panoramic"===this.mode)m=ce(d,{imageHeight:i[1],imageWidth:i[0],cameraHeading:o,cameraLocation:h});else{const e=oe(this.currentBestFeature.attributes,i[0],i[1]);m=he(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:p}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...a,...i,s].filter(lt);l.supportsGround&&p&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,p),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],p)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:qe.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=d(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&p&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([S()],yt.prototype,"activeLayer",null),e([S({readOnly:!0})],yt.prototype,"activeViewer",null),e([S()],yt.prototype,"accuracyParametersMissing",null),e([S()],yt.prototype,"additionalFeatures",void 0),e([S({type:s.ofType(t)})],yt.prototype,"additionalCameraLocations",void 0),e([S({type:s.ofType(t)})],yt.prototype,"additionalFootprints",void 0),e([S()],yt.prototype,"areaMeasurementResult",void 0),e([S()],yt.prototype,"areaMeasurementAccuracy",void 0),e([S()],yt.prototype,"bestFeatureAngle",void 0),e([S()],yt.prototype,"bestFeatureCurrentFootprint",void 0),e([S({type:t})],yt.prototype,"bestFeatureFootprint",void 0),e([S({type:Number})],yt.prototype,"brightness",null),e([S()],yt.prototype,"collectionId",void 0),e([S({type:Number})],yt.prototype,"contrast",null),e([S()],yt.prototype,"conversionProps",void 0),e([S()],yt.prototype,"coverageFrustums",void 0),e([S()],yt.prototype,"coveragePolygons",void 0),e([S()],yt.prototype,"currentBestFeature",void 0),e([S()],yt.prototype,"currentBestFeatureLocation",void 0),e([S()],yt.prototype,"currentCoverageVisible",void 0),e([S({json:{write:!1}})],yt.prototype,"determineWorkflowForFeature",void 0),e([S()],yt.prototype,"disabled",void 0),e([S()],yt.prototype,"displayMessage",void 0),e([S()],yt.prototype,"displayNewMeasurementButton",void 0),e([S()],yt.prototype,"distanceMeasurementResult",void 0),e([S()],yt.prototype,"distanceAccuracyArray",void 0),e([S()],yt.prototype,"dataCaptureLayer",void 0),e([S({readOnly:!0})],yt.prototype,"featureCount",null),e([S()],yt.prototype,"features",void 0),e([S()],yt.prototype,"groundCoordinates",void 0),e([S()],yt.prototype,"groundCoordinatesAccuracy",void 0),e([S()],yt.prototype,"heightMeasurementPixels",void 0),e([S()],yt.prototype,"heightGraphic",void 0),e([S()],yt.prototype,"heightMeasurementResult",void 0),e([S()],yt.prototype,"heightMeasurementAccuracy",void 0),e([S()],yt.prototype,"measurementAngle",void 0),e([S()],yt.prototype,"tempDistance",void 0),e([S({readOnly:!0})],yt.prototype,"imageGalleryEnabled",null),e([S()],yt.prototype,"imageGeometryField",void 0),e([S({readOnly:!0})],yt.prototype,"imageLoaded",null),e([S()],yt.prototype,"imageLocationToolState",void 0),e([S({readOnly:!0})],yt.prototype,"invalidCameraHeading",null),e([S()],yt.prototype,"imagePointsInView",null),e([S()],yt.prototype,"isAdditionalCoverageVisible",void 0),e([S()],yt.prototype,"isAdditionalPointSourcesVisible",void 0),e([S()],yt.prototype,"layer",void 0),e([S()],yt.prototype,"layerView",null),e([S({readOnly:!0})],yt.prototype,"layerFloorFilterClause",null),e([S({type:Number})],yt.prototype,"localPort",void 0),e([S()],yt.prototype,"mapImageConversionToolState",void 0),e([S()],yt.prototype,"measureType",void 0),e([S()],yt.prototype,"measurementGraphic",void 0),e([S({readOnly:!0,value:"none"})],yt.prototype,"mode",null),e([S()],yt.prototype,"navigatorCurrentBestFeature",void 0),e([S()],yt.prototype,"oiObjectIdField",void 0),e([S({type:s.ofType(t)})],yt.prototype,"overlayedCameraLocations",void 0),e([S()],yt.prototype,"overlayedMapFeatures",void 0),e([S()],yt.prototype,"pixelCoordinates",void 0),e([S()],yt.prototype,"pointSources",void 0),e([S({readOnly:!0})],yt.prototype,"popupEnabled",null),e([S()],yt.prototype,"previousFeatureAngle",void 0),e([S()],yt.prototype,"referencePoint",null),e([S({readOnly:!0})],yt.prototype,"sectorData",null),e([S()],yt.prototype,"selectedPoint",void 0),e([S({type:Number})],yt.prototype,"sharpness",null),e([S()],yt.prototype,"shouldShowSelectedImage",void 0),e([S()],yt.prototype,"sketch",void 0),e([S()],yt.prototype,"draw",void 0),e([S()],yt.prototype,"sketchAdapter",void 0),e([S({readOnly:!0})],yt.prototype,"sketchGraphicsLayer",null),e([S({readOnly:!0})],yt.prototype,"state",null),e([S({readOnly:!0})],yt.prototype,"thumbnails",null),e([S()],yt.prototype,"updateFootprint",void 0),e([S()],yt.prototype,"updateFootprintPanorama",void 0),e([S({value:null})],yt.prototype,"view",null),e([S()],yt.prototype,"_adapter",void 0),e([S()],yt.prototype,"_sketchGraphicsLayer",null),e([S()],yt.prototype,"_highlightedFeatureHandle",void 0),e([S()],yt.prototype,"_imageViewer",void 0),e([S()],yt.prototype,"_initialCurrentCoverageUpdate",void 0),e([S()],yt.prototype,"_locationPointOnImage",void 0),e([S()],yt.prototype,"_overlays",void 0),e([S({readOnly:!0})],yt.prototype,"_overlaysView",null),e([S()],yt.prototype,"_panoramicViewer",void 0),e([S()],yt.prototype,"_previousCursor",void 0),e([S()],yt.prototype,"_referencePointOnGround",void 0),e([S()],yt.prototype,"_referencePointOnImage",void 0),e([S()],yt.prototype,"_sectorData",void 0),e([S({readOnly:!0})],yt.prototype,"_updatingHandles",void 0),e([S()],yt.prototype,"footprintExtent",void 0),e([S()],yt.prototype,"_featureChangedTask",void 0),yt=e([C("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],yt);const ft=yt;export{ft as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Graphic.js";import{isSome as a,equals as i}from"../../core/arrayUtils.js";import{createTask as r}from"../../core/asyncUtils.js";import s from"../../core/Collection.js";import{deprecatedProperty as o}from"../../core/deprecate.js";import n from"../../core/Error.js";import l from"../../core/Evented.js";import{equalsShallow as c}from"../../core/lang.js";import h from"../../core/Logger.js";import{clamp as u}from"../../core/mathUtils.js";import{abortMaybe as p,destroyMaybe as m}from"../../core/maybe.js";import d from"../../core/Promise.js";import{isAbortError as g,throwIfAborted as y,waitTick as f}from"../../core/promiseUtils.js";import v from"../../core/ReactiveMap.js";import{on as w,watch as b,syncAndInitial as F,initial as _}from"../../core/reactiveUtils.js";import{sqlAnd as P}from"../../core/sql.js";import{getMetersPerUnitForSR as I}from"../../core/unitUtils.js";import{property as M}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import{subclass as S}from"../../core/accessorSupport/decorators/subclass.js";import{distance as C}from"../../core/libs/gl-matrix-2/math/vec2.js";import{isSerializable as k}from"../../core/support/jsonUtils.js";import{UpdatingHandles as V}from"../../core/support/UpdatingHandles.js";import{union as A}from"../../geometry/geometryEngineAsync.js";import R from"../../geometry/Multipoint.js";import G from"../../geometry/Point.js";import O from"../../geometry/Polygon.js";import L from"../../geometry/Polyline.js";import{projectWithZConversion as x}from"../../geometry/projection.js";import j from"../../geometry/SpatialReference.js";import{isClockwise as E}from"../../geometry/support/coordsUtils.js";import{geographicToWebMercator as B}from"../../geometry/support/webMercatorUtils.js";import z from"../../layers/GraphicsLayer.js";import{searchImages as H}from"../../layers/orientedImagery/queries.js";import{calculateSuitabilities as D}from"../../layers/orientedImagery/core/bestImageUtils.js";import{createCoveragePolygon as T,computePolygonForInspection as U,resizePolygon as N,checkIfPolygonContainsSelectedPoint as W}from"../../layers/orientedImagery/core/coverageUtils.js";import{isConstantElevation as q,isElevationSource as $}from"../../layers/orientedImagery/core/ElevationSourceDefinitions.js";import{imageToWorld as J,imageToWorldPanoramic as Z}from"../../layers/orientedImagery/transformations/imageToWorld.js";import K from"../../layers/orientedImagery/transformations/updateElevation.js";import{getElevationSampler as Q}from"../../layers/orientedImagery/transformations/updateElevationUtils.js";import{getInitialAngle as X,convertPixelToHeadingPitch as Y,getImageToWorldProperties as ee,getUpdateElevationProps as te,isElevationSampler as ae,getImageToWorldPanoramicProperties as ie,pointToArray as re,transformGraphicCoordinatesToPixel as se,getWorldToImageProperties as oe,convertHeadingPitchToSphereVertex as ne,or as le}from"../../layers/orientedImagery/transformations/utils.js";import{worldToImagePanoramic as ce,worldToImage as he}from"../../layers/orientedImagery/transformations/worldToImage.js";import{getFloorFilterClause as ue}from"../../layers/support/floorFilterUtils.js";import pe from"../../symbols/SimpleLineSymbol.js";import me from"../../views/draw/Draw.js";import{scale as de}from"../../views/draw/support/drawUtils.js";import{ViewEventPriorities as ge}from"../../views/input/InputManager.js";import ye from"../PanoramicViewer.js";import{invalidCameraHeading as fe,sectorsInOrder as ve,sectorsRadii as we}from"./constants.js";import{configureSketchTool as be,extractFieldsFromDataCaptureLayer as Fe,isValidDataCaptureLayer as _e,constructGraphicFromImageGeometry as Pe}from"./dataCaptureUtils.js";import{isFeatureAttachment as Ie,getImageSourceFromAttachment as Me}from"./galleryUtils.js";import{formatPixels as Se,heightMeasurementPanoramic as Ce,heightMeasurement2D as ke,calculateHeightAccuracyPanoramic as Ve,calculateHeightAccuracy as Ae,pixelAreaMeasurement2D as Re,pixelAreaMeasurementPanoramic as Ge,pixelDistanceMeasurement2D as Oe,pixelDistanceMeasurementPanoramic as Le,generateCombinations as xe,getRootOfSumOfSquaredErrors as je,generateCombinationsPanoramic as Ee,calculateLocationAccuracyFromDeviations as Be,calculateReferenceImagePointPanoramic as ze,calculateAnglePano as He,calculateTempImagePoint as De,calculateAngle as Te,getModeCorrectedPoint as Ue,calculateCorrectedPixel as Ne,calculateHeightFromTemporaryDistance as We}from"./imageMeasurementUtils.js";import{crossSymbol as qe,crossSymbol3D as $e,measurementPolygonSymbol as Je,polylineSymbolPanoramic as Ze,measurementPolylineSymbol as Ke,sourcePointSymbol as Qe,diamondSymbol as Xe,diamondSymbol3D as Ye,locationSymbol as et,locationSymbol3D as tt,activeSourcePointSymbol as at}from"./symbols.js";import{isNoAttachmentError as it,getContentType as rt,isTifOrMrf as st,filterOILLayerView as ot,isSceneView as nt,isGraphic as lt,calculateSegment as ct,calculateDirection as ht}from"./utils.js";import ut from"./components/ImageViewer.js";const pt={click:"view-click",imageClick:"image-click",interactionHandles:"interaction-handles",footprintHandles:"footprint-handles",sketchHandles:"sketch-handles"},mt=new Set(["JPG","JPEG"]),dt=/\.(\w+)$/,gt=()=>new n("orientedimageryviewer:sketch-not-initialized","Sketch property is not initialized, call loadSketch first");let yt=class extends(l.EventedMixin(d)){constructor(e){super(e),this.additionalFeatures=new s,this.additionalCameraLocations=new s,this.additionalFootprints=new s,this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.bestFeatureAngle=0,this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null,this.collectionId=null,this.conversionProps=null,this.coverageFrustums=new s,this.coveragePolygons=new s,this.currentBestFeature=null,this.currentBestFeatureLocation=null,this.currentCoverageVisible=!0,this.determineWorkflowForFeature=async(e,t,a)=>{const{currentBestFeature:i,selectedPoint:r,view:s}=this;if(s?.closePopup(),i&&r){this._initialCurrentCoverageUpdate=!0,this._updateGroundElevation=!0;try{await this._updatePointsAndPolygons(a),await this._loadImage(a)}catch(o){g(o)||(this.loadImageError(o),h.getLogger(this).error("#loadIImage()","error occured while loading image",o))}}},this.disabled=!1,this.displayMessage={key:"onLoadMessage",type:"info"},this.displayNewMeasurementButton=!0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.dataCaptureLayer=null,this.features=new s,this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.heightMeasurementPixels=[],this.heightGraphic=null,this.heightMeasurementResult=0,this.heightMeasurementAccuracy=0,this.measurementAngle=null,this.tempDistance=null,this.imageGeometryField=null,this.imageLocationToolState=!1,this.isAdditionalCoverageVisible=!1,this.isAdditionalPointSourcesVisible=!1,this.layer=null,this.localPort=null,this.mapImageConversionToolState=!1,this.measureType=null,this.measurementGraphic=null,this.navigatorCurrentBestFeature=null,this.oiObjectIdField=null,this.overlayedCameraLocations=new s,this.overlayedMapFeatures=new v,this.pixelCoordinates=null,this.pointSources=new s,this.previousFeatureAngle=0,this.selectedPoint=null,this.shouldShowSelectedImage=!1,this.sketch=null,this.draw=null,this.sketchAdapter=null,this.updateFootprint=async(e,t)=>{"image-loaded"===this.state&&await(this._adapter?.updateFootprint(e,t))},this.updateFootprintPanorama=async(e,t)=>{await(this._adapter?.updateFootprintPanorama(e,t))},this._adapter=null,this._highlightedFeatureHandle=null,this._imageViewer=new ut,this._initialCurrentCoverageUpdate=!0,this._locationPointOnImage=null,this._overlays=new z({listMode:"hide",internal:!0,elevationInfo:{mode:"absolute-height"}}),this._panoramicViewer=new ye,this._previousCursor=null,this._referencePointOnGround=null,this._referencePointOnImage=null,this._sectorData=null,this._updatingHandles=new V,this._clickTask=null,this._crossSymbol=null,this.footprintExtent=null,this._featureChangedTask=null,this._openPopupTask=null,this._suitabilities=null,this._transformController=new AbortController,this._updateFootprintTask=null,this._updateGroundElevation=!1,this.hideImageGeometry=e=>{},this.highlight=e=>{if(!this._overlaysView)return;this.removeHighlight();const t=this.additionalFootprints.find((({attributes:{imageID:t}})=>t===Number(e)));this._highlightedFeatureHandle=t?this._overlaysView?.highlight(t):null},this.loadDataCaptureAdapter=async e=>{await this.loadSketch(e);const t=import("./adapters/sketch/DataCaptureAdapter.js"),{default:a}=await t;return y(e),this.sketchAdapter=new a({viewModel:this}),this.sketchAdapter},this.loadImageFromSource=async(e,t)=>this._updatingHandles.addPromise(this._loadImageFromSourceInternal(e,t)),this.loadImageViewer=e=>{this._imageViewer.container=e},this.loadPanoramicViewer=e=>{this._panoramicViewer.container=e},this.removeHighlight=()=>this._highlightedFeatureHandle?.remove(),this.revealImageGeometry=e=>{},this.toggleImageAttributes=()=>{p(this._openPopupTask),this._openPopupTask=r((async e=>{const{currentBestFeature:a,popupEnabled:i,layer:r,view:s}=this;if(s?.closePopup(),!(s&&a&&i&&r))return;const{attributes:o,geometry:n}=a,l=new t({geometry:n,attributes:o.toJSON(),layer:r});y(e),await s.openPopup({features:[l],location:o.location.clone()})}))},this._createViewClickHandle=()=>{if(this.removeHandles(pt.click),"disabled"===this.state||null==this.view)return;const e=this.mapImageConversionToolState&&"image-loaded"===this.state?this._mapImageConversionToolViewClickHandler:this._viewClickHandler;this.addHandles(this.view.on("click",e,ge.WIDGET),pt.click)},this._createImageClickHandle=()=>{this.removeHandles(pt.imageClick);const{mapImageConversionToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const l=w((()=>a),"pixel-location",(e=>{this.plotReferencePointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;const r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t}).then((e=>{const t=this.view?.spatialReference;return le(!t,e.spatialReference.equals(t))?e:x(e,t)}));y(a),this.plotReferencePointOnGround(r)}))}));this.addHandles(l,pt.imageClick)},this._createImageLocationHandle=()=>{this.removeHandles(pt.imageClick);const{imageLocationToolState:e,mode:t,activeViewer:a,currentBestFeature:i,footprintExtent:s}=this,o=a?.imageSize;if(!(e&&"none"!==t&&o&&s&&i))return;a.clickAction="pixel-location";let n=null;const l=w((()=>a),"pixel-location",(e=>{this.pixelCoordinates=e,this.plotLocationPointOnImage(e),n?.abort(),n=r((async a=>{if(!e)return;let r=await this.getMapPoint(e,{feature:i,imageSize:o,mode:t});y(a);const s=this.view?.spatialReference;s&&!r.spatialReference.equals(s)&&(r=await x(r,s),y(a)),this.groundCoordinates=r;const n=await this.calculateLocationAccuracy(e,r,t,a);y(a),n&&(this.groundCoordinatesAccuracy=n)}))}));this.addHandles(l,pt.imageClick)},this._loadImage=async e=>{const{currentBestFeature:t,layer:a,mode:i}=this;if(this.clearGraphics(),!a||!t||"none"===i)return;const{attributes:r}=t,{imagePath:s,imageRotation:o,cameraHeading:n,cameraRoll:l,cameraPitch:c,objectId:u,cameraOrientation:p,location:m}=r,d=(l??0)+(o??0),f=m.spatialReference.isWGS84&&4!==p?.type?B(m):new G(m);let v=s;if(Ie(s))try{v=await Me(a,u,e)}catch(w){if(g(w))return;return it(w)?(h.getLogger(this).error(w),void this.setMessage("noAttachment","error",`${a.objectIdField}: ${u}`)):(h.getLogger(this).error(w,{[a.objectIdField]:u,layer:a}),void this.setMessage("imageLoadError","error",`query-attachments-failed:${a.objectIdField} ${u}`))}try{await this.loadImageFromSource(v,{imageRotation:d,options:e,pitch:c,yaw:n,mode:i,cameraLocation:f}),y(e),await this.transformAndPlotSelectedLocation(e)}catch(w){g(w)||this.loadImageError(w)}},this._loadImageFromSourceInternal=async(e,t)=>{const{mode:a,imageRotation:i,options:r}=t,s="string"==typeof e,o=s?e:e.url,{pathname:n,searchParams:l}=new URL(o);let c=s?n.match(dt)?.[1]:e.datasetFormat;if(!c)try{c=await rt(o,{...t.options})}catch(u){g(u)||h.getLogger(this).error("#getContentType()",u)}switch(c??="UNKNOWN FORMAT",a){case"default":this._imageViewer.imageSource={datasetFormat:c.toUpperCase(),url:o.split("?")[0]},this._imageViewer.customParameters=Object.fromEntries(l),this._imageViewer.imageRotation=i??0,await this._imageViewer.loadImage(r);break;case"panoramic":if(mt.has(c.toUpperCase())){const{selectedPoint:e}=this,{pitch:a,yaw:i,cameraLocation:s,viewAngle:n}=t;this._panoramicViewer.imageSource=o;let l=i??0;"number"==typeof n?l=n-l:s&&e&&(l=await X(s,e)-l),this._panoramicViewer.pitch=a??0,this._panoramicViewer.yaw=l,await this._panoramicViewer.loadImage(r)}else this.setMessage("unsupportedPanoramicImageryError","error",void 0,{datasetFormat:c});break}},this._loadViewAdapter=async e=>{const{view:t}=this;if(t)switch(t.type){case"2d":{const{default:t}=await import("./adapters/view/MapViewAdapter.js");y(e),this._adapter=new t(this);break}case"3d":{const{default:t}=await import("./adapters/view/SceneViewAdapter.js");y(e),this._adapter=new t(this);break}}else this._adapter=null},this._mapImageConversionToolViewClickHandler=e=>{e.stopPropagation(),e.preventDefault(),e.mapPoint&&this.plotMapPoint(e.mapPoint)},this._viewClickHandler=e=>{this._clickTask?.abort(),this._clickTask=r((async t=>{const{pointerType:a,button:i,mapPoint:r}=e;if(("mouse"!==a||0===i)&&r)return e.stopPropagation(),e.preventDefault(),this._updatingHandles.addPromise(this.loadBestImage(r,{signal:t}))}))},this.plotSelectedPointOnImage=async(e,a)=>{if(await f(a),!e)return;const i=new G({...k(e)?e.toJSON():e});if("default"===this.mode)i.x-=.5,i.y=.5-i.y,i.spatialReference=this._imageViewer.imageRenderer.spatialReference.clone(),this._crossSymbol=new t({geometry:i,symbol:qe}),this._imageViewer.addGraphic(this._crossSymbol,0);else if("panoramic"===this.mode){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._crossSymbol=new t({geometry:new G(n,j.WebMercator),symbol:$e}),this._panoramicViewer.addGraphic(this._crossSymbol,0)}},this.handleSectorClick=this.handleSectorClick.bind(this),this.searchBestImage=this.searchBestImage.bind(this),this.transformAndPlotReferencePointOnImage=this.transformAndPlotReferencePointOnImage.bind(this),this.updateSuitabilities=this.updateSuitabilities.bind(this),this.selectBestFeature=this.selectBestFeature.bind(this)}initialize(){this.addHandles([b((()=>this.view),(()=>{this.load()}),F),b((()=>this.view?.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),_),b((()=>this.view?.map?.allLayers?.length),(e=>{e&&this.view?.map?.layers.reorder(this._overlays,e-1)}),_),b((()=>[this.state,this.mapImageConversionToolState,this.view]),(()=>{this._createViewClickHandle(),this._createImageClickHandle()}),F),b((()=>[this.state,this.imageLocationToolState,this.view]),(()=>{if(this._createImageLocationHandle(),!this.imageLocationToolState)return this.clearPreviousGroundLocation(),void this._resetCursor();this._setMeasurementCursor()}),F),b((()=>this.measureType),(()=>{this.clearPreviousMeasurements()}),F),b((()=>this.bestFeatureAngle),((e,t)=>{this.previousFeatureAngle=t??0}),F),b((()=>this.currentBestFeature),(async(e,t)=>{p(this._featureChangedTask),this._featureChangedTask=r((async a=>this.determineWorkflowForFeature.apply(this,[e,t,{signal:a}]))),await this._featureChangedTask.promise}),{sync:!0}),b((()=>this.mode),(e=>{switch(this.removeHandles(pt.interactionHandles),e){case"default":this.addHandles(b((()=>{const{state:e}=this;return"image-loaded"===e?this._imageViewer.imagePointsInView:null}),(e=>{e&&(p(this._updateFootprintTask),this._updateFootprintTask=r((async t=>{await this.updateFootprint(e,{signal:t})})))}),{...F,equals:(e,t)=>i(e,t,c)}),pt.interactionHandles);break;case"panoramic":this.addHandles(b((()=>{const{currentBestFeature:e,state:t}=this,{imageSize:a,vfov:i,hfov:r,pitch:s,yaw:o}=this._panoramicViewer;return e&&a&&!t.includes("loading")?[i,r,o,s]:null}),(e=>{if(!e||this.state.includes("loading"))return;const[t,a,i,s]=e;p(this._updateFootprintTask),this._updateFootprintTask=r((async e=>{await this.updateFootprintPanorama({verticalFieldOfView:t,horizontalFieldOfView:a,yaw:i,pitch:s},{signal:e})}))}),{...F,equals:(e,t)=>i(e,t,c)}),pt.interactionHandles)}}),F),b((()=>[this.brightness,this.contrast,this.sharpness]),(()=>{const{_imageViewer:e,brightness:t,contrast:a,mode:i,sharpness:r}=this;"default"===i&&(e.brightness=t,e.contrast=a,e.sharpness=r)}),F),b((()=>this.activeViewer?.imageRenderer),(()=>{this.sketch&&(this.sketch.view=this.activeViewer?.imageRenderer)}))]),this.when().finally((()=>{this.notifyChange("state")}))}destroy(){this._updateFootprintTask=p(this._updateFootprintTask),this._clickTask=p(this._clickTask),this.coverageFrustums.destroy(),this.coveragePolygons.destroy(),this.pointSources.destroy(),this.additionalFootprints.destroy(),this.additionalCameraLocations.destroy(),this.bestFeatureFootprint=m(this.bestFeatureFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._crossSymbol=m(this._crossSymbol),this._referencePointOnGround=m(this._referencePointOnGround),this._referencePointOnImage=m(this._referencePointOnImage),this._locationPointOnImage=m(this._locationPointOnImage),this._overlays&&this.view?.map?.remove(this._overlays),this._overlays.destroy(),this._imageViewer.destroy(),this._panoramicViewer.destroy()}get activeLayer(){return o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer}set activeLayer(e){o(h.getLogger(this),"activeLayer",{replacement:"layer"}),this.layer=e}get activeViewer(){const{_imageViewer:e,_panoramicViewer:t,mode:a}=this;switch(a){case"default":return e;case"panoramic":return t;default:return null}}get accuracyParametersMissing(){return this.layer?.orientationAccuracy?.every((e=>0===e))??!0}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",u(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",u(e,-10,10))}get featureCount(){return this.features?.length??0}get imageGalleryEnabled(){const{currentBestFeature:e}=this;if(!e)return!1;const t=e.attributes.imagePath?.trim();return st(t)||Ie(t)}get imageLoaded(){return o(h.getLogger(this),"imageLoaded",{replacement:'Use OrientedImageryViewer.state === "image-loaded"',version:"4.29",warnOnce:!0}),"image-loaded"===this.state}get invalidCameraHeading(){return this.currentBestFeature?.attributes?.cameraHeading===fe}get imagePointsInView(){const{mode:e,_imageViewer:t}=this;return"default"===e?t.imagePointsInView:null}get layerView(){const{layer:e,view:t}=this;if(e&&t)return t.allLayerViews.find(ot(e))}get layerFloorFilterClause(){const{layerView:e}=this;return e?ue(e):null}get mode(){const e=this.currentBestFeature?.attributes;if(!e)return"none";const{horizontalFieldOfView:t,isSpherical:a}=e;return 360===t||a?"panoramic":"default"}get popupEnabled(){return!0===this.layer?.popupEnabled}get referencePoint(){return this._referencePointOnGround?.geometry}get sectorData(){const{_sectorData:e}=this;return e?ve.map((t=>e[t])):null}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",u(e,0,1))}get sketchGraphicsLayer(){return this.sketch?.layer}get state(){const{mode:e,disabled:t,_updatingHandles:{updating:a},_featureChangedTask:i}=this;if(t)return"disabled";if(!this.isFulfilled()||a||!1===i?.finished)return"loading";if(this.isRejected())return"error";if("error"===this.displayMessage?.type)return"image-load-error";switch(e){case"default":return this._imageViewer.state;case"panoramic":return this._panoramicViewer.state}return"ready"}get thumbnails(){const{features:e}=this;return e?new s(e.map((({attributes:{imagePath:e,objectId:t,cameraRoll:a,imageRotation:i}})=>{const r=e?.trim();return st(r)||Ie(r)?{url:r,objectId:t,rotation:(a??0)+(i??0)}:null})).filter(a)):null}set view(e){this._set("view",e)}get _sketchGraphicsLayer(){const{mode:e}=this;switch(e){case"panoramic":return new z({elevationInfo:{mode:"absolute-height"}});case"default":return new z;case"none":return}}get _overlaysView(){return this.view?.layerViews.find((({layer:e})=>e===this._overlays))}async computeHeight(e,t,a=!0){const{currentBestFeature:i,activeViewer:r,layer:s,footprintExtent:o}=this,n=r?.imageSize,l=i?.attributes,c=s?.orientationAccuracy;if(!l||!n||!e||e.length<2||!c)return;const h="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(l,n[0],n[1]),u=e.at(0),p=e.at(-1);if(!(h&&u&&p&&c&&o))return;const m=[p,u],d=Se(m,!1),g="panoramic"===t?await Ce(m,h,c,i,!0,!1):await ke(m,h,c,!0,a);if(!g)return;const y="panoramic"===t?await Ve(c,d,h,g,i,!0):await Ae(c,d,h,g,!0);return y?{value:g,accuracy:y}:{value:g}}async calculateAreaMeasurement(e,t,a){if(e.length<3||!this.currentBestFeature||!this.activeViewer?.imageSize||"none"===t)return null;const i="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return y(a),i?"default"===t?await Re(e,i,!0):await Ge(e,i,!0,a):null}async calculateDistanceMeasurement(e,t,a){const{currentBestFeature:i,activeViewer:r}=this;if(e.length<2||!i||!r?.imageSize||"none"===t)return null;const s="default"===t?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();return y(a),s?"default"===t?await Oe([e.at(0),e.at(-1)],s,!0):await Le([e.at(0),e.at(-1)],s,!0):null}async calculateAccuracy(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s}=this,o=i?.orientationAccuracy,n=o?.every((e=>0===e))||!o?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||n)return null;const l=await this.getMeasurementProperties();if(y(a),!l)return null;const c="area"===t?await Re(e,l,!0):await Oe([e.at(0),e.at(-1)],l,!0);y(a);const{updateElevationProps:h,...u}=l,p=xe(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async i=>{const r="area"===t?await Re(e,i,!0):await Oe([e.at(0),e.at(-1)],i,!0);if(y(a),r&&c){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-c.area):null}return Math.abs(r-c)}return null})),d=await Promise.all(m);y(a);const g=d.filter((e=>null!==e));return 0===g.length?null:je(g)}async calculateLocationAccuracy(e,t,a="default",i){const{layer:r,currentBestFeature:s}=this,o=r?.orientationAccuracy,n=this.view?.spatialReference,l=o?.every((e=>0===e))||!o?.length;if(!s||l)return null;const c="default"===a?await this.getMeasurementProperties():await this.getMeasurementPropertiesPanoramic();if(y(i),!c)return null;const{updateElevationProps:h,...u}=c,p="default"===a?xe(u,o):Ee(u,o);if(!p?.length)return null;const m=p.map((e=>({...e,updateElevationProps:h}))).map((async r=>{const{updateElevationProps:s,...o}=r;let l="default"===a?await J(e,o,s):await Z(e,o,s);return y(i),n&&!l.spatialReference.equals(n)&&(l=await x(l,n),y(i)),l&&t?[Math.abs(l.x-t.x),Math.abs(l.y-t.y),l.z&&t.z?Math.abs(l.z-t.z):0]:null})),d=await Promise.all(m);if(y(i),!d?.length)return null;const g=d.map((e=>[e?.[0]??0,e?.[1]??0,e?.[2]??0])),[f,v,w]=Be(g);return{x:f,y:v,z:w}}async calculateAccuracyPanoramic(e,t,a){const{layer:i,currentBestFeature:r,activeViewer:s,mode:o}=this,n=i?.orientationAccuracy,l=n?.every((e=>0===e))||!n?.length;if("area"===t&&e.length<3||"distance"===t&&e.length<2||!r||!s?.imageSize||l||"panoramic"!==o)return null;const c=await this.getMeasurementPropertiesPanoramic();if(y(a),!c)return null;const h="area"===t?await Ge(e,c,!0):await Le([e.at(0),e.at(-1)],c,!0);y(a);const{updateElevationProps:u,...p}=c,m=Ee(p,n);if(!m?.length)return null;const d=m.map((e=>({...e,updateElevationProps:u}))).map((async i=>{const r="area"===t?await Ge(e,i,!0):await Le([e.at(0),e.at(-1)],i,!0);if(y(a),r&&h){if("area"===t){const e="number"!=typeof r?r.area:null;return e?Math.abs(e-h.area):null}return Math.abs(r-h)}return null})),g=await Promise.all(d);y(a);const f=g.filter((e=>null!==e));return 0===f.length?null:je(f)}async calculateHeightMeasurementInfo(e,t,a){const{currentBestFeature:i,activeViewer:r}=this,s=r?.imageSize;if(!i||!r||!s?.length||"none"===t)return;const{attributes:o}=i,[n]=Se([e],"panoramic"!==t),l="panoramic"===t?await this.getMeasurementPropertiesPanoramic():ee(o,s[0],s[1]);if("panoramic"===t){if(!l)return;const e=await ze(n,l,i,a);if(!e)return;e?.heading>180&&(e.heading-=360);const t=He(n,e),r=C([n.x,n.y],[e.x,e.y]);if(!t||!r)return;return{measurementAngle:t,tempDistance:r}}const c=await De(n,l,a);if(!c)return;const h=Te(n,c),u=C([n.x,n.y],[c.x,c.y]);return h&&u?{measurementAngle:h,tempDistance:u}:void 0}clearPreviousMeasurements(){this.clearMeasurementGraphics(),this.resetMeasurementData(),this.stopMeasurement()}clearPreviousGroundLocation(){this.groundCoordinates=null,this.groundCoordinatesAccuracy=null,this.pixelCoordinates=null,this.clearLocationPointOnImage()}clearMeasurementGraphics(){this.measurementGraphic&&(this.activeViewer?.removeGraphic(this.measurementGraphic),this.measurementGraphic=null),this.heightGraphic&&(this.activeViewer?.removeGraphic(this.heightGraphic),this.heightGraphic=null)}digitizeCancel(){return this.sketch?.cancel()}digitizeCanRedo(){return this.sketch?.canRedo()??!1}digitizeCanUndo(){return this.sketch?.canUndo()??!1}digitizeComplete(){return this.sketch?.complete()}async digitizeCreate(e,t){const{sketch:a,dataCaptureLayer:i}=this;if(!a)throw gt();be(i,e,a),await a.create(e,{...t,defaultZ:0})}async digitizeDelete(){if(!this.sketch)throw gt();return this.sketch.delete()}digitizeDuplicate(){if(!this.sketch)throw gt();return this.sketch.duplicate()}digitizePlace(e,t){if(!this.sketch)throw gt();return this.sketch.place(e,t)}digitizeRedo(){if(!this.sketch)throw gt();return this.sketch.redo()}digitizeUndo(){if(!this.sketch)throw gt();return this.sketch.undo()}digitizeUpdate(e,t){if(!this.sketch)throw gt();return this.sketch.update(e,t)}async displayHeightResults(){const{currentBestFeature:e,activeViewer:t,heightMeasurementPixels:a,mode:i}=this,r=t?.imageSize,s=e?.attributes;if(!s||!r)return;const o=await this.computeHeight(a,i);o?.value&&o?.accuracy&&(this.heightMeasurementResult=o.value,this.heightMeasurementAccuracy=o.accuracy)}filterByFootprints(e,t){const a=[],i=[],r=[];return e.forEach((e=>{const{layer:{coveragePercent:s},attributes:o}=e;let n;const l=I(e.geometry.spatialReference);o.cameraHeight/=l,o.farDistance/=l,o.nearDistance/=l,q(o.elevationSource)&&(o.elevationSource.constantElevation/=l);const{polygon:c,frustum:h}=T(o);if(n=c.clone(),o.isInspection&&(n=U(o)),s&&(n=N(n,s)),W(n,t)){r.push(e);const{geometry:t,objectId:s,cameraHeight:n,cameraHeading:l}=o,u=t.clone();u.z=n,u.imageID=s,this.pointSources.push(u),l!==fe&&(a.push(c),h&&i.push(h))}})),{features:r,polygons:a,frustums:i}}getMeasurementProperties(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ee(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}getMeasurementPropertiesPanoramic(){const{currentBestFeature:e,activeViewer:t}=this;if(!e||!t?.imageSize)return;const{elevationSample:a,attributes:i}=e,{elevationSource:r,cameraHeight:s}=i,o=ie(i,t.imageSize[0],t.imageSize[1]);let n=o.cameraLocation;return(n.spatialReference.isGeographic?x(n,j.WebMercator):Promise.resolve(n)).then((e=>(n=e,te((n.z??0)-s,{elevationSample:a,elevationSource:r,extent:this.footprintExtent})))).then((t=>("elevationSample"in t&&ae(t.elevationSample)&&(e.elevationSample=t.elevationSample),{...o,cameraLocation:n,updateElevationProps:t})))}async deleteDataCaptureFeatures(e){const{dataCaptureLayer:t}=this;if(!t)throw new n("orientedimagery","Data capture layer is not available");return t.queryFeatures({objectIds:e}).then((({features:e})=>t.applyEdits({deleteFeatures:e})))}handleSectorClick(e){if(isNaN(e))return;const t=this._sectorData?.[ve[e]];t?.length&&this._updateCurrentBestFeature(t.at(0))}handleFeatureClick(e){const{sector:t,featureIndexInSector:a}=e;if(isNaN(a))return;const i=this._sectorData?.[t];i?.length&&this._updateCurrentBestFeature(i.at(a))}handleDrawCursorUpdateEvents(e){const{measurementAngle:t,tempDistance:a,heightMeasurementPixels:i,mode:r,activeViewer:s}=this,o=s?.imageSize;if(!e.vertices||!o)return;const n=Ue(e.vertices.at(-1),r,o);if(i.length<1||!n||!a||!t||"none"===r)return;const l=Ne(i[0],n,t);if(!l?.length)return;this.heightMeasurementPixels.push(l),"panoramic"===r?this.createPolylineGraphicPano():this.createPolylineGraphic();const c=We(this.heightMeasurementPixels,a);c&&(this.heightMeasurementResult=c)}async handleDrawVertexAddEvents(e,t){const{currentBestFeature:a,activeViewer:i,heightMeasurementPixels:r,mode:s}=this;if(!a||!i||!e.vertices?.length||"none"===s)return;const o=i?.imageSize;if(!r.length&&o){const a=Ue(e.vertices.at(-1),s,o);this.heightMeasurementPixels.push(a);const i=await this.calculateHeightMeasurementInfo(a,s,t);if(!i?.measurementAngle||!i?.tempDistance)return;this.measurementAngle=i.measurementAngle,this.tempDistance=i.tempDistance}}async load(e){return this.addResolvingPromise(this._loadViewAdapter(e).catch((e=>{if(!g(e))throw e}))),this}async loadBestImage(e,t){return this.view?.closePopup(),this.displayMessage=null,this.clearPreviousGroundLocation(),this.imageLocationToolState=!1,this.selectedPoint=e.spatialReference.isGeographic?B(e):e.clone(),this.features.removeAll(),this.currentBestFeature=null,this.additionalFeatures.removeAll(),this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),this._overlays?.removeAll(),this._fetchFeaturesWithController(e,t)}loadImageError(e){h.getLogger(this).error("oriented-imagery-viewer:load-image",e),this.setMessage("imageLoadError","error",e.message)}async loadSketch(e){if(!this.sketch){const t=import("../Sketch/SketchViewModel.js"),{default:a}=await t;y(e),this.sketch=new a({layer:this._sketchGraphicsLayer,view:this.activeViewer?.imageRenderer,updateOnGraphicClick:!1,defaultUpdateOptions:{reshapeOptions:{edgeOperation:"none",shapeOperation:"none",vertexOperation:void 0},enableMoveAllGraphics:!1,enableRotation:!1,enableScaling:!1,multipleSelectionEnabled:!1,toggleToolOnClick:!1,tool:"transform"}})}return this.sketch}async loadMeasurementAdapter(e){if(!this.sketchAdapter){const t=import("./adapters/sketch/MeasurementAdapter.js"),{default:a}=await t;if(y(e),this.sketchAdapter=new a({viewModel:this}),!this.sketchAdapter.viewModel.isResolved())return}return this.sketchAdapter}async startMeasurement(e,t){await this.loadSketch(t),await this.loadMeasurementAdapter(t);const{sketch:a,sketchAdapter:i,activeViewer:r,mode:s}=this;if(!a||!i||!r||"none"===s)return;if(this.displayNewMeasurementButton=!1,"panoramic"===s&&(a.defaultCreateOptions.defaultZ=0),await a.create(e),"panoramic"===s){const{drawOperation:e}=a.view.activeTool;e.constraintsEnabled=!1,e._set("elevationDrawSurface",null)}const o=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;o&&this.sketch&&(this.sketch.polygonSymbol=Je(o),this.sketch.polylineSymbol="panoramic"===s?Ze:Ke(o))}startHeightMeasurement(){this.heightMeasurementPixels=[],this.displayNewMeasurementButton=!1,this.draw??=new me({view:this.activeViewer?.imageRenderer});this.draw.create("polyline").on(["cursor-update","vertex-add","draw-complete"],(e=>this.handleDrawEvents(e)))}createPolylineGraphic(){const e=[this.heightMeasurementPixels[0],this.heightMeasurementPixels.at(-1)],a=this.activeViewer?.imageRenderer.spatialReference;if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[e],spatialReference:a});else{const i=new L({paths:[e],spatialReference:a}),r=this.activeViewer?.imageRenderer.effectiveTheme.accentColor;this.heightGraphic=new t({geometry:i,symbol:Ke(r,2.5)}),this.activeViewer?.addGraphic(this.heightGraphic)}}createPolylineGraphicPano(){const e=this.activeViewer?.imageRenderer.spatialReference,a=this.activeViewer?.imageSize;if(!a)return;const i={x:this.heightMeasurementPixels[0][0],y:this.heightMeasurementPixels[0][1]},r={x:this.heightMeasurementPixels.at(-1)[0],y:this.heightMeasurementPixels.at(-1)[1]},{heading:s,pitch:o}=Y(i,a[0],a[1]),{heading:n,pitch:l}=Y(r,a[0],a[1]),c=[[...ne(s,o)],[...ne(n,l)]];if(this.heightGraphic)this.heightGraphic.geometry=new L({paths:[c],spatialReference:e});else{const a=new L({paths:[c],spatialReference:e});this.heightGraphic=new t({geometry:a,symbol:Ze}),this._panoramicViewer.addGraphic(this.heightGraphic,0)}}async handleDrawEvents(e,t){if(this.draw)switch(e.type){case"cursor-update":this.handleDrawCursorUpdateEvents(e);break;case"vertex-add":this.handleDrawVertexAddEvents(e,t);break;case"draw-complete":await this.displayHeightResults()}}initializeMeasurement(e){switch(this.clearMeasurementGraphics(),this.resetMeasurementData(),e){case"distance":this.startMeasurement("polyline");break;case"area":this.startMeasurement("polygon");break;case"height":this.startHeightMeasurement()}}async overlayCameraLocations(e){const{activeViewer:a,currentBestFeature:i,overlayedCameraLocations:r,layer:s,mode:o,state:n}=this,l=a?.imageSize;if(!l||!i||!s||"none"===o||n.includes("loading"))return;const{polygon:c}=T(i.attributes);if(a.removeManyGraphics(r.toArray()),r.removeAll(),e){const{features:e}=await s.queryFeatures({where:`${s.objectIdField} <> ${i.attributes.objectId}`,geometry:c,returnGeometry:!0,outFields:[s.objectIdField]}),n=await Promise.all(e.map((async e=>{const{attributes:a,geometry:r}=e,s=await this.getPixels(r,{feature:i,imageSize:l,mode:o}),n=Qe.clone();return n.outline=new pe({color:[0,0,0],width:1}),new t({attributes:a,symbol:n,geometry:s})})));r.addMany(n),a.addManyGraphics(r.toArray())}}overlayGraphicsOnImage(e,t){this.removeOverlayedGraphicsOnImage(e),this.overlayedMapFeatures.set(e,t),this.activeViewer?.addManyGraphics(t.toArray())}async overlayMapFeatures(e,i=!1){const{activeViewer:r,currentBestFeature:o,mode:n,state:l,layer:c}=this,u=r?.imageSize;if(!u||!o||"none"===n||l.includes("loading")||!c)return;const{polygon:p}=T(o.attributes);try{const{imageGeometryField:t,oiObjectIdField:a}=Fe(e,c.imageGeometryField,c.imageReferenceField);this.imageGeometryField=t.name,this.oiObjectIdField=a.name}catch(g){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features",g)}const{features:m}=await e.queryFeatures({geometry:p,returnGeometry:!0,outFields:["*"]}),d=new s((await Promise.all(m.map((async a=>{const r=a.symbol?.clone()??e.renderer?.getSymbol(a)?.clone(),{attributes:s,geometry:l}=a,c=l,{imageGeometryField:p,oiObjectIdField:m}=this;if(p&&m&&_e(e,p,m)&&`${s[m]}`==`${o.attributes.objectId}`)try{return Pe(s,p,e,i,u,n,r)}catch(g){h.getLogger(this).warn("oriented-imagery-viewer:overlay-map-features","couldn't create graphic from attributes, geometry will be used",{error:g,feature:a,layer:e,imageGeometryField:this.imageGeometryField,imageReferenceField:this.oiObjectIdField})}switch(c?.type){case"point":{const a=await this.getPixels(c,{feature:o,imageSize:u,mode:n});return new t({attributes:s,layer:e,symbol:r,geometry:a,visible:e.visible&&i})}case"polygon":{const{rings:a,spatialReference:l}=c,h=a.map((e=>e.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))))),p=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new O({rings:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}case"polyline":{const{paths:a,spatialReference:l}=c,h=a.map((e=>e.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))))),p=await Promise.all(h.map((async e=>this.getPixels(e,{feature:o,imageSize:u,mode:n}).then((e=>e.map(re))))));return new t({attributes:s,layer:e,symbol:r,geometry:new L({paths:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}case"multipoint":{const{points:a,spatialReference:l}=c,h=a.map((([e,t,a])=>new G({x:e,y:t,z:a,spatialReference:l}))),p=await this.getPixels(h,{feature:o,imageSize:u,mode:n}).then((e=>e.map(re)));return new t({attributes:s,layer:e,symbol:r,geometry:new R({points:p,spatialReference:j.WebMercator}),visible:e.visible&&i})}}return null})))).filter(a));this.overlayGraphicsOnImage(`${e.id}`,d)}async getPixels(e,t){const{imageSize:a,mode:i}=t,r=(await this.worldToImage(Array.isArray(e)?e:[e])).map((e=>{if("default"===i)return new G({x:e.x-.5,y:.5-e.y,spatialReference:j.WebMercator});const[t,r]=a,{heading:s,pitch:o}=Y(e,t,r),n=ne(s,o);return new G(n,j.WebMercator)}));return Array.isArray(e)?r:r[0]}async getMapPoint(e,t){const{feature:a,mode:i,imageSize:r}=t,{elevationSample:s,attributes:o}=a,{elevationSource:n,location:l,elevation:c,cameraHeight:h}=o;let u=l.clone();u.spatialReference.isGeographic&&(u=await x(u,j.WebMercator));const p=await te(c??(l.z??0)-h,{elevationSample:s,elevationSource:n,extent:this.footprintExtent});let m;if("elevationSample"in p&&ae(p.elevationSample)&&(a.elevationSample=p.elevationSample),"default"===i){const t=ee(o,r[0],r[1]);m=await J(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}else{const t=ie(o,r[0],r[1]);m=await Z(Array.isArray(e)?e:[e],{...t,cameraLocation:u},p)}return Array.isArray(e)?m:m[0]}async plotMapPoint(e){return this.plotReferencePoint(e),this.transformAndPlotReferencePointOnImage({feature:this.currentBestFeature,selectedLocation:e,options:{signal:this._transformController?.signal}})}plotReferencePointOnGround(e){this._referencePointOnGround&&(this._overlays?.remove(this._referencePointOnGround),this._referencePointOnGround.destroy()),null!=e&&(this._referencePointOnGround=new t({geometry:new G({...e.toJSON()}),symbol:Xe}),this.view?this._overlays?.add(this._referencePointOnGround):this.emit("plot-ground-point",{data:{point:this._referencePointOnGround?.geometry}}))}plotReferencePointOnImage(e){if("image-loaded"===this.state)switch(this.clearReferencePointOnImage(),this.mode){case"default":{const a=k(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._referencePointOnImage=new t({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:Xe}),this._imageViewer.addGraphic(this._referencePointOnImage,0);break}case"panoramic":{const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._referencePointOnImage=new t({geometry:new G(n,j.WebMercator),symbol:Ye}),this._panoramicViewer.addGraphic(this._referencePointOnImage,0);break}}}plotLocationPointOnImage(e){if("image-loaded"===this.state)switch(this.clearLocationPointOnImage(),this.mode){case"default":this._plotLocationPointOnDefaultImage(e);break;case"panoramic":this._plotLocationPointOnPanoramicImage(e)}}removeAllOverlayMapFeatures(){this.overlayedMapFeatures.forEach((e=>{this._imageViewer.removeManyGraphics(e.toArray())})),this.overlayedMapFeatures.clear()}removeOverlayedGraphicsOnImage(e){const t=this.overlayedMapFeatures.get(e);t?.length&&(this.activeViewer?.removeManyGraphics(t.toArray()),this.overlayedMapFeatures.delete(e))}resetImage(){switch(this.setMessage("onLoadMessage","info"),this.mode){case"default":this._imageViewer.clearImage(),this._imageViewer.clearGraphics();break;case"panoramic":this._panoramicViewer.clearGraphics()}this._clickTask=p(this._clickTask)}resetMeasurementData(){this.areaMeasurementResult=0,this.areaMeasurementAccuracy=0,this.distanceMeasurementResult=0,this.distanceAccuracyArray=[],this.heightMeasurementPixels=[],this.heightMeasurementResult=0,this.tempDistance=null,this.measurementAngle=null,this.heightMeasurementAccuracy=0,this.heightGraphic=null}async saveDrawing(){const{dataCaptureLayer:e,sketchAdapter:t}=this;if(!e||"data-capture"!==t?.type)return;const{pendingGraphics:a,savedGraphics:i}=t,r=a.get(e.id),s=r?.toArray();if(!r||!s?.length)return;const{addFeatureResults:o}=await this.saveDataCaptureFeatures(s),n=o.reduce(((t,{objectId:a,globalId:i,error:r},o)=>{const n=s[o],{attributes:l}=n;return r?t.error.push(n):(a&&(l[e.objectIdField]=a),i&&e.globalIdField&&(l[e.globalIdField]=i),t.success.push(n)),t}),{success:[],error:[]});i.addMany(n.success),r.removeAll(),r.addMany(n.error)}async saveDataCaptureFeatures(e){const{activeViewer:t,currentBestFeature:i,dataCaptureLayer:r,mode:s}=this,o=t?.imageSize;if(!o||!i||"none"===s)throw new n("orientedimagery","Image size, current best feature and mode are required to save data capture features");if(!r)throw new n("orientedimagery","Data capture layer is not available");const l=await Promise.all(e.map((async e=>{const t=e.clone(),{geometry:a}=t;if(!a)return;const n=a.type,l=r.hasZ,c=r.geometryType,h=n!==c,u=h?await import("./transformers.js"):null,p=u?.default[c],m=h?p?.(a):a;if(m)switch(m.type){case"point":return t.geometry=await this.getMapPoint(se(s,m,o),{feature:i,imageSize:o,mode:s}),l||(delete t.geometry.z,t.geometry.hasZ=!1),t.geometry.hasM=!1,t;case"polygon":{const e=await Promise.all(m.rings.map((async e=>this.getMapPoint(e.map((([e,t,a])=>se(s,{x:e,y:t,z:a},o))),{feature:i,imageSize:o,mode:s}))));return t.geometry=new O({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,rings:e.map((e=>e.map(re)))}),t}case"polyline":{const e=await Promise.all(m.paths.map((async e=>this.getMapPoint(e.map((([e,t,a])=>se(s,{x:e,y:t,z:a},o))),{feature:i,imageSize:o,mode:s}))));return t.geometry=new L({spatialReference:e[0][0].spatialReference,hasZ:l,hasM:!1,paths:e.map((e=>e.map(re)))}),t}}}))),c=l.filter(a);return r.applyEdits({addFeatures:c}).then((e=>{const{addFeatureResults:t}=e;let a=0;const i=l.map((e=>{const i=t[a++];return e?i:{error:new n("orientedimagery","Error in saving data capture features"),objectId:null,globalId:null}}));return{...e,addFeatureResults:i}}))}async searchBestImage(e,t){try{const a=await H(e,t);a&&await this._processFeatureResponse(a,e.point,{signal:t?.signal})}catch(a){g(a)||(this.setMessage("imageLoadError","error",a.message),h.getLogger(this).error("error occurred while finding best image",a))}}selectBestFeature(e){this.currentBestFeature=this.features?.find((({attributes:t})=>t.objectId===Number(e)))}setAdditionalCameraLocationsVisibility(e){this.additionalCameraLocations.forEach((t=>{t.visible=e}))}setAdditionalCoverageVisibility(e){this.additionalFootprints.forEach((t=>{t.visible=e}))}setCurrentCoverageVisibility(e){this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.visible=e),this.currentBestFeatureLocation&&(this.currentBestFeatureLocation.visible=e)}setMapImageConversionToolState(e){this.mapImageConversionToolState=e}async startDataCapture(e,t){const a=this.activeViewer?.imageRenderer,{oiObjectIdField:i,currentBestFeature:r}=this;if(!a||!r||!i)return;const{attributes:{objectId:o}}=r,n=this.overlayedMapFeatures.get(e.id)?.toArray()??[],l=[],c=[];for(const s of n)`${s.getAttribute(i)}`==`${o}`?l.push(s):c.push(s);this.overlayGraphicsOnImage(e.id,new s(c)),this.collectionId=e.id;const h=await this.loadSketch(t),u=await this.loadDataCaptureAdapter(t);y(t),h.layer.addMany(l),h.layer.blendMode="source-atop",u.savedGraphics.addMany(l);a.ui.find("zoom").visible=!1,a.map.layers.add(this.sketchGraphicsLayer)}async stopDataCapture(e=!1){this.sketch?.cancel(),this.sketchGraphicsLayer?.removeAll(),this.sketchAdapter=m(this.sketchAdapter),this.sketch=m(this.sketch),this.collectionId=null;const{dataCaptureLayer:t}=this,a=this.activeViewer?.imageRenderer;if(!a||a.destroyed)return;a.map.layers.remove(this.sketchGraphicsLayer),e&&t&&await this.overlayMapFeatures(t,!0);const i=a.ui.find("zoom");i&&(i.visible=!0)}stopMeasurement(){this.heightMeasurementPixels=[],this.draw?.reset(),this.sketch?.cancel()}toggleAllOverlayMapFeatures(e){this.overlayedMapFeatures.forEach((t=>{this._toggleVisiblity(t,e)}))}toggleOverlayMapFeatures(e,t){const a=this.overlayedMapFeatures.get(e);a&&this._toggleVisiblity(a,t)}toggleSelection(e){const{sketch:t}=this;t&&(t.updateOnGraphicClick=e,t.cancel())}async transformAndPlotReferencePointOnImage(e){const{selectedLocation:t,options:a}=e;let i=!1,r=!1;const s=this.bestFeatureFootprint?.geometry;switch(s?.type){case"polygon":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);i=s.contains(e);break}case"mesh":{const e=t.spatialReference.equals(s.spatialReference)?t:await x(t,s.spatialReference);r=s.extent.contains(e);break}}if(!i&&!r)return void this.clearReferencePointOnImage();const o=await this.worldToImage(t,a);if(o)return y(a),this.plotReferencePointOnImage(o),{x:o.x,y:o.y};this.clearReferencePointOnImage()}updateSuitabilities(e){e.sort(((e,t)=>e.suitability-t.suitability)),this._suitabilities=e;const t=this._suitabilities.map((({feature:e})=>e));this._initialCurrentCoverageUpdate=!0,this._updateFeatures(t),this._groupFeaturesBySectors()}async _fetchFeatures(e,t){if(!this.view)return;const a=this.layer;if(a){const i={include:a},r=this.view.toScreen(e);if(!r)return;const s=await this.view.hitTest(r,i);return this._processHitTestResults(a,s,t)}}async _fetchFeaturesWithController(e,t){try{await this._fetchFeatures(e,t)}catch(a){if(g(a))return;this.setMessage("imageLoadError","error"),h.getLogger(this).error("error occurred while fetching features",a)}}_groupFeaturesBySectors(){const{_suitabilities:e,additionalFeatures:t,currentBestFeature:a,features:i,invalidCameraHeading:r}=this;if(!e||!t||!a||!i||r)return void(this._sectorData=null);this._sectorData={};for(const c of ve)this._sectorData[c]=new s;const o=e.map(((e,t)=>({...e,featureIndex:t})));o.sort(((e,t)=>e.trueSuitability-t.trueSuitability));const n=o.map((({distance:e})=>e)),l=Math.max(...n);o.forEach((e=>{const{distance:t,angle:a,featureIndex:r}=e,s=t/l*we[2],o=ct(t,l),n=ht(a);if(!this._sectorData)return;const c=we[3]+s*Math.sin(a*Math.PI/180),h=we[3]+s*Math.cos(a*Math.PI/180);let u;const p=i.at(r),m=p===this.currentBestFeature,d=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;if(m&&d)u=-90;else{const e=c-we[3],t=h-we[3],a=t/Math.sqrt(e**2+t**2);let i=180*Math.acos(a)/Math.PI;(e<0&&t<0||e<0&&t>0)&&(i*=-1),u=i}const g=""===o?n:`${o}_${n}`;m&&(u===this.bestFeatureAngle?this.previousFeatureAngle=u:this.bestFeatureAngle=u,this.navigatorCurrentBestFeature=d?null:{x:c,y:h,direction:n});const y=this._sectorData[g];y.add({angle:a,featureIndex:r,x:c,y:h,objectID:p.attributes.objectId,sector:g,featureIndexInSector:y.length})}))}_plotLocationPointOnDefaultImage(e){const a=k(e)?e.toJSON():e;a.x-=.5,a.y=.5-a.y,this._locationPointOnImage=new t({geometry:new G({spatialReference:this._imageViewer.imageRenderer.spatialReference,...a}),symbol:et}),this._imageViewer.addGraphic(this._locationPointOnImage,0)}_plotLocationPointOnPanoramicImage(e){const{imageSize:a}=this._panoramicViewer;if(!a)return;const[i,r]=a,{heading:s,pitch:o}=Y(e,i,r),n=ne(s,o);this._locationPointOnImage=new t({geometry:new G(n,j.WebMercator),symbol:tt}),this._panoramicViewer.addGraphic(this._locationPointOnImage,0)}async _processFeatureResponse(e,t,a){const{features:i}=e;if(!i?.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);this.coveragePolygons.removeAll(),this.coverageFrustums.removeAll(),this.pointSources.removeAll();const{features:r,polygons:s,frustums:o}=this.filterByFootprints(i,t);if(!r.length)return this.setMessage("noImageError","error"),void(this.currentBestFeature=null);let n;if(this.coveragePolygons.addMany(s),this.coverageFrustums.addMany(o),s[0]){let e=new O({spatialReference:s[0].spatialReference});for(const a of s)e=await A(e,a);const t=[];for(const{geometry:a}of r)e.contains(a)||t.push([a.x,a.y]);if(t.sort(((e,t)=>+E([e,t]))),e.addRing(t),this.footprintExtent=de(e.extent,2,2),this.view?.supportsGround)try{n=await this.view.map.ground.createElevationSampler(this.footprintExtent,a)}catch(l){g(l)||h.getLogger(this).error(l)}}if((n||r[0].attributes.elevationSource)&&this.footprintExtent){const e=r[0].attributes.elevationSource;$(e)&&!n&&(n=await Q({extent:this.footprintExtent,lod:e.lod,url:e.url,rasterFunction:e.rasterFunction}));const a=await te((r[0].attributes.location.z??0)-r[0].attributes.cameraHeight,{elevationSample:n,elevationSource:e,extent:this.footprintExtent}),[i,...s]=await K([t,...r.map((e=>e.attributes.geometry.clone()))],a);r[0].elevationSample=n??a.elevationSample,t.elevation=i.z,r.forEach(((e,t)=>{e.attributes.elevation=s[t].z}))}r[0].elevationSample&&r.forEach((e=>{e.elevationSample=r[0].elevationSample})),this._suitabilities=D({features:r,selectedPoint:t,camera:nt(this.view)?this.view.camera:null,currentImage:this.currentBestFeature}),this.updateSuitabilities(this._suitabilities)}async _processHitTestResults(e,t,a){const{screenPoint:i,results:[r]}=t,s="graphic"===r?.type&&this.shouldShowSelectedImage,o=r?.mapPoint??this.view?.toMap(i);if(!o)return;const{layerFloorFilterClause:n}=this,l=e.spatialReference.equals(o.spatialReference)?o:await x(o,e.spatialReference),c=P("1=1",P(e.definitionExpression,n)),h=l.spatialReference.isGeographic?1:I(l.spatialReference),u={layerInstanceOrURL:e,point:l,queryParams:{where:c,maximumDistance:e.maximumDistance?e.maximumDistance/h:void 0,objectIds:s?[r.graphic.getAttribute(e.objectIdField)]:void 0}};await this.searchBestImage(u,a)}_resetCursor(){const{activeViewer:e}=this;e&&(e.imageRenderer.cursor=this._previousCursor)}_setMeasurementCursor(){const{activeViewer:e}=this;e&&(this._previousCursor=e.imageRenderer.cursor,e.imageRenderer.cursor="crosshair")}_toggleVisiblity(e,t){e.forEach((e=>{e.visible=t}))}_updateFeatures(e){if(!e.length)return this.currentBestFeature=null,void this.additionalFeatures.removeAll();this.features.removeAll(),this.features.addMany(e),e.length>1?this.additionalFeatures.addMany(e.slice(1)):this.additionalFeatures.removeAll(),this._updateGroundElevation=!0,this.currentBestFeature=e[0]}async _updatePointsAndPolygons(e){const{pointSources:a,currentBestFeature:i,currentCoverageVisible:r,isAdditionalPointSourcesVisible:s}=this;if(i&&(this.additionalFootprints.removeAll(),this.additionalCameraLocations.removeAll(),this.bestFeatureCurrentFootprint&&(this.bestFeatureCurrentFootprint.destroy(),this.bestFeatureCurrentFootprint=null,this.bestFeatureFootprint=null),!this.invalidCameraHeading)){await(this._adapter?.createFootprints(e)),y(e);for(const e of a)e.imageID===i.attributes.objectId?this.currentBestFeatureLocation=new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:at,visible:r}):this.additionalCameraLocations.push(new t({attributes:{imageID:e.imageID},geometry:e.clone(),symbol:Qe,visible:s}))}}_updateCurrentBestFeature(e){if(!e)return;this.currentBestFeature=this.features?.at(e.featureIndex);const t=this.currentBestFeature?.attributes.cameraPitch&&this.currentBestFeature?.attributes.cameraPitch<5;let a;if(t)a=-90;else{const t=e.x-we[3],i=e.y-we[3],r=i/Math.sqrt(t**2+i**2);let s=180*Math.acos(r)/Math.PI;(t<0&&i<0||t<0&&i>0)&&(s*=-1),a=s}a===this.bestFeatureAngle?this.previousFeatureAngle=a:this.bestFeatureAngle=a,this.navigatorCurrentBestFeature=t?null:{x:e.x,y:e.y,direction:e.sector.includes("_")?e.sector.split("_")[1]:e.sector}}clearGraphics(){this._imageViewer.clearGraphics(),this._panoramicViewer.clearGraphics()}clearReferencePointOnImage(){this._referencePointOnImage&&(this._imageViewer.removeGraphic(this._referencePointOnImage),this._panoramicViewer.removeGraphic(this._referencePointOnImage),this._referencePointOnImage=m(this._referencePointOnImage))}clearLocationPointOnImage(){this._locationPointOnImage&&(this._imageViewer.removeGraphic(this._locationPointOnImage),this._panoramicViewer.removeGraphic(this._locationPointOnImage),this._locationPointOnImage=m(this._locationPointOnImage))}plotReferencePoint(e){"mapPoint"in e?this.plotReferencePointOnGround(e.mapPoint):this.plotReferencePointOnGround(e)}setMessage(e,t,a,i){this.displayMessage={key:e,type:t,data:a,map:i}}async transformAndPlotSelectedLocation(e){const{currentBestFeature:t,invalidCameraHeading:a,selectedPoint:i,activeViewer:r}=this;if(this._crossSymbol&&(this._panoramicViewer.removeGraphic(this._crossSymbol),this._imageViewer.removeGraphic(this._crossSymbol),this._crossSymbol=m(this._crossSymbol)),!i||!t||"image-loaded"!==r?.state||a)return;let s;try{s=await this.worldToImage(i,e),y(e),await this.plotSelectedPointOnImage(s,e)}catch(o){g(o)||h.getLogger(this).error("failed to transform map point to pixel, cross symbol will not be plotted on image",{error:o,selectedPoint:i,feature:t})}}async worldToImage(e,t){const{footprintExtent:a}=this,{imageSize:i}=this.activeViewer;if("none"===this.mode||!this.currentBestFeature||!i||!a)return;const{attributes:{location:r,elevationSource:s,cameraHeading:o,elevation:n,cameraHeight:l},elevationSample:c}=this.currentBestFeature;let h=r.clone();const u=await te(n??(r.z??0)-l,{elevationSample:c,elevationSource:s});this.currentBestFeature.elevationSample=u.elevationSample;const p=Array.isArray(e)?e:[e];let m,d=await Promise.all(p.map((e=>new Promise((t=>{if(!e.hasZ)return t(K(e,u));t(e)})))));if(r.spatialReference.isGeographic&&(h=await x(h,j.WebMercator,t)),d=await Promise.all(d.map((async e=>h.spatialReference.equals(e.spatialReference)?e:await x(e,h.spatialReference,t)))),y(t),"panoramic"===this.mode)m=ce(d,{imageHeight:i[1],imageWidth:i[0],cameraHeading:o,cameraLocation:h});else{const e=oe(this.currentBestFeature.attributes,i[0],i[1]);m=he(d,{...e,cameraLocation:h})}return Array.isArray(e)?m:m[0]}updateCurrentCoveragePolygon(e){const{additionalFootprints:a,additionalCameraLocations:i,currentBestFeature:r,currentBestFeatureLocation:s,currentCoverageVisible:o,selectedPoint:n,view:l,_adapter:c,mode:h}=this,{attributes:{objectId:u},elevationSample:p}=r;if(this._initialCurrentCoverageUpdate){if(this._overlays?.removeAll(),this._initialCurrentCoverageUpdate=!1,this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint),e&&!this.invalidCameraHeading&&(e.visible=o,this.bestFeatureCurrentFootprint=e),l){const e=[...a,...i,s].filter(lt);l.supportsGround&&p&&c?.updateGroundElevation&&(this._updateGroundElevation&&c.updateGroundElevation(e,p),"panoramic"===h&&c.updateGroundElevation([this.bestFeatureCurrentFootprint],p)),this._updateGroundElevation=!1,n&&(e.splice(-2,0,this.bestFeatureCurrentFootprint),e.push(new t({geometry:n.clone(),symbol:qe.clone(),attributes:{imageID:u}}))),this._overlays.graphics.addMany(e)}}else if(l){if(this.invalidCameraHeading)return;this.bestFeatureCurrentFootprint&&(this._overlays?.remove(this.bestFeatureCurrentFootprint),this.bestFeatureCurrentFootprint=m(this.bestFeatureCurrentFootprint));const t=this.bestFeatureCurrentFootprint&&this._overlays?this._overlays.graphics.indexOf(this.bestFeatureCurrentFootprint):-1;e&&(this.bestFeatureCurrentFootprint=e,l?.supportsGround&&p&&c?.updateGroundElevation&&"panoramic"===h&&c.updateGroundElevation([e],p),e.visible=this.currentCoverageVisible,this._overlays?.graphics.add(this.bestFeatureCurrentFootprint,t>=0?t:this._overlays.graphics.length-1))}}};e([M()],yt.prototype,"activeLayer",null),e([M({readOnly:!0})],yt.prototype,"activeViewer",null),e([M()],yt.prototype,"accuracyParametersMissing",null),e([M()],yt.prototype,"additionalFeatures",void 0),e([M({type:s.ofType(t)})],yt.prototype,"additionalCameraLocations",void 0),e([M({type:s.ofType(t)})],yt.prototype,"additionalFootprints",void 0),e([M()],yt.prototype,"areaMeasurementResult",void 0),e([M()],yt.prototype,"areaMeasurementAccuracy",void 0),e([M()],yt.prototype,"bestFeatureAngle",void 0),e([M()],yt.prototype,"bestFeatureCurrentFootprint",void 0),e([M({type:t})],yt.prototype,"bestFeatureFootprint",void 0),e([M({type:Number})],yt.prototype,"brightness",null),e([M()],yt.prototype,"collectionId",void 0),e([M({type:Number})],yt.prototype,"contrast",null),e([M()],yt.prototype,"conversionProps",void 0),e([M()],yt.prototype,"coverageFrustums",void 0),e([M()],yt.prototype,"coveragePolygons",void 0),e([M()],yt.prototype,"currentBestFeature",void 0),e([M()],yt.prototype,"currentBestFeatureLocation",void 0),e([M()],yt.prototype,"currentCoverageVisible",void 0),e([M({json:{write:!1}})],yt.prototype,"determineWorkflowForFeature",void 0),e([M()],yt.prototype,"disabled",void 0),e([M()],yt.prototype,"displayMessage",void 0),e([M()],yt.prototype,"displayNewMeasurementButton",void 0),e([M()],yt.prototype,"distanceMeasurementResult",void 0),e([M()],yt.prototype,"distanceAccuracyArray",void 0),e([M()],yt.prototype,"dataCaptureLayer",void 0),e([M({readOnly:!0})],yt.prototype,"featureCount",null),e([M()],yt.prototype,"features",void 0),e([M()],yt.prototype,"groundCoordinates",void 0),e([M()],yt.prototype,"groundCoordinatesAccuracy",void 0),e([M()],yt.prototype,"heightMeasurementPixels",void 0),e([M()],yt.prototype,"heightGraphic",void 0),e([M()],yt.prototype,"heightMeasurementResult",void 0),e([M()],yt.prototype,"heightMeasurementAccuracy",void 0),e([M()],yt.prototype,"measurementAngle",void 0),e([M()],yt.prototype,"tempDistance",void 0),e([M({readOnly:!0})],yt.prototype,"imageGalleryEnabled",null),e([M()],yt.prototype,"imageGeometryField",void 0),e([M({readOnly:!0})],yt.prototype,"imageLoaded",null),e([M()],yt.prototype,"imageLocationToolState",void 0),e([M({readOnly:!0})],yt.prototype,"invalidCameraHeading",null),e([M()],yt.prototype,"imagePointsInView",null),e([M()],yt.prototype,"isAdditionalCoverageVisible",void 0),e([M()],yt.prototype,"isAdditionalPointSourcesVisible",void 0),e([M()],yt.prototype,"layer",void 0),e([M()],yt.prototype,"layerView",null),e([M({readOnly:!0})],yt.prototype,"layerFloorFilterClause",null),e([M({type:Number})],yt.prototype,"localPort",void 0),e([M()],yt.prototype,"mapImageConversionToolState",void 0),e([M()],yt.prototype,"measureType",void 0),e([M()],yt.prototype,"measurementGraphic",void 0),e([M({readOnly:!0,value:"none"})],yt.prototype,"mode",null),e([M()],yt.prototype,"navigatorCurrentBestFeature",void 0),e([M()],yt.prototype,"oiObjectIdField",void 0),e([M({type:s.ofType(t)})],yt.prototype,"overlayedCameraLocations",void 0),e([M()],yt.prototype,"overlayedMapFeatures",void 0),e([M()],yt.prototype,"pixelCoordinates",void 0),e([M()],yt.prototype,"pointSources",void 0),e([M({readOnly:!0})],yt.prototype,"popupEnabled",null),e([M()],yt.prototype,"previousFeatureAngle",void 0),e([M()],yt.prototype,"referencePoint",null),e([M({readOnly:!0})],yt.prototype,"sectorData",null),e([M()],yt.prototype,"selectedPoint",void 0),e([M({type:Number})],yt.prototype,"sharpness",null),e([M()],yt.prototype,"shouldShowSelectedImage",void 0),e([M()],yt.prototype,"sketch",void 0),e([M()],yt.prototype,"draw",void 0),e([M()],yt.prototype,"sketchAdapter",void 0),e([M({readOnly:!0})],yt.prototype,"sketchGraphicsLayer",null),e([M({readOnly:!0})],yt.prototype,"state",null),e([M({readOnly:!0})],yt.prototype,"thumbnails",null),e([M()],yt.prototype,"updateFootprint",void 0),e([M()],yt.prototype,"updateFootprintPanorama",void 0),e([M({value:null})],yt.prototype,"view",null),e([M()],yt.prototype,"_adapter",void 0),e([M()],yt.prototype,"_sketchGraphicsLayer",null),e([M()],yt.prototype,"_highlightedFeatureHandle",void 0),e([M()],yt.prototype,"_imageViewer",void 0),e([M()],yt.prototype,"_initialCurrentCoverageUpdate",void 0),e([M()],yt.prototype,"_locationPointOnImage",void 0),e([M()],yt.prototype,"_overlays",void 0),e([M({readOnly:!0})],yt.prototype,"_overlaysView",null),e([M()],yt.prototype,"_panoramicViewer",void 0),e([M()],yt.prototype,"_previousCursor",void 0),e([M()],yt.prototype,"_referencePointOnGround",void 0),e([M()],yt.prototype,"_referencePointOnImage",void 0),e([M()],yt.prototype,"_sectorData",void 0),e([M({readOnly:!0})],yt.prototype,"_updatingHandles",void 0),e([M()],yt.prototype,"footprintExtent",void 0),e([M()],yt.prototype,"_featureChangedTask",void 0),yt=e([S("esri.widgets.OrientedImageryViewer.OrientedImageryViewerViewModel")],yt);const ft=yt;export{ft as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Map.js";import r from"../../../core/Error.js";import i from"../../../core/Evented.js";import s from"../../../core/Logger.js";import{clamp as a}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as l,initial as h}from"../../../core/reactiveUtils.js";import{property as
|
|
5
|
+
import{_ as e}from"../../../chunks/tslib.es6.js";import t from"../../../Map.js";import r from"../../../core/Error.js";import i from"../../../core/Evented.js";import s from"../../../core/Logger.js";import{clamp as a}from"../../../core/mathUtils.js";import{destroyMaybe as o}from"../../../core/maybe.js";import{isAbortError as n}from"../../../core/promiseUtils.js";import{watch as m,syncAndInitial as l,initial as h}from"../../../core/reactiveUtils.js";import{property as d}from"../../../core/accessorSupport/decorators/property.js";import"../../../core/has.js";import"../../../core/RandomLCG.js";import{subclass as c}from"../../../core/accessorSupport/decorators/subclass.js";import{rotate as p,intersect as g,nearestCoordinate as u}from"../../../geometry/geometryEngine.js";import y from"../../../geometry/Point.js";import _ from"../../../geometry/Polygon.js";import f from"../../../geometry/SpatialReference.js";import v from"../../../layers/GraphicsLayer.js";import R from"../../../layers/ImageryTileLayer.js";import x from"../../../layers/support/RasterFunction.js";import{convolutionKernel as w}from"../../../layers/support/rasterFunctionConstants.js";import C from"../../../layers/support/TileInfo.js";import I from"../../../views/MapView.js";import{getResolutionToScaleFactor as b}from"../../../views/2d/viewpointUtils.js";import{logAndThrow as j,getMissingPropertyErrorName as P,getMissingPropertyErrorMessage as S,castImageSource as k}from"../utils.js";const E={click:"click-handle",enhancements:"enhancements-handle",rotation:"rotation-handle"};let L=class extends i.EventedAccessor{constructor(e){super(e),this._imageChanged=!1,this._panConstraint=null,this._image=null,this._loadController=null,this._overlays=new v({blendMode:"source-atop"}),this._map=new t,this.autoLoad=!1,this.clickAction="none",this.error=null,this.imageSource=null,this.imageRotation=0,this.state="ready",this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._createImageHandles=()=>{this.removeHandles(E.enhancements),this.addHandles(m((()=>[this.brightness,this.contrast,this.sharpness]),(([e,t,r])=>{this.image?.loaded&&(this.image.effect=`contrast(${10*(t+10)}%) brightness(${10*(e+10)}%)`,this.sharpenImage(this.image,r))}),l))},this._createPanConstraint=()=>{const{image:e,imageRenderer:t}=this,r=r=>{if(!(e&&t&&r.targetGeometry&&e.serviceRasterInfo))return r;const{extent:i}=e.serviceRasterInfo,{constraints:s,rotation:a,width:o,height:n}=t,{extent:m}=p(_.fromExtent(i),a),{width:l,height:h}=m,d=r.targetGeometry.clone(),c=s.scaleToZoom(r.scale),g=1/2**c,y=o/n;let f=g*l,v=g*h;c&&(l/o>h/n?v=f/y:f=v*y);const R=m.clone();return R.xmin+=f/2,R.xmax-=f/2,R.ymin+=v/2,R.ymax-=v/2,r.targetGeometry=u(R,d).coordinate,this.state="image-loaded",r};return{constrain:r,applyPanConstraint:r}},this._createResizeHandles=e=>{e.removeHandles("resize"),e.addHandles(m((()=>{if(!this.imageRenderer.ready)return;const{extent:t}=e.serviceRasterInfo,{width:r,height:i,rotation:s}=this.imageRenderer,{extent:a}=p(_.fromExtent(t),s),{width:o,height:n}=a;return Math.max(o/r,n/i)}),(e=>{if(!this.imageRenderer||null==e)return;const{constraints:t,scale:r,spatialReference:i}=this.imageRenderer,s=t.minScale,a=b(i),o=.25*a,n=a*e;let m=n;const l=[];for(;m>o;)l.push(m),m/=2;l.push(m);const{lods:h}=C.create({scales:l});if(t.set({minScale:n,lods:h}),this._imageChanged)return this.imageRenderer.scale=n,void(this._imageChanged=!1);this.imageRenderer.scale=Math.abs(r-s)<=1e-6?n:r}),l),"resize")},this._loadImageInternal=(e,t={})=>{this.state="image-loading",this.clearImage(),this.error=null,this._imageChanged=!0;const r="string"==typeof e,i=r?void 0:e.datasetFormat,a=r?e:e.url,{customParameters:o,options:m}=t;return this._image=new R({ioConfig:{skipExtensions:["aux.xml","jgw"],skipMapInfo:!0,datasetFormat:i},url:a,customParameters:o}),this._image.when((async e=>{this._updatePanConstraint(),this._createResizeHandles(e),this._map.add(e),this.state="image-loaded"}),(t=>{n(t)?this.state="image-load-aborted":(this.state="image-load-error",this.error=t,s.getLogger(this).error(`error occurred while loading image ${r?e:JSON.stringify(e)}`,t),this.imageSource=null)})),this._image.load(m)},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._updatePanConstraint=()=>{this._panConstraint&&this.imageRenderer.constraints.customConstraints.remove(this._panConstraint),this._panConstraint=this._createPanConstraint(),this.imageRenderer.constraints.customConstraints.add(this._panConstraint)},this.addGraphic=(e,t)=>{this._overlays.graphics.add(e,t)},this.addManyGraphics=e=>{this._overlays.addMany(e)},this.clearGraphics=()=>{this._overlays.graphics.removeAll()},this.clearImage=()=>{this.image&&(this._map.layers.remove(this.image),this._image=o(this._image))},this.loadImage=e=>{const{customParameters:t,imageSource:i}=this;return i?this._loadImageInternal(i,{customParameters:t,options:e}):j(this.declaredClass,new r(P("image-viewer"),S("ImageViewerViewModel","imageSource")))},this.removeGraphic=e=>{this._overlays.remove(e)},this.removeManyGraphics=e=>{this._overlays.removeMany(e)},this._imageRenderer=new I({constraints:{snapToZoom:!0,rotationEnabled:!1},map:this._map,popupEnabled:!1,spatialReference:f.WebMercator,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([m((()=>this.imageSource),(e=>{e&&this.autoLoad&&this._loadWithController()}),l),m((()=>this.image?.loaded),(()=>{this._createImageHandles()})),m((()=>this.imageRotation),(()=>{this._rotateImage()})),m((()=>this.imageRenderer.map),((e,t)=>{t?.layers.remove(this._overlays),e?.layers.add(this._overlays)}),h),m((()=>this.imageRenderer.map.allLayers.length),(e=>{e&&this.imageRenderer.map.layers.reorder(this._overlays,e-1)}),l),m((()=>this.clickAction),(e=>{this.removeHandles(E.click),"none"!==e&&this.addHandles(this.imageRenderer.on("click",(t=>{if(this.image?.loaded&&this.imageRenderer.ready)switch(e){case"emit":t.stopPropagation(),this.emit("click",t);break;case"hittest":t.stopPropagation(),t.defer((async()=>{const e=await this.imageRenderer.hitTest(t.screenPoint,{include:this._overlays});this.emit("hittest-response",e)}));break;case"pixel-location":{if(t.stopPropagation(),!this.image?.serviceRasterInfo||!t.mapPoint)return void this.emit("pixel-location",null);const{extent:e,pixelSize:r}=this.image.serviceRasterInfo,i=(t.mapPoint.x-e.xmin)*r.x,s=(e.ymax-t.mapPoint.y)*r.y,a=new y({x:i,y:s,spatialReference:e.spatialReference});this.emit("pixel-location",a);break}}})))}),l)])}get brightness(){return this._get("brightness")??0}set brightness(e){this._set("brightness",a(e,-10,10))}get contrast(){return this._get("contrast")??0}set contrast(e){this._set("contrast",a(e,-10,10))}get image(){return this._image}get imagePointsInView(){const{extent:e,ready:t}=this.imageRenderer,r=this.imageRotation,i=this.image?.fullExtent,s=this.image?.serviceRasterInfo,a=!0===this._imageRenderer.allLayerViews.find((({layer:e})=>e===this.image))?.attached;if(!(t&&e&&i&&s&&a))return null;const o=p(_.fromExtent(e),r),n=_.fromExtent(i),m=g(o,n),{rings:l}=m;return l.flat().map((([e,t])=>({x:(e-s.extent.xmin)*s.pixelSize.x,y:(s.extent.ymax-t)*s.pixelSize.y})))}get imageSize(){const{image:e}=this;if(!e?.raster)return null;const{width:t,height:r}=e.raster.rasterInfo;return[t,r]}get imageRenderer(){return this._imageRenderer}get imageView(){return this.imageRenderer.allLayerViews.find((e=>e.layer===this.image))}get sharpness(){return this._get("sharpness")??0}set sharpness(e){this._set("sharpness",a(e,0,1))}_rotateImage(){this.imageRenderer.constraints.rotationEnabled=!0,this.imageRenderer.rotation=this.imageRotation,this.imageRenderer.constraints.rotationEnabled=!1}sharpenImage(e,t){if(!t)return void(e.rasterFunction=null);const r=[0,-1*t,0,-1*t,4*t+1,-1*t,0,-1*t,0],i=new x({functionName:"Convolution",functionArguments:{type:w.userDefined,cols:3,rows:3,kernel:r,convolutionType:w.userDefined}});e.rasterFunction=i}};e([d()],L.prototype,"_image",void 0),e([d()],L.prototype,"_imageRenderer",void 0),e([d()],L.prototype,"_loadController",void 0),e([d()],L.prototype,"_overlays",void 0),e([d()],L.prototype,"_map",void 0),e([d({type:Boolean})],L.prototype,"autoLoad",void 0),e([d({type:Number})],L.prototype,"brightness",null),e([d()],L.prototype,"clickAction",void 0),e([d({type:Number})],L.prototype,"contrast",null),e([d({type:Object})],L.prototype,"customParameters",void 0),e([d({type:r})],L.prototype,"error",void 0),e([d({readOnly:!0})],L.prototype,"image",null),e([d({readOnly:!0})],L.prototype,"imagePointsInView",null),e([d({readOnly:!0})],L.prototype,"imageSize",null),e([d({cast:k})],L.prototype,"imageSource",void 0),e([d({readOnly:!0})],L.prototype,"imageRenderer",null),e([d({type:Number})],L.prototype,"imageRotation",void 0),e([d()],L.prototype,"imageView",null),e([d({type:Number})],L.prototype,"sharpness",null),e([d()],L.prototype,"state",void 0),L=e([c("esri.widgets.OrientedImageryViewer.components.ImageViewerViewModel")],L);const M=L;export{M as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as l}from"../../core/mathUtils.js";import{destroyMaybe as d}from"../../core/maybe.js";import{isAbortError as c,waitTick as p}from"../../core/promiseUtils.js";import{watch as g,when as _,syncAndInitial as u}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as v}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../geometry/SpatialReference.js";import z from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as R}from"../../layers/orientedImagery/transformations/utils.js";import V from"../../views/SceneView.js";import{logAndThrow as C,getMissingPropertyErrorName as M,getMissingPropertyErrorMessage as j}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as P,maxPanoramicViewerHFOV as H,minPanoramicViewerHFOV as O,humanBinocularHFOV as S}from"./constants.js";import b from"./PanoramicZoomConditions.js";import k from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as x,meshToGraphic as I,createImageSphere as F}from"./utils.js";const G={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let A=class extends n.EventedAccessor{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new z({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new r([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.imageSize=null,this.imageSource=null,this.pitch=90,this.state="ready",this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(G.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",(e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()}))],G.navigation)},this._addHFOVHandles=()=>{this.removeHandles(G.fovConstraint),this.addHandles(g((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),u),G.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new k({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Camera.js";import i from"../../Ground.js";import o from"../../Map.js";import a from"../../request.js";import r from"../../core/Collection.js";import s from"../../core/Error.js";import n from"../../core/Evented.js";import{JSONMap as h}from"../../core/jsonMap.js";import{rad2deg as m,deg2rad as l}from"../../core/mathUtils.js";import{destroyMaybe as d}from"../../core/maybe.js";import{isAbortError as c,waitTick as p}from"../../core/promiseUtils.js";import{watch as g,when as _,syncAndInitial as u}from"../../core/reactiveUtils.js";import{property as y}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{enumeration as v}from"../../core/accessorSupport/decorators/enumeration.js";import{subclass as f}from"../../core/accessorSupport/decorators/subclass.js";import w from"../../geometry/SpatialReference.js";import z from"../../layers/GraphicsLayer.js";import{convertSphereVertexToPixelLocation as R}from"../../layers/orientedImagery/transformations/utils.js";import V from"../../views/SceneView.js";import{logAndThrow as C,getMissingPropertyErrorName as M,getMissingPropertyErrorMessage as j}from"../OrientedImageryViewer/utils.js";import{defaultImageSphereCenter as P,maxPanoramicViewerHFOV as H,minPanoramicViewerHFOV as O,humanBinocularHFOV as S}from"./constants.js";import b from"./PanoramicZoomConditions.js";import k from"./PanoramicZoomViewModel.js";import{findDiagonalFOV as x,meshToGraphic as I,createImageSphere as F}from"./utils.js";const G={autoLoad:"auto-load",default:"default",navigation:"navigation",fovConstraint:"fov-constraint",clickAction:"image-click-action"};let A=class extends n.EventedAccessor{constructor(e){super(e),this._startPosition=null,this._targetPosition=null,this._graphics=new z({elevationInfo:{mode:"relative-to-ground"}}),this._imageGraphic=null,this._loadController=null,this._map=new o({ground:new i({opacity:0,navigationConstraint:null}),layers:new r([this._graphics])}),this._zoomViewModel=null,this.autoLoad=!1,this.clickAction="none",this.imageSize=null,this.imageSource=null,this.pitch=90,this.state="ready",this.yaw=0,this._addNavigationHandles=()=>{this.imageRenderer.basemapTerrain.suspended=!0,this.imageRenderer.constraints.tilt.max=180,this.removeHandles(G.navigation),this.addHandles([this.imageRenderer.on("mouse-wheel",this._handleWheel),this.imageRenderer.on("double-click",this._handleDoubleClick),this.imageRenderer.on("drag",this._handleDrag),this.imageRenderer.on("key-down",(e=>{const t=["+","-","Shift","_","=","ArrowUp","ArrowDown","ArrowRight","ArrowLeft"],i=e.key;t.includes(i)&&e.stopPropagation()}))],G.navigation)},this._addHFOVHandles=()=>{this.removeHandles(G.fovConstraint),this.addHandles(g((()=>[this.maxHFOV,this.minHFOV]),(()=>{this._zoomViewModel&&(this._zoomViewModel.panoramicZoomConditions=new b({view:this.imageRenderer,maxFOV:this.maxHFOV,minFOV:this.minHFOV}))}),u),G.fovConstraint)},this._addZoomHandles=()=>{this._zoomViewModel=new k({view:this.imageRenderer,panoramicZoomConditions:new b({maxFOV:this.maxHFOV,minFOV:this.minHFOV})});const e=this.imageRenderer.ui.find("zoom");e&&(e.viewModel=this._zoomViewModel),this._addHFOVHandles()},this._cancelLoadWithController=()=>{this._loadController?.abort(),this._loadController=null},this._handleDoubleClick=e=>{e.stopPropagation(),e.native.ctrlKey?this._zoomOut():this._zoomIn()},this._handleDrag=e=>{e.stopPropagation();const{action:t,x:i,y:o}=e;switch(t){case"start":this._startPosition=this._targetPosition={x:i,y:o};break;case"update":this._targetPosition={x:i,y:o},this._updateCameraHeadingAndTilt()}},this._handleImageClick=e=>{if("image-loaded"===this.state&&this.imageRenderer.ready)switch(this.clickAction){case"emit":e.stopPropagation(),this.emit("click",e);break;case"hittest":e.stopPropagation(),e.defer((async()=>{const t=await this.imageRenderer.hitTest(e.screenPoint,{include:this._graphics});this.emit("hittest-response",t)}));break;case"pixel-location":{if(e.stopPropagation(),!this.imageSize||!e.mapPoint)return void this.emit("pixel-location",null);const t=R(e.mapPoint,this.imageSize[0],this.imageSize[1]);this.emit("pixel-location",{...t,spatialReference:w.WebMercator});break}}},this._handleWheel=e=>{const t=e.deltaX??e.native.deltaX;e.stopPropagation(),t>0||e.deltaY>0?this._zoomOut():this._zoomIn()},this._loadWithController=()=>{this._cancelLoadWithController(),this._loadController=new AbortController,this.loadImage(this._loadController)},this._zoomIn=()=>this._zoomViewModel?.zoomIn(),this._zoomOut=()=>this._zoomViewModel?.zoomOut(),this.addGraphic=(e,t)=>"image-loaded"===this.state&&!this._graphics.graphics.includes(e)&&(this._graphics.graphics.add(e,t),!0),this.addManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>!this._graphics.graphics.includes(e)));return this._graphics.graphics.addMany(t),!0},this.clearGraphics=()=>{this._graphics.graphics.removeAll()},this.clearImage=()=>{this.imageSize=null,this._removeImageSphere()},this.removeGraphic=e=>!("image-loaded"!==this.state||!this._graphics.graphics.includes(e))&&(this._graphics.remove(e),!0),this.removeManyGraphics=e=>{if("image-loaded"!==this.state)return!1;const t=e.filter((e=>this._graphics.graphics.includes(e)));return this._graphics.removeMany(t),!0},this._imageRenderer=new V({map:this._map,viewingMode:"local",camera:{position:P},environment:{atmosphereEnabled:!1,starsEnabled:!1,lighting:{type:"virtual"}},popupEnabled:!1,spatialReference:w.WebMercator,ui:{components:["zoom"]}})}destroy(){this._imageRenderer.destroy()}initialize(){this.state="initialized",this.addHandles([g((()=>this.imageSource),(()=>{this.imageSource&&this.autoLoad&&this._loadWithController()}),u),g((()=>this.fov),(()=>{this._reloadCamera()}),u),g((()=>this.yaw),(e=>{this.camera.heading=e,this._reloadCamera()}),u),g((()=>this.pitch),(e=>{this.camera.tilt=e,this._reloadCamera()}),u),_((()=>this.imageRenderer.ready),(()=>{this._addNavigationHandles(),this._addZoomHandles()}),u),g((()=>this.clickAction),(e=>{this.removeHandles(G.clickAction),"none"!==e&&this.addHandles(this.imageRenderer.on("click",this._handleImageClick))}),u)],G.default)}get camera(){return this.imageRenderer.camera}set camera(e){e&&(this.imageRenderer.camera=e.clone())}get fov(){return this.camera.fov}set fov(e){Number.isFinite(e)&&this._zoomViewModel?.zoomTo(e)}get hfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.sin(a)))}get imageRenderer(){return this._imageRenderer}get maxHFOV(){const{size:[e,t]}=this.imageRenderer;return x(H,e/t)}get minHFOV(){const{size:[e,t]}=this.imageRenderer;return x(O,e/t)}get vfov(){const{fov:e}=this.camera,{size:[t,i]}=this.imageRenderer,o=t/i,a=Math.atan(o);return 2*m(Math.atan(Math.tan(l(e/2))*Math.cos(a)))}async _loadImageInternal(e,t){let i;this.state="image-loading";try{i=(await a(e,{responseType:"image",...t})).data}catch(o){throw c(o)?this.state="image-load-aborted":this.state="image-load-error",o}return this._updateImageSphere(i,t)}_reloadCamera(){this.camera=this.camera.clone()}_removeImageSphere(){this._imageGraphic&&(this._graphics.remove(this._imageGraphic),this._imageGraphic=d(this._imageGraphic)),this.state="ready",this.imageSize=null}_updateCameraHeadingAndTilt(){if(!this._startPosition||!this._targetPosition)return;const e=this.camera.heading+(this._startPosition.x-this._targetPosition.x)/this.imageRenderer.width*this.camera.fov;this.yaw=(e+360)%360;const t=this.camera.tilt-(this._startPosition.y-this._targetPosition.y)/this.imageRenderer.height*this.imageRenderer.camera.tilt;this.pitch=Math.min(179.5,Math.max(.5,t)),this._startPosition=this._targetPosition}async _updateImageSphere(e,t){await p(t);const{size:[i,o]}=this.imageRenderer;return this._imageGraphic=I(F(e)),this._graphics.add(this._imageGraphic),this.fov=x(S,i/o),this.state="image-loaded",this.imageSize=[e.width,e.height],this._imageGraphic.geometry}async loadImage(e){return this._removeImageSphere(),this.imageSource?this._loadImageInternal(this.imageSource,e):C(this.declaredClass,new s(M("panoramic-viewer"),j("PanoramicViewerViewModel","imageSource")))}};e([y()],A.prototype,"_graphics",void 0),e([y()],A.prototype,"_imageGraphic",void 0),e([y()],A.prototype,"_imageRenderer",void 0),e([y()],A.prototype,"_loadController",void 0),e([y()],A.prototype,"_map",void 0),e([y()],A.prototype,"_zoomViewModel",void 0),e([y({type:Boolean})],A.prototype,"autoLoad",void 0),e([y({type:t})],A.prototype,"camera",null),e([v(new h({emit:"emit",hittest:"hittest",none:"none","pixel-location":"pixel-location"}))],A.prototype,"clickAction",void 0),e([y({type:Number})],A.prototype,"fov",null),e([y({readOnly:!0})],A.prototype,"hfov",null),e([y({readOnly:!0})],A.prototype,"imageRenderer",null),e([y()],A.prototype,"imageSize",void 0),e([y()],A.prototype,"imageSource",void 0),e([y({readOnly:!0})],A.prototype,"maxHFOV",null),e([y({readOnly:!0})],A.prototype,"minHFOV",null),e([y({type:Number})],A.prototype,"pitch",void 0),e([y()],A.prototype,"state",void 0),e([y({readOnly:!0})],A.prototype,"vfov",null),e([y({type:Number})],A.prototype,"yaw",void 0),A=e([f("esri.widgets.PanoramicViewer.PanoramicViewerViewModel")],A);const L=A;export{L as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import i from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import"../../core/has.js";import{abortMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{after as a,throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as p,syncAndInitial as u}from"../../core/reactiveUtils.js";import{createScreenPointArray as d,createRenderScreenPointArray as c}from"../../core/screenUtils.js";import{convertTime as h,offsetDateUTC as m}from"../../core/timeUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{create as y}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{longitudeToTimezone as g}from"../../views/3d/support/earthUtils.js";import{computeDirectionsOverTime as v}from"../../views/3d/support/sunUtils.js";import{ShadowCastVisualization as w}from"../../views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js";import T from"./DiscreteOptions.js";import{DurationMode as D}from"./DurationMode.js";import b from"./DurationOptions.js";import{ShadowCastState as O}from"./ShadowCastState.js";import{ShadowTooltipViewModel as P}from"./ShadowTooltipViewModel.js";import{ShadowVisualizationType as j}from"./ShadowVisualizationType.js";import z from"./ThresholdOptions.js";import{breadthFirstBinaryPartitioning as U}from"../support/traversalUtils.js";const C=[],V=y(),E=[],R=255,S=h(1,"hours","milliseconds"),A=500;let x=class extends i{constructor(e){super(e),this.view=null,this.tooltip=new P({getDuration:(e,t)=>this.getDuration(e,t)}),this.startTimeOfDay=h(10,"hours","milliseconds"),this.endTimeOfDay=h(16,"hours","milliseconds"),this.visualizationType=j.Threshold,this.thresholdOptions=new z,this.durationOptions=new b,this.discreteOptions=new T,this._running=!0,this._stopPreviewingTask=null,this._forcePreview=!1,this._autoRestoreForcePreviewEnabled=!0,this._utcOffset=null,this.date=new Date}initialize(){this.addHandles([p((()=>({view:this.view,tooltipEnabled:this._tooltipEnabled})),(({view:e,tooltipEnabled:t})=>{this.tooltip.view=e,this.tooltip.enabled=t}),u),p((()=>this._forcePreviewDependencies),(()=>{o(this._stopPreviewingTask),this._forcePreview=!0,this._autoRestoreForcePreviewEnabled&&(this._stopPreviewingTask=s((async e=>{await a(A,e),l(e),this._forcePreview=!1})))}),u),p((()=>({renderer:this.renderer,parameters:this._visualizationParameters})),(e=>N(e.renderer,e.parameters)),u),p((()=>({renderer:this.renderer,parameters:{lightDirections:this._lightDirections}})),(e=>N(e.renderer,e.parameters)),u),p((()=>({renderer:this.renderer,parameters:{enabled:this._running}})),(e=>N(e.renderer,e.parameters)),u),p((()=>({renderer:this.renderer,parameters:{previewing:this._previewing}})),(e=>N(e.renderer,e.parameters)),u)])}destroy(){this.stop(),N(this.renderer,{enabled:!1}),n(this.tooltip)}get state(){return null!=this.view&&this.view.ready&&null!=this._referencePosition?O.Ready:O.Disabled}set date(e){const t=new Date(e);t.setHours(0,0,0,0),this._set("date",t)}get utcOffset(){return this._utcOffset??this._utcOffsetAuto}set utcOffset(e){this._utcOffset=e}get testData(){}get _previewing(){const{view:e}=this;return null==e?.allLayerViews||(this._forcePreview||!e.stationary||e.allLayerViews.some((e=>M(e)&&e.updating)))}get _utcOffsetAuto(){const e=this._referencePosition;return null!=e?g(e[0],!1):0}get _dateUTCOffset(){let e=this.date;return e=m(e,-e.getTimezoneOffset(),"minutes"),e=m(e,-this.utcOffset,"hours"),e}get _startDateTimeUTC(){return m(this._dateUTCOffset,this.startTimeOfDay)}get _endDateTimeUTC(){return m(this._dateUTCOffset,this.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _interval(){const e=this._duration>0?Math.floor(this._duration/R):R,t=this.discreteOptions.interval;switch(this.visualizationType){case j.Threshold:case j.Duration:return e;case j.Discrete:return t>0?t:e}}get _sampleCount(){return this._lightDirections.length}get _duration(){return this.endTimeOfDay-this.startTimeOfDay}get _lightDirections(){const{view:e}=this;if(null==e)return C;const t="global"===e.viewingMode?V:this._referencePosition;if(null==t)return C;const i=this._interval,r=v(this._startDateTimeUTC,this._endDateTimeUTC,i,t,e.state.viewingMode),s=r.length;E.length=0;const o=U(0,s,E),n=new Array(s);for(let a=0;a<s;++a)n[a]=r[o[a]];return n}get _tooltipEnabled(){return this.state===O.Ready&&this.visualizationType!==j.Discrete&&this._running&&!this._previewing}get _visualizationParameters(){if(!this._running)return null;switch(this.visualizationType){case j.Threshold:return this._thresholdVisualizationParameters;case j.Duration:return this._durationVisualizationParameters;case j.Discrete:return this._discreteVisualizationParameters}}get _thresholdVisualizationParameters(){const{value:e,color:i}=this.thresholdOptions,r=this._duration;return{visualization:w.Threshold,color:t.toUnitRGBA(i),threshold:r>0?e/this._duration:0}}get _durationVisualizationParameters(){const{color:e,mode:i}=this.durationOptions,r=this._duration,s=r>0&&i===D.Hourly?S/r:0;return{color:t.toUnitRGBA(e),visualization:w.Gradient,bandsEnabled:s>0,bandSize:s}}get _discreteVisualizationParameters(){return{color:t.toUnitRGBA(this.discreteOptions.color),visualization:w.Gradient,bandsEnabled:!1,bandSize:0}}get _forcePreviewDependencies(){const{view:e}=this;if(null==e)return null;const t=e.slicePlane,i=e.allLayerViews.toArray().filter(M),s=i.map((e=>e.layer)).filter(r),o=i.map((e=>e.visible)),n=s.map((e=>e.visible)),a=s.map((e=>e.opacity)),l=s.filter((e=>"definitionExpression"in e)).map((e=>e.definitionExpression)),p=i.filter((e=>"filter"in e)).map((e=>e.filter));return{slicePlane:t,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewVisibilities:o,layerVisibilities:n,layerOpacities:a,filters:p,definitionExpressions:l}}get renderer(){const{view:e}=this;if(null==e)return null;const t=e.stage;return null==t?null:t.renderer}start(){this.setRunning(!0)}stop(){this.setRunning(!1)}setRunning(e){this._running=e}async getDuration(e,t){const{view:i,renderer:r,_sampleCount:s}=this;if(null==i||null==r||0===s)return 0;const o=i.state.camera.screenToRender(d(e.x,e.y),c());return r.readAccumulatedShadow(o)*this._duration}};function N(e,t){null!=e&&null!=t&&e.setParameters({shadowCast:t})}function M(e){if(e.suspended)return!1;switch(e.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"graphics-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":return!0;case"base-dynamic-3d":case"catalog-3d":case"catalog-footprint-3d":case"catalog-dynamic-group-3d":case"dimension-3d":case"imagery-3d":case"imagery-tile-3d":case"line-of-sight-3d":case"map-image-3d":case"point-cloud-3d":case"tile-3d":case"vector-tile-3d":case"viewshed-3d":case"voxel-3d":case"wfs-3d":case"wmts-3d":case"media-3d":default:return!1;case"group":return e.layerViews.toArray().some((e=>M(e)))}}e([f()],x.prototype,"state",null),e([f()],x.prototype,"view",void 0),e([f()],x.prototype,"tooltip",void 0),e([f({type:Date,nonNullable:!0})],x.prototype,"date",null),e([f({nonNullable:!0})],x.prototype,"utcOffset",null),e([f({nonNullable:!0})],x.prototype,"startTimeOfDay",void 0),e([f({nonNullable:!0})],x.prototype,"endTimeOfDay",void 0),e([f({nonNullable:!0})],x.prototype,"visualizationType",void 0),e([f({type:z,nonNullable:!0})],x.prototype,"thresholdOptions",void 0),e([f({type:b,nonNullable:!0})],x.prototype,"durationOptions",void 0),e([f({type:T,nonNullable:!0})],x.prototype,"discreteOptions",void 0),e([f()],x.prototype,"_running",void 0),e([f()],x.prototype,"_stopPreviewingTask",void 0),e([f()],x.prototype,"_forcePreview",void 0),e([f()],x.prototype,"_autoRestoreForcePreviewEnabled",void 0),e([f()],x.prototype,"_previewing",null),e([f()],x.prototype,"_utcOffset",void 0),e([f()],x.prototype,"_utcOffsetAuto",null),e([f()],x.prototype,"_dateUTCOffset",null),e([f()],x.prototype,"_startDateTimeUTC",null),e([f()],x.prototype,"_endDateTimeUTC",null),e([f()],x.prototype,"_referencePosition",null),e([f()],x.prototype,"_interval",null),e([f()],x.prototype,"_sampleCount",null),e([f()],x.prototype,"_duration",null),e([f()],x.prototype,"_lightDirections",null),e([f()],x.prototype,"_tooltipEnabled",null),e([f()],x.prototype,"_visualizationParameters",null),e([f()],x.prototype,"_thresholdVisualizationParameters",null),e([f()],x.prototype,"_durationVisualizationParameters",null),e([f()],x.prototype,"_discreteVisualizationParameters",null),e([f()],x.prototype,"_forcePreviewDependencies",null),e([f()],x.prototype,"renderer",null),x=e([_("esri.widgets.ShadowCast.ShadowCastViewModel")],x);const G=x;export{G as default};
|
|
5
|
+
import{_ as e}from"../../chunks/tslib.es6.js";import t from"../../Color.js";import i from"../../core/Accessor.js";import{isSome as r}from"../../core/arrayUtils.js";import{createTask as s}from"../../core/asyncUtils.js";import"../../core/has.js";import{abortMaybe as o,destroyMaybe as n}from"../../core/maybe.js";import{after as a,throwIfAborted as l}from"../../core/promiseUtils.js";import{watch as d,syncAndInitial as u}from"../../core/reactiveUtils.js";import{createScreenPointArray as c,createRenderScreenPointArray as p}from"../../core/screenUtils.js";import{convertTime as h,offsetDateUTC as m}from"../../core/timeUtils.js";import{property as f}from"../../core/accessorSupport/decorators/property.js";import"../../core/Logger.js";import{subclass as _}from"../../core/accessorSupport/decorators/subclass.js";import{create as g}from"../../core/libs/gl-matrix-2/factories/vec3f64.js";import{longitudeToTimezone as v}from"../../views/3d/support/earthUtils.js";import{computeDirectionsOverTime as y}from"../../views/3d/support/sunUtils.js";import{ShadowCastVisualization as w}from"../../views/3d/webgl-engine/shaders/ShadowCastVisualizeTechniqueConfiguration.js";import D from"./DiscreteOptions.js";import{DurationMode as T}from"./DurationMode.js";import O from"./DurationOptions.js";import{ShadowCastState as P}from"./ShadowCastState.js";import{ShadowTooltipViewModel as C}from"./ShadowTooltipViewModel.js";import{ShadowVisualizationType as b}from"./ShadowVisualizationType.js";import z from"./ThresholdOptions.js";import{breadthFirstBinaryPartitioning as j}from"../support/traversalUtils.js";const U=[],V=g(),x=[],S=255,A=h(1,"hours","milliseconds"),E=500;let R=class extends i{constructor(e){super(e),this.view=null,this.tooltip=new C({getDuration:(e,t)=>this.getDuration(e,t)}),this.startTimeOfDay=h(10,"hours","milliseconds"),this.endTimeOfDay=h(16,"hours","milliseconds"),this.visualizationType=b.Threshold,this.thresholdOptions=new z,this.durationOptions=new O,this.discreteOptions=new D,this._running=!0,this._stopPreviewingTask=null,this._forcePreview=!1,this._autoRestoreForcePreviewEnabled=!0,this._utcOffset=null,this.date=new Date}initialize(){this.addHandles([d((()=>({view:this.view,tooltipEnabled:this._tooltipEnabled})),(({view:e,tooltipEnabled:t})=>{this.tooltip.view=e,this.tooltip.enabled=t}),u),d((()=>this._forcePreviewDependencies),(()=>{o(this._stopPreviewingTask),this._forcePreview=!0,this._autoRestoreForcePreviewEnabled&&(this._stopPreviewingTask=s((async e=>{await a(E,e),l(e),this._forcePreview=!1})))}),u),d((()=>({renderer:this.renderer,parameters:this._visualizationParameters})),(e=>G(e.renderer,e.parameters)),u),d((()=>({renderer:this.renderer,lightDirections:this._lightDirections,lightDirectionsContext:this._lightDirectionsContext})),(e=>G(e.renderer,{lightDirections:e.lightDirections,lightDirectionsContext:e.lightDirectionsContext})),u),d((()=>({renderer:this.renderer,parameters:{enabled:this._running}})),(e=>G(e.renderer,e.parameters)),u),d((()=>({renderer:this.renderer,parameters:{previewing:this._previewing}})),(e=>G(e.renderer,e.parameters)),u)])}destroy(){this.stop(),G(this.renderer,{enabled:!1}),n(this.tooltip)}get state(){return null!=this.view&&this.view.ready&&null!=this._referencePosition?P.Ready:P.Disabled}set date(e){const t=new Date(e);t.setHours(0,0,0,0),this._set("date",t)}get utcOffset(){return this._utcOffset??this._utcOffsetAuto}set utcOffset(e){this._utcOffset=e}get testData(){}get _previewing(){const{view:e}=this;return null==e?.allLayerViews||(this._forcePreview||!e.stationary||e.allLayerViews.some((e=>N(e)&&e.updating)))}get _utcOffsetAuto(){const e=this._referencePosition;return null!=e?v(e[0],!1):0}get _dateUTCOffset(){let e=this.date;return e=m(e,-e.getTimezoneOffset(),"minutes"),e=m(e,-this.utcOffset,"hours"),e}get _startDateTimeUTC(){return m(this._dateUTCOffset,this.startTimeOfDay)}get _endDateTimeUTC(){return m(this._dateUTCOffset,this.endTimeOfDay)}get _referencePosition(){return this.view?.environmentManager?.referencePositionGeographic}get _durationInterval(){return this._duration>0?Math.floor(this._duration/S):S}get _interval(){const e=this._durationInterval;switch(this.visualizationType){case b.Threshold:case b.Duration:return e;case b.Discrete:return this.discreteOptions.interval||e}}get _intervalContext(){const{discreteEnabled:e,discreteOptions:{interval:t}}=this.thresholdOptions;return this.visualizationType===b.Threshold&&e?t||this._durationInterval:-1}get _durationSampleCount(){return this._lightDirections.length}get _duration(){return this.endTimeOfDay-this.startTimeOfDay}get _lightDirections(){return this._calculateLightDirections(this._interval)}get _lightDirectionsContext(){return this._calculateLightDirections(this._intervalContext)}_calculateLightDirections(e){const{view:t}=this;if(null==t||e<=0)return U;const i="global"===t.viewingMode?V:this._referencePosition;if(null==i)return U;const r=y(this._startDateTimeUTC,this._endDateTimeUTC,e,i,t.state.viewingMode),s=r.length;x.length=0;const o=j(0,s,x),n=new Array(s);for(let a=0;a<s;++a)n[a]=r[o[a]];return n}get _tooltipEnabled(){return this.state===P.Ready&&this.visualizationType!==b.Discrete&&this._running&&!this._previewing}get _visualizationParameters(){if(!this._running)return null;switch(this.visualizationType){case b.Threshold:return this._thresholdVisualizationParameters;case b.Duration:return this._durationVisualizationParameters;case b.Discrete:return this._discreteVisualizationParameters}}get _thresholdVisualizationParameters(){const{value:e,color:i}=this.thresholdOptions,r=this._duration;return{visualization:w.Threshold,thresholdColor:t.toUnitRGBA(i),threshold:r>0?e/this._duration:0,...this._thresholdDiscreteVisualizationParameters}}get _thresholdDiscreteVisualizationParameters(){const{discreteOptions:{color:e},discreteEnabled:i}=this.thresholdOptions;return i?{visualization:w.ThresholdAndGradient,gradientColor:t.toUnitRGBA(e)}:{}}get _durationVisualizationParameters(){const{color:e,mode:i}=this.durationOptions,r=this._duration,s=r>0&&i===T.Hourly?A/r:0,o=t.toUnitRGBA(e);return 0===s?{...this._discreteVisualizationParameters,gradientColor:o}:{bandedGradientColor:o,visualization:w.BandedGradient,bandSize:s}}get _discreteVisualizationParameters(){return{gradientColor:t.toUnitRGBA(this.discreteOptions.color),visualization:w.Gradient}}get _forcePreviewDependencies(){const{view:e}=this;if(null==e)return null;const t=e.slicePlane,i=e.allLayerViews.toArray().filter(N),s=i.map((e=>e.layer)).filter(r),o=i.map((e=>e.visible)),n=s.map((e=>e.visible)),a=s.map((e=>e.opacity)),l=s.filter((e=>"definitionExpression"in e)).map((e=>e.definitionExpression)),d=i.filter((e=>"filter"in e)).map((e=>e.filter));return{slicePlane:t,startDateUTC:this._startDateTimeUTC,endDateUTC:this._endDateTimeUTC,layerViewVisibilities:o,layerVisibilities:n,layerOpacities:a,filters:d,definitionExpressions:l}}get renderer(){const{view:e}=this;if(null==e)return null;const t=e.stage;return null==t?null:t.renderer}start(){this.setRunning(!0)}stop(){this.setRunning(!1)}setRunning(e){this._running=e}async getDuration(e,t){const{view:i,renderer:r,_durationSampleCount:s}=this;if(null==i||null==r||0===s)return 0;const o=i.state.camera.screenToRender(c(e.x,e.y),p());return r.readAccumulatedShadow(o)*this._duration}};function G(e,t){null!=e&&null!=t&&e.setParameters({shadowCast:t})}function N(e){if(e.suspended)return!1;switch(e.type){case"building-scene-3d":case"csv-3d":case"elevation-3d":case"feature-3d":case"geojson-3d":case"graphics-3d":case"integrated-mesh-3d":case"integrated-mesh-3dtiles":case"ogc-feature-3d":case"route-3d":case"scene-layer-3d":case"scene-layer-graphics-3d":case"stream-3d":case"wms-3d":return!0;case"base-dynamic-3d":case"catalog-3d":case"catalog-footprint-3d":case"catalog-dynamic-group-3d":case"dimension-3d":case"imagery-3d":case"imagery-tile-3d":case"line-of-sight-3d":case"map-image-3d":case"point-cloud-3d":case"tile-3d":case"vector-tile-3d":case"viewshed-3d":case"voxel-3d":case"wfs-3d":case"wmts-3d":case"media-3d":default:return!1;case"group":return e.layerViews.toArray().some((e=>N(e)))}}e([f()],R.prototype,"state",null),e([f()],R.prototype,"view",void 0),e([f()],R.prototype,"tooltip",void 0),e([f({type:Date,nonNullable:!0})],R.prototype,"date",null),e([f({nonNullable:!0})],R.prototype,"utcOffset",null),e([f({nonNullable:!0})],R.prototype,"startTimeOfDay",void 0),e([f({nonNullable:!0})],R.prototype,"endTimeOfDay",void 0),e([f({nonNullable:!0})],R.prototype,"visualizationType",void 0),e([f({type:z,nonNullable:!0})],R.prototype,"thresholdOptions",void 0),e([f({type:O,nonNullable:!0})],R.prototype,"durationOptions",void 0),e([f({type:D,nonNullable:!0})],R.prototype,"discreteOptions",void 0),e([f()],R.prototype,"_running",void 0),e([f()],R.prototype,"_stopPreviewingTask",void 0),e([f()],R.prototype,"_forcePreview",void 0),e([f()],R.prototype,"_autoRestoreForcePreviewEnabled",void 0),e([f()],R.prototype,"_previewing",null),e([f()],R.prototype,"_utcOffset",void 0),e([f()],R.prototype,"_utcOffsetAuto",null),e([f()],R.prototype,"_dateUTCOffset",null),e([f()],R.prototype,"_startDateTimeUTC",null),e([f()],R.prototype,"_endDateTimeUTC",null),e([f()],R.prototype,"_referencePosition",null),e([f()],R.prototype,"_interval",null),e([f()],R.prototype,"_intervalContext",null),e([f()],R.prototype,"_durationSampleCount",null),e([f()],R.prototype,"_duration",null),e([f()],R.prototype,"_lightDirections",null),e([f()],R.prototype,"_lightDirectionsContext",null),e([f()],R.prototype,"_tooltipEnabled",null),e([f()],R.prototype,"_visualizationParameters",null),e([f()],R.prototype,"_thresholdVisualizationParameters",null),e([f()],R.prototype,"_thresholdDiscreteVisualizationParameters",null),e([f()],R.prototype,"_durationVisualizationParameters",null),e([f()],R.prototype,"_discreteVisualizationParameters",null),e([f()],R.prototype,"_forcePreviewDependencies",null),e([f()],R.prototype,"renderer",null),R=e([_("esri.widgets.ShadowCast.ShadowCastViewModel")],R);const L=R;export{L as default};
|
|
@@ -2,4 +2,4 @@
|
|
|
2
2
|
All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
|
3
3
|
See https://js.arcgis.com/4.33/esri/copyright.txt for details.
|
|
4
4
|
*/
|
|
5
|
-
import{_ as o}from"../../chunks/tslib.es6.js";import
|
|
5
|
+
import{_ as o}from"../../chunks/tslib.es6.js";import s from"../../Color.js";import r from"../../core/Accessor.js";import{convertTime as t}from"../../core/timeUtils.js";import{property as e}from"../../core/accessorSupport/decorators/property.js";import"../../core/has.js";import"../../core/Logger.js";import"../../core/RandomLCG.js";import{subclass as i}from"../../core/accessorSupport/decorators/subclass.js";import p from"./DiscreteOptions.js";let c=class extends r{constructor(){super(...arguments),this.color=new s([255,0,0,.7]),this.value=t(4,"hours","milliseconds"),this.minValue=0,this.maxValue=t(8,"hours","milliseconds"),this.discreteEnabled=!1,this.discreteOptions=new p}};o([e({type:s})],c.prototype,"color",void 0),o([e()],c.prototype,"value",void 0),o([e()],c.prototype,"minValue",void 0),o([e()],c.prototype,"maxValue",void 0),o([e()],c.prototype,"discreteEnabled",void 0),o([e()],c.prototype,"discreteOptions",void 0),c=o([i("esri.widgets.ShadowCast.ThresholdOptions")],c);const m=c;export{m as default};
|