Skip to content

Commit 452fddc

Browse files
committed
More functions
1 parent c036fda commit 452fddc

File tree

4 files changed

+73
-0
lines changed

4 files changed

+73
-0
lines changed
37.2 KB
Binary file not shown.

Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,49 @@ ECesiumGeoJsonObjectType UCesiumGeoJsonObjectBlueprintLibrary::GetObjectType(
130130
return (ECesiumGeoJsonObjectType)InObject._pObject->getType();
131131
}
132132

133+
FBox UCesiumGeoJsonObjectBlueprintLibrary::GetBoundingBox(
134+
const FCesiumGeoJsonObject& InObject,
135+
EHasValue& Branches) {
136+
if (!InObject._pDocument || !InObject._pObject) {
137+
Branches = EHasValue::NoValue;
138+
return {};
139+
}
140+
141+
const std::optional<CesiumGeometry::AxisAlignedBox>& boundingBox =
142+
InObject._pObject->getBoundingBox();
143+
if (boundingBox) {
144+
Branches = EHasValue::HasValue;
145+
return FBox(
146+
FVector(
147+
boundingBox->minimumX,
148+
boundingBox->minimumY,
149+
boundingBox->minimumZ),
150+
FVector(
151+
boundingBox->maximumX,
152+
boundingBox->maximumY,
153+
boundingBox->maximumZ));
154+
}
155+
156+
Branches = EHasValue::NoValue;
157+
return {};
158+
}
159+
160+
FJsonObjectWrapper UCesiumGeoJsonObjectBlueprintLibrary::GetForeignMembers(
161+
const FCesiumGeoJsonObject& InObject) {
162+
if (!InObject._pDocument || !InObject._pObject) {
163+
return {};
164+
}
165+
166+
TSharedPtr<FJsonObject> object = MakeShared<FJsonObject>();
167+
for (const auto& [k, v] : InObject._pObject->getForeignMembers()) {
168+
object->SetField(UTF8_TO_TCHAR(k.c_str()), jsonValueToUnrealJsonValue(v));
169+
}
170+
171+
FJsonObjectWrapper wrapper;
172+
wrapper.JsonObject = object;
173+
return wrapper;
174+
}
175+
133176
namespace {
134177
FVector degreesToVector(const glm::dvec3& coordinates) {
135178
return FVector(coordinates.x, coordinates.y, coordinates.z);

Source/CesiumRuntime/Public/CesiumGeoJsonObject.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -221,6 +221,9 @@ class UCesiumGeoJsonPolygonBlueprintFunctionLibrary
221221
GetPolygonRings(const FCesiumGeoJsonPolygon& InPolygon);
222222
};
223223

224+
UENUM()
225+
enum class EHasValue : uint8 { HasValue, NoValue };
226+
224227
/**
225228
* @brief A Blueprint Funciton Library for interacting with `FCesiumVectorNode`
226229
* values.
@@ -237,6 +240,17 @@ class UCesiumGeoJsonObjectBlueprintLibrary : public UBlueprintFunctionLibrary {
237240
static ECesiumGeoJsonObjectType
238241
GetObjectType(const FCesiumGeoJsonObject& InObject);
239242

243+
UFUNCTION(
244+
BlueprintCallable,
245+
Category = "Cesium|Vector|Object",
246+
Meta = (ExpandEnumAsExecs = "Branches"))
247+
static FBox
248+
GetBoundingBox(const FCesiumGeoJsonObject& InObject, EHasValue& Branches);
249+
250+
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
251+
static FJsonObjectWrapper
252+
GetForeignMembers(const FCesiumGeoJsonObject& InObject);
253+
240254
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
241255
static FVector GetObjectAsPoint(const FCesiumGeoJsonObject& InObject);
242256

Source/CesiumRuntime/Public/CesiumGeoJsonObjectIterator.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,4 +39,20 @@ class UCesiumGeoJsonObjectIteratorFunctionLibrary
3939
BlueprintPure,
4040
Category = "Cesium|Vector|Iterator")
4141
static bool IsEnded(const FCesiumGeoJsonObjectIterator& Iterator);
42+
43+
UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Iterator")
44+
static FCesiumGeoJsonFeature
45+
GetFeature(UPARAM(Ref) FCesiumGeoJsonObjectIterator& Iterator) {
46+
const CesiumVectorData::GeoJsonObject* pFeatureObject =
47+
Iterator._iterator.getFeature();
48+
if (pFeatureObject) {
49+
const CesiumVectorData::GeoJsonFeature* pFeature =
50+
pFeatureObject->getIf<CesiumVectorData::GeoJsonFeature>();
51+
if (pFeature) {
52+
return FCesiumGeoJsonFeature(Iterator._object.getDocument(), pFeature);
53+
}
54+
}
55+
56+
return FCesiumGeoJsonFeature();
57+
}
4258
};

0 commit comments

Comments
 (0)