# JSSightAnalysis

> Created with the Module.getSightAnalysis API.

```javascript
var sightAnalysis = Module.getSightAnalysis();
```

### GetObjectPositionsOnPath(coordinates, hbuffer, vbuffer, layer) → [JSSightAnalysis.ObjectOnPathResult](#jssightanalysis.objectonpathresult)

> Returns the distance and position of objects from a specified path.
>
> Analyzes based on the path's milestone distance for objects within the range, based on the search range along the path.
>
> The hbuffer input value is the horizontal buffer size. The larger the value, the wider the range of objects analyzed horizontally.
>
> The vbuffer input value is the vertical buffer size. The larger the value, the wider the range of objects analyzed vertically.

{% tabs %}
{% tab title="Information" %}

| Name        | Type                                                                                          | Description                                                                                                                                                                                                                |
| ----------- | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| coordinates | [JSVec3Array](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvec3array) | ([JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d), [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d), ...) Array of paths to analyze. |
| hbuffer     | number                                                                                        | Horizontal buffer size.                                                                                                                                                                                                    |
| vbuffer     | number                                                                                        | Vertical buffer size.                                                                                                                                                                                                      |
| layer       | [JSLayer](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/layer/jslayer)        | The layer to which the objects to be analyzed belong.                                                                                                                                                                      |

* Return
  * Returns the positions of points where the path intersects objects in the vertical direction. ([JSSightAnalysis.ObjectOnPathResult](#jssightanalysis.objectonpathresult))
* Sample
  * Refer to function analysisPositions.
  * [Sandbox\_Path Analysis](https://sandbox.egiscloud.com/code/main.do?id=analysis_line_path_distance)
    {% endtab %}

{% tab title="Template" %}

```javascript
var coordinates = Module.getMap().getInputPoints();
var returnJSON = Module.getSightAnalysis().GetObjectPositionsOnPath(coordinates, 30.0, 5.0, "analysis layer");

let returnJSON = "{
	[
		{
			Longitude : 129.2,
			Latitude : 36.8,
			Altitude : 10.2,
			ObjectKey : "Test1",
			Distance : 10,
			Side : "Left"
		},
		{
			Longitude : 129.222,
			Latitude : 36.811,
			Altitude : 13.5,
			ObjectKey : "Test2",
			Distance : 30,
			Side : "Right"
		},
	]
```

{% endtab %}
{% endtabs %}

### Type Definitions

#### JSSightAnalysis.ObjectOnPathResult

> Format of the analysis result from GetObjectPositionsOnPath
>
> Returns as a string with a JSON structure

| Name   | Type                                                                                               | Attributes | Default | Description                          |
| ------ | -------------------------------------------------------------------------------------------------- | ---------- | ------- | ------------------------------------ |
| return | array([JSSightAnalysis.ObjectOnPathResult.Position](#jssightanalysis.objectonpathresult.position)) |            |         | Array of individual analysis results |

#### JSSightAnalysis.ObjectOnPathResult.Position

> Unit object information of [JSSightAnalysis.ObjectOnPathResult](#jssightanalysisobjectonpathresult)

| Name      | Type   | Attributes | Default | Description                                                                                         |
| --------- | ------ | ---------- | ------- | --------------------------------------------------------------------------------------------------- |
| Longitude | number |            |         | Longitude of the detected object                                                                    |
| Latitude  | number |            |         | Latitude of the detected object                                                                     |
| Altitude  | number |            |         | Altitude of the detected object                                                                     |
| ObjectKey | string |            |         | Key value of the detected object                                                                    |
| Distance  | number |            |         | Milestone distance of the detected object on the path                                               |
| Side      | string |            |         | Whether the detected object is on the left or right side of the path (Left: "Left", Right: "Right") |
