[API](/solutions/geotoolkit/geotoolkit_js/apis/readme) / [geotoolkit](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit) / [selection](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.selection) / [Selector](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.selection.selector) / Selector

# Class: Selector

[selection](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.selection).[Selector](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.selection.selector).Selector

Defines node selection. This class provides the logic to do shape selection using device coordinates.<br>
It implements several algorithms to perform different types of selection:
<ul>
<li> By point: At a given point with an optional radius </li>
<li> By rect: In a given rectangle </li>
<li> By polygon: In a given arbitrary polygon </li>
<li> By ellipse: In a given arbitrary ellipse </li>
</ul>
The picking algorithm implemented in this Selector emulates 'rendering' to perform the selection and find the shape(s) at the given coordinates.<br>
Selection returns multiple objects in the current position. It can be Node or SelectedItem. SelectedItem usually is using when there is a composite object inside selected area
like chart or curve. In this case SelectedItem contains info about samples inside area.

**`Example`**

```ts
// following code show how to get the names of the selected items.
// The method 'select' returns an array of selected objects. Also it has a radius of selection. In this code is 5 pixels.
import {Selector} from '@int/geotoolkit/selection/Selector';
import {isNode} from '@int/geotoolkit/scene/Node';
const radius = 5;
const select = Selector.select(widget, pt.x, pt.y, radius).filter(isNode);
if (select == null) return;
for (let i = 0; i &lt; select.length; i++) {
console.log(select&#91;i&#93;.getName());
}
```

**`Example`**

```ts
// result can be filtered using predicates (https://www.typescriptlang.org/docs/handbook/2/narrowing.html#using-type-predicates)
// embedded predicates or any custom predicate can be used
import {isSelectedItem} from '@int/geotoolkit/selection/SelectedItem';
// after filter 'items' is SelectedItem[]
const items = Selector.select(root, point, 2).filter(isSelectedItem);
```

## Table of contents

