Last updated

API / geotoolkit / selection / QueryBuilder / QueryBuilder

Class: QueryBuilder<T>

selection.QueryBuilder.QueryBuilder

Provides search by any item in the hierarchical structure. <T> is base type for root and child elements

Type parameters

NameType
Textends any = any

Table of contents

Constructors
Methods

Contents

Constructors

new QueryBuilder&lt;T&amp;gt;(item, options)

new QueryBuilder<T>(item, options?)

Type parameters

NameType
Textends unknown = any

Parameters

Name Type Description
itemT | T[]item to apply this query
Optional optionsOptions<T>an additional options
Methods

enumerateNodes

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)

Parameters

Name Type Description
itemT | T[]item to apply this query
callback(node: T, x?: QueryBuilder<any>) => voidThe callback function

Returns

void


execute

execute(callback): QueryBuilder<T>

Execute all queries

Parameters

Name Type Description
callback(item: T) => boolean | voidfunction called for each item that matches this query condition

Returns

QueryBuilder<T>


functions

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)' )

Parameters

Name Type Description
functionsRecord<string, Function>allows to register additional functions

Returns

QueryBuilder<T>


getClassName

getClassName(): string

Returns

string


instanceOf

instanceOf<U>(cls): QueryBuilder<U>

Specify instance filter

Type parameters

NameType
Uextends unknown

Parameters

Name Type Description
clsClassType<U> | Constructor<U>class type to check with

Returns

QueryBuilder<U>


select

select(callback): QueryBuilder<T>

Execute all queries

Parameters

Name Type Description
callback(item: T) => boolean | voidfunction called for each item that matches this query condition

Returns

QueryBuilder<T>


selectFirst

selectFirst(): T

Select the first item

Returns

T


selectLast

selectLast(): T

Select the last item

Returns

T


selectToArray

selectToArray(): T[]

Select all items to array

Returns

T[]

an array of the selected items


where

where(f): QueryBuilder<T>

Specify filter

Parameters

Name Type Description
fstring | (item: T) => booleanfunction or condition to provide filter of items or string to specify query

Returns

QueryBuilder<T>


getClassName

Static getClassName(): string

Returns

string