/
DataSource.js
121 lines (116 loc) · 3.38 KB
/
DataSource.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import DeveloperError from "../Core/DeveloperError.js";
/**
* Defines the interface for data sources, which turn arbitrary data into a
* {@link EntityCollection} for generic consumption. This object is an interface
* for documentation purposes and is not intended to be instantiated directly.
* @alias DataSource
* @constructor
*
* @see Entity
* @see DataSourceDisplay
*/
function DataSource() {
DeveloperError.throwInstantiationError();
}
Object.defineProperties(DataSource.prototype, {
/**
* Gets a human-readable name for this instance.
* @memberof DataSource.prototype
* @type {string}
*/
name: {
get: DeveloperError.throwInstantiationError,
},
/**
* Gets the preferred clock settings for this data source.
* @memberof DataSource.prototype
* @type {DataSourceClock}
*/
clock: {
get: DeveloperError.throwInstantiationError,
},
/**
* Gets the collection of {@link Entity} instances.
* @memberof DataSource.prototype
* @type {EntityCollection}
*/
entities: {
get: DeveloperError.throwInstantiationError,
},
/**
* Gets a value indicating if the data source is currently loading data.
* @memberof DataSource.prototype
* @type {boolean}
*/
isLoading: {
get: DeveloperError.throwInstantiationError,
},
/**
* Gets an event that will be raised when the underlying data changes.
* @memberof DataSource.prototype
* @type {Event}
*/
changedEvent: {
get: DeveloperError.throwInstantiationError,
},
/**
* Gets an event that will be raised if an error is encountered during processing.
* @memberof DataSource.prototype
* @type {Event<function(this, RequestErrorEvent)>}
*/
errorEvent: {
get: DeveloperError.throwInstantiationError,
},
/**
* Gets an event that will be raised when the value of isLoading changes.
* @memberof DataSource.prototype
* @type {Event<function(this, boolean)>}
*/
loadingEvent: {
get: DeveloperError.throwInstantiationError,
},
/**
* Gets whether or not this data source should be displayed.
* @memberof DataSource.prototype
* @type {boolean}
*/
show: {
get: DeveloperError.throwInstantiationError,
},
/**
* Gets or sets the clustering options for this data source. This object can be shared between multiple data sources.
*
* @memberof DataSource.prototype
* @type {EntityCluster}
*/
clustering: {
get: DeveloperError.throwInstantiationError,
},
});
/**
* Updates the data source to the provided time. This function is optional and
* is not required to be implemented. It is provided for data sources which
* retrieve data based on the current animation time or scene state.
* If implemented, update will be called by {@link DataSourceDisplay} once a frame.
*
* @param {JulianDate} time The simulation time.
* @returns {boolean} True if this data source is ready to be displayed at the provided time, false otherwise.
*/
DataSource.prototype.update = function (time) {
DeveloperError.throwInstantiationError();
};
/**
* @private
*/
DataSource.setLoading = function (dataSource, isLoading) {
if (dataSource._isLoading !== isLoading) {
if (isLoading) {
dataSource._entityCollection.suspendEvents();
} else {
dataSource._entityCollection.resumeEvents();
}
dataSource._isLoading = isLoading;
dataSource._loading.raiseEvent(dataSource, isLoading);
}
};
export default DataSource;