/
DynamicModel.js
113 lines (106 loc) · 3.63 KB
/
DynamicModel.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
/*global define*/
define([
'../Core/defaultValue',
'../Core/defined',
'../Core/defineProperties',
'../Core/DeveloperError',
'../Core/Event',
'./createDynamicPropertyDescriptor'
], function(
defaultValue,
defined,
defineProperties,
DeveloperError,
Event,
createDynamicPropertyDescriptor) {
"use strict";
/**
* An optionally time-dynamic model.
*
* @alias DynamicModel
* @constructor
*/
var DynamicModel = function() {
this._show = undefined;
this._showSubscription = undefined;
this._scale = undefined;
this._scaleSubscription = undefined;
this._minimumPixelSize = undefined;
this._minimumPixelSizeSubscription = undefined;
this._uri = undefined;
this._uriSubscription = undefined;
this._definitionChanged = new Event();
};
defineProperties(DynamicModel.prototype, {
/**
* Gets the event that is raised whenever a new property is assigned.
* @memberof DynamicPolygon.prototype
* @type {Event}
*/
definitionChanged : {
get : function() {
return this._definitionChanged;
}
},
/**
* Gets or sets the boolean {@link Property} specifying the model's visibility.
* @memberof DynamicModel.prototype
* @type {Property}
*/
show : createDynamicPropertyDescriptor('show'),
/**
* Gets or sets the Number {@link Property} specifying the model's scale.
* @memberof DynamicModel.prototype
* @type {Property}
*/
scale : createDynamicPropertyDescriptor('scale'),
/**
* Gets or sets the Number {@link Property} specifying the model's approximate minimum pixel size regardless of zoom.
* @memberof DynamicModel.prototype
* @type {Property}
*/
minimumPixelSize : createDynamicPropertyDescriptor('minimumPixelSize'),
/**
* Gets or sets the string {@link Property} specifying the model's uri.
* @memberof DynamicModel.prototype
* @type {Property}
*/
uri : createDynamicPropertyDescriptor('uri')
});
/**
* Duplicates a DynamicModel instance.
* @memberof DynamicModel
*
* @param {DynamicModel} [result] The object onto which to store the result.
* @returns {DynamicModel} The modified result parameter or a new instance if one was not provided.
*/
DynamicModel.prototype.clone = function(result) {
if (!defined(result)) {
result = new DynamicModel();
}
result.show = this.show;
result.scale = this.scale;
result.minimumPixelSize = this.minimumPixelSize;
result.uri = this.uri;
return result;
};
/**
* Assigns each unassigned property on this object to the value
* of the same property on the provided source object.
* @memberof DynamicModel
*
* @param {DynamicModel} source The object to be merged into this object.
*/
DynamicModel.prototype.merge = function(source) {
//>>includeStart('debug', pragmas.debug);
if (!defined(source)) {
throw new DeveloperError('source is required.');
}
//>>includeEnd('debug');
this.show = defaultValue(this.show, source.show);
this.scale = defaultValue(this.scale, source.scale);
this.minimumPixelSize = defaultValue(this.minimumPixelSize, source.minimumPixelSize);
this.uri = defaultValue(this.uri, source.uri);
};
return DynamicModel;
});