Browse Source

remove SchemaUri support

Bert Temme 1 year ago
parent
commit
73d042cef3

+ 7 - 3
src/SharpGLTF.Ext.3DTiles/Schema2/Ext.StructuralMetadataRoot.cs

@@ -61,11 +61,13 @@ namespace SharpGLTF.Schema2
 
             #region properties
 
+            /**
             internal string SchemaUri
             {
                 get => _schemaUri;
                 set { _schemaUri = value; }
             }
+            */
 
             internal StructuralMetadataSchema Schema
             {
@@ -96,16 +98,18 @@ namespace SharpGLTF.Schema2
                 return schema;
             }
 
+            /**
             // Sets the schema to use an external schema, returns an empty schema to used for adding schema properties
             public StructuralMetadataSchema UseExternalSchema(Uri uri)
             {
                 SchemaUri = uri.ToString();
                 return new StructuralMetadataSchema();
             }
+            */
 
             public StructuralMetadataSchema UseEmbeddedSchema()
             {
-                SchemaUri = null;
+                // SchemaUri = null;
 
                 if (_schema == null) GetChildSetter(this).SetProperty(ref _schema, new StructuralMetadataSchema());
 
@@ -257,8 +261,8 @@ namespace SharpGLTF.Schema2
                 }
 
                 // Check one of schema or schemaUri is defined, but not both
-                Guard.IsFalse(Schema != null && SchemaUri != null, "Schema/SchemaUri", "Schema and SchemaUri cannot both be defined");
-                Guard.IsFalse(Schema == null && SchemaUri == null, "Schema/SchemaUri", "One of Schema and SchemaUri must be defined");
+                // Guard.IsFalse(Schema != null && SchemaUri != null, "Schema/SchemaUri", "Schema and SchemaUri cannot both be defined");
+                // Guard.IsFalse(Schema == null && SchemaUri == null, "Schema/SchemaUri", "One of Schema and SchemaUri must be defined");
 
                 base.OnValidateContent(result);
             }

+ 20 - 8
tests/SharpGLTF.Cesium.Tests/ExtStructuralMetadataTests.cs

@@ -730,17 +730,29 @@ namespace SharpGLTF.Schema2.Tiles3D
             // --------------------------------------------------------------
 
             var rootMetadata = model.UseStructuralMetadata();
-            var schemaUri = new Uri("MetadataSchema.json", UriKind.Relative);            
-            var schema = rootMetadata.UseExternalSchema(schemaUri);
-            var externalClass = schema.UseClassMetadata("exampleMetadataClass");
+            var schema = rootMetadata.UseEmbeddedSchema();
 
-            var propertyAttribute = rootMetadata.AddPropertyAttribute(externalClass);
+            var classA = schema
+                .UseClassMetadata("exampleMetadataClass")
+                .WithName("Example metadata class")
+                .WithDescription("An example metadata class for property attributes");
+
+            var intensityProperty = classA.UseProperty("intensity")
+                .WithName("Example intensity property")
+                .WithDescription("An example property for the intensity, with component type FLOAT32")
+                .WithValueType(ElementType.SCALAR, DataType.FLOAT32);
+
+            var classificationProperty = classA
+                .UseProperty("classification")
+                .WithName("Example classification property")
+                .WithDescription("An example property for the classification, with the classificationEnumType");
+
+            classificationProperty.Type = ElementType.ENUM;
+            classificationProperty.EnumType = "classificationEnumType";
 
-            var intensityProperty = propertyAttribute.CreateProperty("intensity");             
-            intensityProperty.Attribute = "_INTENSITY";
+            var speciesEnum = schema.UseEnumMetadata("classificationEnumType", ("MediumVegetation", 0), ("Buildings", 1));
 
-            var classificationProperty = propertyAttribute.CreateProperty("classification");
-            classificationProperty.Attribute = "_CLASSIFICATION";
+            // todo: add propertyAttributes
 
             var ctx = new ValidationResult(model, ValidationMode.Strict, true);