Skip to content

Commit e8aa593

Browse files
committed
Some review comments
1 parent fd684be commit e8aa593

File tree

4 files changed

+128
-8
lines changed

4 files changed

+128
-8
lines changed

Source/CesiumRuntime/Private/CesiumGeoJsonDocument.cpp

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#include "CesiumGeoJsonDocument.h"
2+
#include "CesiumIonServer.h"
23
#include "CesiumRuntime.h"
34

45
#include <CesiumAsync/IAssetAccessor.h>
@@ -52,23 +53,27 @@ FCesiumGeoJsonObject UCesiumGeoJsonDocumentBlueprintLibrary::GetRootObject(
5253
UCesiumLoadVectorDocumentFromIonAsyncAction*
5354
UCesiumLoadVectorDocumentFromIonAsyncAction::LoadFromIon(
5455
int64 AssetId,
55-
const FString& IonAccessToken,
56-
const FString& IonAssetEndpointUrl) {
56+
const UCesiumIonServer* CesiumIonServer,
57+
const FString& IonAccessToken) {
5758
UCesiumLoadVectorDocumentFromIonAsyncAction* pAction =
5859
NewObject<UCesiumLoadVectorDocumentFromIonAsyncAction>();
5960
pAction->AssetId = AssetId;
6061
pAction->IonAccessToken = IonAccessToken;
61-
pAction->IonAssetEndpointUrl = IonAssetEndpointUrl;
62+
pAction->CesiumIonServer = CesiumIonServer;
6263
return pAction;
6364
}
6465

6566
void UCesiumLoadVectorDocumentFromIonAsyncAction::Activate() {
67+
const std::string token(
68+
this->IonAccessToken.IsEmpty()
69+
? TCHAR_TO_UTF8(*this->CesiumIonServer->DefaultIonAccessToken)
70+
: TCHAR_TO_UTF8(*this->IonAccessToken));
6671
CesiumVectorData::GeoJsonDocument::fromCesiumIonAsset(
6772
getAsyncSystem(),
6873
getAssetAccessor(),
6974
this->AssetId,
70-
TCHAR_TO_UTF8(*this->IonAccessToken),
71-
TCHAR_TO_UTF8(*this->IonAssetEndpointUrl))
75+
token,
76+
std::string(TCHAR_TO_UTF8(*this->CesiumIonServer->ApiUrl)) + "/")
7277
.thenInMainThread(
7378
[Callback = this->OnLoadResult](
7479
CesiumUtility::Result<CesiumVectorData::GeoJsonDocument>&&

Source/CesiumRuntime/Private/CesiumGeoJsonObject.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,18 @@
77
#include <variant>
88
#include <vector>
99

10+
ECesiumGeoJsonFeatureIdType UCesiumGeoJsonFeatureBlueprintLibrary::GetIdType(
11+
const FCesiumGeoJsonFeature& InFeature) {
12+
if (!InFeature._document || !InFeature._feature ||
13+
std::holds_alternative<std::monostate>(InFeature._feature->id)) {
14+
return ECesiumGeoJsonFeatureIdType::None;
15+
}
16+
17+
return std::holds_alternative<int64_t>(InFeature._feature->id)
18+
? ECesiumGeoJsonFeatureIdType::Integer
19+
: ECesiumGeoJsonFeatureIdType::String;
20+
}
21+
1022
int64 UCesiumGeoJsonFeatureBlueprintLibrary::GetIdAsInteger(
1123
const FCesiumGeoJsonFeature& InFeature) {
1224
if (!InFeature._document || !InFeature._feature) {

Source/CesiumRuntime/Public/CesiumGeoJsonDocument.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,10 @@ class CESIUMRUNTIME_API UCesiumLoadVectorDocumentFromIonAsyncAction
9393
/**
9494
* @brief Attempts to load a vector document from a Cesium ion asset.
9595
*
96+
* If the provided `IonAccessToken` is an empty string, the
97+
* `DefaultIonAccessToken` from the provided `CesiumIonServer` will be used
98+
* instead.
99+
*
96100
* If successful, `Success` will be true and `Document` will contain the
97101
* loaded document.
98102
*/
@@ -104,8 +108,8 @@ class CESIUMRUNTIME_API UCesiumLoadVectorDocumentFromIonAsyncAction
104108
DisplayName = "Load Vector Document from Cesium ion"))
105109
static UCesiumLoadVectorDocumentFromIonAsyncAction* LoadFromIon(
106110
int64 AssetId,
107-
const FString& IonAccessToken,
108-
const FString& IonAssetEndpointUrl = "https://api.cesium.com/");
111+
const UCesiumIonServer* CesiumIonServer,
112+
const FString& IonAccessToken);
109113

110114
UPROPERTY(BlueprintAssignable)
111115
FCesiumVectorDocumentAsyncLoadDelegate OnLoadResult;
@@ -114,7 +118,9 @@ class CESIUMRUNTIME_API UCesiumLoadVectorDocumentFromIonAsyncAction
114118

115119
int64 AssetId;
116120
FString IonAccessToken;
117-
FString IonAssetEndpointUrl;
121+
122+
UPROPERTY()
123+
const UCesiumIonServer* CesiumIonServer;
118124
};
119125

120126
UCLASS()

Source/CesiumRuntime/Public/CesiumGeoJsonObject.h

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,40 @@ struct FCesiumGeoJsonFeature {
9494
friend class UCesiumGeoJsonFeatureBlueprintLibrary;
9595
};
9696

97+
/**
98+
* @brief The type of a feature's ID field.
99+
*/
100+
UENUM(BlueprintType)
101+
enum class ECesiumGeoJsonFeatureIdType {
102+
/**
103+
* @brief The feature has no ID.
104+
*/
105+
None,
106+
/**
107+
* @brief The feature's ID is an integer.
108+
*/
109+
Integer,
110+
/**
111+
* @brief The feature's ID is a string.
112+
*/
113+
String
114+
};
115+
97116
UCLASS()
98117
class UCesiumGeoJsonFeatureBlueprintLibrary : public UBlueprintFunctionLibrary {
99118
GENERATED_BODY()
100119

101120
public:
121+
/**
122+
* @brief Returns true if this feature's
123+
*/
124+
UFUNCTION(
125+
BlueprintCallable,
126+
BlueprintPure,
127+
Category = "Cesium|Vector|Feature")
128+
static ECesiumGeoJsonFeatureIdType
129+
GetIdType(const FCesiumGeoJsonFeature& InFeature);
130+
102131
/**
103132
* @brief Returns the ID of the provided feature, or -1 if no ID was
104133
* present or if the ID is not an integer.
@@ -221,6 +250,10 @@ class UCesiumGeoJsonPolygonBlueprintFunctionLibrary
221250
GetPolygonRings(const FCesiumGeoJsonPolygon& InPolygon);
222251
};
223252

253+
/**
254+
* @brief Enum used for branching when a UFUNCTION could return a value or could
255+
* return no value.
256+
*/
224257
UENUM()
225258
enum class EHasValue : uint8 { HasValue, NoValue };
226259

@@ -233,55 +266,119 @@ class UCesiumGeoJsonObjectBlueprintLibrary : public UBlueprintFunctionLibrary {
233266
GENERATED_BODY()
234267

235268
public:
269+
/**
270+
* @brief Checks if the provided GeoJSON object is valid.
271+
*
272+
* Any operations performed with an invalid object will likely give incorrect
273+
* results.
274+
*/
236275
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
237276
static bool IsValid(const FCesiumGeoJsonObject& InObject);
238277

278+
/**
279+
* @brief Returns the `ECesiumGeoJsonObjectType` of the GeoJSON value this
280+
* object represents.
281+
*/
239282
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
240283
static ECesiumGeoJsonObjectType
241284
GetObjectType(const FCesiumGeoJsonObject& InObject);
242285

286+
/**
287+
* @brief Attempts to obtain this GeoJSON object's bounding box. If the `No
288+
* Value` branch is called, the object has no bounding box.
289+
*/
243290
UFUNCTION(
244291
BlueprintCallable,
245292
Category = "Cesium|Vector|Object",
246293
Meta = (ExpandEnumAsExecs = "Branches"))
247294
static FBox
248295
GetBoundingBox(const FCesiumGeoJsonObject& InObject, EHasValue& Branches);
249296

297+
/**
298+
* @brief Obtains any foreign members on this GeoJSON object.
299+
*
300+
* Foreign members are members found in the loaded GeoJSON document that
301+
* are not part of the specification for this GeoJSON object type.
302+
*/
250303
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
251304
static FJsonObjectWrapper
252305
GetForeignMembers(const FCesiumGeoJsonObject& InObject);
253306

307+
/**
308+
* @brief If this object is a GeoJSON Point type, this returns the
309+
* `coordinates` of that Point. Otherwise, a zero vector is returned.
310+
*/
254311
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
255312
static FVector GetObjectAsPoint(const FCesiumGeoJsonObject& InObject);
256313

314+
/**
315+
* @brief If this object is a GeoJSON MultiPoint type, this returns the array
316+
* of `coordinates` on that MultiPoint object. Otherwise, an empty array is
317+
* returned.
318+
*/
257319
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
258320
static TArray<FVector>
259321
GetObjectAsMultiPoint(const FCesiumGeoJsonObject& InObject);
260322

323+
/**
324+
* @brief If this object is a GeoJSON LineString type, this returns a
325+
* `FCesiumGeoJsonLineString` representing that line. Otherwise, a
326+
* `FCesiumGeoJsonLineString` without any points is returned.
327+
*/
261328
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
262329
static FCesiumGeoJsonLineString
263330
GetObjectAsLineString(const FCesiumGeoJsonObject& InObject);
264331

332+
/**
333+
* @brief If this object is a GeoJSON MultiLineString type, this returns an
334+
* array of `FCesiumGeoJsonLineString` objects representing the lines.
335+
* Otherwise, an empty array is returned.
336+
*/
265337
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
266338
static TArray<FCesiumGeoJsonLineString>
267339
GetObjectAsMultiLineString(const FCesiumGeoJsonObject& InObject);
268340

341+
/**
342+
* @brief If this object is a GeoJSON Polygon type, this returns a
343+
* `FCesiumGeoJsonPolygon` representing that line. Otherwise, a
344+
* `FCesiumGeoJsonPolygon` without any points is returned.
345+
*/
269346
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
270347
static FCesiumGeoJsonPolygon
271348
GetObjectAsPolygon(const FCesiumGeoJsonObject& InObject);
272349

350+
/**
351+
* @brief If this object is a GeoJSON MultiPolygon type, this returns an
352+
* array of `FCesiumGeoJsonPolygon` objects representing the polygons.
353+
* Otherwise, an empty array is returned.
354+
*/
273355
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
274356
static TArray<FCesiumGeoJsonPolygon>
275357
GetObjectAsMultiPolygon(const FCesiumGeoJsonObject& InObject);
276358

359+
/**
360+
* @brief If this object is a GeoJSON GeometryCollection type, this returns an
361+
* array of `FCesiumGeoJsonObject` objects representing the objects.
362+
* Otherwise, an empty array is returned.
363+
*/
277364
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
278365
static TArray<FCesiumGeoJsonObject>
279366
GetObjectAsGeometryCollection(const FCesiumGeoJsonObject& InObject);
280367

368+
/**
369+
* @brief If this object is a GeoJSON Feature type, this returns a
370+
* `FCesiumGeoJsonFeature` representing that feature. Otherwise, an invalid
371+
* `FCesiumGeoJsonFeature` is returned.
372+
*/
281373
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
282374
static FCesiumGeoJsonFeature
283375
GetObjectAsFeature(const FCesiumGeoJsonObject& InObject);
284376

377+
/**
378+
* @brief If this object is a GeoJSON FeatureCollection type, this returns an
379+
* array of `FCesiumGeoJsonFeature` objects representing the features.
380+
* Otherwise, an empty array is returned.
381+
*/
285382
UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
286383
static TArray<FCesiumGeoJsonFeature>
287384
GetObjectAsFeatureCollection(const FCesiumGeoJsonObject& InObject);

0 commit comments

Comments
 (0)