/// <summary> /// Set of dimensions for each CS must be equal to the set of dimensions for the variable. /// </summary> private void CheckCoordinateSystems() { DimensionList dlist = changes.Dimensions == null ? dims : changes.Dimensions; CoordinateSystemCollection cscoll = changes.Cs == null ? csystems : changes.Cs; foreach (CoordinateSystem cs in cscoll) { if (dlist != cs.GetDimensions(SchemaVersion.Recent)) { throw new Exception("Set of dimensions for each coordinate system must be equal to the set of dimensions for the variable."); } } }
/// <summary> /// Gets specified version of the schema for the variable describing its structure. /// </summary> public override VariableSchema GetSchema(SchemaVersion version) { if (HasChanges) { if (version == SchemaVersion.Committed) { return(changes.InitialSchema); } // Making a schema for proposed version of the variable string name = changes.Name == null ? this.name : changes.Name; ReadOnlyDimensionList roDims = new ReadOnlyDimensionList(changes.Dimensions == null ? dims : changes.Dimensions); VariableMetadata metadata = this.metadata.Clone(); CoordinateSystemCollection cs = changes.Cs == null ? csystems : changes.Cs; CoordinateSystemSchema[] csSchemas = new CoordinateSystemSchema[cs.Count]; for (int i = 0; i < csSchemas.Length; i++) { csSchemas[i] = cs[i].GetSchema(); } VariableSchema schema = new VariableSchema(name, TypeOfData, roDims, csSchemas, metadata); return(schema); } else { if (version == SchemaVersion.Proposed) { throw new Exception("Variable is commited and has no changes."); } CoordinateSystemSchema[] csSchemas = new CoordinateSystemSchema[csystems.Count]; for (int i = 0; i < csSchemas.Length; i++) { csSchemas[i] = csystems[i].GetSchema(); } VariableSchema schema = new VariableSchema( name, TypeOfData, new ReadOnlyDimensionList(dimensions), csSchemas, metadata.Clone()); return(schema); } }