15832144755
2022-01-06 7b4c8991dca9cf2a809a95e239d144697d3afb56
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
import { ArcType } from "../../Source/Cesium.js";
import { Color } from "../../Source/Cesium.js";
import { DistanceDisplayCondition } from "../../Source/Cesium.js";
import { ColorMaterialProperty } from "../../Source/Cesium.js";
import { ConstantProperty } from "../../Source/Cesium.js";
import { PolylineGraphics } from "../../Source/Cesium.js";
import { ClassificationType } from "../../Source/Cesium.js";
import { ShadowMode } from "../../Source/Cesium.js";
import testDefinitionChanged from "../testDefinitionChanged.js";
import testMaterialDefinitionChanged from "../testMaterialDefinitionChanged.js";
 
describe("DataSources/PolylineGraphics", function () {
  it("creates expected instance from raw assignment and construction", function () {
    var options = {
      material: Color.BLUE,
      depthFailMaterial: Color.RED,
      positions: [],
      show: true,
      width: 1,
      clampToGround: true,
      granularity: 2,
      shadows: ShadowMode.DISABLED,
      distanceDisplayCondition: new DistanceDisplayCondition(),
      classificationType: ClassificationType.TERRAIN,
      arcType: ArcType.GEODESIC,
      zIndex: 0,
    };
 
    var polyline = new PolylineGraphics(options);
    expect(polyline.material).toBeInstanceOf(ColorMaterialProperty);
    expect(polyline.depthFailMaterial).toBeInstanceOf(ColorMaterialProperty);
    expect(polyline.positions).toBeInstanceOf(ConstantProperty);
    expect(polyline.show).toBeInstanceOf(ConstantProperty);
    expect(polyline.width).toBeInstanceOf(ConstantProperty);
    expect(polyline.clampToGround).toBeInstanceOf(ConstantProperty);
    expect(polyline.granularity).toBeInstanceOf(ConstantProperty);
    expect(polyline.shadows).toBeInstanceOf(ConstantProperty);
    expect(polyline.distanceDisplayCondition).toBeInstanceOf(ConstantProperty);
    expect(polyline.classificationType).toBeInstanceOf(ConstantProperty);
    expect(polyline.arcType).toBeInstanceOf(ConstantProperty);
    expect(polyline.zIndex).toBeInstanceOf(ConstantProperty);
 
    expect(polyline.material.color.getValue()).toEqual(options.material);
    expect(polyline.depthFailMaterial.color.getValue()).toEqual(
      options.depthFailMaterial
    );
    expect(polyline.positions.getValue()).toEqual(options.positions);
    expect(polyline.show.getValue()).toEqual(options.show);
    expect(polyline.width.getValue()).toEqual(options.width);
    expect(polyline.clampToGround.getValue()).toEqual(options.clampToGround);
    expect(polyline.granularity.getValue()).toEqual(options.granularity);
    expect(polyline.shadows.getValue()).toEqual(options.shadows);
    expect(polyline.distanceDisplayCondition.getValue()).toEqual(
      options.distanceDisplayCondition
    );
    expect(polyline.classificationType.getValue()).toEqual(
      options.classificationType
    );
    expect(polyline.arcType.getValue()).toEqual(options.arcType);
    expect(polyline.zIndex.getValue()).toEqual(options.zIndex);
  });
 
  it("merge assigns unassigned properties", function () {
    var source = new PolylineGraphics();
    source.material = new ColorMaterialProperty();
    source.depthFailMaterial = new ColorMaterialProperty();
    source.positions = new ConstantProperty();
    source.width = new ConstantProperty();
    source.show = new ConstantProperty();
    source.clampToGround = new ConstantProperty();
    source.granularity = new ConstantProperty();
    source.shadows = new ConstantProperty(ShadowMode.ENABLED);
    source.distanceDisplayCondition = new ConstantProperty(
      new DistanceDisplayCondition()
    );
    source.classificationType = new ConstantProperty(
      ClassificationType.TERRAIN
    );
    source.arcType = new ConstantProperty(ArcType.GEODESIC);
    source.zIndex = new ConstantProperty();
 
    var target = new PolylineGraphics();
    target.merge(source);
    expect(target.material).toBe(source.material);
    expect(target.depthFailMaterial).toBe(source.depthFailMaterial);
    expect(target.positions).toBe(source.positions);
    expect(target.width).toBe(source.width);
    expect(target.show).toBe(source.show);
    expect(target.clampToGround).toBe(source.clampToGround);
    expect(target.granularity).toBe(source.granularity);
    expect(target.shadows).toBe(source.shadows);
    expect(target.distanceDisplayCondition).toBe(
      source.distanceDisplayCondition
    );
    expect(target.classificationType).toBe(source.classificationType);
    expect(target.arcType).toBe(source.arcType);
    expect(target.zIndex).toBe(source.zIndex);
  });
 
  it("merge does not assign assigned properties", function () {
    var source = new PolylineGraphics();
    source.material = new ColorMaterialProperty();
    source.depthFailMaterial = new ColorMaterialProperty();
    source.positions = new ConstantProperty();
    source.width = new ConstantProperty();
    source.show = new ConstantProperty();
    source.clampToGround = new ConstantProperty();
    source.granularity = new ConstantProperty();
    source.shadows = new ConstantProperty();
    source.distanceDisplayCondition = new ConstantProperty();
    source.classificationType = new ConstantProperty();
    source.arcType = new ConstantProperty();
    source.zIndex = new ConstantProperty();
 
    var color = new ColorMaterialProperty();
    var depthFailColor = new ColorMaterialProperty();
    var positions = new ConstantProperty();
    var width = new ConstantProperty();
    var show = new ConstantProperty();
    var clampToGround = new ConstantProperty();
    var granularity = new ConstantProperty();
    var shadows = new ConstantProperty();
    var distanceDisplayCondition = new ConstantProperty();
    var classificationType = new ConstantProperty();
    var arcType = new ConstantProperty();
    var zIndex = new ConstantProperty();
 
    var target = new PolylineGraphics();
    target.material = color;
    target.depthFailMaterial = depthFailColor;
    target.positions = positions;
    target.width = width;
    target.show = show;
    target.clampToGround = clampToGround;
    target.granularity = granularity;
    target.shadows = shadows;
    target.distanceDisplayCondition = distanceDisplayCondition;
    target.classificationType = classificationType;
    target.arcType = arcType;
    target.zIndex = zIndex;
 
    target.merge(source);
    expect(target.material).toBe(color);
    expect(target.depthFailMaterial).toBe(depthFailColor);
    expect(target.positions).toBe(positions);
    expect(target.width).toBe(width);
    expect(target.show).toBe(show);
    expect(target.clampToGround).toBe(clampToGround);
    expect(target.granularity).toBe(granularity);
    expect(target.shadows).toBe(shadows);
    expect(target.distanceDisplayCondition).toBe(distanceDisplayCondition);
    expect(target.classificationType).toBe(classificationType);
    expect(target.arcType).toBe(arcType);
    expect(target.zIndex).toBe(zIndex);
  });
 
  it("clone works", function () {
    var source = new PolylineGraphics();
    source.material = new ColorMaterialProperty();
    source.depthFailMaterial = new ColorMaterialProperty();
    source.width = new ConstantProperty();
    source.positions = new ConstantProperty();
    source.show = new ConstantProperty();
    source.clampToGround = new ConstantProperty();
    source.granularity = new ConstantProperty();
    source.shadows = new ConstantProperty();
    source.distanceDisplayCondition = new ConstantProperty();
    source.classificationType = new ConstantProperty();
    source.arcType = new ConstantProperty();
    source.zIndex = new ConstantProperty();
 
    var result = source.clone();
    expect(result.material).toBe(source.material);
    expect(result.depthFailMaterial).toBe(source.depthFailMaterial);
    expect(result.positions).toBe(source.positions);
    expect(result.width).toBe(source.width);
    expect(result.show).toBe(source.show);
    expect(result.clampToGround).toBe(source.clampToGround);
    expect(result.granularity).toBe(source.granularity);
    expect(result.shadows).toBe(source.shadows);
    expect(result.distanceDisplayCondition).toBe(
      source.distanceDisplayCondition
    );
    expect(result.classificationType).toBe(source.classificationType);
    expect(result.arcType).toBe(source.arcType);
    expect(result.zIndex).toBe(source.zIndex);
  });
 
  it("merge throws if source undefined", function () {
    var target = new PolylineGraphics();
    expect(function () {
      target.merge(undefined);
    }).toThrowDeveloperError();
  });
 
  it("raises definitionChanged when a property is assigned or modified", function () {
    var property = new PolylineGraphics();
    testMaterialDefinitionChanged(property, "material", Color.RED, Color.BLUE);
    testMaterialDefinitionChanged(
      property,
      "depthFailMaterial",
      Color.RED,
      Color.BLUE
    );
    testDefinitionChanged(property, "show", true, false);
    testDefinitionChanged(property, "positions", [], []);
    testDefinitionChanged(property, "width", 3, 4);
    testDefinitionChanged(property, "clampToGround", false, true);
    testDefinitionChanged(property, "granularity", 2, 1);
    testDefinitionChanged(
      property,
      "shadows",
      ShadowMode.ENABLED,
      ShadowMode.DISABLED
    );
    testDefinitionChanged(
      property,
      "distanceDisplayCondition",
      new DistanceDisplayCondition(),
      new DistanceDisplayCondition(10.0, 20.0)
    );
    testDefinitionChanged(
      property,
      "classificationType",
      ClassificationType.TERRAIN
    );
    testDefinitionChanged(property, "arcType", ArcType.GEODESIC, ArcType.RHUMB);
    testDefinitionChanged(property, "zIndex", 20, 5);
  });
});