Пример #1
0
 private void hDFToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         using (SaveFileDialog dlg = new SaveFileDialog())
         {
             dlg.Title            = "修正全球火点HDF另存";
             dlg.OverwritePrompt  = true;
             dlg.Filter           = _openFileFilter;
             dlg.FileName         = _hdfFileName;
             dlg.InitialDirectory = Path.GetDirectoryName(_hdfFileName);
             if (dlg.ShowDialog() == DialogResult.OK)
             {
                 string    outhdffilename = dlg.FileName;
                 Feature[] lestfeatures   = GetLeftFeatures();
                 if (lestfeatures != null && lestfeatures.Length > 0)
                 {
                     HDF5Filter.SaveAsNewHDF5ByFeatures(_hdfFileName, outhdffilename, lestfeatures, new Action <int, string>(Progress));
                     this.canvasHost1.Canvas.CurrentViewControl = new DefaultControlLayer();
                     this.canvasHost1.Canvas.Refresh(enumRefreshType.All);
                 }
             }
         }
     }
     catch (System.Exception ex)
     {
         MessageBox.Show("处理出错:" + ex.Message);
     }
     finally
     {
         FinishProgress();
     }
 }
Пример #2
0
        public static void SaveToDBLVDat(string hdffname, string rasterFileName, Feature[] features, double resolution, Action <int, string> processPolback)
        {
            CoordEnvelope envelope;

            HDF5Filter.GetDataCoordEnvelope(hdffname, out envelope);
            int height = (int)Math.Ceiling((envelope.MaxY - envelope.MinY) / resolution);
            int width  = (int)Math.Ceiling((envelope.MaxX - envelope.MinX) / resolution);

            Int16[] dblv = new Int16[height * width];
            if (processPolback != null)
            {
                processPolback(15, "开始计算火点判识结果...");
            }
            ProcessFeaturesDBLV(features, resolution, width, envelope.MaxY, envelope.MinX, ref dblv);
            if (processPolback != null)
            {
                processPolback(50, "开始输出火点判识结果...");
            }
            IRasterDataProvider dataPrd = null;

            try
            {
                IRasterDataDriver driver  = GeoDataDriver.GetDriverByName("MEM") as IRasterDataDriver;
                string            mapInfo = envelope.ToMapInfoString(new Size(width, height));
                //string mapInfo = new CoordEnvelope(envelope.MinX - 0.01, envelope.MaxX - 0.01, envelope.MinY - 0.1, envelope.MaxY - 0.1).ToMapInfoString(new Size(width, height));
                dataPrd = driver.Create(rasterFileName, width, height, 1, enumDataType.Int16, mapInfo);
                unsafe
                {
                    fixed(Int16 *ptr = dblv)
                    {
                        IntPtr bufferPtr = new IntPtr(ptr);

                        dataPrd.GetRasterBand(1).Write(0, 0, width, height, bufferPtr, enumDataType.Int16, width, height);
                    }
                }
                if (processPolback != null)
                {
                    processPolback(100, "输出火点判识结果完成!");
                }
            }
            finally
            {
                if (dataPrd != null)
                {
                    dataPrd.Dispose();
                }
            }
        }