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
| import { MetadataSchema } from "../../Source/Cesium.js";
|
| describe("Scene/MetadataSchema", function () {
| it("creates schema with default values", function () {
| var schema = new MetadataSchema({});
|
| expect(schema.classes).toEqual({});
| expect(schema.enums).toEqual({});
| expect(schema.name).toBeUndefined();
| expect(schema.description).toBeUndefined();
| expect(schema.version).toBeUndefined();
| expect(schema.extras).toBeUndefined();
| });
|
| it("creates schema", function () {
| var extras = {
| description: "Extra",
| };
|
| var extensions = {
| EXT_other_extension: {},
| };
|
| var schema = new MetadataSchema({
| enums: {
| color: {
| values: [
| {
| name: "RED",
| value: 0,
| },
| {
| name: "GREEN",
| value: 1,
| },
| {
| name: "BLUE",
| value: 2,
| },
| ],
| },
| species: {
| values: [
| {
| name: "Oak",
| value: 0,
| },
| {
| name: "Pine",
| value: 1,
| },
| {
| name: "Other",
| value: -1,
| },
| ],
| },
| },
| classes: {
| city: {
| properties: {
| name: {
| componentType: "STRING",
| },
| },
| },
| neighborhood: {
| properties: {
| color: {
| componentType: "ENUM",
| enumType: "color",
| },
| coordinates: {
| type: "ARRAY",
| componentType: "FLOAT64",
| componentCount: 2,
| },
| },
| },
| tree: {
| properties: {
| species: {
| type: "ARRAY",
| componentType: "ENUM",
| enumType: "species",
| },
| height: {
| componentType: "FLOAT32",
| },
| },
| },
| },
| name: "My Schema",
| description: "My Schema Description",
| version: "3.1.0",
| extras: extras,
| extensions: extensions,
| });
|
| var cityClass = schema.classes.city;
| var neighborhoodClass = schema.classes.neighborhood;
| var treeClass = schema.classes.tree;
|
| var cityProperties = cityClass.properties;
| var neighborhoodProperties = neighborhoodClass.properties;
| var treeProperties = treeClass.properties;
|
| expect(cityClass.id).toBe("city");
| expect(neighborhoodClass.id).toBe("neighborhood");
| expect(treeClass.id).toBe("tree");
|
| expect(cityProperties.name.id).toBe("name");
| expect(neighborhoodProperties.color.enumType.id).toBe("color");
| expect(neighborhoodProperties.coordinates.id).toBe("coordinates");
| expect(treeProperties.species.enumType.id).toBe("species");
| expect(treeProperties.height.id).toBe("height");
|
| expect(schema.name).toBe("My Schema");
| expect(schema.description).toBe("My Schema Description");
| expect(schema.version).toBe("3.1.0");
|
| expect(schema.extras).toBe(extras);
| expect(schema.extensions).toBe(extensions);
| });
|
| it("constructor throws without schema", function () {
| expect(function () {
| return new MetadataSchema();
| }).toThrowDeveloperError();
| });
| });
|
|