예제 #1
0
        private void WriteAttribute(int varId, NetCdfAttribute ncAttribute)
        {
            var value = ncAttribute.Value;

            if (value is string)
            {
                var str = (string)value;
                CheckResult(NetCdfWrapper.nc_put_att_text(id, varId, ncAttribute.Name,
                                                          new IntPtr(str.Length), UTF8Marshal.StringUTF8ToPtr(str)));
            }
            else if (value is double)
            {
                var d = (double)value;
                CheckResult(NetCdfWrapper.nc_put_att_double(id, varId, ncAttribute.Name,
                                                            NetCdfDataType.NC_DOUBLE, new IntPtr(1),
                                                            new[] { d }));
            }
            else if (value is float)
            {
                var i = (float)value;
                CheckResult(NetCdfWrapper.nc_put_att_float(id, varId, ncAttribute.Name,
                                                           NetCdfDataType.NC_FLOAT, new IntPtr(1),
                                                           new[] { i }));
            }
            else if (value is int)
            {
                var i = (int)value;
                CheckResult(NetCdfWrapper.nc_put_att_int(id, varId, ncAttribute.Name,
                                                         NetCdfDataType.NC_INT, new IntPtr(1),
                                                         new[] { i }));
            }
            else
            {
                throw new NotImplementedException(string.Format("NetCdf Attribute type '{0}' not implemented",
                                                                value != null ? value.GetType().ToString() : "<null>"));
            }
        }
예제 #2
0
 public void AddAttribute(NetCdfVariable ncVariable, NetCdfAttribute ncAttribute)
 {
     WriteAttribute(ncVariable, ncAttribute);
 }
예제 #3
0
 public void AddGlobalAttribute(NetCdfAttribute ncAttribute)
 {
     WriteAttribute(NetCdfWrapper.NC_GLOBAL, ncAttribute);
 }
예제 #4
0
 private void WriteAttribute(int varId, NetCdfAttribute ncAttribute)
 {
     var value = ncAttribute.Value;
     if (value is string)
     {
         var str = (string) value;
         CheckResult(NetCdfWrapper.nc_put_att_text(id, varId, ncAttribute.Name,
                                                   new IntPtr(str.Length), UTF8Marshal.StringUTF8ToPtr(str)));
     }
     else if (value is double)
     {
         var d = (double) value;
         CheckResult(NetCdfWrapper.nc_put_att_double(id, varId, ncAttribute.Name,
                                                     NetCdfDataType.NC_DOUBLE, new IntPtr(1),
                                                     new[] {d} ));
     }
     else if (value is float)
     {
         var i = (float)value;
         CheckResult(NetCdfWrapper.nc_put_att_float(id, varId, ncAttribute.Name,
                                                     NetCdfDataType.NC_FLOAT, new IntPtr(1),
                                                     new[] { i }));
     }
     else if (value is int)
     {
         var i = (int)value;
         CheckResult(NetCdfWrapper.nc_put_att_int(id, varId, ncAttribute.Name,
                                                     NetCdfDataType.NC_INT, new IntPtr(1),
                                                     new[] { i }));
     }
     else
     {
         throw new NotImplementedException(string.Format("NetCdf Attribute type '{0}' not implemented",
                                                         value != null ? value.GetType().ToString() : "<null>"));
     }
 }
예제 #5
0
 public void AddAttribute(NetCdfVariable ncVariable, NetCdfAttribute ncAttribute)
 {
    WriteAttribute(ncVariable, ncAttribute);
 }
예제 #6
0
 public void AddGlobalAttribute(NetCdfAttribute ncAttribute)
 {
     WriteAttribute(NetCdfWrapper.NC_GLOBAL, ncAttribute);
 }