import type Analysis from "./Analysis.js"; import type LineOfSightAnalysisObserver from "./LineOfSightAnalysisObserver.js"; import type LineOfSightAnalysisTarget from "./LineOfSightAnalysisTarget.js"; import type Collection from "../core/Collection.js"; import type { LineOfSightAnalysisObserverProperties } from "./LineOfSightAnalysisObserver.js"; import type { LineOfSightAnalysisTargetProperties } from "./LineOfSightAnalysisTarget.js"; import type { ReadonlyArrayOrCollection } from "../core/Collection.js"; import type { AnalysisProperties } from "./Analysis.js"; export interface LineOfSightAnalysisProperties extends AnalysisProperties { /** Observer location. This is the point from which line of sight analysis is performed. */ observer?: LineOfSightAnalysisObserverProperties | null; /** Target locations. A list of points to look at from the observer. */ targets?: ReadonlyArrayOrCollection; } /** * LineOfSightAnalysis computes the line of sight from a single observer position towards * a set of targets. The results are visualized in a 3D [SceneView](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/). * * Create a new instance of LineOfSightAnalysis and add it to [SceneView.analyses](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#analyses). * The analysis may contain one [observer](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysisObserver/) with multiple * [targets](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysisTarget/). * The observer and targets can be created programmatically or interactively. * * ```js * // create line of sight analysis * const analysis = new LineOfSightAnalysis({ * observer: new LineOfSightAnalysisObserver({ position: new Point({ }) }), * targets: [ * new LineOfSightAnalysisTarget({ position: new Point({ }) }) * ] * }); * * // add the analysis to the view * view.analyses.add(analysis); * ``` * * The analysis results are displayed as colored lines, where areas visible to the observer are * shown green and occluded parts are marked in red. Also, the color of the target points indicates their visibility. * When the line of sight cannot be calculated, it will be displayed with a gray color. This may happen if either * the target or the observer is not in the view. * * Use the [LineOfSightAnalysisView3D](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/) to retrieve more detailed * analysis results. * * ```js * // wait until the view finishes updating so the results are current * await reactiveUtils.whenOnce(() => !view.updating); * * // retrieve the results from the analysis view. * const analysisView = await view.whenAnalysisView(analysis); * const results = analysisView.results; * ``` * * To place the observer and targets interactively, use the * [LineOfSightAnalysisView3D.place()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#place) method. * * ```js * const abortController = new AbortController(); * * try { * // get a view for the analysis * const analysisView = await view.whenAnalysisView(analysis); * * // start placing the observer and targets 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 an existing line of sight analysis interactively, set the * [LineOfSightAnalysisView3D.interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#interactive) property to `true` and * select the observer or any of the targets. Manipulators are then displayed and the selected item's position can be edited. * * ```js * // allow the observer and targets in the analysis to be selected and edited * analysisView.interactive = true; * ``` * * The line of sight analysis can be persisted in a [WebScene](https://developers.arcgis.com/javascript/latest/references/core/WebScene/) as part of a [LineOfSightLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/LineOfSightLayer/): * * ```js * // create line of sight layer containing the analysis * const lineOfSightLayer = new LineOfSightLayer({ * analysis: analysis * }); * * // add the layer to the map * view.map.add(lineOfSightLayer); * ``` * * Use the [Line Of Sight component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-line-of-sight/) to display a user interface * for the line of sight analysis. * * > [!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.23 * @see [LineOfSightAnalysisView3D](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/) * @see [LineOfSightLayer](https://developers.arcgis.com/javascript/latest/references/core/layers/LineOfSightLayer/) * @see [LineOfSightLayerView](https://developers.arcgis.com/javascript/latest/references/core/views/layers/LineOfSightLayerView/) * @see [LineOfSightAnalysisObserver](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysisObserver/) * @see [LineOfSightAnalysisTarget](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysisTarget/) * @see [ViewOptions](https://developers.arcgis.com/javascript/latest/references/core/views/interactive/options/ViewOptions/) * @see [Line Of Sight component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-line-of-sight/) * @see [Sample - Analysis objects](https://developers.arcgis.com/javascript/latest/sample-code/analysis-objects/) * @see [Sample - Line of sight component](https://developers.arcgis.com/javascript/latest/sample-code/line-of-sight/) */ export default class LineOfSightAnalysis extends Analysis { constructor(properties?: LineOfSightAnalysisProperties); /** Observer location. This is the point from which line of sight analysis is performed. */ get observer(): LineOfSightAnalysisObserver | null | undefined; set observer(value: LineOfSightAnalysisObserverProperties | null | undefined); /** Target locations. A list of points to look at from the observer. */ get targets(): Collection; set targets(value: ReadonlyArrayOrCollection); /** The type of analysis. For line of sight analysis, this is always "line-of-sight". */ get type(): "line-of-sight"; /** * Indicates whether the analysis is ready to be computed and interacted with in the view. * It requires an [observer](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/#observer) with a position. * * @since 4.33 */ get valid(): boolean; /** * Clears the analysis by resetting the [observer](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/#observer) property and removing all * [targets](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/#targets). * * @since 5.0 */ clear(): void; }