Exemplo n.º 1
0
 private void Disposed(IGeoDataDriver ldfDrv, IRasterDataProvider ldfPrd, IRasterBand ldfBand, IMvgDriver mvgDrv, IMvgDataProvider mvgPrd, IRasterBand mvgBand)
 {
     if (mvgBand != null)
     {
         mvgBand.Dispose();
     }
     if (mvgPrd != null)
     {
         mvgPrd.Dispose();
     }
     if (mvgDrv != null)
     {
         mvgDrv.Dispose();
     }
     if (ldfBand != null)
     {
         ldfBand.Dispose();
     }
     if (ldfPrd != null)
     {
         ldfPrd.Dispose();
     }
     if (ldfDrv != null)
     {
         ldfDrv.Dispose();
     }
 }
Exemplo n.º 2
0
        public unsafe void WriteMvgFileNormal()
        {
            // _fname = @"C:\工作\3.13\SNW_DBLV_FY3A_VIRR_1000M_NULL_P001_200911131356.mvg";
            IGeoDataDriver      drv = GeoDataDriver.GetDriverByName("MVG");
            IRasterDataProvider prd = drv.Open(_fname, enumDataProviderAccess.ReadOnly) as IRasterDataProvider;

            Assert.NotNull(prd);
            IRasterBand band = prd.GetRasterBand(1);

            Assert.NotNull(band);
            Int16[] buffer = new Int16[prd.Width * prd.Height];
            Console.WriteLine("prd.Width = " + prd.Width);
            Console.WriteLine("prd.Height = " + prd.Height);
            Console.WriteLine("band.Width = " + band.Width);
            Console.WriteLine("band.Height= " + band.Height);
            fixed(Int16 *ptr = buffer)
            {
                IntPtr bufferPtr = new IntPtr(ptr);

                band.Read(0, 0, prd.Width, prd.Height, bufferPtr, enumDataType.Int16, prd.Width, prd.Height);
            }

            string           dstFname   = @"e:\mvg_writer.bin";
            string           mapInfo    = "{1,1}:{110,35}:{0.01,0.01}";
            Int16            valueCount = 2;
            bool             withHdr    = true;
            string           values     = "{ 0, 1 }";
            string           valueNames = "{120,99}";
            IMvgDataProvider prdWriter  = (drv as IRasterDataDriver).Create(dstFname, prd.Width, prd.Height, 1, enumDataType.Int16, "VALUECOUNT=" + valueCount, "VALUES=" + values,
                                                                            "VALUENAMES=" + valueNames, "MAPINFO=" + mapInfo, "WITHHDR=" + withHdr.ToString()) as IMvgDataProvider;
            IRasterBand bandWriter = prdWriter.GetRasterBand(1);

            fixed(Int16 *ptr = buffer)
            {
                IntPtr bufferPtr = new IntPtr(ptr);

                bandWriter.Write(0, 0, prd.Width, prd.Height, bufferPtr, enumDataType.Int16, prd.Width, prd.Height);
            }

            prd.Dispose();
            drv.Dispose();
            prdWriter.Dispose();
        }
Exemplo n.º 3
0
        public void MvgToLdfFile()
        {
            _fname = @"E:\气象局项目\MAS二期\mvg文件\FOG_DBLV_FY3A_VIRR_1000M_DXX_P001_200911131354.mvg";
            IGeoDataDriver      drv = GeoDataDriver.GetDriverByName("MVG");
            IRasterDataProvider prd = drv.Open(_fname, enumDataProviderAccess.ReadOnly) as IRasterDataProvider;

            Assert.NotNull(prd);

            IMvgDataProvider mvgPrd    = prd as IMvgDataProvider;
            MvgHeader        mvgHeader = mvgPrd.Header;

            Assert.NotNull(mvgHeader);
            Console.WriteLine("mvgHeader.HeaderSize = " + mvgHeader.HeaderSize);
            Console.WriteLine("mvgHeader.Width = " + mvgHeader.Width);
            Console.WriteLine("mvgHeader.Height = " + mvgHeader.Height);

            mvgPrd.ToLdfFile();
            mvgPrd.Dispose();
            prd.Dispose();
            drv.Dispose();
        }
Exemplo n.º 4
0
        public void CreatEmptyMvgFile()
        {
            Assert.That(_newFileName != null);
            IRasterDataDriver driver = GeoDataDriver.GetDriverByName("MVG") as IRasterDataDriver;

            Assert.NotNull(driver);
            IMvgDriver drv = driver as IMvgDriver;

            Assert.NotNull(drv);
            int    width      = 2048;
            int    height     = 3390;
            string mapInfo    = "{1,1}:{110,35}:{0.01,0.01}";
            Int16  valueCount = 2;
            bool   withHdr    = true;
            string values     = "{ 0, 1 }";
            string valueNames = "{120,99}";

            IMvgDataProvider prd = drv.Create(_newFileName, width, height, 1, enumDataType.Int16, "VALUECOUNT=" + valueCount, "VALUES=" + values,
                                              "VALUENAMES=" + valueNames, "MAPINFO=" + mapInfo, "WITHHDR=" + withHdr.ToString()) as IMvgDataProvider;

            Assert.NotNull(prd);
            Assert.That(prd.BandCount == 1);
            Assert.That(prd.DataType == enumDataType.Int16);


            MvgHeader header = prd.Header;

            Assert.True(File.Exists(_newFileName));
            FileInfo fInfo = new FileInfo(_newFileName);
            HdrFile  hdr   = (header as MvgHeader).ToHdrFile();

            PrintHdrInfo(hdr);

            prd.Dispose();
            drv.Dispose();
            Assert.True(File.Exists(_newFileName));
        }