import type LineOfSightAnalysis from "../../../analysis/LineOfSightAnalysis.js"; import type LineOfSightAnalysisObserver from "../../../analysis/LineOfSightAnalysisObserver.js"; import type LineOfSightAnalysisTarget from "../../../analysis/LineOfSightAnalysisTarget.js"; import type Collection from "../../../core/Collection.js"; import type AnalysisView3D from "./AnalysisView3D.js"; import type LineOfSightAnalysisResult from "./LineOfSightAnalysisResult.js"; import type { LineOfSightPlacementOptions, LineOfSightPlacementResult } from "./LineOfSight/types.js"; /** * Represents the analysis view of a [LineOfSightAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/) * after it has been added to [SceneView.analyses](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#analyses). * * The LineOfSightAnalysisView3D is responsible for rendering a [LineOfSightAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/) * using custom visualizations. * * It allows to create an observer and targets interactively using the [place()](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#place) method, query analysis [results](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#results), * or make an existing analysis editable by enabling the [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#interactive) property. * * * The view for an analysis can be retrieved using [SceneView.whenAnalysisView()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#whenAnalysisView) * similar to how layer views are retrieved for layers using [SceneView.whenLayerView()](https://developers.arcgis.com/javascript/latest/references/core/views/SceneView/#whenLayerView). * * ```js * // retrieve analysis view for analysis * const analysis = new LineOfSightAnalysis(); * view.analyses.add(analysis); // add to the view * const analysisView = await view.whenAnalysisView(analysis); * ``` * * > [!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/). * * @see [LineOfSightAnalysis](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/) * @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/) * @see [Async cancellation with AbortController](https://developers.arcgis.com/javascript/latest/async-cancellation-with-abortcontroller/) */ export default abstract class LineOfSightAnalysisView3D extends AnalysisView3D { /** * The line of sight analysis object associated with the analysis view. * * @since 4.24 */ get analysis(): LineOfSightAnalysis; /** * Enables interactivity for the [analysis](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#analysis). * When set to `true`, and the analysis includes a valid [LineOfSightAnalysis.observer](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/#observer) and any * [LineOfSightAnalysis.targets](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysis/#targets), they become selectable and editable. * * Targets can be removed by right-clicking on them or with the `Delete` key. * The observer and the last target cannot be deleted interactively. * * This property is automatically set to `true` when the analysis is assigned to a * [Line Of Sight component](https://developers.arcgis.com/javascript/latest/references/map-components/components/arcgis-line-of-sight/). * * @default false * @since 4.24 */ accessor interactive: boolean; /** * Analysis results for each target. * * The order of results matches the order of targets, so if the index of the target is known the collection can be * indexed directly: * * ```js * const analysisView = await view.whenAnalysisView(analysis); * const result = analysisView.results.at(targetIdx); * ``` * * Given a [target](https://developers.arcgis.com/javascript/latest/references/core/analysis/LineOfSightAnalysisTarget/) object, the results collection can also be * searched: * * ```js * const result = analysisView.results.find((result) => result.target === targetObject); * ``` */ get results(): Collection; /** * The observer or target currently selected for interactive editing. * * When [interactive](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#interactive) is `true`, any observer or target in the * [analysis](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#analysis) can be selected * and its properties can be edited by interacting with the manipulators in the view. * * Use the item's `type` property to determine whether it is an observer or a target. * * @since 5.2 * @example * ```ts * const analysisView = await view.whenAnalysisView(analysis); * analysisView.interactive = true; * * reactiveUtils.watch(() => analysisView.selectedItem, (item) => { * if (item?.type === "observer") { * const observer = item; // LineOfSightAnalysisObserver * console.log("Selected observer:", observer.position); * } else if (item?.type === "target") { * const target = item; // LineOfSightAnalysisTarget * console.log("Selected target:", target.position); * } * }); * ``` */ get selectedItem(): LineOfSightAnalysisObserver | LineOfSightAnalysisTarget | null | undefined; /** * The analysis view type. * * @since 4.24 */ get type(): "line-of-sight-view-3d"; /** * When `true`, the [analysis](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#analysis) is visualized in the view. * * @since 4.24 */ get visible(): boolean; set visible(value: boolean | null | undefined); /** * Starts the interactive placement of an observer and targets on the [analysis](https://developers.arcgis.com/javascript/latest/references/core/views/3d/analysis/LineOfSightAnalysisView3D/#analysis). * * If the analysis does not have a valid observer yet, this method will allow placing an observer, which can be followed * by zero or more targets. Otherwise, if it already has a valid observer, it will allow placing targets. An observer * is valid when it has a position. Placing an observer without any targets is a productive operation. * * The placement operation will finish when the user presses the escape key. Pressing escape after placing an observer * or target finalizes a productive operation. Pressing escape before a valid observer is placed rejects the promise. * To stop the placing programmatically, pass an abort signal as an argument when calling the method. * The promise resolves when the operation is productive, i.e. an observer or any targets were added. * Otherwise, if nothing was added or signal was aborted, the promise is rejected. * * By default, the observer and targets are 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/3d/analysis/LineOfSightAnalysisView3D/#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 - i.e. the user places an observer and/or target(s), * leaving the analysis in a valid state. Otherwise, the promise is rejected. * @since 4.33 * @example * const abortController = new AbortController(); * * try { * await analysisView.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?: LineOfSightPlacementOptions | null | undefined): Promise; }