Cesium for Unreal 2.18.0
Loading...
Searching...
No Matches
CesiumGeoJsonObject.h
Go to the documentation of this file.
1// Copyright 2020-2025 CesiumGS, Inc. and Contributors
2
3#pragma once
4
5#include "CesiumUtility/IntrusivePointer.h"
6#include "CesiumVectorData/GeoJsonDocument.h"
7#include "CesiumVectorData/GeoJsonObject.h"
8#include "CesiumVectorStyle.h"
9#include "JsonObjectWrapper.h"
10#include "Kismet/BlueprintFunctionLibrary.h"
11#include "Templates/SharedPointer.h"
12
13#include <glm/ext/vector_double3.hpp>
14#include <memory>
15
16#include "CesiumGeoJsonObject.generated.h"
17
18/**
19 * @brief A single object in the GeoJSON document.
20 */
21USTRUCT(BlueprintType)
23 GENERATED_BODY()
24
25 /**
26 * @brief Creates a new `FCesiumGeoJsonObject` containing an empty GeoJSON
27 * object.
28 */
29 FCesiumGeoJsonObject() : _pDocument(nullptr), _pObject(nullptr) {}
30
31 /**
32 * @brief Creates a new `FCesiumGeoJsonObject` wrapping the provided
33 * `CesiumVectorData::GeoJsonObject`.
34 */
36 const std::shared_ptr<CesiumVectorData::GeoJsonDocument>& doc,
37 const CesiumVectorData::GeoJsonObject* pObject)
38 : _pDocument(doc), _pObject(pObject) {}
39
40 const std::shared_ptr<CesiumVectorData::GeoJsonDocument>&
41 getDocument() const {
42 return this->_pDocument;
43 }
44
45 const CesiumVectorData::GeoJsonObject* getObject() const {
46 return this->_pObject;
47 }
48
49private:
50 std::shared_ptr<CesiumVectorData::GeoJsonDocument> _pDocument;
51 const CesiumVectorData::GeoJsonObject* _pObject;
52
54};
55
56/**
57 * @brief The supported GeoJSON object types.
58 */
59UENUM(BlueprintType)
71
72/**
73 * @brief a GeoJson "Feature" object.
74 */
75USTRUCT(BlueprintType)
77 GENERATED_BODY()
78
79 /** @brief Creates a new `FCesiumVectorPrimitive` with an empty primitive. */
81
82 /**
83 * @brief Creates a new `FCesiumGeoJsonFeature` wrapping the provided
84 * `CesiumVectorData::GeoJsonFeature`.
85 */
87 const std::shared_ptr<CesiumVectorData::GeoJsonDocument>& document,
88 const CesiumVectorData::GeoJsonFeature* feature);
89
90private:
91 std::shared_ptr<CesiumVectorData::GeoJsonDocument> _pDocument;
92 const CesiumVectorData::GeoJsonFeature* _pFeature;
93
95};
96
97/**
98 * @brief The type of a feature's ID field.
99 */
100UENUM(BlueprintType)
101enum class ECesiumGeoJsonFeatureIdType : uint8 {
102 /**
103 * @brief The feature has no ID.
104 */
106 /**
107 * @brief The feature's ID is an integer.
108 */
110 /**
111 * @brief The feature's ID is a string.
112 */
114};
115
116UCLASS()
117class UCesiumGeoJsonFeatureBlueprintLibrary : public UBlueprintFunctionLibrary {
118 GENERATED_BODY()
119
120public:
121 /**
122 * @brief Returns true if this feature's
123 */
124 UFUNCTION(
125 BlueprintCallable,
126 BlueprintPure,
127 Category = "Cesium|Vector|Feature")
130
131 /**
132 * @brief Returns the ID of the provided feature, or -1 if no ID was
133 * present or if the ID is not an integer.
134 */
135 UFUNCTION(
136 BlueprintCallable,
137 BlueprintPure,
138 Category = "Cesium|Vector|Feature")
139 static int64 GetIdAsInteger(const FCesiumGeoJsonFeature& InFeature);
140
141 /**
142 * @brief Returns the ID of the provided feature, or an empty string if no
143 * ID was present. If the ID is an integer, it will be converted to a string.
144 */
145 UFUNCTION(
146 BlueprintCallable,
147 BlueprintPure,
148 Category = "Cesium|Vector|Feature")
149 static FString GetIdAsString(const FCesiumGeoJsonFeature& InFeature);
150
151 /**
152 * @brief Obtains the properties attached to this feature, if any.
153 */
154 UFUNCTION(
155 BlueprintCallable,
156 BlueprintPure,
157 Category = "Cesium|Vector|Feature")
158 static FJsonObjectWrapper
160
161 /**
162 * @brief Obtains the `FCesiumGeoJsonObject` specified as the geometry of this
163 * feature, if any.
164 */
165 UFUNCTION(
166 BlueprintCallable,
167 BlueprintPure,
168 Category = "Cesium|Vector|Feature")
171
172 /**
173 * @brief Checks if this `FCesiumGeoJsonFeature` is valid or not.
174 */
175 UFUNCTION(
176 BlueprintCallable,
177 BlueprintPure,
178 Category = "Cesium|Vector|Feature")
179 static bool IsValid(const FCesiumGeoJsonFeature& InFeature);
180};
181
182/**
183 * @brief A `FCesiumGeoJsonPolygon` is a polygon made up of one or
184 * more linear rings.
185 */
186USTRUCT(BlueprintType)
188 GENERATED_BODY()
189
190 /**
191 * @brief Creates a new `FCesiumGeoJsonPolygon` with an empty
192 * composite polygon.
193 */
194 FCesiumGeoJsonPolygon() : _document(nullptr), _rings(nullptr) {}
195
196 /**
197 * @brief Creates a new `FCesiumGeoJsonPolygon` wrapping the
198 * provided `CesiumGeospatial::CompositeCartographicPolygon`.
199 */
201 const std::shared_ptr<CesiumVectorData::GeoJsonDocument>& document,
202 const std::vector<std::vector<glm::dvec3>>* rings)
203 : _document(document), _rings(rings) {}
204
205private:
206 std::shared_ptr<CesiumVectorData::GeoJsonDocument> _document;
207 const std::vector<std::vector<glm::dvec3>>* _rings;
208
210};
211
212/**
213 * @brief A `FCesiumGeoJsonLineString` is a set of points representing a line.
214 */
215USTRUCT(BlueprintType)
217 GENERATED_BODY()
218public:
219 /**
220 * @brief Creates a new `FCesiumGeoJsonLineString` with an empty line string.
221 */
223
224 /**
225 * @brief Creates a new `FCesiumGeoJsonLineString` from a set of
226 * Longitude-Latitude-Height points.
227 */
228 FCesiumGeoJsonLineString(TArray<FVector>&& InPoints);
229
230 /**
231 * @brief The Longitude-Latitude-Height points of this polygon.
232 */
233 UPROPERTY(BlueprintReadOnly, Category = "Cesium|Vector|Polygon")
234 TArray<FVector> Points;
235};
236
237UCLASS()
239 : public UBlueprintFunctionLibrary {
240 GENERATED_BODY()
241public:
242 /**
243 * @brief Returns the linear rings that make up this composite polygon.
244 *
245 * The first returned ring represents the outer bounds of the polygon. Any
246 * additional rings define holes within those bounds.
247 */
248 UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Polygon")
249 static TArray<FCesiumGeoJsonLineString>
251};
252
253/**
254 * @brief Enum used for branching when a UFUNCTION could return a value or could
255 * return no value.
256 */
257UENUM()
258enum class EHasValue : uint8 { HasValue, NoValue };
259
260/**
261 * @brief A Blueprint Funciton Library for interacting with `FCesiumVectorNode`
262 * values.
263 */
264UCLASS()
265class UCesiumGeoJsonObjectBlueprintLibrary : public UBlueprintFunctionLibrary {
266 GENERATED_BODY()
267
268public:
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 */
275 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
276 static bool IsValid(const FCesiumGeoJsonObject& InObject);
277
278 /**
279 * @brief Returns the `ECesiumGeoJsonObjectType` of the GeoJSON value this
280 * object represents.
281 */
282 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
285
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 */
290 UFUNCTION(
291 BlueprintCallable,
292 Category = "Cesium|Vector|Object",
293 Meta = (ExpandEnumAsExecs = "Branches"))
294 static FBox
295 GetBoundingBox(const FCesiumGeoJsonObject& InObject, EHasValue& Branches);
296
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 */
303 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
304 static FJsonObjectWrapper
306
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 */
311 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
312 static FVector GetObjectAsPoint(const FCesiumGeoJsonObject& InObject);
313
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 */
319 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
320 static TArray<FVector>
322
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 */
328 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
331
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 */
337 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
338 static TArray<FCesiumGeoJsonLineString>
340
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 */
346 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
349
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 */
355 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
356 static TArray<FCesiumGeoJsonPolygon>
358
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 */
364 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
365 static TArray<FCesiumGeoJsonObject>
367
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 */
373 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
376
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 */
382 UFUNCTION(BlueprintCallable, BlueprintPure, Category = "Cesium|Vector|Object")
383 static TArray<FCesiumGeoJsonFeature>
385
386 /**
387 * @brief Returns the `FCesiumVectorStyle` attached to this object, if any. If
388 * there is no style attached to this object, the `No Value` branch is taken.
389 */
390 UFUNCTION(
391 BlueprintCallable,
392 BlueprintPure,
393 Category = "Cesium|Vector|Object",
394 Meta = (ExpandEnumAsExecs = "Branches"))
395 static FCesiumVectorStyle
396 GetStyle(const FCesiumGeoJsonObject& InObject, EHasValue& Branches);
397
398 /**
399 * @brief Sets the style of the given `FCesiumGeoJsonObject`.
400 */
401 UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Object")
402 static void SetStyle(
403 UPARAM(Ref) FCesiumGeoJsonObject& InObject,
404 const FCesiumVectorStyle& InStyle);
405
406 /**
407 * @brief Removes any existing style on the given GeoJSON object.
408 *
409 * GeoJSON objects without a style specified will inherit their style from
410 * their parent object, or that parent's parent, and so on up the tree. If no
411 * styles are found anywhere in the ancestors of this object, the default
412 * style will be used.
413 */
414 UFUNCTION(BlueprintCallable, Category = "Cesium|Vector|Object")
415 static void ClearStyle(UPARAM(Ref) FCesiumGeoJsonObject& InObject);
416};
ECesiumGeoJsonObjectType
The supported GeoJSON object types.
ECesiumGeoJsonFeatureIdType
The type of a feature's ID field.
@ String
The feature's ID is a string.
@ Integer
The feature's ID is an integer.
EHasValue
Enum used for branching when a UFUNCTION could return a value or could return no value.
static FCesiumGeoJsonObject GetGeometry(const FCesiumGeoJsonFeature &InFeature)
Obtains the FCesiumGeoJsonObject specified as the geometry of this feature, if any.
static ECesiumGeoJsonFeatureIdType GetIdType(const FCesiumGeoJsonFeature &InFeature)
Returns true if this feature's.
static FString GetIdAsString(const FCesiumGeoJsonFeature &InFeature)
Returns the ID of the provided feature, or an empty string if no ID was present.
static FJsonObjectWrapper GetProperties(const FCesiumGeoJsonFeature &InFeature)
Obtains the properties attached to this feature, if any.
static bool IsValid(const FCesiumGeoJsonFeature &InFeature)
Checks if this FCesiumGeoJsonFeature is valid or not.
static int64 GetIdAsInteger(const FCesiumGeoJsonFeature &InFeature)
Returns the ID of the provided feature, or -1 if no ID was present or if the ID is not an integer.
A Blueprint Funciton Library for interacting with FCesiumVectorNode values.
static FCesiumGeoJsonPolygon GetObjectAsPolygon(const FCesiumGeoJsonObject &InObject)
If this object is a GeoJSON Polygon type, this returns a FCesiumGeoJsonPolygon representing that line...
static void ClearStyle(UPARAM(Ref) FCesiumGeoJsonObject &InObject)
Removes any existing style on the given GeoJSON object.
static void SetStyle(UPARAM(Ref) FCesiumGeoJsonObject &InObject, const FCesiumVectorStyle &InStyle)
Sets the style of the given FCesiumGeoJsonObject.
static TArray< FVector > GetObjectAsMultiPoint(const FCesiumGeoJsonObject &InObject)
If this object is a GeoJSON MultiPoint type, this returns the array of coordinates on that MultiPoint...
static FCesiumGeoJsonLineString GetObjectAsLineString(const FCesiumGeoJsonObject &InObject)
If this object is a GeoJSON LineString type, this returns a FCesiumGeoJsonLineString representing tha...
static TArray< FCesiumGeoJsonFeature > GetObjectAsFeatureCollection(const FCesiumGeoJsonObject &InObject)
If this object is a GeoJSON FeatureCollection type, this returns an array of FCesiumGeoJsonFeature ob...
static FJsonObjectWrapper GetForeignMembers(const FCesiumGeoJsonObject &InObject)
Obtains any foreign members on this GeoJSON object.
static FBox GetBoundingBox(const FCesiumGeoJsonObject &InObject, EHasValue &Branches)
Attempts to obtain this GeoJSON object's bounding box.
static TArray< FCesiumGeoJsonObject > GetObjectAsGeometryCollection(const FCesiumGeoJsonObject &InObject)
If this object is a GeoJSON GeometryCollection type, this returns an array of FCesiumGeoJsonObject ob...
static FCesiumGeoJsonFeature GetObjectAsFeature(const FCesiumGeoJsonObject &InObject)
If this object is a GeoJSON Feature type, this returns a FCesiumGeoJsonFeature representing that feat...
static bool IsValid(const FCesiumGeoJsonObject &InObject)
Checks if the provided GeoJSON object is valid.
static FVector GetObjectAsPoint(const FCesiumGeoJsonObject &InObject)
If this object is a GeoJSON Point type, this returns the coordinates of that Point.
static FCesiumVectorStyle GetStyle(const FCesiumGeoJsonObject &InObject, EHasValue &Branches)
Returns the FCesiumVectorStyle attached to this object, if any.
static TArray< FCesiumGeoJsonLineString > GetObjectAsMultiLineString(const FCesiumGeoJsonObject &InObject)
If this object is a GeoJSON MultiLineString type, this returns an array of FCesiumGeoJsonLineString o...
static ECesiumGeoJsonObjectType GetObjectType(const FCesiumGeoJsonObject &InObject)
Returns the ECesiumGeoJsonObjectType of the GeoJSON value this object represents.
static TArray< FCesiumGeoJsonPolygon > GetObjectAsMultiPolygon(const FCesiumGeoJsonObject &InObject)
If this object is a GeoJSON MultiPolygon type, this returns an array of FCesiumGeoJsonPolygon objects...
static TArray< FCesiumGeoJsonLineString > GetPolygonRings(const FCesiumGeoJsonPolygon &InPolygon)
Returns the linear rings that make up this composite polygon.
STL namespace.
a GeoJson "Feature" object.
friend class UCesiumGeoJsonFeatureBlueprintLibrary
FCesiumGeoJsonFeature()
Creates a new FCesiumVectorPrimitive with an empty primitive.
A FCesiumGeoJsonLineString is a set of points representing a line.
FCesiumGeoJsonLineString()
Creates a new FCesiumGeoJsonLineString with an empty line string.
FCesiumGeoJsonLineString(TArray< FVector > &&InPoints)
Creates a new FCesiumGeoJsonLineString from a set of Longitude-Latitude-Height points.
TArray< FVector > Points
The Longitude-Latitude-Height points of this polygon.
A single object in the GeoJSON document.
FCesiumGeoJsonObject()
Creates a new FCesiumGeoJsonObject containing an empty GeoJSON object.
const std::shared_ptr< CesiumVectorData::GeoJsonDocument > & getDocument() const
FCesiumGeoJsonObject(const std::shared_ptr< CesiumVectorData::GeoJsonDocument > &doc, const CesiumVectorData::GeoJsonObject *pObject)
Creates a new FCesiumGeoJsonObject wrapping the provided CesiumVectorData::GeoJsonObject.
const CesiumVectorData::GeoJsonObject * getObject() const
friend class UCesiumGeoJsonObjectBlueprintLibrary
A FCesiumGeoJsonPolygon is a polygon made up of one or more linear rings.
FCesiumGeoJsonPolygon()
Creates a new FCesiumGeoJsonPolygon with an empty composite polygon.
friend class UCesiumGeoJsonPolygonBlueprintFunctionLibrary
FCesiumGeoJsonPolygon(const std::shared_ptr< CesiumVectorData::GeoJsonDocument > &document, const std::vector< std::vector< glm::dvec3 > > *rings)
Creates a new FCesiumGeoJsonPolygon wrapping the provided CesiumGeospatial::CompositeCartographicPoly...
Style information to use when drawing vector data.