import type Analysis from "./Analysis.js"; import type Viewshed from "./Viewshed.js"; import type Collection from "../core/Collection.js"; import type { ViewshedProperties } from "./Viewshed.js"; import type { ReadonlyArrayOrCollection } from "../core/Collection.js"; import type { AnalysisProperties } from "./Analysis.js"; export interface ViewshedAnalysisProperties extends AnalysisProperties { /** A list of viewsheds. */ viewsheds?: ReadonlyArrayOrCollection; } /** * ViewshedAnalysis enables the creation and display of viewshed and view dome type of visibility analysis in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * * Create a new instance of ViewshedAnalysis and add it to [SceneView.analyses](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#analyses). * The analysis may contain multiple [viewsheds](https://developers.arcgis.com/javascript/latest/references/core/analysis/Viewshed/). * The viewsheds can be created programmatically or interactively. * * ```js * const viewshed = new Viewshed({ * observer: new Point({ }), * farDistance: 900, * heading: 64, * tilt: 84, * horizontalFieldOfView: 85, * verticalFieldOfView: 52 * }); * const analysis = new ViewshedAnalysis({ * viewsheds: [viewshed], * }); * * // add the analysis to the view * view.analyses.add(analysis); * ``` * * The analysis colors the areas visible to the observer as green and occluded parts as red. * * To add a viewshed interactively, use the * [ViewshedAnalysisView3D.place()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/#place) method. * * ```js * const abortController = new AbortController(); * * try { * // get a view for the analysis * const analysisView = await view.whenAnalysisView(analysis); * * // start placing a new viewshed interactively * await analysisView.place({ signal: abortController.signal }); * } catch (error) { * if (error.name === "AbortError") { * console.log("Placement operation was cancelled."); * } * } * * // cancel the placement operation at some later point * abortController.abort(); * ``` * * To edit any existing viewsheds interactively, set the * [ViewshedAnalysisView3D.interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/#interactive) property to `true` and * select a viewshed by clicking on its observer. Manipulators for editing the observer's position * and other parameters of the viewshed will then be displayed. * * ```js * // allow existing viewsheds in the analysis to be selected and edited * analysisView.interactive = true; * ``` * * The viewshed analysis can be persisted in a [WebScene](https://developers.arcgis.com/javascript/latest/references/core/WebScene/) as part of a [ViewshedLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/): * * ```js * // create viewshed layer containing the analysis * const viewshedLayer = new ViewshedLayer({ * source: analysis * }); * * // add the layer to the map * view.map.add(viewshedLayer); * ``` * * > [!WARNING] * > * > **Things to consider:** * > * This analysis is only supported in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * > * The results of the tool vary depending on the zoom level, as changes in zoom level affect the level of detail (LOD) of the scene geometry. * > * Snapping, tooltips, display units, and input units used during interactive placement and editing are inherited from * [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/). * > * Snapping is enabled by default. This can be temporarily disabled by holding the `CTRL` key. * > * Layer types currently supported for snapping are: [FeatureLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/FeatureLayer/), [GraphicsLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GraphicsLayer/) (except Mesh geometries), * > [GeoJSONLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/GeoJSONLayer/), [WFSLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/WFSLayer/), [CSVLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/CSVLayer/), * > [3D Object SceneLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/SceneLayer/), and [BuildingSceneLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/BuildingSceneLayer/). * * @since 4.30 * @see [ViewshedAnalysisView3D](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/) * @see [Viewshed](https://developers.arcgis.com/javascript/latest/references/core/analysis/Viewshed/) * @see [ViewshedLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/) * @see [ViewshedLayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/) * @see [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/) * @see [Sample - Interactive viewshed analysis](https://developers.arcgis.com/javascript/latest/sample-code/analysis-viewshed/) * @see [Sample - Analysis objects](https://developers.arcgis.com/javascript/latest/sample-code/analysis-objects/) * @see [3D viewshed overview](https://developers.arcgis.com/documentation/spatial-analysis-services/3d-visual/3d-viewshed/) */ export default class ViewshedAnalysis extends Analysis { constructor(properties?: ViewshedAnalysisProperties); /** The type of analysis. For viewshed analysis, this is always "viewshed". */ get type(): "viewshed"; /** * Indicates whether the analysis is ready to be computed and interacted with in the view. * It requires each of the [viewsheds](https://developers.arcgis.com/javascript/latest/references/core/analysis/ViewshedAnalysis/#viewsheds) to be valid, that is, * the [Viewshed.observer](https://developers.arcgis.com/javascript/latest/references/core/analysis/Viewshed/#observer) needs to be set and the [Viewshed.farDistance](https://developers.arcgis.com/javascript/latest/references/core/analysis/Viewshed/#farDistance) to be * greater than 0. If the analysis has no viewshed, it is considered valid. * * @since 4.33 */ get valid(): boolean; /** A list of viewsheds. */ get viewsheds(): Collection; set viewsheds(value: ReadonlyArrayOrCollection); /** * Clears the analysis by removing all [viewsheds](https://developers.arcgis.com/javascript/latest/references/core/analysis/ViewshedAnalysis/#viewsheds). * * @since 5.0 */ clear(): void; }