11#include " CesiumGeoJsonObject.h"
22
33#include " CesiumGeospatial/Cartographic.h"
4- #include " CesiumGeospatial/CompositeCartographicPolygon.h"
54#include " Dom/JsonObject.h"
65
76#include < utility>
@@ -119,53 +118,49 @@ bool UCesiumGeoJsonFeatureBlueprintLibrary::IsValid(
119118
120119bool UCesiumGeoJsonObjectBlueprintLibrary::IsValid (
121120 const FCesiumGeoJsonObject& InObject) {
122- return InObject._document != nullptr && InObject._object != nullptr ;
121+ return InObject._pDocument != nullptr && InObject._pObject != nullptr ;
123122}
124123
125124ECesiumGeoJsonObjectType UCesiumGeoJsonObjectBlueprintLibrary::GetObjectType (
126125 const FCesiumGeoJsonObject& InObject) {
127- if (!InObject._document || !InObject._object ) {
126+ if (!InObject._pDocument || !InObject._pObject ) {
128127 return {};
129128 }
130129
131- return (ECesiumGeoJsonObjectType)InObject._object ->getType ();
130+ return (ECesiumGeoJsonObjectType)InObject._pObject ->getType ();
132131}
133132
134133namespace {
135- FVector
136- cartographicToVector (const CesiumGeospatial::Cartographic& coordinates) {
137- return FVector (
138- CesiumUtility::Math::radiansToDegrees (coordinates.longitude ),
139- CesiumUtility::Math::radiansToDegrees (coordinates.latitude ),
140- coordinates.height );
134+ FVector degreesToVector (const glm::dvec3& coordinates) {
135+ return FVector (coordinates.x , coordinates.y , coordinates.z );
141136}
142137} // namespace
143138
144139FVector UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsPoint (
145140 const FCesiumGeoJsonObject& InObject) {
146- if (!InObject._document || !InObject._object ) {
141+ if (!InObject._pDocument || !InObject._pObject ) {
147142 return {};
148143 }
149144
150145 const CesiumVectorData::GeoJsonPoint* pPoint =
151- std::get_if<CesiumVectorData::GeoJsonPoint>(&InObject._object ->value );
146+ std::get_if<CesiumVectorData::GeoJsonPoint>(&InObject._pObject ->value );
152147
153148 if (!pPoint) {
154149 return FVector::ZeroVector;
155150 }
156151
157- return cartographicToVector (pPoint->coordinates );
152+ return degreesToVector (pPoint->coordinates );
158153}
159154
160155TArray<FVector> UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsMultiPoint (
161156 const FCesiumGeoJsonObject& InObject) {
162- if (!InObject._document || !InObject._object ) {
157+ if (!InObject._pDocument || !InObject._pObject ) {
163158 return {};
164159 }
165160
166161 const CesiumVectorData::GeoJsonMultiPoint* pMultiPoint =
167162 std::get_if<CesiumVectorData::GeoJsonMultiPoint>(
168- &InObject._object ->value );
163+ &InObject._pObject ->value );
169164
170165 if (!pMultiPoint) {
171166 return TArray<FVector>();
@@ -175,7 +170,7 @@ TArray<FVector> UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsMultiPoint(
175170 Points.Reserve (pMultiPoint->coordinates .size ());
176171
177172 for (size_t i = 0 ; i < pMultiPoint->coordinates .size (); i++) {
178- Points.Emplace (cartographicToVector (pMultiPoint->coordinates [i]));
173+ Points.Emplace (degreesToVector (pMultiPoint->coordinates [i]));
179174 }
180175
181176 return Points;
@@ -184,13 +179,13 @@ TArray<FVector> UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsMultiPoint(
184179FCesiumGeoJsonLineString
185180UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsLineString (
186181 const FCesiumGeoJsonObject& InObject) {
187- if (!InObject._document || !InObject._object ) {
182+ if (!InObject._pDocument || !InObject._pObject ) {
188183 return {};
189184 }
190185
191186 const CesiumVectorData::GeoJsonLineString* pLineString =
192187 std::get_if<CesiumVectorData::GeoJsonLineString>(
193- &InObject._object ->value );
188+ &InObject._pObject ->value );
194189
195190 if (!pLineString) {
196191 return TArray<FVector>();
@@ -200,7 +195,7 @@ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsLineString(
200195 Points.Reserve (pLineString->coordinates .size ());
201196
202197 for (size_t i = 0 ; i < pLineString->coordinates .size (); i++) {
203- Points.Emplace (cartographicToVector (pLineString->coordinates [i]));
198+ Points.Emplace (degreesToVector (pLineString->coordinates [i]));
204199 }
205200
206201 return FCesiumGeoJsonLineString (MoveTemp (Points));
@@ -209,13 +204,13 @@ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsLineString(
209204TArray<FCesiumGeoJsonLineString>
210205UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsMultiLineString (
211206 const FCesiumGeoJsonObject& InObject) {
212- if (!InObject._document || !InObject._object ) {
207+ if (!InObject._pDocument || !InObject._pObject ) {
213208 return {};
214209 }
215210
216211 const CesiumVectorData::GeoJsonMultiLineString* pMultiLineString =
217212 std::get_if<CesiumVectorData::GeoJsonMultiLineString>(
218- &InObject._object ->value );
213+ &InObject._pObject ->value );
219214
220215 if (!pMultiLineString) {
221216 return TArray<FCesiumGeoJsonLineString>();
@@ -229,7 +224,7 @@ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsMultiLineString(
229224 Points.Reserve (pMultiLineString->coordinates [i].size ());
230225
231226 for (size_t j = 0 ; j < pMultiLineString->coordinates [i].size (); j++) {
232- Points.Emplace (cartographicToVector (pMultiLineString->coordinates [i][j]));
227+ Points.Emplace (degreesToVector (pMultiLineString->coordinates [i][j]));
233228 }
234229
235230 Lines.Emplace (MoveTemp (Points));
@@ -240,30 +235,30 @@ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsMultiLineString(
240235
241236FCesiumGeoJsonPolygon UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsPolygon (
242237 const FCesiumGeoJsonObject& InObject) {
243- if (!InObject._document || !InObject._object ) {
238+ if (!InObject._pDocument || !InObject._pObject ) {
244239 return {};
245240 }
246241
247242 const CesiumVectorData::GeoJsonPolygon* pPolygon =
248- std::get_if<CesiumVectorData::GeoJsonPolygon>(&InObject._object ->value );
243+ std::get_if<CesiumVectorData::GeoJsonPolygon>(&InObject._pObject ->value );
249244
250245 if (!pPolygon) {
251246 return FCesiumGeoJsonPolygon ();
252247 }
253248
254- return FCesiumGeoJsonPolygon (InObject._document , &pPolygon->coordinates );
249+ return FCesiumGeoJsonPolygon (InObject._pDocument , &pPolygon->coordinates );
255250}
256251
257252TArray<FCesiumGeoJsonPolygon>
258253UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsMultiPolygon (
259254 const FCesiumGeoJsonObject& InObject) {
260- if (!InObject._document || !InObject._object ) {
255+ if (!InObject._pDocument || !InObject._pObject ) {
261256 return {};
262257 }
263258
264259 const CesiumVectorData::GeoJsonMultiPolygon* pMultiPolygon =
265260 std::get_if<CesiumVectorData::GeoJsonMultiPolygon>(
266- &InObject._object ->value );
261+ &InObject._pObject ->value );
267262
268263 if (!pMultiPolygon) {
269264 return TArray<FCesiumGeoJsonPolygon>();
@@ -273,7 +268,7 @@ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsMultiPolygon(
273268 Polygons.Reserve (pMultiPolygon->coordinates .size ());
274269
275270 for (size_t i = 0 ; i < pMultiPolygon->coordinates .size (); i++) {
276- Polygons.Emplace (InObject._document , &pMultiPolygon->coordinates [i]);
271+ Polygons.Emplace (InObject._pDocument , &pMultiPolygon->coordinates [i]);
277272 }
278273
279274 return Polygons;
@@ -282,13 +277,13 @@ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsMultiPolygon(
282277TArray<FCesiumGeoJsonObject>
283278UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsGeometryCollection (
284279 const FCesiumGeoJsonObject& InObject) {
285- if (!InObject._document || !InObject._object ) {
280+ if (!InObject._pDocument || !InObject._pObject ) {
286281 return {};
287282 }
288283
289284 const CesiumVectorData::GeoJsonGeometryCollection* pGeometryCollection =
290285 std::get_if<CesiumVectorData::GeoJsonGeometryCollection>(
291- &InObject._object ->value );
286+ &InObject._pObject ->value );
292287
293288 if (!pGeometryCollection) {
294289
@@ -300,7 +295,7 @@ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsGeometryCollection(
300295
301296 for (size_t i = 0 ; i < pGeometryCollection->geometries .size (); i++) {
302297 Geometries.Emplace (FCesiumGeoJsonObject (
303- InObject._document ,
298+ InObject._pDocument ,
304299 &pGeometryCollection->geometries [i]));
305300 }
306301
@@ -309,38 +304,42 @@ UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsGeometryCollection(
309304
310305FCesiumGeoJsonFeature UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsFeature (
311306 const FCesiumGeoJsonObject& InObject) {
312- if (!InObject._document || !InObject._object ) {
307+ if (!InObject._pDocument || !InObject._pObject ) {
313308 return {};
314309 }
315310
316311 const CesiumVectorData::GeoJsonFeature* pFeature =
317- std::get_if<CesiumVectorData::GeoJsonFeature>(&InObject._object ->value );
312+ std::get_if<CesiumVectorData::GeoJsonFeature>(&InObject._pObject ->value );
318313
319314 if (!pFeature) {
320315 return FCesiumGeoJsonFeature ();
321316 }
322317
323- return FCesiumGeoJsonFeature (InObject._document , pFeature);
318+ return FCesiumGeoJsonFeature (InObject._pDocument , pFeature);
324319}
325320
326321TArray<FCesiumGeoJsonFeature>
327322UCesiumGeoJsonObjectBlueprintLibrary::GetObjectAsFeatureCollection (
328323 const FCesiumGeoJsonObject& InObject) {
329- if (!InObject._document || !InObject._object ) {
324+ if (!InObject._pDocument || !InObject._pObject ) {
330325 return {};
331326 }
332327
333328 const CesiumVectorData::GeoJsonFeatureCollection* pFeatureCollection =
334329 std::get_if<CesiumVectorData::GeoJsonFeatureCollection>(
335- &InObject._object ->value );
330+ &InObject._pObject ->value );
336331
337332 TArray<FCesiumGeoJsonFeature> Features;
338333 Features.Reserve (pFeatureCollection->features .size ());
339334
340335 for (size_t i = 0 ; i < pFeatureCollection->features .size (); i++) {
341- Features.Emplace (FCesiumGeoJsonFeature (
342- InObject._document ,
343- &pFeatureCollection->features [i]));
336+ const CesiumVectorData::GeoJsonFeature* pFeature =
337+ pFeatureCollection->features [i]
338+ .getIf <CesiumVectorData::GeoJsonFeature>();
339+ if (pFeature == nullptr ) {
340+ continue ;
341+ }
342+ Features.Emplace (FCesiumGeoJsonFeature (InObject._pDocument , pFeature));
344343 }
345344
346345 return Features;
@@ -360,7 +359,7 @@ UCesiumGeoJsonPolygonBlueprintFunctionLibrary::GetPolygonRings(
360359 Points.Reserve ((*InPolygon._rings )[i].size ());
361360
362361 for (size_t j = 0 ; j < (*InPolygon._rings )[i].size (); j++) {
363- Points.Emplace (cartographicToVector ((*InPolygon._rings )[i][j]));
362+ Points.Emplace (degreesToVector ((*InPolygon._rings )[i][j]));
364363 }
365364
366365 Rings.Emplace (MoveTemp (Points));
0 commit comments