API / geotoolkit / selection / QueryBuilder / QueryBuilder
selection.QueryBuilder.QueryBuilder
Provides search by any item in the hierarchical structure. <T> is base type for root and child elements
| Name | Type |
|---|---|
T | extends any = any |
Constructors
Methods
Constructors
• new QueryBuilder<T>(item, options?)
| Name | Type |
|---|---|
T | extends unknown = any |
| Name | Type | Description |
|---|---|---|
item | T | T[] | item to apply this query |
Optional options | Options<T> | an additional options |
Methods
▸ enumerateNodes(item, callback): void
Iterates over the children of the given item. This iterator does not support concurrent modification (the callback provided should not add/remove children)
| Name | Type | Description |
|---|---|---|
item | T | T[] | item to apply this query |
callback | (node: T, x?: QueryBuilder<any>) => void | The callback function |
void
▸ execute(callback): QueryBuilder<T>
Execute all queries
| Name | Type | Description |
|---|---|---|
callback | (item: T) => boolean | void | function called for each item that matches this query condition |
QueryBuilder<T>
▸ functions(functions): QueryBuilder<T>
Register functions
Example
import {from} from '@int/geotoolkit/selection/from';
import {Line} from '@int/geotoolkit/scene/shapes/Line';
import {Rectangle} from '@int/geotoolkit/scene/shapes/Rectangle';
from(group1)
.functions({'isLine': (node) => node instanceof Line,
'isRect': (node) => node instanceof Rectangle})
.where( 'node => isLine(node) || node => isRectangle(node)' )| Name | Type | Description |
|---|---|---|
functions | Record<string, Function> | allows to register additional functions |
QueryBuilder<T>
▸ getClassName(): string
string
▸ instanceOf<U>(cls): QueryBuilder<U>
Specify instance filter
| Name | Type |
|---|---|
U | extends unknown |
| Name | Type | Description |
|---|---|---|
cls | ClassType<U> | Constructor<U> | class type to check with |
QueryBuilder<U>
▸ select(callback): QueryBuilder<T>
Execute all queries
| Name | Type | Description |
|---|---|---|
callback | (item: T) => boolean | void | function called for each item that matches this query condition |
QueryBuilder<T>
▸ selectFirst(): T
Select the first item
T
▸ selectLast(): T
Select the last item
T
▸ selectToArray(): T[]
Select all items to array
T[]
an array of the selected items
▸ where(f): QueryBuilder<T>
Specify filter
| Name | Type | Description |
|---|---|---|
f | string | (item: T) => boolean | function or condition to provide filter of items or string to specify query |
QueryBuilder<T>
▸ Static getClassName(): string
string