An observable collection of
Entity instances where each entity has a unique id.
| Name | Type | Description |
|---|---|---|
owner |
DataSource | CompositeEntityCollection | optional The data source (or composite entity collection) which created this collection. |
Members
readonly collectionChanged : Event.<EntityCollection.CollectionChangedEventCallback>
Gets the event that is fired when entities are added or removed from the collection.
The generated event is a
EntityCollection.CollectionChangedEventCallback.
Gets a globally unique identifier for this collection.
readonly owner : DataSource|CompositeEntityCollection
Gets the owner of this entity collection, ie. the data source or composite entity collection which created it.
Gets whether or not this entity collection should be
displayed. When true, each entity is only displayed if
its own show property is also true.
readonly values : Array.<Entity>
Gets the array of Entity instances in the collection.
This array should not be modified directly.
Methods
add(entity) → Entity
Add an entity to the collection.
| Name | Type | Description |
|---|---|---|
entity |
Entity | Entity.ConstructorOptions | The entity to be added. |
Returns:
The entity that was added.
Throws:
-
DeveloperError : An entity with
already exists in this collection.
addBulk(entities) → Array.<Entity>
Add multiple entities to the collection in one event window.
| Name | Type | Description |
|---|---|---|
entities |
Array.<(Entity|Entity.ConstructorOptions)> | Incoming entities. |
Returns:
Added entities in input order.
Throws:
-
DeveloperError : entities is required.
-
DeveloperError : An entity with duplicate id already exists.
Apply a caller-supplied visibility mask to the whole collection in one pass.
This is the counterpart to
EntityCollection#queryVisibilityMaskByName
and EntityCollection#queryVisibilityMaskBySql: feed either result
straight back in. The mask does not have to come from this collection's own
query surface — a semantic/embedding search, a worker, or a server can build
one — it only has to be aligned to EntityCollection#values.
When the WASM backend holds handles for every entity the mask is applied as a
single batched call; otherwise the collection falls back to setting
Entity#show, with events suspended so listeners see one update.
| Name | Type | Description |
|---|---|---|
mask |
Uint8Array |
One byte per entity, aligned to EntityCollection#values: 1 shows, 0 hides. |
Returns:
The number of entities left visible.
Throws:
-
DeveloperError : mask is required.
-
DeveloperError : mask length must equal the number of entities in the collection.
Example:
const result = viewer.entities.queryVisibilityMaskByName("starlink");
viewer.entities.applyVisibilityMask(result.mask);
computeAvailability() → TimeInterval
Computes the maximum availability of the entities in the collection.
If the collection contains a mix of infinitely available data and non-infinite data,
it will return the interval pertaining to the non-infinite data only. If all
data is infinite, an infinite interval will be returned.
Returns:
The availability of entities in the collection.
Returns true if the provided entity is in this collection, false otherwise.
| Name | Type | Description |
|---|---|---|
entity |
Entity | The entity. |
Returns:
true if the provided entity is in this collection, false otherwise.
getById(id) → Entity|undefined
Gets an entity with the specified id.
| Name | Type | Description |
|---|---|---|
id |
string | The id of the entity to retrieve. |
Returns:
The entity with the provided id or undefined if the id did not exist in the collection.
getOrCreateEntity(id) → Entity
Gets an entity with the specified id or creates it and adds it to the collection if it does not exist.
| Name | Type | Description |
|---|---|---|
id |
string | The id of the entity to retrieve or create. |
Returns:
The new or existing object.
Query entity IDs using collection-wide full-text search.
| Name | Type | Default | Description |
|---|---|---|---|
query |
string | Text query. | |
maxCount |
number |
100
|
optional Max ids to return. |
Returns:
Matching entity IDs.
Execute an arbitrary shared SQL query and extract unique entity ids from the
projected `entity_id`/`ENTITY_ID` column.
| Name | Type | Default | Description |
|---|---|---|---|
sql |
string | SQL query text. | |
maxCount |
number |
100
|
optional Max ids to return. |
Returns:
Matching entity ids.
Query entities using collection-wide full-text search.
Search spans all entity subclasses and known standards metadata fields.
| Name | Type | Default | Description |
|---|---|---|---|
query |
string | Text query. | |
maxCount |
number |
100
|
optional Max rows to return. |
Returns:
Matching rows.
Execute an arbitrary shared SQL query against the collection-wide FlatSQL
entity metadata table.
The SQL result should project `entity_id`/`ENTITY_ID` when the caller intends
to derive ids or visibility from the result.
| Name | Type | Default | Description |
|---|---|---|---|
sql |
string | SQL query text. | |
maxRows |
number |
1000
|
optional Max rows to materialize. |
Returns:
Query rows.
queryVisibilityMaskByName(query) → EntityCollection.VisibilityMaskResult
Build a visibility mask aligned to
EntityCollection#values
using collection-wide full-text search.
| Name | Type | Description |
|---|---|---|
query |
string | Text query. |
Returns:
Visibility result.
queryVisibilityMaskBySql(sql) → EntityCollection.VisibilityMaskResult
Execute an arbitrary shared SQL query and build a visibility mask from the
projected `entity_id`/`ENTITY_ID` column.
| Name | Type | Description |
|---|---|---|
sql |
string | SQL query text. |
Returns:
Visibility result.
Re-index one entity for collection-wide full-text search.
Use this after metadata-only updates that do not emit definitionChanged.
| Name | Type | Description |
|---|---|---|
entity |
Entity | The entity to re-index. |
Removes an entity from the collection.
| Name | Type | Description |
|---|---|---|
entity |
Entity | The entity to be removed. |
Returns:
true if the item was removed, false if it did not exist in the collection.
Removes all Entities from the collection.
Removes an entity with the provided id from the collection.
| Name | Type | Description |
|---|---|---|
id |
string | The id of the entity to remove. |
Returns:
true if the item was removed, false if no item with the provided id existed in the collection.
Resumes raising
EntityCollection#collectionChanged events immediately
when an item is added or removed. Any modifications made while while events were suspended
will be triggered as a single event when this function is called.
This function is reference counted and can safely be called multiple times as long as there
are corresponding calls to EntityCollection#resumeEvents.
Throws:
-
DeveloperError : resumeEvents can not be called before suspendEvents.
Prevents
EntityCollection#collectionChanged events from being raised
until a corresponding call is made to EntityCollection#resumeEvents, at which
point a single event will be raised that covers all suspended operations.
This allows for many items to be added and removed efficiently.
This function can be safely called multiple times as long as there
are corresponding calls to EntityCollection#resumeEvents.
Type Definitions
The signature of the event generated by
EntityCollection#collectionChanged.
| Name | Type | Description |
|---|---|---|
collection |
EntityCollection | The collection that triggered the event. |
added |
Array.<Entity> |
The array of Entity instances that have been added to the collection. |
removed |
Array.<Entity> |
The array of Entity instances that have been removed from the collection. |
changed |
Array.<Entity> |
The array of Entity instances that have been modified. |
A visibility result aligned to
EntityCollection#values: one byte per
entity, in the same order, where 1 means visible and 0 means hidden.
Pass one straight to EntityCollection#applyVisibilityMask to show the
result in the scene. A mask built anywhere else — a semantic/embedding search,
a server response, a worker — is equally valid as long as its length matches
`values.length`.
Properties:
| Name | Type | Description |
|---|---|---|
mask |
Uint8Array | One byte per entity, aligned to EntityCollection#values. |
visibleCount |
number | Number of entries set to 1. |