Constructors
- [new Selector(transformation)](/solutions/geotoolkit/GeoToolkit_JS/apis/classes/geotoolkit.selection.selector.selector.md#new selector(transformation))


Methods
| [asyncSelect](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selector.selector#asyncselect) | [getTransformation](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selector.selector#gettransformation) | [select](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selector.selector#select) |
|  --- | --- | --- |
| [setTransformation](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selector.selector#settransformation) | [select](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selector.selector#select-1) |


## Contents

Constructors
#### new Selector(transformation)

• **new Selector**(`transformation?`)

Create selector

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `Optional` `transformation` | [`Transformation`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.transformation.transformation) | transformation from current node to plot (device). It is equal to node.getParent().getSceneTransform(). If a root node is used as a start node then it is not necessary to specify transformation. |


Methods
#### asyncSelect

▸ **asyncSelect**(`callback`, `root`, `rectArea`, `allowIntersection?`): `void`

Select node in the current rectangular area. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `callback` | [`SelectionCallback`](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.selection.selector#selectioncallback) | callback |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `rectArea` | [`Rect`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.rect.rect) | selection rectangle. |
| `Optional` `allowIntersection` | `boolean` | allow intersection flag |


#### Returns

`void`

▸ **asyncSelect**(`callback`, `root`, `point`, `radius?`): `void`

Select node in the current point. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `callback` | [`SelectionCallback`](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.selection.selector#selectioncallback) | callback |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `point` | [`Point`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.point.point) | selection point |
| `Optional` `radius` | `number` | selection radius |


#### Returns

`void`

▸ **asyncSelect**(`callback`, `root`, `x`, `y`, `radius?`): `void`

Select node in the current point. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `callback` | [`SelectionCallback`](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.selection.selector#selectioncallback) | callback |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `x` | `number` | x-coordinate of the selection point |
| `y` | `number` | y-coordinate of the selection point |
| `Optional` `radius` | `number` | selection radius |


#### Returns

`void`

▸ **asyncSelect**(`callback`, `root`, `point`, `halfWidth`, `halfHeight`, `allowIntersection?`): `void`

Select node in the ellipse area. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `callback` | [`SelectionCallback`](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.selection.selector#selectioncallback) | callback |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `point` | [`Point`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.point.point) | selection point |
| `halfWidth` | `number` | selection ellipse half width |
| `halfHeight` | `number` | selection ellipse half height |
| `Optional` `allowIntersection` | `boolean` | allow intersection |


#### Returns

`void`

▸ **asyncSelect**(`callback`, `root`, `xx`, `yy`, `allowIntersection?`, `evenOdd?`): `void`

Select node in the polygonal area. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `callback` | [`SelectionCallback`](/solutions/geotoolkit/geotoolkit_js/apis/modules/geotoolkit.selection.selector#selectioncallback) | callback |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `xx` | `number`[] | x-coordinates of the selection polygon |
| `yy` | `number`[] | y-coordinates of the selection polygon |
| `Optional` `allowIntersection` | `boolean` | allow intersection flag |
| `Optional` `evenOdd` | `boolean` | even odd mode |


#### Returns

`void`

#### getTransformation

▸ **getTransformation**(): [`Transformation`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.transformation.transformation)

Gets current transformation

#### Returns

[`Transformation`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.transformation.transformation)

#### select

▸ **select**(`root`, `rectArea`, `allowIntersection?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the current rectangular area. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `rectArea` | [`Rect`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.rect.rect) | selection rectangle. |
| `Optional` `allowIntersection` | `boolean` | allow intersection flag |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes

▸ **select**(`root`, `point`, `radius?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the current point. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `point` | [`Point`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.point.point) | selection point |
| `Optional` `radius` | `number` | selection radius |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes

▸ **select**(`root`, `x`, `y`, `radius?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the current point. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `x` | `number` | x-coordinate of the selection point |
| `y` | `number` | y-coordinate of the selection point |
| `Optional` `radius` | `number` | selection radius |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes

▸ **select**(`root`, `point`, `halfWidth`, `halfHeight`, `allowIntersection?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the ellipse area. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `point` | [`Point`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.point.point) | center of ellipse |
| `halfWidth` | `number` | selection ellipse half width |
| `halfHeight` | `number` | selection ellipse half height |
| `Optional` `allowIntersection` | `boolean` | allow intersection |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes

▸ **select**(`root`, `xx`, `yy`, `allowIntersection?`, `evenOdd?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the polygonal area. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `xx` | `number`[] | x-coordinates of the selection polygon |
| `yy` | `number`[] | y-coordinates of the selection polygon |
| `Optional` `allowIntersection` | `boolean` | allow intersection flag |
| `Optional` `evenOdd` | `boolean` | even odd mode |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes

#### setTransformation

▸ **setTransformation**(`transformation`): [`Selector`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selector.selector)

Sets current transformation

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `transformation` | [`Transformation`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.transformation.transformation) | transformation from current node to device |


#### Returns

[`Selector`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selector.selector)

this

#### select

▸ `Static` **select**(`root`, `rectArea`, `allowIntersection?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the current rectangular area. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `rectArea` | [`Rect`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.rect.rect) | selection rectangle. |
| `Optional` `allowIntersection` | `boolean` | allow intersection flag |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes

▸ `Static` **select**(`root`, `point`, `radius?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the current point. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `point` | [`Point`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.point.point) | selection point |
| `Optional` `radius` | `number` | selection radius |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes

▸ `Static` **select**(`root`, `x`, `y`, `radius?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the current point. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `x` | `number` | x-coordinate of the selection point |
| `y` | `number` | y-coordinate of the selection point |
| `Optional` `radius` | `number` | selection radius |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes

▸ `Static` **select**(`root`, `point`, `halfWidth`, `halfHeight`, `allowIntersection?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the current ellipse. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `point` | [`Point`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.util.point.point) | selection point |
| `halfWidth` | `number` | selection ellipse half width |
| `halfHeight` | `number` | selection ellipse half height |
| `Optional` `allowIntersection` | `boolean` | allow intersection |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes

▸ `Static` **select**(`root`, `xx`, `yy`, `allowIntersection?`, `evenOdd?`): ([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

Select node in the polygonal area. This method starts selection from the specified node.
Coordinates provided are in the parent node coordinate system or device coordinates if the node is a root.

#### Parameters

| Name  | Type  | Description  |
|  --- | --- | --- |
| `root` | [`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | node to be used for selection. |
| `xx` | `number`[] | x-coordinates of the selection polygon |
| `yy` | `number`[] | y-coordinates of the selection polygon |
| `Optional` `allowIntersection` | `boolean` | allow intersection flag |
| `Optional` `evenOdd` | `boolean` | even odd mode |


#### Returns

([`Node`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.scene.node.node) | [`SelectedItem`](/solutions/geotoolkit/geotoolkit_js/apis/classes/geotoolkit.selection.selecteditem.selecteditem)<`any`&gt;)[]

a collection of selected nodes