-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow access to Tileset-level metadata (schema
, schemaUri
, groups
, metadata
)
#709
Merged
Merged
Changes from 29 commits
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
31f0ed5
Expose Schema on Tileset.
kring 0dbf930
Start reading metadata and groups properties.
kring 056eecc
Give tileset a root "external" tile.
kring 44ad786
Expose metadata on root tile and external tilesets.
kring 789fed8
Support metadata on external tilesets.
kring e99b00d
Formatting.
kring 79d33e2
Fix Clang/GCC compiler error.
kring 8f8cb9b
Generate Reader classes, remove hand-written versions.
kring cfaaf4d
Add doc for readers.
kring c0fc8b6
More tileset metadata to a separate struct.
kring ef2ac5d
Add missing file.
kring c68207a
Add MetadataQuery class.
kring 056edba
Add a test based on material variants.
kring 20cbc17
Formatting.
kring d0a3091
Fix dodgy destructor declaration.
kring ea6a74e
Fix another clang warning.
kring 3585ba3
Merge remote-tracking branch 'origin/json-read-tweaks' into tileset-m…
kring 532d4e7
Merge remote-tracking branch 'origin/generated-readers' into tileset-…
kring d24e5f9
Update CHANGES.md, remove unnecessary change.
kring fe26c94
Remove unnecessary forward declaration.
kring 9f73df1
Merge remote-tracking branch 'origin/generated-readers' into tileset-…
kring 9a1abb2
Add missing dll export of FoundMetadataProperty.
kring 153890d
Add `Tileset::loadMetadata`.
kring 6145b54
Update CHANGES.md.
kring 51e798e
Add test for async schema loading.
kring 946887a
Add getArrayOfStrings helper to JsonValue.
kring 5bf8a7b
struct -> class
kring 31fc053
Fix clang warning.
kring 3f40341
Fix VS2017/2019 warning.
kring 5637a68
Merge remote-tracking branch 'origin/generated-readers' into tileset-…
kring 7c8f4b1
Fix test failures, change some CHECK to REQUIRE.
kring 57476c3
Changes from review.
kring a2d5b92
Fix misnaming.
kring File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
#pragma once | ||
|
||
#include <Cesium3DTiles/MetadataEntity.h> | ||
#include <Cesium3DTiles/Schema.h> | ||
#include <CesiumUtility/JsonValue.h> | ||
|
||
#include <string> | ||
#include <unordered_map> | ||
|
||
namespace Cesium3DTiles { | ||
|
||
/** | ||
* @brief Holds the details of a found property in a {@link MetadataEntity}. | ||
* | ||
* Because this structure holds _references_ to the original {@link Schema} and | ||
* {@link MetadataEntity} instances, it will be invalided if either are | ||
* destroyed or modified. Continuing to access this result in that scenario will | ||
* result in undefined behavior. | ||
*/ | ||
struct CESIUM3DTILES_API FoundMetadataProperty { | ||
/** | ||
* @brief A reference to the identifier of the class that contains the found | ||
* property within the {@link Schema}. | ||
*/ | ||
const std::string& classIdentifier; | ||
|
||
/** | ||
* @brief A reference to the {@link Class} that contains the found property | ||
* within the {@link Schema}. | ||
*/ | ||
const Class& classDefinition; | ||
|
||
/** | ||
* @brief A reference to the identifier of the found property within the | ||
* {@link Schema}. | ||
*/ | ||
const std::string& propertyIdentifier; | ||
|
||
/** | ||
* @brief A reference to the {@link ClassProperty} describing the found | ||
* property within the {@lnik Schema}. | ||
*/ | ||
const ClassProperty& propertyDefinition; | ||
|
||
/** | ||
* @brief A reference to the value of the found property within the | ||
* {@link MetadataEntity}. | ||
*/ | ||
const CesiumUtility::JsonValue& propertyValue; | ||
}; | ||
|
||
/** | ||
* @brief Convenience functions for querying {@link MetadataEntity} instances. | ||
*/ | ||
class CESIUM3DTILES_API MetadataQuery { | ||
public: | ||
/** | ||
* @brief Gets the first property with a given | ||
* {@link ClassProperty::semantic}. | ||
* | ||
* @param schema The schema to use to look up semantics. | ||
* @param entity The metadata entity to search for a property with the | ||
* semantic. | ||
* @param semantic The semantic to find. | ||
* @return The details of the found property, or `std::nullopt` if a property | ||
* with the given semantic does not exist. | ||
*/ | ||
static std::optional<FoundMetadataProperty> findFirstPropertyWithSemantic( | ||
const Schema& schema, | ||
const MetadataEntity& entity, | ||
const std::string& semantic); | ||
}; | ||
|
||
} // namespace Cesium3DTiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#include <Cesium3DTiles/MetadataQuery.h> | ||
|
||
namespace Cesium3DTiles { | ||
|
||
std::optional<FoundMetadataProperty> | ||
MetadataQuery::findFirstPropertyWithSemantic( | ||
const Schema& schema, | ||
const MetadataEntity& entity, | ||
const std::string& semantic) { | ||
auto classIt = schema.classes.find(entity.classProperty); | ||
if (classIt == schema.classes.end()) { | ||
return std::nullopt; | ||
} | ||
|
||
const Cesium3DTiles::Class& klass = classIt->second; | ||
|
||
for (auto it = entity.properties.begin(); it != entity.properties.end(); | ||
++it) { | ||
const std::pair<std::string, CesiumUtility::JsonValue>& property = *it; | ||
auto propertyIt = klass.properties.find(property.first); | ||
if (propertyIt == klass.properties.end()) | ||
continue; | ||
|
||
const ClassProperty& classProperty = propertyIt->second; | ||
if (classProperty.semantic == semantic) { | ||
return FoundMetadataProperty{ | ||
classIt->first, | ||
classIt->second, | ||
it->first, | ||
propertyIt->second, | ||
it->second}; | ||
} | ||
} | ||
|
||
return std::nullopt; | ||
} | ||
|
||
} // namespace Cesium3DTiles |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#include <Cesium3DTiles/MetadataQuery.h> | ||
|
||
#include <catch2/catch.hpp> | ||
|
||
using namespace Cesium3DTiles; | ||
using namespace CesiumUtility; | ||
|
||
TEST_CASE("MetadataQuery") { | ||
SECTION("findFirstPropertyWithSemantic") { | ||
Schema schema{}; | ||
Class& classDefinition = | ||
schema.classes.emplace("someClass", Class()).first->second; | ||
|
||
ClassProperty& classProperty1 = | ||
classDefinition.properties.emplace("someProperty", ClassProperty()) | ||
.first->second; | ||
classProperty1.type = ClassProperty::Type::SCALAR; | ||
classProperty1.componentType = ClassProperty::ComponentType::FLOAT64; | ||
|
||
ClassProperty& classProperty2 = | ||
classDefinition.properties | ||
.emplace("somePropertyWithSemantic", ClassProperty()) | ||
.first->second; | ||
classProperty2.type = ClassProperty::Type::STRING; | ||
classProperty2.semantic = "SOME_SEMANTIC"; | ||
|
||
MetadataEntity withoutSemantic; | ||
withoutSemantic.classProperty = "someClass"; | ||
withoutSemantic.properties.emplace("someProperty", JsonValue(3.0)); | ||
|
||
MetadataEntity withSemantic = withoutSemantic; | ||
withSemantic.properties.emplace( | ||
"somePropertyWithSemantic", | ||
JsonValue("the value")); | ||
|
||
std::optional<FoundMetadataProperty> foundProperty1 = | ||
MetadataQuery::findFirstPropertyWithSemantic( | ||
schema, | ||
withoutSemantic, | ||
"SOME_SEMANTIC"); | ||
CHECK(!foundProperty1); | ||
|
||
std::optional<FoundMetadataProperty> foundProperty2 = | ||
MetadataQuery::findFirstPropertyWithSemantic( | ||
schema, | ||
withSemantic, | ||
"SOME_SEMANTIC"); | ||
REQUIRE(foundProperty2); | ||
CHECK(foundProperty2->classIdentifier == "someClass"); | ||
CHECK(&foundProperty2->classDefinition == &classDefinition); | ||
CHECK(foundProperty2->propertyIdentifier == "somePropertyWithSemantic"); | ||
CHECK(&foundProperty2->propertyDefinition == &classProperty2); | ||
CHECK(foundProperty2->propertyValue.getStringOrDefault("") == "the value"); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.