@@ -12,11 +12,11 @@ BEGIN_DEFINE_SPEC(
1212END_DEFINE_SPEC(FCesiumVectorDocumentSpec)
1313
1414void FCesiumVectorDocumentSpec::Define() {
15- Describe (" UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString" , [this ]() {
15+ Describe (" UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString" , [this ]() {
1616 It (" loads a valid GeoJSON document" , [this ]() {
1717 FCesiumGeoJsonDocument Document;
1818 const bool bSuccess =
19- UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
19+ UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
2020 R"==( { "type": "Point", "coordinates": [1, 2, 3] })==" ,
2121 Document);
2222 TestTrue (" LoadGeoJsonFromString Success" , bSuccess);
@@ -26,102 +26,112 @@ void FCesiumVectorDocumentSpec::Define() {
2626 " Errors while loading GeoJSON from string:\n - Failed to parse GeoJSON: Missing a name for object member." );
2727 FCesiumGeoJsonDocument Document;
2828 bool bSuccess =
29- UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
29+ UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
3030 R"==( { type: "Point", coordinates: [1, 2, 3] })==" ,
3131 Document);
3232 TestFalse (" LoadGeoJsonFromString Success" , bSuccess);
3333 AddExpectedError (
3434 " Errors while loading GeoJSON from string:\n - Unknown GeoJSON object type: 'Invalid'" );
35- bSuccess = UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
35+ bSuccess = UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
3636 R"==( { "type": "Invalid", "coordinates": [] })==" ,
3737 Document);
3838 TestFalse (" LoadGeoJsonFromString Success" , bSuccess);
3939 AddExpectedError (
4040 " Errors while loading GeoJSON from string:\n - Failed to parse GeoJSON: Invalid value." );
41- bSuccess = UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
41+ bSuccess = UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
4242 R"==( <some_xml_idk />)==" ,
4343 Document);
4444 TestFalse (" LoadGeoJsonFromString Success" , bSuccess);
4545 });
4646 });
4747
48- Describe (" UCesiumVectorNodeBlueprintLibrary ::GetIdAsInteger" , [this ]() {
48+ Describe (" UCesiumGeoJsonFeatureBlueprintLibrary ::GetIdAsInteger" , [this ]() {
4949 It (" correctly interprets an integer ID" , [this ]() {
5050 FCesiumGeoJsonDocument Document;
5151 TestTrue (
5252 " LoadGeoJsonFromString Success" ,
53- UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
53+ UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
5454 R"==( { "type": "Feature", "id": 10, "geometry": null, "properties": null })==" ,
5555 Document));
5656 TestEqual (
5757 " GetIdAsInteger" ,
58- UCesiumVectorNodeBlueprintLibrary::GetIdAsInteger (
59- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document)),
58+ UCesiumGeoJsonFeatureBlueprintLibrary::GetIdAsInteger (
59+ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsFeature (
60+ UCesiumGeoJsonDocumentBlueprintLibrary::GetRootObject (
61+ Document))),
6062 10 );
6163 });
6264 It (" returns -1 when the ID is missing" , [this ]() {
6365 FCesiumGeoJsonDocument Document;
6466 TestTrue (
6567 " LoadGeoJsonFromString Success" ,
66- UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
68+ UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
6769 R"==( { "type": "Feature", "geometry": null, "properties": null })==" ,
6870 Document));
6971 TestEqual (
7072 " GetIdAsInteger" ,
71- UCesiumVectorNodeBlueprintLibrary::GetIdAsInteger (
72- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document)),
73+ UCesiumGeoJsonFeatureBlueprintLibrary::GetIdAsInteger (
74+ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsFeature (
75+ UCesiumGeoJsonDocumentBlueprintLibrary::GetRootObject (
76+ Document))),
7377 -1 );
7478 });
7579 });
7680
77- Describe (" UCesiumVectorNodeBlueprintLibrary ::GetIdAsString" , [this ]() {
81+ Describe (" UCesiumGeoJsonFeatureBlueprintLibrary ::GetIdAsString" , [this ]() {
7882 It (" correctly interprets a string ID" , [this ]() {
7983 FCesiumGeoJsonDocument Document;
8084 TestTrue (
8185 " LoadGeoJsonFromString Success" ,
82- UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
86+ UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
8387 R"==( { "type": "Feature", "id": "test", "geometry": null, "properties": null })==" ,
8488 Document));
8589 TestEqual (
8690 " GetIdAsString" ,
87- UCesiumVectorNodeBlueprintLibrary::GetIdAsString (
88- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document)),
91+ UCesiumGeoJsonFeatureBlueprintLibrary::GetIdAsString (
92+ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsFeature (
93+ UCesiumGeoJsonDocumentBlueprintLibrary::GetRootObject (
94+ Document))),
8995 " test" );
9096 });
9197 It (" stringifies an integer ID" , [this ]() {
9298 FCesiumGeoJsonDocument Document;
9399 TestTrue (
94100 " LoadGeoJsonFromString Success" ,
95- UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
101+ UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
96102 R"==( { "type": "Feature", "id": 10, "geometry": null, "properties": null })==" ,
97103 Document));
98104 TestEqual (
99105 " GetIdAsString" ,
100- UCesiumVectorNodeBlueprintLibrary::GetIdAsString (
101- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document)),
106+ UCesiumGeoJsonFeatureBlueprintLibrary::GetIdAsString (
107+ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsFeature (
108+ UCesiumGeoJsonDocumentBlueprintLibrary::GetRootObject (
109+ Document))),
102110 " 10" );
103111 });
104112 It (" returns an empty string when the ID is missing" , [this ]() {
105113 FCesiumGeoJsonDocument Document;
106114 TestTrue (
107115 " LoadGeoJsonFromString Success" ,
108- UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
116+ UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
109117 R"==( { "type": "Feature", "geometry": null, "properties": null })==" ,
110118 Document));
111119 TestEqual (
112120 " GetIdAsString" ,
113- UCesiumVectorNodeBlueprintLibrary::GetIdAsString (
114- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document)),
121+ UCesiumGeoJsonFeatureBlueprintLibrary::GetIdAsString (
122+ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsFeature (
123+ UCesiumGeoJsonDocumentBlueprintLibrary::GetRootObject (
124+ Document))),
115125 " " );
116126 });
117127 });
118128
119- Describe (" UCesiumVectorNodeBlueprintLibrary ::GetChildren" , [this ]() {
129+ Describe (" UCesiumGeoJsonFeatureBlueprintLibrary ::GetChildren" , [this ]() {
120130 It (" returns an array of children" , [this ]() {
121131 FCesiumGeoJsonDocument Document;
122132 TestTrue (
123133 " LoadGeoJsonFromString Success" ,
124- UCesiumVectorDocumentBlueprintLibrary ::LoadGeoJsonFromString (
134+ UCesiumGeoJsonDocumentBlueprintLibrary ::LoadGeoJsonFromString (
125135 R"==( {
126136 "type": "FeatureCollection",
127137 "features": [
@@ -130,193 +140,18 @@ void FCesiumVectorDocumentSpec::Define() {
130140 ]
131141 })==" ,
132142 Document));
133- TArray<FCesiumGeoJsonObject > Children =
134- UCesiumVectorNodeBlueprintLibrary::GetChildren (
135- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document));
143+ TArray<FCesiumGeoJsonFeature > Children =
144+ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsFeatureCollection (
145+ UCesiumGeoJsonDocumentBlueprintLibrary::GetRootObject (Document));
136146 TestEqual (" Children.Num()" , Children.Num (), 2 );
137147 TestEqual (
138148 " Children[0] Id" ,
139- UCesiumVectorNodeBlueprintLibrary ::GetIdAsString (Children[0 ]),
149+ UCesiumGeoJsonFeatureBlueprintLibrary ::GetIdAsString (Children[0 ]),
140150 " test" );
141151 TestEqual (
142152 " Children[1] Id" ,
143- UCesiumVectorNodeBlueprintLibrary ::GetIdAsString (Children[1 ]),
153+ UCesiumGeoJsonFeatureBlueprintLibrary ::GetIdAsString (Children[1 ]),
144154 " test2" );
145155 });
146156 });
147-
148- Describe (" UCesiumVectorNodeBlueprintLibrary::GetPrimitives" , [this ]() {
149- It (" returns an array of primitives" , [this ]() {
150- FCesiumGeoJsonDocument Document;
151- TestTrue (
152- " LoadGeoJsonFromString Success" ,
153- UCesiumVectorDocumentBlueprintLibrary::LoadGeoJsonFromString (
154- R"==( {
155- "type": "MultiPoint",
156- "coordinates": [
157- [ 1, 2, 3 ],
158- [ 4, 5, 6 ]
159- ]
160- })==" ,
161- Document));
162- TArray<FCesiumVectorPrimitive> Primitives =
163- UCesiumVectorNodeBlueprintLibrary::GetPrimitives (
164- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document));
165- TestEqual (" Primitives.Num()" , Primitives.Num (), 2 );
166- TestEqual (
167- " Primitives[0] as point" ,
168- UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsPoint (
169- Primitives[0 ]),
170- FVector (1 , 2 , 3 ));
171- TestEqual (
172- " Primitives[1] as point" ,
173- UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsPoint (
174- Primitives[1 ]),
175- FVector (4 , 5 , 6 ));
176- });
177- });
178-
179- Describe (
180- " UCesiumVectorNodeBlueprintLibrary::GetPrimitivesOfTypeRecursively" ,
181- [this ]() {
182- It (" returns all primitives of a given type in the document" , [this ]() {
183- FCesiumGeoJsonDocument Document;
184- TestTrue (
185- " LoadGeoJsonFromString Success" ,
186- UCesiumVectorDocumentBlueprintLibrary::LoadGeoJsonFromString (
187- R"==( {
188- "type": "GeometryCollection",
189- "geometries": [
190- {
191- "type": "GeometryCollection",
192- "geometries": [
193- { "type": "Point", "coordinates": [ -2, -1, 0 ] }
194- ]
195- },
196- { "type": "Point", "coordinates": [ 1, 2, 3 ] },
197- { "type": "LineString", "coordinates": [ [ 1, 2, 3 ], [ 4, 5, 6 ] ] },
198- { "type": "Point", "coordinates": [ 7, 8, 9 ] }
199- ]
200- })==" ,
201- Document));
202- TArray<FCesiumVectorPrimitive> Primitives =
203- UCesiumVectorNodeBlueprintLibrary::GetPrimitivesOfTypeRecursively (
204- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document),
205- ECesiumGeoJsonGeometryType::Point);
206- TestEqual (" Primitives.Num()" , Primitives.Num (), 3 );
207- TestEqual (
208- " Primitives[0] as point" ,
209- UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsPoint (
210- Primitives[0 ]),
211- FVector (-2 , -1 , 0 ));
212- TestEqual (
213- " Primitives[0] as point" ,
214- UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsPoint (
215- Primitives[1 ]),
216- FVector (1 , 2 , 3 ));
217- TestEqual (
218- " Primitives[1] as point" ,
219- UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsPoint (
220- Primitives[2 ]),
221- FVector (7 , 8 , 9 ));
222- });
223- });
224-
225- Describe (" UCesiumVectorNodeBlueprintLibrary::FindNodeByStringId" , [this ]() {
226- It (" obtains a node with the given ID" , [this ]() {
227- FCesiumGeoJsonDocument Document;
228- TestTrue (
229- " LoadGeoJsonFromString Success" ,
230- UCesiumVectorDocumentBlueprintLibrary::LoadGeoJsonFromString (
231- R"==( {
232- "type": "FeatureCollection",
233- "features": [
234- { "type": "Feature", "id": "test1", "geometry": null, "properties": null },
235- { "type": "Feature", "id": "test2", "geometry": null, "properties": null },
236- { "type": "Feature", "id": "test3", "geometry": null, "properties": null },
237- {
238- "type": "Feature",
239- "id": "test4",
240- "geometry": {
241- "type": "Point",
242- "coordinates": [ 1, 2, 3 ]
243- },
244- "properties": null
245- },
246- { "type": "Feature", "id": "test5", "geometry": null, "properties": null },
247- { "type": "Feature", "id": "test6", "geometry": null, "properties": null }
248- ]
249- })==" ,
250- Document));
251- FCesiumGeoJsonObject Node;
252- TestTrue (
253- " FindNodeByStringId Success" ,
254- UCesiumVectorNodeBlueprintLibrary::FindNodeByStringId (
255- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document),
256- " test4" ,
257- Node));
258- TestEqual (
259- " Node.Id" ,
260- UCesiumVectorNodeBlueprintLibrary::GetIdAsString (Node),
261- " test4" );
262- TArray<FCesiumVectorPrimitive> Primitives =
263- UCesiumVectorNodeBlueprintLibrary::GetPrimitives (
264- UCesiumVectorNodeBlueprintLibrary::GetChildren (Node)[0 ]);
265- TestEqual (" Primitives.Num()" , Primitives.Num (), 1 );
266- TestEqual (
267- " Primitives[0] as point" ,
268- UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsPoint (
269- Primitives[0 ]),
270- FVector (1 , 2 , 3 ));
271- });
272- });
273-
274- Describe (" UCesiumVectorNodeBlueprintLibrary::FindNodeByIntId" , [this ]() {
275- It (" obtains a node with the given ID" , [this ]() {
276- FCesiumGeoJsonDocument Document;
277- TestTrue (
278- " LoadGeoJsonFromString Success" ,
279- UCesiumVectorDocumentBlueprintLibrary::LoadGeoJsonFromString (
280- R"==( {
281- "type": "FeatureCollection",
282- "features": [
283- { "type": "Feature", "id": 1, "geometry": null, "properties": null },
284- { "type": "Feature", "id": 2, "geometry": null, "properties": null },
285- { "type": "Feature", "id": 3, "geometry": null, "properties": null },
286- {
287- "type": "Feature",
288- "id": 4,
289- "geometry": {
290- "type": "Point",
291- "coordinates": [ 1, 2, 3 ]
292- },
293- "properties": null
294- },
295- { "type": "Feature", "id": 5, "geometry": null, "properties": null },
296- { "type": "Feature", "id": 6, "geometry": null, "properties": null }
297- ]
298- })==" ,
299- Document));
300- FCesiumGeoJsonObject Node;
301- TestTrue (
302- " FindNodeByStringId Success" ,
303- UCesiumVectorNodeBlueprintLibrary::FindNodeByIntId (
304- UCesiumVectorDocumentBlueprintLibrary::GetRootNode (Document),
305- 4 ,
306- Node));
307- TestEqual (
308- " Node.Id" ,
309- UCesiumVectorNodeBlueprintLibrary::GetIdAsInteger (Node),
310- 4 );
311- TArray<FCesiumVectorPrimitive> Primitives =
312- UCesiumVectorNodeBlueprintLibrary::GetPrimitives (
313- UCesiumVectorNodeBlueprintLibrary::GetChildren (Node)[0 ]);
314- TestEqual (" Primitives.Num()" , Primitives.Num (), 1 );
315- TestEqual (
316- " Primitives[0] as point" ,
317- UCesiumVectorPrimitiveBlueprintLibrary::GetPrimitiveAsPoint (
318- Primitives[0 ]),
319- FVector (1 , 2 , 3 ));
320- });
321- });
322157}
0 commit comments