# JSTyphoon

> Create a API with Module.createTyphoon.

```javascript
var object = Module.createTyphoon("id");
```

## Function

### create(position, size, alt) → boolean

> Sets the position and size of the typhoon object.

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

| Name     | Type                                                                                        | Description                                                   |
| -------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------- |
| position | [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d) | typhoon location coordinates (longitude, latitude, altitude). |
| size     | number                                                                                      | Typhoon width.                                                |
| alt      | number                                                                                      | Typhoon height.                                               |

* Return
  * true: Creation successful.
  * false: Creation failed.
    {% endtab %}

{% tab title="Template" %}

```javascript
var vPosition = new Module.JSVector3D(126.7824826, 35.0119469, 15.2752179);
typhoon.create(vPosition, 500.0, 150.0);
```

{% endtab %}
{% endtabs %}

### createbyJson(options) → object

> Creates a typhoon object.
>
> Passes the typhoon object settings as an argument variable.

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

| Name   | Type                                                | Description                                 |
| ------ | --------------------------------------------------- | ------------------------------------------- |
| option | [JSTyphoon.CreateOptions](#jstyphoon.createoptions) | Initialization option property information. |

* Return
  * .result: API success status (1: Success, 0: Failure)
  * .name: Operation API name
  * .return: API return information (object: Normal return value, string: Failure error code)
* Sample
  * Refer to function initPage
  * [Sandbox\_Typhoon](https://sandbox.egiscloud.com/code/main.do?id=weather_typoon)
    {% endtab %}

{% tab title="Template" %}

```javascript
let json = {
    id: "Typhoon",
    size: 800,
    height: 1000,
    position: new Module.JSVector3D(126.7852637, 35.0183227, 30.0),
    complete: complete,
    damage: {
        size: 500,
        altitude: 10,
        color: new Module.JSColor(200, 0, 0, 255),
        unionterrain: false,
    },
};
```

{% endtab %}
{% endtabs %}

### getId() → string

> Returns the ID of the object.

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

* Return
  * string: Successful return of the object's Key string.
  * null: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
lat strKey = object.getId();
```

{% endtab %}
{% endtabs %}

### moveStart()

> Starts the typhoon movement.
>
> Moves the typhoon to the latitude and longitude coordinates added to the JSTyphoon API moveList.
>
> Resets to the creation position after the typhoon movement event ends.

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

* Sample
  * Refer to function moveTyphoon
  * [Sandbox\_Typhoon](https://sandbox.egiscloud.com/code/main.do?id=weather_typoon)
    {% endtab %}

{% tab title="Template" %}

```javascript
```

{% endtab %}
{% endtabs %}

### moveEnd()

> Forces the typhoon movement to end.
>
> Resets to the creation position after forcing the typhoon movement to end.

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

* Sample
  * Refer to function stopTyphoon
  * [Sandbox\_Typhoon](https://sandbox.egiscloud.com/code/main.do?id=weather_typoon)
    {% endtab %}

{% tab title="Template" %}

```javascript
```

{% endtab %}
{% endtabs %}

### moveList(list)

> Sets the latitude and longitude for typhoon movement.
>
> Sequentially moves to the entered latitude and longitude coordinates.

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

| Name | Type                                                                                        | Description                                        |
| ---- | ------------------------------------------------------------------------------------------- | -------------------------------------------------- |
| list | [Collection](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/collection) | List of longitude, latitude, altitude coordinates. |

* Sample
  * Refer to function moveTyphoon
  * [Sandbox\_Typhoon](https://sandbox.egiscloud.com/code/main.do?id=weather_typoon)
    {% endtab %}

{% tab title="Template" %}

```javascript
var movePosition = new Module.Collection();
movePosition.add(new Module.JSVector3D(126.77599416643791, 35.02714918251881, 34.293371013365686));
movePosition.add(new Module.JSVector3D(126.78374897355015, 35.03318059967435, 35.54886215366423));
movePosition.add(new Module.JSVector3D(126.79212321528658, 35.03203801070689, 25.686076117679477));
movePosition.add(new Module.JSVector3D(126.79408620811664, 35.019259090964134, 29.999966450035572));
```

{% endtab %}
{% endtabs %}

### setDamageRange(danger, size, alt, color)

> Sets the damage range of the typhoon.

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

| Name         | Type                                                                                  | Description                                                                                                                                        |
| ------------ | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| danger       | boolean                                                                               | <p>Set the threat/warning type.<br>true: Set the damage range type to 'Danger' level.<br>false: Sets the damage range type to 'warning' level.</p> |
| size         | number                                                                                | Damage range.                                                                                                                                      |
| alt          | number                                                                                | Altitude of range display.                                                                                                                         |
| color        | [JSColor](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jscolor) | Display color.                                                                                                                                     |
| {% endtab %} |                                                                                       |                                                                                                                                                    |

{% tab title="Template" %}

```javascript
var rangeColor = new Module.JSColor(255, 255, 255, 0);
typhoon.setDamageRange(true, 300.0, 10.0, rangeColor);
```

{% endtab %}
{% endtabs %}

### setRotationSpeed(speed)

> Sets the rotation speed of the typhoon.

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

| Name  | Type   | Description             |
| ----- | ------ | ----------------------- |
| speed | number | Typhoon rotation speed. |

* Sample
  * Refer to function setTyphoonSpeed
  * [Sandbox\_Typhoon](https://sandbox.egiscloud.com/code/main.do?id=weather_typoon)
    {% endtab %}

{% tab title="Template" %}

```javascript
```

{% endtab %}
{% endtabs %}

### setSize(radius, alt)

> Sets the size of the typhoon.

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

| Name         | Type   | Description     |
| ------------ | ------ | --------------- |
| radius       | number | Typhoon radius. |
| alt          | number | Typhoon height. |
| {% endtab %} |        |                 |

{% tab title="Template" %}

```javascript
typhoon.setSize(500.0, 150.0);
```

{% endtab %}
{% endtabs %}

### setSpeed(speed)

> Sets the movement speed of the typhoon.

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

| Name  | Type   | Description             |
| ----- | ------ | ----------------------- |
| speed | number | Typhoon movement speed. |

* Sample
  * Refer to function setTyphoonSpeed
  * [Sandbox\_Typhoon](https://sandbox.egiscloud.com/code/main.do?id=weather_typoon)
    {% endtab %}

{% tab title="Template" %}

```javascript
```

{% endtab %}
{% endtabs %}

### setUnionTerrain(type)

> Set whether the typhoon's impact range is combined with the terrain.

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

| Name | Type    | Description                                                                              |
| ---- | ------- | ---------------------------------------------------------------------------------------- |
| type | boolean | <p>true: visualize terrain combination (RTT).<br>false: visualize as a flat polygon.</p> |

* Sample
  * Refer to function setDamageRangeDisplay
  * [Sandbox\_Typhoon](https://sandbox.egiscloud.com/code/main.do?id=weather_typoon)
    {% endtab %}

{% tab title="Template" %}

```javascript
```

{% endtab %}
{% endtabs %}

### setTextureURL(url)

> Sets the image URL for the typhoon. (The image supports a size of 1024\*1024).

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

| Name         | Type   | Description        |
| ------------ | ------ | ------------------ |
| url          | string | Typhoon image URL. |
| {% endtab %} |        |                    |

{% tab title="Template" %}

```javascript
typhoon.setTextureURL("./image/Typhoon.png");
```

{% endtab %}
{% endtabs %}

### setVisibleDamageRange(type)

> Typhoon impact area visualization option.
>
> Set whether to visualize the typhoon impact area.

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

| Name | Type    | Description                                                                             |
| ---- | ------- | --------------------------------------------------------------------------------------- |
| type | boolean | <p>true: Visualize the typhoon impact area.<br>false: Hide the typhoon impact area.</p> |

* Sample
  * Refer to function setDamageRangeDisplay
  * [Sandbox\_Typhoon](https://sandbox.egiscloud.com/code/main.do?id=weather_typoon)
    {% endtab %}

{% tab title="Template" %}

```javascript
```

{% endtab %}
{% endtabs %}

## Getter / Setter

### getDescription(), setDescription(desc) → string

> Set a description for the object.

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

| Name | Type   | Description                |
| ---- | ------ | -------------------------- |
| desc | string | Object description string. |

* Return
  * string: Successful return of the object's description string.
  * null: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
var strDesc = object.getDescription();
// ... or ...
object.setDescription("First Object.");
```

{% endtab %}
{% endtabs %}

### getName(), setName(name) → string

> Sets the name of the object.

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

| Name | Type   | Description                     |
| ---- | ------ | ------------------------------- |
| name | string | The name to set for the object. |

* Return
  * string: Successful return of the object's name.
  * null: If the object is null.
    {% endtab %}

{% tab title="Template" %}

```javascript
var objName = object.getName();
// ... or ...
object.setName("MyObject");
```

{% endtab %}
{% endtabs %}

### getVisible(), setVisible(visible) → boolean

> Sets the visibility state of an object.

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

| Name    | Type    | Description                                                      |
| ------- | ------- | ---------------------------------------------------------------- |
| visible | boolean | <p>true: Make the object visible.<br>false: Hide the object.</p> |

* Return
  * true: Object visible state.
  * false: Object hidden state.
    {% endtab %}

{% tab title="Template" %}

```javascript
var objName = object.getName();
// ... or ...
object.setVisible(true);
```

{% endtab %}
{% endtabs %}

### Type Definitions

#### JSTyphoon.CreateOptions

> Typhoon object creation options.

| Name     | Type                                                                                        | Attributes | Default | Description                                                   |
| -------- | ------------------------------------------------------------------------------------------- | ---------- | ------- | ------------------------------------------------------------- |
| id       | string                                                                                      |            |         | Typhoon ID.                                                   |
| position | [JSVector3D](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jsvector3d) |            |         | Typhoon location coordinates (longitude, latitude, altitude). |
| size     | number                                                                                      | optional   | 500     | Typhoon visualization size.                                   |
| height   | number                                                                                      | optional   | 100     | Typhoon visualization height.                                 |
| complete | function                                                                                    | optional   |         | Callback function when typhoon movement is complete.          |
| damage   | [JSTypoon.CreateOptions.Damage](#jstyphoon.createoptions.damage)                            | optional   |         | Typhoon impact range creation property information.           |

#### JSTyphoon.CreateOptions.Damage

> Typhoon impact range object creation options.

| Name         | Type                                                                                  | Attributes | Default                 | Description                                                       |
| ------------ | ------------------------------------------------------------------------------------- | ---------- | ----------------------- | ----------------------------------------------------------------- |
| size         | number                                                                                | optional   | 500                     | Impact range visualization size (in meters).                      |
| altitude     | number                                                                                | optional   | 10                      | Impact range visualization altitude (in meters).                  |
| unionterrain | boolean                                                                               | optional   | false                   | Whether the impact range visualization combines with the terrain. |
| color        | [JSColor](https://egiscorp.gitbook.io/xdworld_global_manual/introduce-1/core/jscolor) | optional   | JSColor(200, 255, 0, 0) | Impact range visualization color.                                 |
