MCPcopy Create free account
hub / github.com/CesiumGS/cesium-native / parsePosition

Function parsePosition

CesiumVectorData/src/GeoJsonDocument.cpp:66–89  ·  view source on GitHub ↗

GeoJSON position is an array of two or three components, representing [longitude, latitude, (height)]

Source from the content-addressed store, hash-verified

64// GeoJSON position is an array of two or three components, representing
65// [longitude, latitude, (height)]
66Result<glm::dvec3> parsePosition(const rapidjson::Value& pos) {
67 if (!pos.IsArray()) {
68 return Result<glm::dvec3>(
69 ErrorList::error("Position value must be an array."));
70 }
71
72 const rapidjson::Value::ConstArray& arr = pos.GetArray();
73
74 const int32_t size = static_cast<int32_t>(pos.GetArray().Size());
75 if (size < 2 || size > 3) {
76 return Result<glm::dvec3>(ErrorList::error(
77 "Position value must be an array with two or three members."));
78 }
79
80 if (!arr[0].IsNumber() || !arr[1].IsNumber() ||
81 (size > 2 && !arr[2].IsNumber())) {
82 return ErrorList::error("Position value must be an array of only numbers.");
83 }
84
85 return glm::dvec3(
86 arr[0].GetDouble(),
87 arr[1].GetDouble(),
88 size == 3 ? arr[2].GetDouble() : 0);
89}
90
91Result<std::vector<glm::dvec3>>
92parsePositionArray(const rapidjson::Value::ConstArray& arr) {

Callers 2

parsePositionArrayFunction · 0.85
parseGeoJsonObjectFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected