import type Viewshed from "../../analysis/Viewshed.js"; import type ViewshedLayer from "../../layers/ViewshedLayer.js"; import type LayerView from "./LayerView.js"; import type { ViewshedPlacementOptions, ViewshedPlacementResult } from "../3d/analysis/Viewshed/types.js"; import type { LayerViewProperties } from "./LayerView.js"; export interface ViewshedLayerViewProperties extends LayerViewProperties, Partial> {} /** * Represents the [LayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LayerView/) of a [ViewshedLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/) * after it has been added to a [Map](https://developers.arcgis.com/javascript/latest/references/core/Map/) in a [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * * The viewshed layer view controls whether the [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/ViewshedAnalysis/) in its associated * [ViewshedLayer.source](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/#source) can be created or edited interactively. * * It allows to create new viewsheds interactively using the [place()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#place) method, * or to make existing viewsheds selectable and editable by enabling the [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#interactive) property. * To select a viewshed, hover and click on its observer. * * The view for the layer can be retrieved using [SceneView.whenLayerView()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#whenLayerView). * * ```js * // create new layer and add it to the map * const viewshedLayer = new ViewshedLayer(); * view.map.add(viewshedLayer); * * // retrieve layer view for the layer * const layerView = await view.whenLayerView(viewshedLayer); * ``` * * > [!WARNING] * > * > **Things to consider:** * > * 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.31 * @see [ViewshedLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/) * @see [Viewshed](https://developers.arcgis.com/javascript/latest/references/core/analysis/Viewshed/) * @see [ViewshedAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/ViewshedAnalysis/) * @see [ViewshedAnalysisView3D](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/ViewshedAnalysisView3D/) * @see [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/) * @see [Sample - ViewshedLayer in slides](https://developers.arcgis.com/javascript/latest/sample-code/layers-viewshed/) * @see [Async cancellation with AbortController](https://developers.arcgis.com/javascript/latest/async-cancellation-with-abortcontroller/) */ export default abstract class ViewshedLayerView extends LayerView { /** * Enables interactivity for the [layer](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#layer). When set to `true` and the layer's * [ViewshedLayer.source](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/#source) includes any valid [viewsheds](https://developers.arcgis.com/javascript/latest/references/core/analysis/Viewshed/), * they become selectable and editable. * * Viewsheds can be removed with the `Delete` key. * * @default false */ accessor interactive: boolean; /** The layer this layer view represents. */ get layer(): ViewshedLayer; /** * The selected viewshed. If [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#interactive) is `true`, any viewshed in the * [layer](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#layer) can be selected by clicking on it in the view. As long as [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#interactive) * remains `true`, the properties of the selected viewshed can be edited by interacting with * manipulators in the view. */ accessor selectedViewshed: Viewshed | null | undefined; /** * Starts the interactive creation of new viewsheds and adds them to the * [ViewshedLayer.source](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/#source) of the associated [layer](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#layer). * * The first click in the scene places the observer point and the second sets the viewshed's orientation and distance. * * The creation process will finish when the user double-clicks the mouse or presses the escape key. * To stop the creation programmatically, pass an abort signal as an argument when calling the method. * * This method is similar to the [place()](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#place) method, but it allows to create multiple viewsheds in a row. * * By default, the observer is created at absolute height. * Optionally, by specifying the options of the method, * you can change the [elevation info](https://developers.arcgis.com/javascript/latest/references/core/symbols/support/ElevationInfo/). * * Calling this method sets [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#interactive) to `true`. * * @param options - An object specifying additional placement options, including elevation information and an abort signal. * @returns A promise which resolves when creation is completed successfully or rejected if it is * canceled. * @example * const abortController = new AbortController(); * * try { * await viewshedLayerView.createViewsheds({ signal: abortController.signal }); * } catch (error) { * if (error.name === "AbortError") { * console.log("Creation operation was cancelled."); * } * } * * // cancel the placement operation at some later point * abortController.abort(); */ createViewsheds(options?: ViewshedPlacementOptions | null | undefined): Promise; /** * Starts the interactive placement of a single viewshed, adding it to the * [ViewshedLayer.source](https://developers.arcgis.com/javascript/latest/references/core/layers/ViewshedLayer/#source) of the associated [layer](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#layer). * * The first click in the scene places the observer point and the second sets the viewshed's orientation and distance. * * The placement operation will finish when the user presses the escape key. * To stop the placing programmatically, pass an abort signal as an argument when calling the method. * * By default, the observer is created at absolute height. * Optionally, by specifying the options of the method, * you can change the [elevation info](https://developers.arcgis.com/javascript/latest/references/core/symbols/support/ElevationInfo/). * * Calling this method sets [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/layers/ViewshedLayerView/#interactive) to `true`. * * @param options - An object specifying additional placement options, including elevation information and an abort signal. * @returns A promise which * resolves when the operation is completed successfully or rejected if it is canceled. * @since 4.33 * @example * const abortController = new AbortController(); * * try { * await layerView.place({ * signal: abortController.signal, * // optional elevation info * elevationInfo: { mode: "relative-to-ground", offset: 1.5 }, * }); * } catch (error) { * if (error.name === "AbortError") { * console.log("Placement operation was cancelled."); * } * } * * // cancel the placement operation at some later point * abortController.abort(); */ place(options?: ViewshedPlacementOptions | null | undefined): Promise; }