API / geotoolkit / data / DataSet / DataSet
Define a set of tables to make requests, manage allocated memory, merge received data samples
Data source can contain several data tables with different data ranges. Each table has a virtual range, which usually contains a full data range on server. If method fetch is called then data set verifies if data already exists. If data does not exist then it makes request to retrieve a data range. If data set receives a new data it merges existing data table with new data and keeps a valid range. if data is not received then it marks invalid range and it can be updated the next time. In the same time data set tracks allocated memory and deallocate automatically old ranges.
Example
// How to provide data
import {Events} from '@int/geotoolkit/data/Events';
import {Range} from '@int/geotoolkit/util/Range';
...
dataset.on(Events.DataFetching, (event, sender, args) => {
const data = [[500, 600], [0.5, 0.7], [100, 200]];
args['callback'](null, [data]);
});
dataset.fetch(new Range(1000, 2000), 5);Example
// How to provide data with limits
dataset.on(Events.DataFetching, (event, sender, args) => {
const data = [[500, 600], [0.5, 0.7], [100, 200]];
args['callback'](null, { 'limits': new Range(500, 600), 'colsdata': data });
});
dataset.fetch(new Range(500, 600), 5);↳
DataSet
Constructors
Methods
Constructors
• new DataSet(options?)
Creates data set
| Name | Type | Description |
|---|---|---|
Optional options | Options | options |
DataSource.constructor
Methods
▸ addChild(data): DataSet
Add a child object
| Name | Type | Description |
|---|---|---|
data | DataObject | DataObject[] | the child data to be added |
this
▸ addTable(table, range, indexColumnName?): DataSet
Add a new data table to data set
Throws
if table is null or range is null or table has less then one column or index column is not NumericalDataSeries
| Name | Type | Description |
|---|---|---|
table | DataTable | a table to add |
range | Range | a virtual range on the server |
Optional indexColumnName | string | name of column used for Index data, index column must be NumericalDataSeries |
this
▸ beginUpdate(): DataSet
begin transaction
this
▸ cancelAllRequests(): DataSet
▸ clearAllTables(limits?): DataSet
Clear the current data
| Name | Type | Description |
|---|---|---|
Optional limits | Range | limits that has been released |
this
▸ clearChildren(): DataSet
Remove all child data
this
▸ dispose(): void
Dispose.
void
▸ enableDecimation(enabled): DataSet
Enable / disable decimation
| Name | Type | Description |
|---|---|---|
enabled | boolean | enable decimation |
this
▸ endUpdate(): DataSet
end transaction
▸ fetch(limits, scale): DataSet
Fetch data for all tables from the source. This method can modify existing data
| Name | Type | Description |
|---|---|---|
limits | Range | data range to fetch |
scale | number | current scale factor |
this
▸ Protected fetchDataRange(tables, limits, scale, callback): void
Fetch data range.
| Name | Type | Description |
|---|---|---|
tables | DataTable[] | an array of updating tables |
limits | Range | limits |
scale | number | scale |
callback | FetchCallback | callback function to return a result of query |
void
▸ fetchTable(index, limits, scale): DataSet
Fetch data table from the source. This method can modify existing data
Throws
if index is out of range
| Name | Type | Description |
|---|---|---|
index | number | index of the table |
limits | Range | data range to fetch |
scale | number | current scale factor |
this
▸ getChild(i): DataObject
Return data by index
| Name | Type | Description |
|---|---|---|
i | number | index of the data |
▸ getChildrenCount(): number
Return number of child data
number
▸ getClassName(): string
string
▸ getFullIndexRange(): Range
Return a union data range by all tables
▸ getIndexColumn(index): AbstractDataSeries<any>
Gets index column for the specified table
Throws
if index is out of range
| Name | Type | Description |
|---|---|---|
index | number | index of table |
AbstractDataSeries<any>
▸ getIndexRange(index): Range
Return data range by index
Throws
if index is out of range
| Name | Type | Description |
|---|---|---|
index | number | index of table |
data table depth or time range
▸ getIndexScale(index): number
Return data scale by index
Throws
if index is out of range
| Name | Type | Description |
|---|---|---|
index | number | index of table |
number
data table scale
▸ getNumberOfTables(): number
Returns number of tables
number
number of tables
▸ getTable(index): DataTable
Return data table by index
Throws
if index is out of range
| Name | Type | Description |
|---|---|---|
index | number | index of table |
data table
▸ hasEventListener(type, callback?): boolean
Check if a list of event listeners for this type contains this listener
| Name | Type | Description |
|---|---|---|
type | string | type of event or property |
Optional callback | Function | to be called, if null, check if any callback is registered |
boolean
▸ invalidateRange(range?, clearData?): void
Invalid a data range of all tables
| Name | Type | Description |
|---|---|---|
Optional range | Range | range to invalidate |
Optional clearData | boolean | clear rows of data table |
void
▸ invalidateTableRange(index, range?, clearData?): DataSet
Invalid a data range of the specified table
Throws
if index is out of range
| Name | Type | Description |
|---|---|---|
index | number | index of table |
Optional range | Range | range to invalidate |
Optional clearData | boolean | clear rows of data table |
this
▸ isDecimationEnabled(): boolean
Returns status if decimation is enabled
boolean
▸ isDisposed(): boolean
Returns whether this object has been disposed
boolean
▸ isSilent(): boolean
Return true if the event dispatcher doesn't notify any events
boolean
▸ needIncludeRequestLimits(): boolean
Return need to include request limits
boolean
need to include request limits
▸ needIncludeRequestRimits(): boolean
Return need to include request limits
Deprecated
since 4.2 Use needIncludeRequestLimits instead
boolean
need to include request limits
▸ notify<E>(type, source, args?): DataSet
Notify listeners
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | event types |
source | DataSet | of the event |
Optional args | EventMap[E] | arguments of the event |
this
▸ off<E>(type?, callback?): DataSet
Detach listener on event. Calling .off() with no arguments removes all attached listeners. Calling .off(type) with no callback removes all attached listeners for specific type.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
Optional type | E | type of the event |
Optional callback | (eventType: E, sender: DataSet, args: EventMap[E]) => void | function to be called |
this
▸ on<E>(type, callback): DataSet
Attach listener on event that will be called whenever the specified event is delivered to the target
If the callback function is already in the list of event listeners for this target, the function is not added a second time.
If a particular anonymous function is in the list of event listeners registered for a certain target, and then later in the code, an identical anonymous function is given in an "on" call, the second function will also be added to the list of event listeners for that target.
| Name | Type |
|---|---|
E | extends string |
| Name | Type | Description |
|---|---|---|
type | E | type of event or property |
callback | (eventType: E, sender: DataSet, args: EventMap[E]) => void | to be called |
this
▸ query(): QueryBuilder<any>
Query data object items
QueryBuilder<any>
▸ removeChild(data): DataSet
Remove child data object
| Name | Type | Description |
|---|---|---|
data | DataObject | data to be removed |
this
▸ removeTable(table?): DataSet
Remove table from data set
| Name | Type | Description |
|---|---|---|
Optional table | DataTable | table to be removed |
this
▸ removeTableAt(index): DataSet
Remove table from data set by index
Throws
if index is out of range
| Name | Type | Description |
|---|---|---|
index | number | index of the table to be removed |
this
▸ setIndexRange(index, range): DataSet
Sets data range by index
Throws
if index is out of range
| Name | Type | Description |
|---|---|---|
index | number | index of table |
range | Range | a virtual range on the server |
this
▸ setSilent(bool): DataSet
Set silent mode
| Name | Type | Description |
|---|---|---|
bool | boolean | flag to enable silent mode |
this
▸ update(): DataSet
Load a part of the data
this
▸ updateTable(index, limits, data, scale?): DataSet
Update table data
Throws
if index is out of range
Example
// How to update data with limits
const data = [[500, 600], [0.5, 0.7], [100, 200]];
dataSet.updateTableData(0, new Range(500, 600), data);| Name | Type | Description |
|---|---|---|
index | number | index of the table |
limits | Range | limits to be update |
data | number[][] | an arrays of cells |
Optional scale | number | scale to be update |
this
▸ Static getClassName(): string
string