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
import { Color } from "../../Source/Cesium.js";
import { DistanceDisplayCondition } from "../../Source/Cesium.js";
import { NearFarScalar } from "../../Source/Cesium.js";
import { ConstantProperty } from "../../Source/Cesium.js";
import { PointGraphics } from "../../Source/Cesium.js";
import { HeightReference } from "../../Source/Cesium.js";
 
describe("DataSources/PointGraphics", function () {
  it("creates expected instance from raw assignment and construction", function () {
    var options = {
      color: Color.RED,
      pixelSize: 1,
      outlineColor: Color.BLUE,
      outlineWidth: 2,
      show: false,
      scaleByDistance: new NearFarScalar(3, 4, 5, 6),
      heightReference: HeightReference.RELATIVE_TO_GROUND,
      distanceDisplayCondition: new DistanceDisplayCondition(10.0, 100.0),
      disableDepthTestDistance: 10.0,
    };
 
    var point = new PointGraphics(options);
    expect(point.color).toBeInstanceOf(ConstantProperty);
    expect(point.pixelSize).toBeInstanceOf(ConstantProperty);
    expect(point.outlineColor).toBeInstanceOf(ConstantProperty);
    expect(point.outlineWidth).toBeInstanceOf(ConstantProperty);
    expect(point.show).toBeInstanceOf(ConstantProperty);
    expect(point.scaleByDistance).toBeInstanceOf(ConstantProperty);
    expect(point.heightReference).toBeInstanceOf(ConstantProperty);
    expect(point.distanceDisplayCondition).toBeInstanceOf(ConstantProperty);
    expect(point.disableDepthTestDistance).toBeInstanceOf(ConstantProperty);
 
    expect(point.color.getValue()).toEqual(options.color);
    expect(point.pixelSize.getValue()).toEqual(options.pixelSize);
    expect(point.outlineColor.getValue()).toEqual(options.outlineColor);
    expect(point.outlineWidth.getValue()).toEqual(options.outlineWidth);
    expect(point.show.getValue()).toEqual(options.show);
    expect(point.scaleByDistance.getValue()).toEqual(options.scaleByDistance);
    expect(point.heightReference.getValue()).toEqual(options.heightReference);
    expect(point.distanceDisplayCondition.getValue()).toEqual(
      options.distanceDisplayCondition
    );
    expect(point.disableDepthTestDistance.getValue()).toEqual(
      options.disableDepthTestDistance
    );
  });
 
  it("merge assigns unassigned properties", function () {
    var source = new PointGraphics();
    source.color = new ConstantProperty(Color.WHITE);
    source.pixelSize = new ConstantProperty(1);
    source.outlineColor = new ConstantProperty(Color.WHITE);
    source.outlineWidth = new ConstantProperty(1);
    source.show = new ConstantProperty(true);
    source.scaleByDistance = new ConstantProperty(new NearFarScalar());
    source.heightReference = new ConstantProperty(
      HeightReference.RELATIVE_TO_GROUND
    );
    source.distanceDisplayCondition = new ConstantProperty(
      new DistanceDisplayCondition(10.0, 100.0)
    );
    source.disableDepthTestDistance = new ConstantProperty(10.0);
 
    var target = new PointGraphics();
    target.merge(source);
    expect(target.color).toBe(source.color);
    expect(target.pixelSize).toBe(source.pixelSize);
    expect(target.outlineColor).toBe(source.outlineColor);
    expect(target.outlineWidth).toBe(source.outlineWidth);
    expect(target.show).toBe(source.show);
    expect(target.scaleByDistance).toBe(source.scaleByDistance);
    expect(target.heightReference).toBe(source.heightReference);
    expect(target.distanceDisplayCondition).toBe(
      source.distanceDisplayCondition
    );
    expect(target.disableDepthTestDistance).toBe(
      source.disableDepthTestDistance
    );
  });
 
  it("merge does not assign assigned properties", function () {
    var source = new PointGraphics();
    source.color = new ConstantProperty(Color.WHITE);
    source.pixelSize = new ConstantProperty(1);
    source.outlineColor = new ConstantProperty(Color.WHITE);
    source.outlineWidth = new ConstantProperty(1);
    source.show = new ConstantProperty(true);
    source.scaleByDistance = new ConstantProperty(new NearFarScalar());
    source.heightReference = new ConstantProperty(
      HeightReference.RELATIVE_TO_GROUND
    );
    source.distanceDisplayCondition = new ConstantProperty(
      new DistanceDisplayCondition(10.0, 100.0)
    );
    source.disableDepthTestDistance = new ConstantProperty(10.0);
 
    var color = new ConstantProperty(Color.WHITE);
    var pixelSize = new ConstantProperty(1);
    var outlineColor = new ConstantProperty(Color.WHITE);
    var outlineWidth = new ConstantProperty(1);
    var show = new ConstantProperty(true);
    var heightReference = new ConstantProperty(HeightReference.CLAMP_TO_GROUND);
    var distanDisplayCondition = new ConstantProperty(
      new DistanceDisplayCondition(10.0, 100.0)
    );
    var disableDepthTestDistance = new ConstantProperty(20.0);
 
    var target = new PointGraphics();
    target.color = color;
    target.pixelSize = pixelSize;
    target.outlineColor = outlineColor;
    target.outlineWidth = outlineWidth;
    target.show = show;
    target.scaleByDistance = show;
    target.heightReference = heightReference;
    target.distanceDisplayCondition = distanDisplayCondition;
    target.disableDepthTestDistance = disableDepthTestDistance;
 
    target.merge(source);
    expect(target.color).toBe(color);
    expect(target.pixelSize).toBe(pixelSize);
    expect(target.outlineColor).toBe(outlineColor);
    expect(target.outlineWidth).toBe(outlineWidth);
    expect(target.show).toBe(show);
    expect(target.scaleByDistance).toBe(show);
    expect(target.heightReference).toBe(heightReference);
    expect(target.distanceDisplayCondition).toBe(distanDisplayCondition);
    expect(target.disableDepthTestDistance).toBe(disableDepthTestDistance);
  });
 
  it("clone works", function () {
    var source = new PointGraphics();
    source.color = new ConstantProperty(Color.WHITE);
    source.pixelSize = new ConstantProperty(1);
    source.outlineColor = new ConstantProperty(Color.WHITE);
    source.outlineWidth = new ConstantProperty(1);
    source.show = new ConstantProperty(true);
    source.scaleByDistance = new ConstantProperty(new NearFarScalar());
    source.heightReference = new ConstantProperty(
      HeightReference.RELATIVE_TO_GROUND
    );
    source.distanceDisplayCondition = new ConstantProperty(
      new DistanceDisplayCondition(10.0, 100.0)
    );
    source.disableDepthTestDistance = new ConstantProperty(10.0);
 
    var result = source.clone();
    expect(result.color).toBe(source.color);
    expect(result.pixelSize).toBe(source.pixelSize);
    expect(result.outlineColor).toBe(source.outlineColor);
    expect(result.outlineWidth).toBe(source.outlineWidth);
    expect(result.show).toBe(source.show);
    expect(result.scaleByDistance).toBe(source.scaleByDistance);
    expect(result.heightReference).toBe(source.heightReference);
    expect(result.distanceDisplayCondition).toBe(
      source.distanceDisplayCondition
    );
    expect(result.disableDepthTestDistance).toBe(
      source.disableDepthTestDistance
    );
  });
 
  it("merge throws if source undefined", function () {
    var target = new PointGraphics();
    expect(function () {
      target.merge(undefined);
    }).toThrowDeveloperError();
  });
});